forked from ispysoftware/iSpy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GridView.cs
213 lines (177 loc) · 6.19 KB
/
GridView.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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using iSpyApplication.Controls;
namespace iSpyApplication
{
public partial class GridView : Form
{
private readonly Controls.GridView _gv;
private readonly configurationGrid _layout;
public configurationGrid Cg;
public GridView(MainForm parent, ref configurationGrid layout)
{
InitializeComponent();
_gv = new Controls.GridView(parent, ref layout, this);
_gv.KeyDown += GridView_KeyDown;
Controls.Add(_gv);
_gv.Dock = DockStyle.Fill;
_layout = layout;
fullScreenToolStripMenuItem.Checked = layout.FullScreen;
alwaysOnTopToolStripMenuItem.Checked = layout.AlwaysOnTop;
Cg = layout;
}
private void GridView_Load(object sender, EventArgs e)
{
Text = _gv.Text;
var screen = Screen.AllScreens.Where(s => s.DeviceName == _layout.Display).DefaultIfEmpty(Screen.PrimaryScreen).First();
StartPosition = FormStartPosition.Manual;
Location = screen.Bounds.Location;
if (fullScreenToolStripMenuItem.Checked)
MaxMin();
if (alwaysOnTopToolStripMenuItem.Checked)
OnTop();
}
private void MaxMin()
{
if (fullScreenToolStripMenuItem.Checked)
{
WindowState = FormWindowState.Maximized;
FormBorderStyle = FormBorderStyle.None;
WinApi.SetWinFullScreen(Handle);
}
else
{
WindowState = FormWindowState.Maximized;
FormBorderStyle = FormBorderStyle.Sizable;
}
}
public void ShowForm()
{
if (InvokeRequired)
{
Invoke(new Delegates.SimpleDelegate(ShowForm));
return;
}
Activate();
Visible = true;
if (WindowState == FormWindowState.Minimized)
{
Show();
WindowState = FormWindowState.Maximized;
}
}
private void OnTop()
{
TopMost = alwaysOnTopToolStripMenuItem.Checked;
}
private void Edit()
{
_gv.MainClass.EditGridView(_layout.name,this);
}
private void GridView_KeyDown(object sender, KeyEventArgs e)
{
if (e.Alt && e.KeyCode == Keys.Enter)
{
fullScreenToolStripMenuItem.Checked = !fullScreenToolStripMenuItem.Checked;
MaxMin();
}
}
private void fullScreenToolStripMenuItem_Click(object sender, EventArgs e)
{
MaxMin();
}
private void alwaysOnTopToolStripMenuItem_Click(object sender, EventArgs e)
{
OnTop();
}
private void closeGridViewToolStripMenuItem_Click(object sender, EventArgs e)
{
Close();
}
private void editToolStripMenuItem_Click(object sender, EventArgs e)
{
Edit();
_gv.Init();
}
private void switchFillModeAltFToolStripMenuItem_Click(object sender, EventArgs e)
{
_gv.Cg.Fill = !_gv.Cg.Fill;
}
private void GridView_FormClosing(object sender, FormClosingEventArgs e)
{
}
private void quickSelectToolStripMenuItem_Click(object sender, EventArgs e)
{
using (var so = new SelectObjects())
{
so.ShowDialog(this);
if (so.DialogResult == DialogResult.OK)
{
var l = so.SelectedObjects;
int i = 0;
var lg = new List<configurationGridGridItem>();
foreach (var o in l)
{
int oid = -1, otid = -1;
var k = o as objectsCamera;
if (k != null)
{
oid = k.id;
otid = 2;
}
var j = o as objectsMicrophone;
if (j != null)
{
oid = j.id;
otid = 1;
}
var m = o as objectsFloorplan;
if (m != null)
{
oid = m.id;
otid = 3;
}
lg.Add(new configurationGridGridItem
{
CycleDelay = 4,
GridIndex = i,
Item =
new[]
{
new configurationGridGridItemItem
{
ObjectID = oid,
TypeID = otid
}
}
});
i++;
if (i >= _gv.Cg.Columns*_gv.Cg.Rows)
break;
}
_gv.Cg.GridItem = lg.ToArray();
_gv.Init();
}
}
}
private void quickSelectToolStripMenuItem_DropDownOpening(object sender, EventArgs e)
{
quickSelectToolStripMenuItem.Visible = _gv.Cg.ModeIndex == 0;
}
private void contextMenuStrip1_Opening(object sender, System.ComponentModel.CancelEventArgs e)
{
}
private void GridView_MouseDown(object sender, MouseEventArgs e)
{
}
private void contextMenuStrip1_MouseMove(object sender, MouseEventArgs e)
{
}
private void GridView_MouseMove(object sender, MouseEventArgs e)
{
}
}
}