-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDisplay.cs
82 lines (77 loc) · 2.66 KB
/
Display.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
using System;
using System.Collections.Generic;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Zernike_coefficients_AI
{
internal class Display
{
public void DisplayPicture(string pathImage, PictureBox pictureBox)
{
if (pictureBox.Image != null)
{
DisplayClear(new List<PictureBox> { pictureBox });
FileStream fileStream = new System.IO.FileStream(pathImage, FileMode.Open, FileAccess.Read);
pictureBox.Image = System.Drawing.Image.FromStream(fileStream);
fileStream.Close();
}
else
{
FileStream fileStream = new System.IO.FileStream(pathImage, FileMode.Open, FileAccess.Read);
pictureBox.Image = System.Drawing.Image.FromStream(fileStream);
fileStream.Close();
}
}
public void DisplayClear(List<PictureBox> pictureBoxes)
{
foreach (PictureBox pb in pictureBoxes)
{
if (pb.Image != null)
{
pb.Image.Dispose();
pb.Image = null;
}
else
{
return;
}
}
}
public void RadioButonEnabled(List<RadioButton> radioButtons, bool trueFalse)
{
foreach (RadioButton rb in radioButtons)
{
rb.Enabled = trueFalse;
}
}
public void RadioButonChecked(List<RadioButton> radioButtons, bool trueFalse)
{
foreach (RadioButton rb in radioButtons)
{
rb.Checked = trueFalse;
}
}
public void Magnifying(PictureBox pictureBoxOriginal, PictureBox pictureBoxZoom, int coordrectMouseX, int coordrectMouseY)
{
if (pictureBoxOriginal.Image == null)
{
return;
}
else
{
Bitmap tempImage = new Bitmap(160, 160, PixelFormat.Format24bppRgb);
Graphics bitmapGraphics = Graphics.FromImage(tempImage);
bitmapGraphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
bitmapGraphics.DrawImage(pictureBoxOriginal.Image,
new Rectangle(0, 0, 160, 160),
new Rectangle(coordrectMouseX - 40, coordrectMouseY - 40,80, 80),
GraphicsUnit.Pixel);
pictureBoxZoom.Image = tempImage;
}
}
}
}