本文整理汇总了C#中System.Windows.Forms.TrackBar类的典型用法代码示例。如果您正苦于以下问题:C# TrackBar类的具体用法?C# TrackBar怎么用?C# TrackBar使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TrackBar类属于System.Windows.Forms命名空间,在下文中一共展示了TrackBar类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EditValue
public override object EditValue( ITypeDescriptorContext context, IServiceProvider provider, object value )
{
if( context != null && provider != null )
{
editorService = (IWindowsFormsEditorService)provider.GetService( typeof( IWindowsFormsEditorService ) );
if( editorService != null )
{
// Create a new trackbar and set it up.
TrackBar trackBar = new TrackBar();
trackBar.ValueChanged += new EventHandler( this.ValueChanged );
trackBar.MouseLeave += new EventHandler( this.MouseLeave );
trackBar.Minimum = 0;
trackBar.Maximum = 100;
trackBar.TickStyle = TickStyle.None;
// Get the low/high values.
PropertyDescriptor prop = context.PropertyDescriptor;
RangeAttribute ra = prop.Attributes[typeof( RangeAttribute )] as RangeAttribute;
valueLow = ra.Low;
valueHigh = ra.High;
// Set the corresponding trackbar value.
double percent = ( System.Convert.ToDouble( value ) - valueLow ) / ( valueHigh - valueLow );
trackBar.Value = (int)( 100 * percent );
// Show the control.
editorService.DropDownControl( trackBar );
// Here is the output value.
value = valueLow + ( (double)trackBar.Value / 100 ) * ( valueHigh - valueLow );
}
}
return value;
}
示例2: TrackBarPropertyTest
public void TrackBarPropertyTest ()
{
TrackBar myTrackBar = new TrackBar ();
// A
Assert.AreEqual (true, myTrackBar.AutoSize, "#A1");
// L
Assert.AreEqual (5, myTrackBar.LargeChange, "#L1");
// M
Assert.AreEqual (10, myTrackBar.Maximum, "#M1");
Assert.AreEqual (0, myTrackBar.Minimum, "#M2");
// O
Assert.AreEqual (Orientation.Horizontal, myTrackBar.Orientation, "#O1");
// S
Assert.AreEqual (1, myTrackBar.SmallChange, "#S1");
// T
Assert.AreEqual (1, myTrackBar.TickFrequency, "#T1");
Assert.AreEqual (TickStyle.BottomRight, myTrackBar.TickStyle, "#T2");
Assert.AreEqual ("", myTrackBar.Text, "#T3");
myTrackBar.Text = "New TrackBar";
Assert.AreEqual ("New TrackBar", myTrackBar.Text, "#T4");
// V
Assert.AreEqual (0, myTrackBar.Value, "#V1");
}
示例3: ToolStripLabeledTrackBar
public ToolStripLabeledTrackBar()
: base(new Panel())
{
Panel panel = (Panel) this.Control;
Label = new Label();
Label.Location = new Point(0, 0);
TrackBar = new TrackBar();
TrackBar.Location = new Point(0, Label.Bottom);
TrackBar.AutoSize = false;
TrackBar.TickStyle = TickStyle.None;
// no tickstyle, make the height smaller and the width
// a bit larger to compensate:
TrackBar.Height = (Int32) (TrackBar.PreferredSize.Height * 0.65);
TrackBar.Width = (Int32) (TrackBar.PreferredSize.Width * 1.25);
// the label and panel follow the trackbar width:
Label.Width = TrackBar.Width;
Width = TrackBar.Width;
panel.Controls.Add(Label);
panel.Controls.Add(TrackBar);
}
示例4: Form2
public Form2()
{
InitializeComponent();
f1 = new Form1();
trackBar1 = new TrackBar();
Controls.Add(trackBar1);
groupBox3.Controls.Add(trackBar1);
loca = new Point(comboBox1.Location.X, comboBox1.Location.Y);
trackBar1.Location = loca;
trackBar1.Size = new Size(trackBar1.Size.Width + 50, trackBar1.Size.Height - 50);
trackBar1.TickFrequency = 10;
trackBar1.LargeChange = 3;
trackBar1.SmallChange = 2;
trackBar1.Maximum = 100;
trackBar1.Minimum = 0;
trackBar1.TickStyle = TickStyle.BottomRight;
this.trackBar1.Scroll += new System.EventHandler(this.trackBar1_Scroll);
string tr = comboBox1.Text.Trim('%');
f1.Opacity = double.Parse(tr) / 100.0;
pl = f1.axWindowsMediaPlayer1.playlistCollection.newPlaylist("list1");//axwindowsMediaPlayer.playlistCollection.newPlaylist(myPlaylist);
f1.axWindowsMediaPlayer1.currentPlaylist = pl;
itemm = new List<WMPLib.IWMPMedia>();
f1.Show();
}
示例5: Editor
public Editor(PckImage curr)
{
edit = new EditorPanel(curr);
buttons = new ButtonPanel();
size = new TrackBar();
size.Minimum=1;
size.Maximum=10;
InitializeComponent();
Controls.Add(edit);
Controls.Add(buttons);
Controls.Add(size);
buttons.Location = new Point(0,0);
buttons.Width = buttons.PreferredWidth;
size.Left=buttons.Right;
size.Top=buttons.Top;
edit.Top=size.Bottom;
edit.Left=buttons.Right;
ClientSize=new Size(buttons.PreferredWidth+edit.Editor.PreferredWidth,
edit.Editor.PreferredHeight+size.Height);
palView = new PalView();
palView.Closing+=new CancelEventHandler(palClose);
palView.PaletteIndexChanged+=new PaletteClickDelegate(edit.Editor.SelectColor);
size.Scroll+=new EventHandler(sizeScroll);
}
示例6: InitializeComponent
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.trackBar1 = new System.Windows.Forms.TrackBar();
((System.ComponentModel.ISupportInitialize)(this.trackBar1)).BeginInit();
this.SuspendLayout();
//
// trackBar1
//
this.trackBar1.Location = new System.Drawing.Point(12, 12);
this.trackBar1.Minimum = 1;
this.trackBar1.Name = "trackBar1";
this.trackBar1.Size = new System.Drawing.Size(432, 45);
this.trackBar1.TabIndex = 0;
this.trackBar1.Value = 1;
this.trackBar1.ValueChanged += new System.EventHandler(this.trackBar1_ValueChanged);
//
// LineWidthForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(469, 66);
this.Controls.Add(this.trackBar1);
this.Icon = global::Diagram.Properties.Resources.ico_diagramico_forms;
this.MaximizeBox = false;
this.Name = "LineWidthForm";
this.Text = "Line width";
this.Load += new System.EventHandler(this.LineWidthForm_Load);
((System.ComponentModel.ISupportInitialize)(this.trackBar1)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
示例7: vibLab_updateStatus
private void vibLab_updateStatus(TrackBar barfreq, TrackBar barwidth, Label lbl, ref double vfreq, ref double vwidth)
{
vfreq = Math.Max(-1 * 2 * Math.Log((101-barfreq.Value) / 100.0),0.001); //logarithmic scale
vwidth = (barwidth.Value / 100.0) * 4 + 0.01;
lbl.Text = Math.Round(vfreq, 3) + " ; " + Math.Round(vwidth, 3);
}
示例8: Load
public void Load(Dictionary<string, HashSet<object>> valuerange)
{
this.images = Viewer.images;
this.arguments = Global.arguments;
// Create track bars for each argument
trackbars.Clear();
int argidx = -1;
foreach(Cinema.CinemaArgument argument in arguments)
{
++argidx;
/*if(argument.values.Length <= 1)
continue;*/
TrackBar newtrackbar = new TrackBar(argument, argidx, meshBorders, meshTick, meshSelection);
newtrackbar.label = argument.label;
trackbars.Add(newtrackbar);
}
/*// Create track bars for meta data value
foreach(KeyValuePair<string, HashSet<object>> range in valuerange)
{
TrackBar newtrackbar = new TrackBar(range.Value.Count, meshSelection);
newtrackbar.label = range.Key;
trackbars.Add(newtrackbar);
}*/
}
示例9: SetRangeTest
public void SetRangeTest ()
{
TrackBar myTrackBar = new TrackBar ();
myTrackBar.SetRange (2,9);
Assert.AreEqual (9, myTrackBar.Maximum, "#setM1");
Assert.AreEqual (2, myTrackBar.Minimum, "#setM2");
}
示例10: MainLayout
public MainLayout(DockPanel panel, List<ToolStripComboBox> comboBoxes, List<ToolStripButton> buttons, TrackBar trackBar, string path)
{
Logger = LogManager.GetLogger(Settings.Default.ApplicationLogger);
Panel = panel;
ComboBoxes = comboBoxes;
Buttons = buttons;
TrackBar = trackBar;
if (!Directory.Exists(path))
Directory.CreateDirectory(path);
DockConfigPath = Path.Combine(path, Settings.Default.DockingConfigurationPath);
TreeView = new TreeViewFrame();
TreeView.SelectedDatabaseChanged += TreeView_SlectedDatabaseChanged;
TreeView.PropertiesClick += TreeView_PropertiesClick;
StepFrames = new Dictionary<TestMethod, StepFrame>();
LogFrame = new LogFrame();
PropertiesFrame = new PropertiesFrame();
PropertiesFrame.Caller = TreeView;
foreach (TestMethod method in GetTestMethods())
StepFrames[method] = CreateStepFrame(method);
}
示例11: GridController
public GridController(IView<string> view, GridFieldModel model)
{
_view = view;
_model = model;
_zoomCheckbox = false;
_view.SetController(this);
_panel = (Panel) _view.Get("Panel");
_trackBar = (TrackBar) _view.Get("Trackbar");
_trackBar.Enabled = false;
_comboBox = (ComboBox) _view.Get("ComboBox");
float tWidth = _panel.Width/_model.Rows.GetLength(1);
float tHeight = _panel.Height/_model.Rows.GetLength(0);
// Doing these checks to make sure that we don't have pixels left
_tileWidth = (_panel.Width%_model.Rows.GetLength(1) != 0 // if width%length != 0
? (int) tWidth++ // then set to width++
: (int) tWidth) // else set to width
*_model.Rows[0, 0].Width; // finally multiply by the tile width
_tileHeight = (_panel.Width%_model.Rows.GetLength(0) != 0
? (int) tHeight++
: (int) tHeight)
*_model.Rows[0, 0].Height;
// only need to draw the grid once, so we can set it as the panel's background
_panel.BackgroundImage = PaintBackground();
_rectangle = new Rectangle(0, 0, 50, 50);
_buffer = new Bitmap(_panel.Width, _panel.Height);
PopulateCombobox();
Resize(this, null);
}
示例12: TgcFloatModifier
public TgcFloatModifier(string varName, float minValue, float maxValue, float defaultValue) : base(varName)
{
this.minValue = minValue;
this.maxValue = maxValue;
numericUpDown = new NumericUpDown();
numericUpDown.Size = new System.Drawing.Size(100, 20);
numericUpDown.Margin = new Padding(0);
numericUpDown.DecimalPlaces = 4;
numericUpDown.Minimum = (decimal)minValue;
numericUpDown.Maximum = (decimal)maxValue;
numericUpDown.Value = (decimal)defaultValue;
numericUpDown.Increment = (decimal)(2f * (maxValue - minValue) / 100f);
numericUpDown.ValueChanged += new EventHandler(numericUpDown_ValueChanged);
trackBar = new TrackBar();
trackBar.Size = new System.Drawing.Size(100, 20);
trackBar.Margin = new Padding(0);
trackBar.Minimum = 0;
trackBar.Maximum = 20;
trackBar.Value = (int)((defaultValue - minValue) * 20 / (maxValue - minValue));
trackBar.ValueChanged += new EventHandler(trackBar_ValueChanged);
contentPanel.Controls.Add(numericUpDown);
contentPanel.Controls.Add(trackBar);
}
示例13: StartCalc
protected override void StartCalc()
{
if (!tool_bar_inited){
tool_bar_inited = true;
ChartToolBar.AccessToolBar(tb=>
{
var _tsi3 = new ToolStripButton {Text = "plot color"};
set_color_tsi(_tsi3, m_plot_color);
_tsi3.Click += button1_Click;
AddItem2ToolStrip(tb, _tsi3);
var _track = new TrackBar
{
Dock = DockStyle.Fill,
Maximum = 1000,
Minimum = 10,
SmallChange = 10,
Value = Length,
Text = "Average Length"
};
_track.ValueChanged += _new_track;
AddItem2ToolStrip(tb, new ToolStripControlHost(_track));
AddItem2ToolStrip(tb, new ToolStripSeparator());
});
}
}
示例14: ColorUIWrapper
/// <summary>
/// Creates a new instance.
/// </summary>
/// <param name="colorEditor">The editor this instance belongs to.</param>
public ColorUIWrapper(XNAColorUITypeEditor colorEditor)
{
Type colorUiType = typeof(ColorEditor).GetNestedType("ColorUI", BindingFlags.CreateInstance | BindingFlags.NonPublic);
ConstructorInfo constructorInfo = colorUiType.GetConstructor(new Type[] { typeof(ColorEditor) });
_control = (Control)constructorInfo.Invoke(new object[] { colorEditor });
_control.BackColor = System.Drawing.SystemColors.Control;
Panel alphaPanel = new Panel();
alphaPanel.BackColor = System.Drawing.SystemColors.Control;
alphaPanel.Dock = DockStyle.Right;
alphaPanel.Width = 28;
_control.Controls.Add(alphaPanel);
_tbAlpha = new TrackBar();
_tbAlpha.Orientation = Orientation.Vertical;
_tbAlpha.Dock = DockStyle.Fill;
_tbAlpha.TickStyle = TickStyle.None;
_tbAlpha.Maximum = byte.MaxValue;
_tbAlpha.Minimum = byte.MinValue;
_tbAlpha.ValueChanged += new EventHandler(OnTrackBarAlphaValueChanged);
alphaPanel.Controls.Add(_tbAlpha);
_lblAlpha = new Label();
_lblAlpha.Text = "0";
_lblAlpha.Dock = DockStyle.Bottom;
_lblAlpha.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
alphaPanel.Controls.Add(_lblAlpha);
_startMethodInfo = _control.GetType().GetMethod("Start");
_endMethodInfo = _control.GetType().GetMethod("End");
_valuePropertyInfo = _control.GetType().GetProperty("Value");
_control.SizeChanged += new EventHandler(OnControlSizeChanged);
}
示例15: TgcVertex2fModifier
public TgcVertex2fModifier(string varName, Vector2 minValue, Vector2 maxValue, Vector2 defaultValue)
: base(varName)
{
this.minValue = minValue;
this.maxValue = maxValue;
//numericUpDownX
numericUpDownX = new NumericUpDown();
numericUpDownX.Size = new System.Drawing.Size(50, 20);
numericUpDownX.Margin = new Padding(0);
numericUpDownX.DecimalPlaces = 4;
numericUpDownX.Minimum = (decimal)minValue.X;
numericUpDownX.Maximum = (decimal)maxValue.X;
numericUpDownX.Value = (decimal)defaultValue.X;
numericUpDownX.Increment = (decimal)(2f * (maxValue.X - minValue.X) / 100f);
numericUpDownX.ValueChanged += new EventHandler(numericUpDownX_ValueChanged);
//numericUpDownY
numericUpDownY = new NumericUpDown();
numericUpDownY.Size = new System.Drawing.Size(50, 20);
numericUpDownY.Margin = new Padding(0);
numericUpDownY.DecimalPlaces = 4;
numericUpDownY.Minimum = (decimal)minValue.Y;
numericUpDownY.Maximum = (decimal)maxValue.Y;
numericUpDownY.Value = (decimal)defaultValue.Y;
numericUpDownY.Increment = (decimal)(2f * (maxValue.Y - minValue.Y) / 100f);
numericUpDownY.ValueChanged += new EventHandler(numericUpDownY_ValueChanged);
//Panel para los dos numericUpDown
vertexValuesPanel = new FlowLayoutPanel();
vertexValuesPanel.Margin = new Padding(0);
vertexValuesPanel.AutoSize = true;
vertexValuesPanel.FlowDirection = FlowDirection.LeftToRight;
vertexValuesPanel.Controls.Add(numericUpDownX);
vertexValuesPanel.Controls.Add(numericUpDownY);
//trackBarX
trackBarX = new TrackBar();
trackBarX.Size = new System.Drawing.Size(100, 20);
trackBarX.Margin = new Padding(0);
trackBarX.Minimum = 0;
trackBarX.Maximum = 20;
trackBarX.Value = (int)((defaultValue.X - minValue.X) * 20 / (maxValue.X - minValue.X));
trackBarX.ValueChanged += new EventHandler(trackBarX_ValueChanged);
//trackBarY
trackBarY = new TrackBar();
trackBarY.Size = new System.Drawing.Size(100, 20);
trackBarY.Margin = new Padding(0);
trackBarY.Minimum = 0;
trackBarY.Maximum = 20;
trackBarY.Value = (int)((defaultValue.Y - minValue.Y) * 20 / (maxValue.Y - minValue.Y));
trackBarY.ValueChanged += new EventHandler(trackBarY_ValueChanged);
contentPanel.Controls.Add(vertexValuesPanel);
contentPanel.Controls.Add(trackBarX);
contentPanel.Controls.Add(trackBarY);
}