Skip to content
This repository has been archived by the owner on Dec 21, 2023. It is now read-only.

WinForms.GDI Sample: Add Scrolling #186

Merged
merged 4 commits into from
Oct 3, 2021
Merged

Conversation

swharden
Copy link
Contributor

@swharden swharden commented Oct 3, 2021

This PR improves the WinForms GDI control and sample application:

  • The panel containing the canvas now scrolls to improve usability on small monitors
  • Panel dimensions are sized to fit the canvas (defined in the initializer of each AbstractScenario)
  • OnPaint() dirty rectangle was expanded by 1 pixel to eliminate rendering artifacts
  • A new DimensionCheck AbstractScenario confirms the dirty rectangle is pixel-perfect
  • The panel now has a gray background to make the dimensions of the white canvas more obvious

If this PR is positively received I can create separate PRs which:

  • Fix AbstractScenario sizes by correcting the dimensions they pass into their base initializers
  • Add a scrolling canvas area to more sample applications (e.g., WPF)

Demonstration

Originally it's difficult to view the whole canvas

forms-scroll-before

Enabling AutoScroll works, but caused render artifacts

forms-scroll-before-artifacts

It looks good after expanding the dirty rectangle by 1px on all sides

This AbstractScenario is improperly sized (which is why it won't scroll to the bottom). I can fix these in a separate PR.

forms-scroll-works

Dimension Test Scenario

This new Scenario confirms the dirty rectangle is pixel-perfect. Too small and the black lines would get cut-off. Too large and there would be a white border.

dimension-test

Make the split panel scrollable (to the size of the selected Scenario). This improves the window, but not all Scenario objects have accurate dimensions presently.

Changes in the designer files (indentation and deletion of comments) were performed automatically by the visual Visual Studio 2022 (preview) editor.
eliminates rendering artifacts observed when scrolling or resizing the window
The background of the scrollpanel containing the graphics view is now ControlDark so when a Scenario is loaded its obvious how large it is (it resembles a white page on a light gray backdrop)
This scenario draws 1px thick lines at the edges of the canvas. This can be used to confirm that rendering does not crop or extend beyond the canvas.

This scenario is useful verifying that dirty rectangle size and placement on the window is accurate to the pixel.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants