-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMiniVisor.cs
109 lines (86 loc) · 3.56 KB
/
MiniVisor.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Horus {
public partial class MiniVisor : Form {
Int32 Sized = 0;
public MiniVisor() {
InitializeComponent();
}
private void MiniVisor_Load(object sender, EventArgs e) {
Program.MiniVisor_visible = true;
}
private void MiniVisor_Closing(object sender, FormClosingEventArgs e) {
Program.MiniVisor_visible = false;
}
private Bitmap CombineBitmap(Image[] Images) {
List<Bitmap> images = new List<Bitmap>();
Bitmap finalImage = null;
try {
Int32 width = 0;
Int32 height = 0;
foreach (Image image in Images) {
if (image != null) {
Bitmap bitmap = new Bitmap(image);
width += bitmap.Width;
height = bitmap.Height > height ? bitmap.Height : height;
images.Add(bitmap);
}
}
if (images.Count > 0) {
finalImage = new Bitmap(width, height);
using (Graphics g = Graphics.FromImage(finalImage)) {
g.Clear(Color.Black);
Int32 offset = 0;
foreach (Bitmap image in images) {
if (image != null) {
g.DrawImage(image, new Rectangle(offset, 0, image.Width, image.Height));
offset += image.Width;
}
}
}
return finalImage;
}
else {
return null;
}
}
catch (Exception ex) {
if (finalImage != null)
finalImage.Dispose();
throw ex;
}
finally {
foreach (Bitmap image in images) {
image.Dispose();
}
}
}
private void timer1_Tick(object sender, EventArgs e) {
try {
Bitmap ImagenToShow = CombineBitmap(Program.PreviewMatrix);
if (ImagenToShow != null) {
if (Sized != ImagenToShow.Width) {
Int32 ToDivide = 1;
for (Int32 Ciclos = 0; Ciclos <= 10; Ciclos++)
if ((ImagenToShow.Width / ToDivide) > Screen.PrimaryScreen.WorkingArea.Width)
ToDivide++;
this.Width = Convert.ToInt32(Math.Truncate(Convert.ToDecimal(ImagenToShow.Width / ToDivide)));
this.Height = Convert.ToInt32(Math.Truncate(Convert.ToDecimal(ImagenToShow.Height / ToDivide)));
this.Top = Screen.PrimaryScreen.WorkingArea.Height - this.Height - 30;
this.Left = Convert.ToInt32(Math.Truncate(Convert.ToDecimal(Screen.PrimaryScreen.WorkingArea.Width - this.Width) / 2));
Sized = ImagenToShow.Width;
}
this.PreviewWindow.Image = ImagenToShow;
}
}
catch { }
}
}
}