Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature proposal: Gauge Control #909

Open
wants to merge 8 commits into
base: development
Choose a base branch
from

Conversation

ElectroAttacks
Copy link

Pull request type

Please check the type of change your PR introduces:

  • Update
  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes

What is the current behavior?

Issue Number: N/A

What is the new behavior?

  • Added a new control ('Gauge') for displaying values with a range
  • Added a default style that's using theme colors for the bar, foreground and indicator color
  • The arc and angle calculations are based on the arc control, with some small adjustments
  • The control provides a content and header property within it's arc for customization
  • Background (Bar) and Foreground (Indicator) arcs can be customized separately

Other information

Example Usecase
Gauge (Designer)

Added a reference to the new 'Gauge' control.
Added a custom 'Gauge' control for displaying values.
Added a default control and style template for the 'Gauge' control.
Increased default thickness
Added FrameworkPropertyMetadataOptions.AffectsRender for Content and Header property
@github-actions github-actions bot added controls Changes to the appearance or logic of custom controls. styles Topic is related to styles PR Pull request dotnet labels Mar 19, 2024
@m0lDaViA
Copy link
Contributor

@ElectroAttacks If you resize the control what does the gauge do? Does it resize correctly?

@ElectroAttacks
Copy link
Author

ElectroAttacks commented Mar 31, 2024

@ElectroAttacks If you resize the control what does the gauge do? Does it resize correctly?

Well, the default template for the Gauge includes a Data binding that ensures symmetrical resizing.

If the control is resized it will be redrawn based on the new location and size, like a normal control will do.

The Arc control inherits from a shape, which can lead to weird behavior if you stack two of them and perform any resizing. That's one of the reasons the Gauge control is derived from the RangeBase class.

@m0lDaViA
Copy link
Contributor

m0lDaViA commented Mar 31, 2024

@ElectroAttacks Well the arc couldn't do that, at least in 2.1. That's why i'm asking.
@pomianowski What do you say?

@ElectroAttacks
Copy link
Author

ElectroAttacks commented Mar 31, 2024

@ElectroAttacks Well the arc couldn't do that, at least in 2.1. That's why i'm asking.

@m0lDaViA This is exactly what I figured out. I reported that issue a few months ago and fixed it myself... I'm already working on splitting the logic of the Gauge control into a base class and two controls, so it will be structured like so:

  • abstract class GaugeBase : RangeBase
  • Gauge : GaugeBase
  • Angular Gauge : GaugeBase

But that might take a while due to the complexity of the Angular Gauge. I want a kinda similar experience than the one in Livecharts 2...

For the Arc itself it might be easier to figure out why a size change does not affect render by default, maybe it would be enough to override it's MetaData to enable the redrawing...

@m0lDaViA
Copy link
Contributor

m0lDaViA commented Apr 1, 2024

@ElectroAttacks As i wanted to create a knob control myself i was thinking about fixing the arc.
So you fixed the arc but didn't commit? :D

@ElectroAttacks
Copy link
Author

@ElectroAttacks As i wanted to create a knob control myself i was thinking about fixing the arc. So you fixed the arc but didn't commit? :D

@m0lDaViA Well, I had some ideas that might fix the issue where the arc is not being redrawn after a resize, if you are talking about that issue.
My Gauge control does not have any code that ensures a square shape, but it will always be redrawn completely when resizing.

@pomianowski
Copy link
Member

I'm still not sure if these types of controls should be in the main package or if it would be better to create a new one, like Wpf.Ui.Diagrams or something like that

@ElectroAttacks
Copy link
Author

I'm still not sure if these types of controls should be in the main package or if it would be better to create a new one, like Wpf.Ui.Diagrams or something like that

@pomianowski Well, yeah it would make maintenance a little bit easier... I would prefer Wpf.Ui.Graphs though.
There are quite a few controls missing for displaying data efficiently in WPF, for example Skiasharps Line diagrams are very dynamic and featurerich but are cpu bound. I wish I could make something like that using WPFs GPU Rendering, but that's a pretty large project and my coding skills will not meet the requirements to do so either...

@m0lDaViA
Copy link
Contributor

@pomianowski
Doesn't it depend on what we want to achive? I mean basic controls like textboxes or shapes are clearly fine in Wpf.Ui but should we really add all kind of other controls to it? And if yes, in a seperated project?
And where does this control places? Or the arc control? Or should those controls be all outsourced to like Wpf.Ui.Controls?
Questions after questions.
For my part, I think Wpf.Ui.Controls is a good idea in itself but that's ultimately your decision.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
controls Changes to the appearance or logic of custom controls. dotnet PR Pull request styles Topic is related to styles
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants