|
|
|
@ -1,11 +1,13 @@ |
|
|
|
using System; |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Collections.Generic; |
|
|
|
|
|
|
|
using System.ComponentModel; |
|
|
|
using System.Diagnostics; |
|
|
|
using System.Diagnostics; |
|
|
|
using System.Drawing; |
|
|
|
using System.Drawing; |
|
|
|
using System.Drawing.Drawing2D; |
|
|
|
using System.Drawing.Drawing2D; |
|
|
|
using System.Drawing.Imaging; |
|
|
|
using System.Drawing.Imaging; |
|
|
|
using System.Reflection; |
|
|
|
using System.Reflection; |
|
|
|
using System.Windows.Forms; |
|
|
|
using System.Windows.Forms; |
|
|
|
|
|
|
|
using System.Windows.Forms.Design; |
|
|
|
using UTIL; |
|
|
|
using UTIL; |
|
|
|
|
|
|
|
|
|
|
|
namespace Test_img |
|
|
|
namespace Test_img |
|
|
|
@ -44,6 +46,12 @@ namespace Test_img |
|
|
|
public Form1() |
|
|
|
public Form1() |
|
|
|
{ |
|
|
|
{ |
|
|
|
InitializeComponent(); |
|
|
|
InitializeComponent(); |
|
|
|
|
|
|
|
//ToolStripControlHost trackBar1 = new ToolStripControlHost(new TrackBar()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//trackBar1.AutoSize = false; |
|
|
|
|
|
|
|
//trackBar1.Size = new Size(150, 10); |
|
|
|
|
|
|
|
//MenuItem3.DropDownItems.Add(trackBar1); |
|
|
|
|
|
|
|
//statusStrip1.Items.Add(trackBar1); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void Form1_Load(object sender, EventArgs e) |
|
|
|
private void Form1_Load(object sender, EventArgs e) |
|
|
|
@ -51,14 +59,15 @@ namespace Test_img |
|
|
|
pictureBox1.MouseWheel += new MouseEventHandler(pictureBox1_MouseWheel); |
|
|
|
pictureBox1.MouseWheel += new MouseEventHandler(pictureBox1_MouseWheel); |
|
|
|
resolution = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Size; |
|
|
|
resolution = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Size; |
|
|
|
img_aspect.Text = $"Аспект: {zoomFactor:F3}"; |
|
|
|
img_aspect.Text = $"Аспект: {zoomFactor:F3}"; |
|
|
|
StaticData.ValueChanged += (sender1, e1) => |
|
|
|
//StaticData.ValueChanged += (sender1, e1) => |
|
|
|
{ |
|
|
|
//{ |
|
|
|
imgsearch = StaticData.DataBuffer; |
|
|
|
// imgsearch = StaticData.DataBuffer; |
|
|
|
//img_srch.Text = StaticData.DataBuffer.ToString(); |
|
|
|
// //img_srch.Text = StaticData.DataBuffer.ToString(); |
|
|
|
}; |
|
|
|
//}; |
|
|
|
StaticData.SHandlerSearch = new StaticData.SHandler(SearchPixel); |
|
|
|
//StaticData.SHandlerSearch = new StaticData.SHandler(SearchPixel); |
|
|
|
pictureBox1.Image = bm = new Bitmap(pictureBox1.Width, pictureBox1.Height); |
|
|
|
pictureBox1.Image = bm = new Bitmap(pictureBox1.Width, pictureBox1.Height); |
|
|
|
StaticData.TrgEventHandler += SearchPixel2; |
|
|
|
// StaticData.TrgEventHandler += SearchPixel2; |
|
|
|
|
|
|
|
Label1.Text = trackbar1.Value.ToString(); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
private void Form1_SizeChanged(object sender, EventArgs e) |
|
|
|
private void Form1_SizeChanged(object sender, EventArgs e) |
|
|
|
@ -80,6 +89,8 @@ namespace Test_img |
|
|
|
movingPoint = new Point((pictureBox1.Width - bm.Width) / 2, (pictureBox1.Height - bm.Height) / 2); |
|
|
|
movingPoint = new Point((pictureBox1.Width - bm.Width) / 2, (pictureBox1.Height - bm.Height) / 2); |
|
|
|
pictureBox1.Invalidate(); |
|
|
|
pictureBox1.Invalidate(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region Мышиные события |
|
|
|
private void pictureBox1_MouseEnter(object sender, EventArgs e) |
|
|
|
private void pictureBox1_MouseEnter(object sender, EventArgs e) |
|
|
|
{ |
|
|
|
{ |
|
|
|
pictureBox1.MouseWheel += pictureBox1_MouseWheel; |
|
|
|
pictureBox1.MouseWheel += pictureBox1_MouseWheel; |
|
|
|
@ -186,6 +197,8 @@ namespace Test_img |
|
|
|
yyy.Text = $"{xPos:D4} {yPos:D4}"; |
|
|
|
yyy.Text = $"{xPos:D4} {yPos:D4}"; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion |
|
|
|
private void pictureBox1_Paint(object sender, PaintEventArgs e) |
|
|
|
private void pictureBox1_Paint(object sender, PaintEventArgs e) |
|
|
|
{ |
|
|
|
{ |
|
|
|
e.Graphics.Clear(Color.White); |
|
|
|
e.Graphics.Clear(Color.White); |
|
|
|
@ -196,17 +209,46 @@ namespace Test_img |
|
|
|
if (img_center.Checked) |
|
|
|
if (img_center.Checked) |
|
|
|
{ |
|
|
|
{ |
|
|
|
e.Graphics.DrawLine(new Pen(Color.LimeGreen, 1), |
|
|
|
e.Graphics.DrawLine(new Pen(Color.LimeGreen, 1), |
|
|
|
BmToPb(MassCenter).X, |
|
|
|
PointBmToPb(MassCenter).X, |
|
|
|
BmToPb(MassCenter).Y - 20, |
|
|
|
PointBmToPb(MassCenter).Y - 20, |
|
|
|
BmToPb(MassCenter).X, |
|
|
|
PointBmToPb(MassCenter).X, |
|
|
|
BmToPb(MassCenter).Y + 20); |
|
|
|
PointBmToPb(MassCenter).Y + 20); |
|
|
|
e.Graphics.DrawLine(new Pen(Color.LimeGreen, 1), |
|
|
|
e.Graphics.DrawLine(new Pen(Color.LimeGreen, 1), |
|
|
|
BmToPb(MassCenter).X - 20, |
|
|
|
PointBmToPb(MassCenter).X - 20, |
|
|
|
BmToPb(MassCenter).Y, |
|
|
|
PointBmToPb(MassCenter).Y, |
|
|
|
BmToPb(MassCenter).X + 20, |
|
|
|
PointBmToPb(MassCenter).X + 20, |
|
|
|
BmToPb(MassCenter).Y); |
|
|
|
PointBmToPb(MassCenter).Y); |
|
|
|
e.Graphics.DrawRectangle(new Pen(Color.LimeGreen, 1), BmToPb(MassCenter).X - 20, BmToPb(MassCenter).Y - 20, 40, 40); |
|
|
|
e.Graphics.DrawRectangle(new Pen(Color.LimeGreen, 1), PointBmToPb(MassCenter).X - 20, PointBmToPb(MassCenter).Y - 20, 40, 40); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (img_clusters.Checked) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
SearchClusters((UInt16)imgsearch); |
|
|
|
|
|
|
|
for (int m = 0; m < g_super_cluster_count; m++) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
e.Graphics.DrawRectangle(new Pen(Color.Cyan, 1), |
|
|
|
|
|
|
|
PointBmToPb(new Point(g_super_cluster_coords[m].rect.left, g_super_cluster_coords[m].rect.top)).X, |
|
|
|
|
|
|
|
PointBmToPb(new Point(g_super_cluster_coords[m].rect.left, g_super_cluster_coords[m].rect.top)).Y, |
|
|
|
|
|
|
|
(g_super_cluster_coords[m].rect.right - g_super_cluster_coords[m].rect.left) * zoomFactor, |
|
|
|
|
|
|
|
(g_super_cluster_coords[m].rect.bottom - g_super_cluster_coords[m].rect.top) * zoomFactor); |
|
|
|
|
|
|
|
if (show_mass_center.Checked) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Point r = CalcCenterMass(CLUSTER_COORD2Rect(g_super_cluster_coords[m])); |
|
|
|
|
|
|
|
Point rct = PointBmToPb(r); |
|
|
|
|
|
|
|
e.Graphics.DrawLine(new Pen(Color.LimeGreen, 1), rct.X, rct.Y - 20, rct.X, rct.Y + 20); |
|
|
|
|
|
|
|
e.Graphics.DrawLine(new Pen(Color.LimeGreen, 1), rct.X - 20, rct.Y, rct.X + 20, rct.Y); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (img_search.Checked) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
foreach (var pnt in SearchPixel2(imgsearch)) |
|
|
|
|
|
|
|
e.Graphics.DrawEllipse(new Pen(Color.Red), |
|
|
|
|
|
|
|
PointBmToPb(pnt).X - 5 * zoomFactor, |
|
|
|
|
|
|
|
PointBmToPb(pnt).Y - 5 * zoomFactor, |
|
|
|
|
|
|
|
10 * zoomFactor, |
|
|
|
|
|
|
|
10 * zoomFactor); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
GC.Collect(); |
|
|
|
GC.Collect(); |
|
|
|
} |
|
|
|
} |
|
|
|
public Bitmap ResizeImage(Image image, float zoom) |
|
|
|
public Bitmap ResizeImage(Image image, float zoom) |
|
|
|
@ -260,36 +302,36 @@ namespace Test_img |
|
|
|
return new Rectangle(p3, new Size(p4.X - p3.X, p2.Y - p3.Y)); |
|
|
|
return new Rectangle(p3, new Size(p4.X - p3.X, p2.Y - p3.Y)); |
|
|
|
return r; |
|
|
|
return r; |
|
|
|
} |
|
|
|
} |
|
|
|
private void SearchPixel() |
|
|
|
//private void SearchPixel() |
|
|
|
{ |
|
|
|
//{ |
|
|
|
List<Point> points = new List<Point>(); |
|
|
|
// List<Point> points = new List<Point>(); |
|
|
|
Stopwatch stopwatch = Stopwatch.StartNew(); |
|
|
|
// Stopwatch stopwatch = Stopwatch.StartNew(); |
|
|
|
UnsafeBitmap btm = new UnsafeBitmap(bm); |
|
|
|
// UnsafeBitmap btm = new UnsafeBitmap(bm); |
|
|
|
btm.LockBitmap(); |
|
|
|
// btm.LockBitmap(); |
|
|
|
for (int y = 0; y < bm.Height; y++) |
|
|
|
// for (int y = 0; y < bm.Height; y++) |
|
|
|
{ |
|
|
|
// { |
|
|
|
for (int x = 0; x < bm.Width; x++) |
|
|
|
// for (int x = 0; x < bm.Width; x++) |
|
|
|
{ |
|
|
|
// { |
|
|
|
PixelData c = btm.GetPixel(x, y); |
|
|
|
// PixelData c = btm.GetPixel(x, y); |
|
|
|
if (c.blue >= imgsearch) |
|
|
|
// if (c.blue >= imgsearch) |
|
|
|
{ |
|
|
|
// { |
|
|
|
points.Add(new Point(x, y)); |
|
|
|
// points.Add(new Point(x, y)); |
|
|
|
//Console.WriteLine($"{x} {y}"); |
|
|
|
// //Console.WriteLine($"{x} {y}"); |
|
|
|
} |
|
|
|
// } |
|
|
|
} |
|
|
|
// } |
|
|
|
} |
|
|
|
// } |
|
|
|
stopwatch.Stop(); |
|
|
|
// stopwatch.Stop(); |
|
|
|
Console.WriteLine(stopwatch.Elapsed.ToString()); |
|
|
|
// Console.WriteLine(stopwatch.Elapsed.ToString()); |
|
|
|
btm.Dispose(); |
|
|
|
// btm.Dispose(); |
|
|
|
using (Graphics g = Graphics.FromImage(newbm)) |
|
|
|
// using (Graphics g = Graphics.FromImage(newbm)) |
|
|
|
{ |
|
|
|
// { |
|
|
|
//g.Clear(Color.White); |
|
|
|
// //g.Clear(Color.White); |
|
|
|
for (int i = 0; i < points.Count; i++) |
|
|
|
// for (int i = 0; i < points.Count; i++) |
|
|
|
g.DrawEllipse(new Pen(Color.Red), points[i].X - 5, points[i].Y - 5, 10, 10); |
|
|
|
// g.DrawEllipse(new Pen(Color.Red), points[i].X - 5, points[i].Y - 5, 10, 10); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
// } |
|
|
|
pictureBox1.Invalidate(); |
|
|
|
// pictureBox1.Invalidate(); |
|
|
|
} |
|
|
|
//} |
|
|
|
private Point CalcCenterMass(Rectangle r) |
|
|
|
private Point CalcCenterMass(Rectangle r) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Int32 sX = 0; |
|
|
|
Int32 sX = 0; |
|
|
|
@ -305,7 +347,7 @@ namespace Test_img |
|
|
|
for (int x = r.X; x < r.Right; x++) |
|
|
|
for (int x = r.X; x < r.Right; x++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
PixelData c = btm.GetPixel(x, y); |
|
|
|
PixelData c = btm.GetPixel(x, y); |
|
|
|
if (minus_fon.Checked) |
|
|
|
if (minus_fon.Checked || minus_fon2.Checked) |
|
|
|
{ |
|
|
|
{ |
|
|
|
sX += (Int32)((c.blue - fon) * x); |
|
|
|
sX += (Int32)((c.blue - fon) * x); |
|
|
|
sY += (Int32)((c.blue - fon) * y); |
|
|
|
sY += (Int32)((c.blue - fon) * y); |
|
|
|
@ -327,16 +369,20 @@ namespace Test_img |
|
|
|
sX /= sZ; |
|
|
|
sX /= sZ; |
|
|
|
sY /= sZ; |
|
|
|
sY /= sZ; |
|
|
|
btm.Dispose(); |
|
|
|
btm.Dispose(); |
|
|
|
Console.WriteLine($"num: {num} num2: {r.Width * r.Height} x: {sX} y: {sY}"); |
|
|
|
//Console.WriteLine($"num: {num} num2: {r.Width * r.Height} x: {sX} y: {sY}"); |
|
|
|
return new Point(sX, sY); |
|
|
|
return new Point(sX, sY); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
return Point.Empty; |
|
|
|
return Point.Empty; |
|
|
|
} |
|
|
|
} |
|
|
|
private Point BmToPb(Point p) |
|
|
|
private Point PointBmToPb(Point p) |
|
|
|
{ |
|
|
|
{ |
|
|
|
return new Point((int)(p.X * zoomFactor + movingPoint.X), (int)(p.Y * zoomFactor + movingPoint.Y)); |
|
|
|
return new Point((int)(p.X * zoomFactor + movingPoint.X), (int)(p.Y * zoomFactor + movingPoint.Y)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private Rectangle RectBmToPb(Rectangle p) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return new Rectangle((int)(p.X * zoomFactor + movingPoint.X), (int)(p.Y * zoomFactor + movingPoint.Y), (int)(p.Width * zoomFactor), (int)(p.Height * zoomFactor)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#region Меню |
|
|
|
#region Меню |
|
|
|
private void img_load_Click(object sender, EventArgs e) |
|
|
|
private void img_load_Click(object sender, EventArgs e) |
|
|
|
@ -382,13 +428,13 @@ namespace Test_img |
|
|
|
if (img_search.Checked) |
|
|
|
if (img_search.Checked) |
|
|
|
{ |
|
|
|
{ |
|
|
|
img_search.Image = Properties.Resources.CheckBoxChecked; |
|
|
|
img_search.Image = Properties.Resources.CheckBoxChecked; |
|
|
|
srch.Show(); |
|
|
|
//srch.Show(); |
|
|
|
StaticData.Fon?.Invoke(fon); |
|
|
|
//StaticData.Fon?.Invoke(fon); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
img_search.Image = Properties.Resources.CheckBoxUnchecked; |
|
|
|
img_search.Image = Properties.Resources.CheckBoxUnchecked; |
|
|
|
srch.Hide(); |
|
|
|
//srch.Hide(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
private void img_save_Click(object sender, EventArgs e) |
|
|
|
private void img_save_Click(object sender, EventArgs e) |
|
|
|
@ -467,8 +513,26 @@ namespace Test_img |
|
|
|
} |
|
|
|
} |
|
|
|
#endregion |
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
|
|
private void SearchPixel2() |
|
|
|
private List<Point> SearchPixel2(int isrch) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
List<Point> points = new List<Point>(); |
|
|
|
|
|
|
|
Stopwatch stopwatch = Stopwatch.StartNew(); |
|
|
|
|
|
|
|
UnsafeBitmap btm = new UnsafeBitmap(bm); |
|
|
|
|
|
|
|
btm.LockBitmap(); |
|
|
|
|
|
|
|
for (int y = 0; y < bm.Height; y++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
for (int x = 0; x < bm.Width; x++) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
PixelData c = btm.GetPixel(x, y); |
|
|
|
|
|
|
|
if (c.blue >= isrch && c.red >= isrch && c.green >= isrch) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
points.Add(new Point(x, y)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
stopwatch.Stop(); |
|
|
|
|
|
|
|
btm.Dispose(); |
|
|
|
|
|
|
|
return points; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void img_fon_Click(object sender, EventArgs e) |
|
|
|
private void img_fon_Click(object sender, EventArgs e) |
|
|
|
@ -513,6 +577,8 @@ namespace Test_img |
|
|
|
btm.UnlockBitmap(); |
|
|
|
btm.UnlockBitmap(); |
|
|
|
btm.Dispose(); |
|
|
|
btm.Dispose(); |
|
|
|
fon = sc; |
|
|
|
fon = sc; |
|
|
|
|
|
|
|
trackbar1.Value = (int)fon + 1; |
|
|
|
|
|
|
|
imgsearch = (int)fon; |
|
|
|
StaticData.Fon?.Invoke(sc); |
|
|
|
StaticData.Fon?.Invoke(sc); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -533,10 +599,6 @@ namespace Test_img |
|
|
|
private void timer1_Tick(object sender, EventArgs e) |
|
|
|
private void timer1_Tick(object sender, EventArgs e) |
|
|
|
{ |
|
|
|
{ |
|
|
|
newbm = (Bitmap)bm.Clone(); |
|
|
|
newbm = (Bitmap)bm.Clone(); |
|
|
|
if (img_search.Checked) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
SearchPixel(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
pictureBox1.Invalidate(); |
|
|
|
pictureBox1.Invalidate(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -563,5 +625,204 @@ namespace Test_img |
|
|
|
minus_fon.Image = Properties.Resources.CheckBoxUnchecked; |
|
|
|
minus_fon.Image = Properties.Resources.CheckBoxUnchecked; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void img_clusters_Click(object sender, EventArgs e) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (img_clusters.Checked) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
img_clusters.Image = Properties.Resources.CheckBoxChecked; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
img_clusters.Image = Properties.Resources.CheckBoxUnchecked; |
|
|
|
|
|
|
|
minus_fon2.Image = Properties.Resources.CheckBoxUnchecked; |
|
|
|
|
|
|
|
minus_fon2.Checked = false; |
|
|
|
|
|
|
|
show_mass_center.Image = Properties.Resources.CheckBoxUnchecked; |
|
|
|
|
|
|
|
show_mass_center.Checked = false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
SearchClusters((UInt16)imgsearch); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void show_mass_center_Click(object sender, EventArgs e) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (show_mass_center.Checked) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
show_mass_center.Image = Properties.Resources.CheckBoxChecked; |
|
|
|
|
|
|
|
img_clusters.Image = Properties.Resources.CheckBoxChecked; |
|
|
|
|
|
|
|
img_clusters.Checked = true; |
|
|
|
|
|
|
|
SearchClusters((UInt16)imgsearch); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
show_mass_center.Image = Properties.Resources.CheckBoxUnchecked; |
|
|
|
|
|
|
|
//img_clusters.Image = Properties.Resources.CheckBoxUnchecked; |
|
|
|
|
|
|
|
//img_clusters.Checked = false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void minus_fon2_Click(object sender, EventArgs e) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (show_mass_center.Checked) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
minus_fon2.Image = Properties.Resources.CheckBoxChecked; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
minus_fon2.Image = Properties.Resources.CheckBoxUnchecked; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void trackbar1_ValueChanged(object sender, EventArgs e) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Label1.Text = trackbar1.Value.ToString(); |
|
|
|
|
|
|
|
imgsearch = trackbar1.Value; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region Компоненты меню |
|
|
|
|
|
|
|
[System.ComponentModel.DesignerCategory("code")] |
|
|
|
|
|
|
|
[ToolStripItemDesignerAvailability(ToolStripItemDesignerAvailability.ContextMenuStrip | ToolStripItemDesignerAvailability.MenuStrip)] |
|
|
|
|
|
|
|
public partial class ToolStripMenuItem : ToolStripControlHost |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
public ToolStripMenuItem() |
|
|
|
|
|
|
|
: base(CreateControlInstance()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
|
|
|
/// Create a strongly typed property called TrackBar - handy to prevent casting everywhere. |
|
|
|
|
|
|
|
/// </summary> |
|
|
|
|
|
|
|
public TrackBar TrackBar |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
get |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return Control as TrackBar; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
|
|
|
/// Create the actual control, note this is static so it can be called from the |
|
|
|
|
|
|
|
/// constructor. |
|
|
|
|
|
|
|
/// |
|
|
|
|
|
|
|
/// </summary> |
|
|
|
|
|
|
|
/// <returns></returns> |
|
|
|
|
|
|
|
private static Control CreateControlInstance() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
TrackBar t = new TrackBar(); |
|
|
|
|
|
|
|
t.AutoSize = false; |
|
|
|
|
|
|
|
// Add other initialization code here. |
|
|
|
|
|
|
|
return t; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
[DefaultValue(0)] |
|
|
|
|
|
|
|
public int Value |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
get { return TrackBar.Value; } |
|
|
|
|
|
|
|
set { TrackBar.Value = value; } |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
|
|
|
/// Attach to events we want to re-wrap |
|
|
|
|
|
|
|
/// </summary> |
|
|
|
|
|
|
|
/// <param name="control"></param> |
|
|
|
|
|
|
|
[DefaultValue(0)] |
|
|
|
|
|
|
|
public int Minimum |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
get { return TrackBar.Minimum; } |
|
|
|
|
|
|
|
set { TrackBar.Minimum = value; } |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
[DefaultValue(100)] |
|
|
|
|
|
|
|
public int Maximum |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
get { return TrackBar.Maximum; } |
|
|
|
|
|
|
|
set { TrackBar.Maximum = value; } |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
[DefaultValue(10)] |
|
|
|
|
|
|
|
public int TickFrequency |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
get { return TrackBar.TickFrequency; } |
|
|
|
|
|
|
|
set { TrackBar.TickFrequency = value; } |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public TickStyle TickStyle |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
get { return TrackBar.TickStyle; } |
|
|
|
|
|
|
|
set { TrackBar.TickStyle = value; } |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
protected override void OnSubscribeControlEvents(Control control) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
base.OnSubscribeControlEvents(control); |
|
|
|
|
|
|
|
TrackBar trackBar = control as TrackBar; |
|
|
|
|
|
|
|
trackBar.ValueChanged += new EventHandler(trackBar_ValueChanged); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
|
|
|
/// Detach from events. |
|
|
|
|
|
|
|
/// </summary> |
|
|
|
|
|
|
|
/// <param name="control"></param> |
|
|
|
|
|
|
|
protected override void OnUnsubscribeControlEvents(Control control) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
base.OnUnsubscribeControlEvents(control); |
|
|
|
|
|
|
|
TrackBar trackBar = control as TrackBar; |
|
|
|
|
|
|
|
trackBar.ValueChanged -= new EventHandler(trackBar_ValueChanged); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
|
|
|
/// Routing for event |
|
|
|
|
|
|
|
/// TrackBar.ValueChanged -> ToolStripTrackBar.ValueChanged |
|
|
|
|
|
|
|
/// </summary> |
|
|
|
|
|
|
|
/// <param name="sender"></param> |
|
|
|
|
|
|
|
/// <param name="e"></param> |
|
|
|
|
|
|
|
void trackBar_ValueChanged(object sender, EventArgs e) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// when the trackbar value changes, fire an event. |
|
|
|
|
|
|
|
if (this.ValueChanged != null) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
ValueChanged(sender, e); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// add an event that is subscribable from the designer. |
|
|
|
|
|
|
|
public event EventHandler ValueChanged; |
|
|
|
|
|
|
|
// set other defaults that are interesting |
|
|
|
|
|
|
|
protected override Size DefaultSize |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
get |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return new Size(200, 16); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
[System.ComponentModel.DesignerCategory("code")] |
|
|
|
|
|
|
|
[ToolStripItemDesignerAvailability(ToolStripItemDesignerAvailability.ContextMenuStrip | ToolStripItemDesignerAvailability.MenuStrip)] |
|
|
|
|
|
|
|
public partial class ToolStripLabel : ToolStripControlHost |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
public ToolStripLabel() : base(CreateControlInstance()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public Label Label |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
get |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return Control as Label; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
private static Control CreateControlInstance() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Label t = new Label(); |
|
|
|
|
|
|
|
t.AutoSize = false; |
|
|
|
|
|
|
|
// Add other initialization code here. |
|
|
|
|
|
|
|
return t; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//public String Text |
|
|
|
|
|
|
|
//{ |
|
|
|
|
|
|
|
// get { return Label.Text; } |
|
|
|
|
|
|
|
// set { Label.Text = value; } |
|
|
|
|
|
|
|
//} |
|
|
|
|
|
|
|
//public System.Drawing.ContentAlignment TextAlign |
|
|
|
|
|
|
|
//{ |
|
|
|
|
|
|
|
// get { return Label.TextAlign; } |
|
|
|
|
|
|
|
// set { Label.TextAlign = value; } |
|
|
|
|
|
|
|
//} |
|
|
|
|
|
|
|
//protected override Size DefaultSize |
|
|
|
|
|
|
|
//{ |
|
|
|
|
|
|
|
// get |
|
|
|
|
|
|
|
// { |
|
|
|
|
|
|
|
// return new Size(200, 16); |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
//} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#endregion |
|
|
|
} |
|
|
|
} |
|
|
|
|