Csharp/C Sharp by API/System.Windows.Forms/TrackBar
Версия от 15:31, 26 мая 2010; (обсуждение)
Содержание
TrackBar.BackColor
using System;
using System.Drawing;
using System.Windows.Forms;
public class TrackBars : Form
{
Panel pnl;
PictureBox pb;
TrackBar htbar;
TrackBar vtbar;
public TrackBars()
{
Size = new Size(500,520);
Image img = Image.FromFile("YourFile.bmp");
pnl = new Panel();
pnl.Parent = this;
pnl.BorderStyle = BorderStyle.FixedSingle;
pnl.Size = new Size(400,400);
pnl.Location = new Point(10,10);
pb = new PictureBox();
pb.Parent = pnl;
pb.Size = new Size(200, 200);
pb.Location = new Point((pnl.Size.Width / 2) - (pb.Size.Width / 2),
(pnl.Size.Height / 2) - (pb.Size.Height /2));
pb.BorderStyle = BorderStyle.FixedSingle;
pb.SizeMode = PictureBoxSizeMode.StretchImage;
pb.Image = img;
htbar = new TrackBar();
htbar.Parent = this;
htbar.Orientation = Orientation.Horizontal;
htbar.Size = new Size(pnl.Width, 10);
htbar.Location = new Point(pnl.Left, pnl.Bottom + 25);
htbar.TickStyle = TickStyle.BottomRight;
htbar.TickFrequency = 25;
htbar.Minimum = 25;
htbar.Maximum = 400;
htbar.SmallChange = 10;
htbar.LargeChange = 25;
htbar.BackColor = Color.Yellow;
htbar.Value = pb.Width;
htbar.ValueChanged += new EventHandler(htbar_OnValueChanged);
vtbar = new TrackBar();
vtbar.Parent = this;
vtbar.Orientation = Orientation.Vertical;
vtbar.Size = new Size(25, pnl.Height);
vtbar.Location = new Point(pnl.Right + 25, pnl.Top);
vtbar.TickStyle = TickStyle.Both;
vtbar.SetRange(25,400);
vtbar.SmallChange = 10;
vtbar.LargeChange = 50;
vtbar.TickFrequency = vtbar.Maximum / 20;
vtbar.BackColor = Color.Pink;
vtbar.Value = pb.Height;
vtbar.ValueChanged += new EventHandler(vtbar_OnValueChanged);
}
private void htbar_OnValueChanged(object sender, EventArgs e)
{
pb.Size = new Size(htbar.Value, pb.Height);
}
private void vtbar_OnValueChanged(object sender, EventArgs e)
{
pb.Size = new Size(pb.Width, vtbar.Value);
}
static void Main()
{
Application.Run(new TrackBars());
}
}
TrackBar.LargeChange
using System;
using System.Drawing;
using System.Windows.Forms;
public class TrackBars : Form
{
Panel pnl;
PictureBox pb;
TrackBar htbar;
TrackBar vtbar;
public TrackBars()
{
Size = new Size(500,520);
Image img = Image.FromFile("YourFile.bmp");
pnl = new Panel();
pnl.Parent = this;
pnl.BorderStyle = BorderStyle.FixedSingle;
pnl.Size = new Size(400,400);
pnl.Location = new Point(10,10);
pb = new PictureBox();
pb.Parent = pnl;
pb.Size = new Size(200, 200);
pb.Location = new Point((pnl.Size.Width / 2) - (pb.Size.Width / 2),
(pnl.Size.Height / 2) - (pb.Size.Height /2));
pb.BorderStyle = BorderStyle.FixedSingle;
pb.SizeMode = PictureBoxSizeMode.StretchImage;
pb.Image = img;
htbar = new TrackBar();
htbar.Parent = this;
htbar.Orientation = Orientation.Horizontal;
htbar.Size = new Size(pnl.Width, 10);
htbar.Location = new Point(pnl.Left, pnl.Bottom + 25);
htbar.TickStyle = TickStyle.BottomRight;
htbar.TickFrequency = 25;
htbar.Minimum = 25;
htbar.Maximum = 400;
htbar.SmallChange = 10;
htbar.LargeChange = 25;
htbar.BackColor = Color.Yellow;
htbar.Value = pb.Width;
htbar.ValueChanged += new EventHandler(htbar_OnValueChanged);
vtbar = new TrackBar();
vtbar.Parent = this;
vtbar.Orientation = Orientation.Vertical;
vtbar.Size = new Size(25, pnl.Height);
vtbar.Location = new Point(pnl.Right + 25, pnl.Top);
vtbar.TickStyle = TickStyle.Both;
vtbar.SetRange(25,400);
vtbar.SmallChange = 10;
vtbar.LargeChange = 50;
vtbar.TickFrequency = vtbar.Maximum / 20;
vtbar.BackColor = Color.Pink;
vtbar.Value = pb.Height;
vtbar.ValueChanged += new EventHandler(vtbar_OnValueChanged);
}
private void htbar_OnValueChanged(object sender, EventArgs e)
{
pb.Size = new Size(htbar.Value, pb.Height);
}
private void vtbar_OnValueChanged(object sender, EventArgs e)
{
pb.Size = new Size(pb.Width, vtbar.Value);
}
static void Main()
{
Application.Run(new TrackBars());
}
}
TrackBar.Maximum
using System;
using System.Drawing;
using System.Windows.Forms;
public class TrackBars : Form
{
Panel pnl;
PictureBox pb;
TrackBar htbar;
TrackBar vtbar;
public TrackBars()
{
Size = new Size(500,520);
Image img = Image.FromFile("YourFile.bmp");
pnl = new Panel();
pnl.Parent = this;
pnl.BorderStyle = BorderStyle.FixedSingle;
pnl.Size = new Size(400,400);
pnl.Location = new Point(10,10);
pb = new PictureBox();
pb.Parent = pnl;
pb.Size = new Size(200, 200);
pb.Location = new Point((pnl.Size.Width / 2) - (pb.Size.Width / 2),
(pnl.Size.Height / 2) - (pb.Size.Height /2));
pb.BorderStyle = BorderStyle.FixedSingle;
pb.SizeMode = PictureBoxSizeMode.StretchImage;
pb.Image = img;
htbar = new TrackBar();
htbar.Parent = this;
htbar.Orientation = Orientation.Horizontal;
htbar.Size = new Size(pnl.Width, 10);
htbar.Location = new Point(pnl.Left, pnl.Bottom + 25);
htbar.TickStyle = TickStyle.BottomRight;
htbar.TickFrequency = 25;
htbar.Minimum = 25;
htbar.Maximum = 400;
htbar.SmallChange = 10;
htbar.LargeChange = 25;
htbar.BackColor = Color.Yellow;
htbar.Value = pb.Width;
htbar.ValueChanged += new EventHandler(htbar_OnValueChanged);
vtbar = new TrackBar();
vtbar.Parent = this;
vtbar.Orientation = Orientation.Vertical;
vtbar.Size = new Size(25, pnl.Height);
vtbar.Location = new Point(pnl.Right + 25, pnl.Top);
vtbar.TickStyle = TickStyle.Both;
vtbar.SetRange(25,400);
vtbar.SmallChange = 10;
vtbar.LargeChange = 50;
vtbar.TickFrequency = vtbar.Maximum / 20;
vtbar.BackColor = Color.Pink;
vtbar.Value = pb.Height;
vtbar.ValueChanged += new EventHandler(vtbar_OnValueChanged);
}
private void htbar_OnValueChanged(object sender, EventArgs e)
{
pb.Size = new Size(htbar.Value, pb.Height);
}
private void vtbar_OnValueChanged(object sender, EventArgs e)
{
pb.Size = new Size(pb.Width, vtbar.Value);
}
static void Main()
{
Application.Run(new TrackBars());
}
}
TrackBar.Minimum
using System;
using System.Drawing;
using System.Windows.Forms;
public class TrackBars : Form
{
Panel pnl;
PictureBox pb;
TrackBar htbar;
TrackBar vtbar;
public TrackBars()
{
Size = new Size(500,520);
Image img = Image.FromFile("YourFile.bmp");
pnl = new Panel();
pnl.Parent = this;
pnl.BorderStyle = BorderStyle.FixedSingle;
pnl.Size = new Size(400,400);
pnl.Location = new Point(10,10);
pb = new PictureBox();
pb.Parent = pnl;
pb.Size = new Size(200, 200);
pb.Location = new Point((pnl.Size.Width / 2) - (pb.Size.Width / 2),
(pnl.Size.Height / 2) - (pb.Size.Height /2));
pb.BorderStyle = BorderStyle.FixedSingle;
pb.SizeMode = PictureBoxSizeMode.StretchImage;
pb.Image = img;
htbar = new TrackBar();
htbar.Parent = this;
htbar.Orientation = Orientation.Horizontal;
htbar.Size = new Size(pnl.Width, 10);
htbar.Location = new Point(pnl.Left, pnl.Bottom + 25);
htbar.TickStyle = TickStyle.BottomRight;
htbar.TickFrequency = 25;
htbar.Minimum = 25;
htbar.Maximum = 400;
htbar.SmallChange = 10;
htbar.LargeChange = 25;
htbar.BackColor = Color.Yellow;
htbar.Value = pb.Width;
htbar.ValueChanged += new EventHandler(htbar_OnValueChanged);
vtbar = new TrackBar();
vtbar.Parent = this;
vtbar.Orientation = Orientation.Vertical;
vtbar.Size = new Size(25, pnl.Height);
vtbar.Location = new Point(pnl.Right + 25, pnl.Top);
vtbar.TickStyle = TickStyle.Both;
vtbar.SetRange(25,400);
vtbar.SmallChange = 10;
vtbar.LargeChange = 50;
vtbar.TickFrequency = vtbar.Maximum / 20;
vtbar.BackColor = Color.Pink;
vtbar.Value = pb.Height;
vtbar.ValueChanged += new EventHandler(vtbar_OnValueChanged);
}
private void htbar_OnValueChanged(object sender, EventArgs e)
{
pb.Size = new Size(htbar.Value, pb.Height);
}
private void vtbar_OnValueChanged(object sender, EventArgs e)
{
pb.Size = new Size(pb.Width, vtbar.Value);
}
static void Main()
{
Application.Run(new TrackBars());
}
}
TrackBar.SmallChange
using System;
using System.Drawing;
using System.Windows.Forms;
public class TrackBars : Form
{
Panel pnl;
PictureBox pb;
TrackBar htbar;
TrackBar vtbar;
public TrackBars()
{
Size = new Size(500,520);
Image img = Image.FromFile("YourFile.bmp");
pnl = new Panel();
pnl.Parent = this;
pnl.BorderStyle = BorderStyle.FixedSingle;
pnl.Size = new Size(400,400);
pnl.Location = new Point(10,10);
pb = new PictureBox();
pb.Parent = pnl;
pb.Size = new Size(200, 200);
pb.Location = new Point((pnl.Size.Width / 2) - (pb.Size.Width / 2),
(pnl.Size.Height / 2) - (pb.Size.Height /2));
pb.BorderStyle = BorderStyle.FixedSingle;
pb.SizeMode = PictureBoxSizeMode.StretchImage;
pb.Image = img;
htbar = new TrackBar();
htbar.Parent = this;
htbar.Orientation = Orientation.Horizontal;
htbar.Size = new Size(pnl.Width, 10);
htbar.Location = new Point(pnl.Left, pnl.Bottom + 25);
htbar.TickStyle = TickStyle.BottomRight;
htbar.TickFrequency = 25;
htbar.Minimum = 25;
htbar.Maximum = 400;
htbar.SmallChange = 10;
htbar.LargeChange = 25;
htbar.BackColor = Color.Yellow;
htbar.Value = pb.Width;
htbar.ValueChanged += new EventHandler(htbar_OnValueChanged);
vtbar = new TrackBar();
vtbar.Parent = this;
vtbar.Orientation = Orientation.Vertical;
vtbar.Size = new Size(25, pnl.Height);
vtbar.Location = new Point(pnl.Right + 25, pnl.Top);
vtbar.TickStyle = TickStyle.Both;
vtbar.SetRange(25,400);
vtbar.SmallChange = 10;
vtbar.LargeChange = 50;
vtbar.TickFrequency = vtbar.Maximum / 20;
vtbar.BackColor = Color.Pink;
vtbar.Value = pb.Height;
vtbar.ValueChanged += new EventHandler(vtbar_OnValueChanged);
}
private void htbar_OnValueChanged(object sender, EventArgs e)
{
pb.Size = new Size(htbar.Value, pb.Height);
}
private void vtbar_OnValueChanged(object sender, EventArgs e)
{
pb.Size = new Size(pb.Width, vtbar.Value);
}
static void Main()
{
Application.Run(new TrackBars());
}
}
TrackBar.TickFrequency
using System;
using System.Drawing;
using System.Windows.Forms;
public class TrackBars : Form
{
Panel pnl;
PictureBox pb;
TrackBar htbar;
TrackBar vtbar;
public TrackBars()
{
Size = new Size(500,520);
Image img = Image.FromFile("YourFile.bmp");
pnl = new Panel();
pnl.Parent = this;
pnl.BorderStyle = BorderStyle.FixedSingle;
pnl.Size = new Size(400,400);
pnl.Location = new Point(10,10);
pb = new PictureBox();
pb.Parent = pnl;
pb.Size = new Size(200, 200);
pb.Location = new Point((pnl.Size.Width / 2) - (pb.Size.Width / 2),
(pnl.Size.Height / 2) - (pb.Size.Height /2));
pb.BorderStyle = BorderStyle.FixedSingle;
pb.SizeMode = PictureBoxSizeMode.StretchImage;
pb.Image = img;
htbar = new TrackBar();
htbar.Parent = this;
htbar.Orientation = Orientation.Horizontal;
htbar.Size = new Size(pnl.Width, 10);
htbar.Location = new Point(pnl.Left, pnl.Bottom + 25);
htbar.TickStyle = TickStyle.BottomRight;
htbar.TickFrequency = 25;
htbar.Minimum = 25;
htbar.Maximum = 400;
htbar.SmallChange = 10;
htbar.LargeChange = 25;
htbar.BackColor = Color.Yellow;
htbar.Value = pb.Width;
htbar.ValueChanged += new EventHandler(htbar_OnValueChanged);
vtbar = new TrackBar();
vtbar.Parent = this;
vtbar.Orientation = Orientation.Vertical;
vtbar.Size = new Size(25, pnl.Height);
vtbar.Location = new Point(pnl.Right + 25, pnl.Top);
vtbar.TickStyle = TickStyle.Both;
vtbar.SetRange(25,400);
vtbar.SmallChange = 10;
vtbar.LargeChange = 50;
vtbar.TickFrequency = vtbar.Maximum / 20;
vtbar.BackColor = Color.Pink;
vtbar.Value = pb.Height;
vtbar.ValueChanged += new EventHandler(vtbar_OnValueChanged);
}
private void htbar_OnValueChanged(object sender, EventArgs e)
{
pb.Size = new Size(htbar.Value, pb.Height);
}
private void vtbar_OnValueChanged(object sender, EventArgs e)
{
pb.Size = new Size(pb.Width, vtbar.Value);
}
static void Main()
{
Application.Run(new TrackBars());
}
}
TrackBar.TickStyle
using System;
using System.Drawing;
using System.Windows.Forms;
public class TrackBars : Form
{
Panel pnl;
PictureBox pb;
TrackBar htbar;
TrackBar vtbar;
public TrackBars()
{
Size = new Size(500,520);
Image img = Image.FromFile("YourFile.bmp");
pnl = new Panel();
pnl.Parent = this;
pnl.BorderStyle = BorderStyle.FixedSingle;
pnl.Size = new Size(400,400);
pnl.Location = new Point(10,10);
pb = new PictureBox();
pb.Parent = pnl;
pb.Size = new Size(200, 200);
pb.Location = new Point((pnl.Size.Width / 2) - (pb.Size.Width / 2),
(pnl.Size.Height / 2) - (pb.Size.Height /2));
pb.BorderStyle = BorderStyle.FixedSingle;
pb.SizeMode = PictureBoxSizeMode.StretchImage;
pb.Image = img;
htbar = new TrackBar();
htbar.Parent = this;
htbar.Orientation = Orientation.Horizontal;
htbar.Size = new Size(pnl.Width, 10);
htbar.Location = new Point(pnl.Left, pnl.Bottom + 25);
htbar.TickStyle = TickStyle.BottomRight;
htbar.TickFrequency = 25;
htbar.Minimum = 25;
htbar.Maximum = 400;
htbar.SmallChange = 10;
htbar.LargeChange = 25;
htbar.BackColor = Color.Yellow;
htbar.Value = pb.Width;
htbar.ValueChanged += new EventHandler(htbar_OnValueChanged);
vtbar = new TrackBar();
vtbar.Parent = this;
vtbar.Orientation = Orientation.Vertical;
vtbar.Size = new Size(25, pnl.Height);
vtbar.Location = new Point(pnl.Right + 25, pnl.Top);
vtbar.TickStyle = TickStyle.Both;
vtbar.SetRange(25,400);
vtbar.SmallChange = 10;
vtbar.LargeChange = 50;
vtbar.TickFrequency = vtbar.Maximum / 20;
vtbar.BackColor = Color.Pink;
vtbar.Value = pb.Height;
vtbar.ValueChanged += new EventHandler(vtbar_OnValueChanged);
}
private void htbar_OnValueChanged(object sender, EventArgs e)
{
pb.Size = new Size(htbar.Value, pb.Height);
}
private void vtbar_OnValueChanged(object sender, EventArgs e)
{
pb.Size = new Size(pb.Width, vtbar.Value);
}
static void Main()
{
Application.Run(new TrackBars());
}
}
TrackBar.Value
using System;
using System.Drawing;
using System.Windows.Forms;
public class TrackBars : Form
{
Panel pnl;
PictureBox pb;
TrackBar htbar;
TrackBar vtbar;
public TrackBars()
{
Size = new Size(500,520);
Image img = Image.FromFile("YourFile.bmp");
pnl = new Panel();
pnl.Parent = this;
pnl.BorderStyle = BorderStyle.FixedSingle;
pnl.Size = new Size(400,400);
pnl.Location = new Point(10,10);
pb = new PictureBox();
pb.Parent = pnl;
pb.Size = new Size(200, 200);
pb.Location = new Point((pnl.Size.Width / 2) - (pb.Size.Width / 2),
(pnl.Size.Height / 2) - (pb.Size.Height /2));
pb.BorderStyle = BorderStyle.FixedSingle;
pb.SizeMode = PictureBoxSizeMode.StretchImage;
pb.Image = img;
htbar = new TrackBar();
htbar.Parent = this;
htbar.Orientation = Orientation.Horizontal;
htbar.Size = new Size(pnl.Width, 10);
htbar.Location = new Point(pnl.Left, pnl.Bottom + 25);
htbar.TickStyle = TickStyle.BottomRight;
htbar.TickFrequency = 25;
htbar.Minimum = 25;
htbar.Maximum = 400;
htbar.SmallChange = 10;
htbar.LargeChange = 25;
htbar.BackColor = Color.Yellow;
htbar.Value = pb.Width;
htbar.ValueChanged += new EventHandler(htbar_OnValueChanged);
vtbar = new TrackBar();
vtbar.Parent = this;
vtbar.Orientation = Orientation.Vertical;
vtbar.Size = new Size(25, pnl.Height);
vtbar.Location = new Point(pnl.Right + 25, pnl.Top);
vtbar.TickStyle = TickStyle.Both;
vtbar.SetRange(25,400);
vtbar.SmallChange = 10;
vtbar.LargeChange = 50;
vtbar.TickFrequency = vtbar.Maximum / 20;
vtbar.BackColor = Color.Pink;
vtbar.Value = pb.Height;
vtbar.ValueChanged += new EventHandler(vtbar_OnValueChanged);
}
private void htbar_OnValueChanged(object sender, EventArgs e)
{
pb.Size = new Size(htbar.Value, pb.Height);
}
private void vtbar_OnValueChanged(object sender, EventArgs e)
{
pb.Size = new Size(pb.Width, vtbar.Value);
}
static void Main()
{
Application.Run(new TrackBars());
}
}
TrackBar.ValueChanged
using System;
using System.Drawing;
using System.Windows.Forms;
public class TrackBars : Form
{
Panel pnl;
PictureBox pb;
TrackBar htbar;
TrackBar vtbar;
public TrackBars()
{
Size = new Size(500,520);
Image img = Image.FromFile("YourFile.bmp");
pnl = new Panel();
pnl.Parent = this;
pnl.BorderStyle = BorderStyle.FixedSingle;
pnl.Size = new Size(400,400);
pnl.Location = new Point(10,10);
pb = new PictureBox();
pb.Parent = pnl;
pb.Size = new Size(200, 200);
pb.Location = new Point((pnl.Size.Width / 2) - (pb.Size.Width / 2),
(pnl.Size.Height / 2) - (pb.Size.Height /2));
pb.BorderStyle = BorderStyle.FixedSingle;
pb.SizeMode = PictureBoxSizeMode.StretchImage;
pb.Image = img;
htbar = new TrackBar();
htbar.Parent = this;
htbar.Orientation = Orientation.Horizontal;
htbar.Size = new Size(pnl.Width, 10);
htbar.Location = new Point(pnl.Left, pnl.Bottom + 25);
htbar.TickStyle = TickStyle.BottomRight;
htbar.TickFrequency = 25;
htbar.Minimum = 25;
htbar.Maximum = 400;
htbar.SmallChange = 10;
htbar.LargeChange = 25;
htbar.BackColor = Color.Yellow;
htbar.Value = pb.Width;
htbar.ValueChanged += new EventHandler(htbar_OnValueChanged);
vtbar = new TrackBar();
vtbar.Parent = this;
vtbar.Orientation = Orientation.Vertical;
vtbar.Size = new Size(25, pnl.Height);
vtbar.Location = new Point(pnl.Right + 25, pnl.Top);
vtbar.TickStyle = TickStyle.Both;
vtbar.SetRange(25,400);
vtbar.SmallChange = 10;
vtbar.LargeChange = 50;
vtbar.TickFrequency = vtbar.Maximum / 20;
vtbar.BackColor = Color.Pink;
vtbar.Value = pb.Height;
vtbar.ValueChanged += new EventHandler(vtbar_OnValueChanged);
}
private void htbar_OnValueChanged(object sender, EventArgs e)
{
pb.Size = new Size(htbar.Value, pb.Height);
}
private void vtbar_OnValueChanged(object sender, EventArgs e)
{
pb.Size = new Size(pb.Width, vtbar.Value);
}
static void Main()
{
Application.Run(new TrackBars());
}
}