-
Notifications
You must be signed in to change notification settings - Fork 954
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
Proposal: add SelectionStart and SelectionEnd to TrackBar #2642
Comments
Chosing -1 as sentinel value is bad because I think you can have a negative Minimum. Letting users chose a value centered around zero (e.g. between -100 and +100) is probably a common usecase of this control. Having a separate boolean property is how this is usually done in WinForms so that would be my first choice here as well. One question I'm not clear on is whether this is an input property (can the user edit the selection) or is it informative only (e.g. for presenting the current range of values within a multi-selection). If the user cannot edit this through user input I'm hesitant to name it "Selection" even if the native API names it this way. |
From what I can see it is informative only. In my example gif I showed how it can be connected to the value of the thumb as an example use case. Open to any other suggestions for names (perhaps |
I'm not too picky about naming, its just that
After thinking about this I tend to go for Start/End because this maps most closely to what the control is doing: the user is selecting a value and you put markers at two other values to mark a range. This allows easy binding of the properties against two values, going for Start/Length would more probably require coding for calculating the length.
|
@hughbe could you please share your test app (e.g. publish it to GitHub under your account)? It would be great to have some hands on experience to make better informed decisions. I'm leaning towards defining a new class similar to
These values must also be within the range.
What do you think of |
The team had some preliminary discussions about enhancing the control.
With the regards to this specific feature the first question is where I expect most questions. |
namespace System.Windows.Forms
{
public partial class TrackBar
{
public bool ShowSelectionRange { get; set; }
public int SelectionStart { get; set; }
public int SelectionLength { get; set; }
}
} @hughbe What the other properties you show in your UI? Like |
Few questions:
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@conorgee This is another trackbar improvement if you want to give it a go? |
You can set the
TBS_ENABLESELRANGE
onTrackBar
and send theTBM_SETSELSTART
andTBM_SETSELSTART
to set the selection rangeSee docs
Example:
![Screenshot 2020-01-06 at 16 31 38](https://user-images.githubusercontent.com/1275900/71832306-958b7000-30a2-11ea-93df-019c0e929f3c.png)
![Screen Recording 2020-01-06 at 04 32 pm](https://user-images.githubusercontent.com/1275900/71832296-915f5280-30a2-11ea-9ca2-24b47d3d35b8.gif)
We could add the following APIs to
TrackBar
:Discussion
SelectionStart
andSelectionEnd
be if we haven't enabled selections? In my experiments I set them to0
which worked nicely.ShowSelectionRange
totrue
if the user setsSelectionStart
/SelectionEnd
. One option could be to removeShowSelectionRange
and setSelectionStart
/SelectionEnd
to minus one or have some logic that sets theTrackBar
style toTBS_ENABLESELRANGE
if it is set to a custom value. However, this is negative as it leaves us with no way of removing the selection indicators once they've been created.SelectionStart
andSelectionEnd
orSelectionStart
andSelectionLength
or some sort ofSelectionRange
struct that encapsulates this? (e.gMonthCalendar.SelectionRange
)The text was updated successfully, but these errors were encountered: