Hour and minute slider
-
Hello I find on the internet many slider on the internet from 0-10 and so on but I don't find any for hour and minute. I am trying to make something like this (jquery): https://codepen.io/caseymhunt/pen/kertA I don't know how I can make in C# winform. I just need to able select beginning and ending of the hour and minute. When moving the slider then increasing and decreasing with 15 minutes. Is there an open source for this or how I can make this? The design can be basic too, I just need the function to work. I don't have any idea how to make this possible. Thank you in advance all of the answers.
-
Hello I find on the internet many slider on the internet from 0-10 and so on but I don't find any for hour and minute. I am trying to make something like this (jquery): https://codepen.io/caseymhunt/pen/kertA I don't know how I can make in C# winform. I just need to able select beginning and ending of the hour and minute. When moving the slider then increasing and decreasing with 15 minutes. Is there an open source for this or how I can make this? The design can be basic too, I just need the function to work. I don't have any idea how to make this possible. Thank you in advance all of the answers.
Create a UserControl, and start there. Give it a fixed height, and add four "points": minimum, maximum, low, high. These are probably integer values which do not relate in any way directly to hours and minutes, so the control can be flexible. Handle the Paint event to draw the control and two "handles" that you can move. Handle the MouseDown, MouseUp, and MouseMove events to let you move the handles. As they move, update the low and high values. Provide properties to read the values, and in there translate the integers to hours and minutes - perhaps return a timespan? One digit move could be your fifteen minutes. Provide an event to indicate "slider changed" so the outside world can react to it.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!
-
Hello I find on the internet many slider on the internet from 0-10 and so on but I don't find any for hour and minute. I am trying to make something like this (jquery): https://codepen.io/caseymhunt/pen/kertA I don't know how I can make in C# winform. I just need to able select beginning and ending of the hour and minute. When moving the slider then increasing and decreasing with 15 minutes. Is there an open source for this or how I can make this? The design can be basic too, I just need the function to work. I don't have any idea how to make this possible. Thank you in advance all of the answers.
put two System.Windows.Forms.TrackBar Controls on a form: tBarHour, tBarMinute. Configure:
// tBarHour
//
this.tBarHour.LargeChange = 4;
this.tBarHour.Location = new System.Drawing.Point(280, 148);
this.tBarHour.Maximum = 23;
this.tBarHour.Name = "tBarHour";
this.tBarHour.Size = new System.Drawing.Size(375, 45);
this.tBarHour.TabIndex = 11;
this.tBarHour.Value = 12;
this.tBarHour.ValueChanged += new System.EventHandler(this.tBarHourMinute_ValueChanged);
//
// tBarMinute
//
this.tBarMinute.LargeChange = 10;
this.tBarMinute.Location = new System.Drawing.Point(280, 200);
this.tBarMinute.Maximum = 59;
this.tBarMinute.Name = "tBarMinute";
this.tBarMinute.Size = new System.Drawing.Size(375, 45);
this.tBarMinute.TabIndex = 12;
this.tBarMinute.ValueChanged += new System.EventHandler(this.tBarHourMinute_ValueChanged);The Minimum TrackBar value is #0 by default. Set the ValueChanged event handler for both TrackBars to:
private TimeSpan tSpan;
private string tSpanStr;
private void tBarHourMinute_ValueChanged(object sender, EventArgs e)
{
tSpan = new TimeSpan(0, tBarHour.Value, tBarMinute.Value, 0);tSpanStr = tSpan.ToString());
}
«One day it will have to be officially admitted that what we have christened reality is an even greater illusion than the world of dreams.» Salvador Dali