-
Notifications
You must be signed in to change notification settings - Fork 0
/
Form1.cs
183 lines (153 loc) · 8.83 KB
/
Form1.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
using Asso.Launcher.Classes;
using DevExpress.XtraBars.Controls;
using DevExpress.XtraEditors;
using DevExpress.XtraEditors.TableLayout;
using DevExpress.XtraGrid.Views.Tile;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Asso.Launcher
{
public partial class Form1 : Form
{
public const int WM_NCLBUTTONDOWN = 0xA1;
public const int HT_CAPTION = 0x2;
public Form1()
{
InitializeComponent();
labelControlAppTitle.Text += " v." + AppUtilities.GetCurrentAppVersion();
if(true)
{
lciRecentFiles.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
}
FillRecentOpenedFileGrid();
//https://supportcenter.devexpress.com/ticket/details/t1006182/barmanager-how-to-drag-a-form-by-clicking-a-bar
this.MouseDown += DragForm_MouseDown;
//emptySpaceItem2.MouseDown += DragForm_MouseDown;
layoutControlItem1.MouseDown += DragForm_MouseDown;
labelControlAppTitle.MouseDown += DragForm_MouseDown;
gcToolOptions.MouseDown += DragForm_MouseDown;
layoutControl1.ShowCustomization += LayoutControl1_ShowHideCustomization;
layoutControl1.HideCustomization += LayoutControl1_ShowHideCustomization;
}
bool allowDragForm = true;
private void LayoutControl1_ShowHideCustomization(object sender, EventArgs e)
{
allowDragForm = !allowDragForm;
}
private void FillRecentOpenedFileGrid()
{
gcToolOptions.DataSource = Asso.Launcher.Data.AssoToolForLaunch.LoadData();
tileViewAssoLaunchOptions.OptionsTiles.Orientation = Orientation.Vertical;
TableColumnDefinition tableColumnDefinition1 = new TableColumnDefinition();
TableColumnDefinition tableColumnDefinition2 = new TableColumnDefinition();
TableRowDefinition tableRowDefinition1 = new TableRowDefinition();
TableRowDefinition tableRowDefinition2 = new TableRowDefinition();
TileViewItemElement tileViewItemElement1 = new TileViewItemElement();
TileViewItemElement tileViewItemElement2 = new TileViewItemElement();
TileViewItemElement tileViewItemElement3 = new TileViewItemElement();
//TileViewItemElement tileViewItemElement4 = new TileViewItemElement();
//TileViewItemElement tileViewItemElement5 = new TileViewItemElement();
tableColumnDefinition1.Length.Value = 15D;
tableColumnDefinition2.Length.Value = 81D;
tileViewAssoLaunchOptions.TileColumns.Add(tableColumnDefinition1);
tileViewAssoLaunchOptions.TileColumns.Add(tableColumnDefinition2);
tileViewAssoLaunchOptions.TileRows.Add(tableRowDefinition1);
tileViewAssoLaunchOptions.TileRows.Add(tableRowDefinition2);
tileViewItemElement1.Column = tileViewAssoLaunchOptions.Columns["Picture"];
tileViewItemElement1.ImageOptions.ImageAlignment = TileItemContentAlignment.MiddleCenter;
tileViewItemElement1.ImageOptions.ImageScaleMode = TileItemImageScaleMode.Squeeze;
//tileViewItemElement1.Text = "colID";
tileViewItemElement1.TextAlignment = TileItemContentAlignment.MiddleCenter;
tileViewItemElement1.ColumnIndex = 0;
tileViewItemElement1.RowIndex = 0;
tileViewItemElement2.Appearance.Hovered.Font = new System.Drawing.Font("Tahoma", 12F, System.Drawing.FontStyle.Bold);
tileViewItemElement2.Appearance.Hovered.Options.UseFont = true;
tileViewItemElement2.Appearance.Hovered.Options.UseTextOptions = true;
tileViewItemElement2.Appearance.Hovered.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
tileViewItemElement2.Appearance.Normal.Font = new System.Drawing.Font("Tahoma", 12F, System.Drawing.FontStyle.Bold);
tileViewItemElement2.Appearance.Normal.Options.UseFont = true;
tileViewItemElement2.Appearance.Normal.Options.UseTextOptions = true;
tileViewItemElement2.Appearance.Normal.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
tileViewItemElement2.Appearance.Pressed.Font = new System.Drawing.Font("Tahoma", 12F, System.Drawing.FontStyle.Bold);
tileViewItemElement2.Appearance.Pressed.Options.UseFont = true;
tileViewItemElement2.Appearance.Pressed.Options.UseTextOptions = true;
tileViewItemElement2.Appearance.Pressed.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
tileViewItemElement2.Appearance.Selected.Font = new System.Drawing.Font("Tahoma", 12F, System.Drawing.FontStyle.Bold);
tileViewItemElement2.Appearance.Selected.Options.UseFont = true;
tileViewItemElement2.Appearance.Selected.Options.UseTextOptions = true;
tileViewItemElement2.Appearance.Selected.Font = new System.Drawing.Font("Tahoma", 12F, System.Drawing.FontStyle.Bold);
tileViewItemElement2.Appearance.Selected.Options.UseFont = true;
tileViewItemElement2.Appearance.Selected.Options.UseTextOptions = true;
tileViewItemElement2.Column = tileViewAssoLaunchOptions.Columns["Name"];
tileViewItemElement2.ImageOptions.ImageAlignment = TileItemContentAlignment.MiddleCenter;
tileViewItemElement2.ImageOptions.ImageScaleMode = TileItemImageScaleMode.Squeeze;
tileViewItemElement2.ColumnIndex = 1;
tileViewItemElement2.RowIndex = 0;
tileViewItemElement2.Text = "";
tileViewItemElement2.TextAlignment = TileItemContentAlignment.MiddleCenter;
tileViewItemElement3.Column = tileViewAssoLaunchOptions.Columns["Description"];
tileViewItemElement3.ColumnIndex = 1;
tileViewItemElement3.ImageOptions.ImageAlignment = TileItemContentAlignment.MiddleCenter;
tileViewItemElement3.ImageOptions.ImageScaleMode = TileItemImageScaleMode.Squeeze;
tileViewItemElement3.RowIndex = 1;
tileViewItemElement3.Text = "";
tileViewItemElement3.TextAlignment = TileItemContentAlignment.MiddleCenter;
//tileViewItemElement4.Column = tileView1.Columns["Name"];
//tileViewItemElement4.ColumnIndex = 3;
//tileViewItemElement4.ImageOptions.ImageAlignment = TileItemContentAlignment.MiddleCenter;
//tileViewItemElement4.ImageOptions.ImageScaleMode = TileItemImageScaleMode.Squeeze;
//tileViewItemElement4.Text = "colTypeOfObject";
//tileViewItemElement4.TextAlignment = TileItemContentAlignment.MiddleCenter;
//tileViewItemElement5.Column = tileView1.Columns["Name"];
//tileViewItemElement5.ColumnIndex = 1;
//tileViewItemElement5.ImageOptions.ImageAlignment = TileItemContentAlignment.MiddleCenter;
//tileViewItemElement5.ImageOptions.ImageScaleMode = TileItemImageScaleMode.Squeeze;
//tileViewItemElement5.RowIndex = 1;
//tileViewItemElement5.Text = "colRecordDate";
//tileViewItemElement5.TextAlignment = TileItemContentAlignment.MiddleCenter;
tileViewAssoLaunchOptions.TileTemplate.Add(tileViewItemElement1);
tileViewAssoLaunchOptions.TileTemplate.Add(tileViewItemElement2);
tileViewAssoLaunchOptions.TileTemplate.Add(tileViewItemElement3);
}
[DllImport("user32.dll")]
public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
[DllImport("user32.dll")]
public static extern bool ReleaseCapture();
private void lciRecentFiles_MouseDown(object sender, MouseEventArgs e)
{
//if (e.Button != MouseButtons.Left)
// return;
//CustomBarControl barControl = (CustomBarControl)sender;
//var link = lciRecentFiles.GetLinkByPoint(Control.MousePosition, true);
//if (link != null)
// return;
//ReleaseCapture();
//SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0);
}
private void DragForm_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button != MouseButtons.Left || !allowDragForm) return;
ReleaseCapture();
SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0);
}
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Escape)
{
this.Close();
}
else if(e.KeyCode == Keys.F4 && e.Alt)
{
this.Close();
}
}
}
}