init commit
This commit is contained in:
203
output_3234/VideoReader/SelectionRangeSlider.cs
Normal file
203
output_3234/VideoReader/SelectionRangeSlider.cs
Normal file
@@ -0,0 +1,203 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace VideoReader;
|
||||
|
||||
[Description("Very basic slider control with selection range.")]
|
||||
public class SelectionRangeSlider : UserControl
|
||||
{
|
||||
private enum MovingMode
|
||||
{
|
||||
MovingValue,
|
||||
MovingMin,
|
||||
MovingMax
|
||||
}
|
||||
|
||||
private int min;
|
||||
|
||||
private int max = 100;
|
||||
|
||||
private int selectedMin;
|
||||
|
||||
private int selectedMax = 100;
|
||||
|
||||
private int value = 50;
|
||||
|
||||
private MovingMode movingMode;
|
||||
|
||||
private IContainer components;
|
||||
|
||||
[Description("Minimum value of the slider.")]
|
||||
public int Min
|
||||
{
|
||||
get
|
||||
{
|
||||
return min;
|
||||
}
|
||||
set
|
||||
{
|
||||
min = value;
|
||||
((Control)this).Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
[Description("Maximum value of the slider.")]
|
||||
public int Max
|
||||
{
|
||||
get
|
||||
{
|
||||
return max;
|
||||
}
|
||||
set
|
||||
{
|
||||
max = value;
|
||||
((Control)this).Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
[Description("Minimum value of the selection range.")]
|
||||
public int SelectedMin
|
||||
{
|
||||
get
|
||||
{
|
||||
return selectedMin;
|
||||
}
|
||||
set
|
||||
{
|
||||
selectedMin = value;
|
||||
if (this.SelectionChanged != null)
|
||||
{
|
||||
this.SelectionChanged(this, null);
|
||||
}
|
||||
((Control)this).Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
[Description("Maximum value of the selection range.")]
|
||||
public int SelectedMax
|
||||
{
|
||||
get
|
||||
{
|
||||
return selectedMax;
|
||||
}
|
||||
set
|
||||
{
|
||||
selectedMax = value;
|
||||
if (this.SelectionChanged != null)
|
||||
{
|
||||
this.SelectionChanged(this, null);
|
||||
}
|
||||
((Control)this).Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
[Description("Current value.")]
|
||||
public int Value
|
||||
{
|
||||
get
|
||||
{
|
||||
return value;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.value = value;
|
||||
if (this.ValueChanged != null)
|
||||
{
|
||||
this.ValueChanged(this, null);
|
||||
}
|
||||
((Control)this).Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
[Description("Fired when SelectedMin or SelectedMax changes.")]
|
||||
public event EventHandler SelectionChanged;
|
||||
|
||||
[Description("Fired when Value changes.")]
|
||||
public event EventHandler ValueChanged;
|
||||
|
||||
public SelectionRangeSlider()
|
||||
{
|
||||
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_004e: Expected O, but got Unknown
|
||||
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0060: Expected O, but got Unknown
|
||||
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0072: Expected O, but got Unknown
|
||||
InitializeComponent();
|
||||
((Control)this).SetStyle((ControlStyles)8192, true);
|
||||
((Control)this).SetStyle((ControlStyles)131072, true);
|
||||
((Control)this).Paint += new PaintEventHandler(SelectionRangeSlider_Paint);
|
||||
((Control)this).MouseDown += new MouseEventHandler(SelectionRangeSlider_MouseDown);
|
||||
((Control)this).MouseMove += new MouseEventHandler(SelectionRangeSlider_MouseMove);
|
||||
}
|
||||
|
||||
private void SelectionRangeSlider_Paint(object sender, PaintEventArgs e)
|
||||
{
|
||||
e.Graphics.FillRectangle(Brushes.White, ((Control)this).ClientRectangle);
|
||||
Rectangle rectangle = new Rectangle((selectedMin - Min) * ((Control)this).Width / (Max - Min), 0, (selectedMax - selectedMin) * ((Control)this).Width / (Max - Min), ((Control)this).Height);
|
||||
e.Graphics.FillRectangle(Brushes.Blue, rectangle);
|
||||
e.Graphics.DrawRectangle(Pens.Black, 0, 0, ((Control)this).Width - 1, ((Control)this).Height - 1);
|
||||
e.Graphics.DrawLine(Pens.Black, (Value - Min) * ((Control)this).Width / (Max - Min), 0, (Value - Min) * ((Control)this).Width / (Max - Min), ((Control)this).Height);
|
||||
}
|
||||
|
||||
private void SelectionRangeSlider_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
int num = Min + e.X * (Max - Min) / ((Control)this).Width;
|
||||
int num2 = Math.Abs(num - Value);
|
||||
int num3 = Math.Abs(num - SelectedMin);
|
||||
int val = Math.Abs(num - SelectedMax);
|
||||
int num4 = Math.Min(num2, Math.Min(num3, val));
|
||||
if (num4 == num2)
|
||||
{
|
||||
movingMode = MovingMode.MovingValue;
|
||||
}
|
||||
else if (num4 == num3)
|
||||
{
|
||||
movingMode = MovingMode.MovingMin;
|
||||
}
|
||||
else
|
||||
{
|
||||
movingMode = MovingMode.MovingMax;
|
||||
}
|
||||
SelectionRangeSlider_MouseMove(sender, e);
|
||||
}
|
||||
|
||||
private void SelectionRangeSlider_MouseMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_000b: Invalid comparison between Unknown and I4
|
||||
if ((int)e.Button == 1048576)
|
||||
{
|
||||
int num = Min + e.X * (Max - Min) / ((Control)this).Width;
|
||||
if (movingMode == MovingMode.MovingValue)
|
||||
{
|
||||
Value = num;
|
||||
}
|
||||
else if (movingMode == MovingMode.MovingMin)
|
||||
{
|
||||
SelectedMin = num;
|
||||
}
|
||||
else if (movingMode == MovingMode.MovingMax)
|
||||
{
|
||||
SelectedMax = num;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && components != null)
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
((ContainerControl)this).Dispose(disposing);
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
components = new Container();
|
||||
((ContainerControl)this).AutoScaleMode = (AutoScaleMode)1;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user