Skip to content
This repository was archived by the owner on Feb 3, 2019. It is now read-only.

Commit 0c999ed

Browse files
author
Mike Tarkus
committed
Minor changes
Some text changes, nothing important
1 parent cf99092 commit 0c999ed

5 files changed

Lines changed: 89 additions & 58 deletions

File tree

cls_Settings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace hyperdesktop2
77
public static class Settings
88
{
99
// Unused
10-
public static Int32 build = 3;
10+
public static Int32 build = 4;
1111
public static String build_url = "https://raw.githubusercontent.com/TheTarkus/Hyperdesktop2/master/BUILD";
1212
public static String release_url = "https://github.com/TheTarkus/Hyperdesktop2/releases";
1313

frm_About.Designer.cs

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frm_Main.Designer.cs

Lines changed: 15 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frm_Main.cs

Lines changed: 70 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -13,35 +13,9 @@ namespace hyperdesktop2
1313

1414
public partial class frm_Main : Form
1515
{
16-
17-
#region Tray Icon
18-
void balloon_tip(String text, String title, Int32 duration, ToolTipIcon icon = ToolTipIcon.Info) {
19-
tray_icon.BalloonTipText = text;
20-
tray_icon.BalloonTipTitle = title;
21-
tray_icon.BalloonTipIcon = icon;
22-
tray_icon.ShowBalloonTip(duration);
23-
}
24-
void Tray_iconBalloonTipClicked(object sender, System.EventArgs e)
25-
{
26-
Process.Start(tray_icon.BalloonTipText);
27-
}
28-
#endregion
29-
30-
#region Drag and Drop
31-
void drag_enter(object sender, DragEventArgs e)
32-
{
33-
e.Effect = e.Data.GetDataPresent(DataFormats.FileDrop) ? DragDropEffects.Move : DragDropEffects.None;
34-
}
35-
void drag_drop(object sender, DragEventArgs e)
36-
{
37-
var files = (String[])e.Data.GetData(DataFormats.FileDrop);
38-
39-
foreach(String file in files) {
40-
work_image(new Bitmap(Image.FromFile(file)));
41-
}
42-
}
43-
#endregion
44-
16+
Hotkeys hook;
17+
Boolean snipper_open;
18+
4519
#region Main Form
4620
public frm_Main()
4721
{
@@ -93,16 +67,65 @@ public frm_Main()
9367
Process.GetCurrentProcess().Kill();
9468
}
9569
}
96-
97-
var hook = new Hotkeys();
70+
71+
register_hotkeys();
72+
}
73+
74+
void Frm_MainLoad(object sender, EventArgs e)
75+
{
76+
Settings.get_settings();
77+
tray_icon.Visible = true;
78+
79+
Snipper.initialize();
80+
}
81+
82+
void Frm_MainFormClosing(object sender, FormClosingEventArgs e)
83+
{
84+
inverse_tray_options(sender, e);
85+
e.Cancel = true;
86+
}
87+
#endregion
88+
89+
#region Tray Icon
90+
void balloon_tip(String text, String title, Int32 duration, ToolTipIcon icon = ToolTipIcon.Info) {
91+
tray_icon.BalloonTipText = text;
92+
tray_icon.BalloonTipTitle = title;
93+
tray_icon.BalloonTipIcon = icon;
94+
tray_icon.ShowBalloonTip(duration);
95+
}
96+
void Tray_iconBalloonTipClicked(object sender, System.EventArgs e)
97+
{
98+
Process.Start(tray_icon.BalloonTipText);
99+
}
100+
#endregion
101+
102+
#region Drag and Drop
103+
void drag_enter(object sender, DragEventArgs e)
104+
{
105+
e.Effect = e.Data.GetDataPresent(DataFormats.FileDrop) ? DragDropEffects.Move : DragDropEffects.None;
106+
}
107+
void drag_drop(object sender, DragEventArgs e)
108+
{
109+
var files = (String[])e.Data.GetData(DataFormats.FileDrop);
110+
111+
foreach(String file in files) {
112+
work_image(new Bitmap(Image.FromFile(file)));
113+
}
114+
}
115+
#endregion
116+
117+
#region Hotkeys
118+
public void register_hotkeys()
119+
{
120+
hook = new Hotkeys();
98121
hook.KeyPressed += hook_KeyPressed;
99122

100123
try {
101124
hook.RegisterHotKey(global::ModifierKeys.Control | global::ModifierKeys.Shift, Keys.D3);
102125
hook.RegisterHotKey(global::ModifierKeys.Control | global::ModifierKeys.Shift, Keys.D4);
103126
hook.RegisterHotKey(global::ModifierKeys.Control | global::ModifierKeys.Shift, Keys.D5);
104127
} catch {
105-
MessageBox.Show("Couldn't register hotkeys. Try running as an Administrator.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
128+
MessageBox.Show("Couldn't register hotkeys. Perhaps they are already in use or try running as an Administrator.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
106129
}
107130
}
108131

@@ -122,20 +145,6 @@ void hook_KeyPressed(object sender, KeyPressedEventArgs e)
122145
break;
123146
}
124147
}
125-
126-
void Frm_MainLoad(object sender, EventArgs e)
127-
{
128-
Settings.get_settings();
129-
tray_icon.Visible = true;
130-
131-
Snipper.initialize();
132-
}
133-
134-
void Frm_MainFormClosing(object sender, FormClosingEventArgs e)
135-
{
136-
inverse_tray_options(sender, e);
137-
e.Cancel = true;
138-
}
139148
#endregion
140149

141150
#region Upload Images
@@ -195,10 +204,14 @@ void screen_capture(String type)
195204
break;
196205

197206
default:
207+
if(snipper_open)
208+
return;
209+
210+
snipper_open = true;
198211
bmp = Screen_Capture.region(Snipper.get_region());
212+
snipper_open = false;
199213
break;
200214
}
201-
202215
work_image(bmp);
203216
}
204217

@@ -235,6 +248,10 @@ void AboutToolStripMenuItemClick(object sender, EventArgs e)
235248
{
236249
new frm_About().ShowDialog();
237250
}
251+
void RegisterHotkeysToolStripMenuItemClick(object sender, System.EventArgs e)
252+
{
253+
register_hotkeys();
254+
}
238255
#endregion
239256

240257
#region Tray Menu
@@ -272,7 +289,6 @@ void imgur_upload(Bitmap bmp)
272289
{
273290
try {
274291
var web_client = new WebClient();
275-
276292
var data = new NameValueCollection();
277293

278294
web_client.UploadProgressChanged += upload_progress_changed;
@@ -321,11 +337,12 @@ Boolean imgur_delete(String delete_hash)
321337
}
322338
}
323339

324-
void upload_progress_changed(object sender, ProgressChangedEventArgs e)
340+
void upload_progress_changed(object sender, UploadProgressChangedEventArgs e)
325341
{
326342
try {
327-
group_upload_progress.Text = String.Format("Upload Progress - {0}%", e.ProgressPercentage);
328-
progress.Value = e.ProgressPercentage;
343+
Int32 percent = Convert.ToInt32(e.BytesSent / e.TotalBytesToSend) * 100;
344+
group_upload_progress.Text = String.Format("Upload Progress - {0}% ({1}kb/{2}kb)", percent, e.BytesSent / 1024, e.TotalBytesToSend / 1024d);
345+
progress.Value = percent;
329346
} catch {
330347
// below .NET 4.0, sometimes it throws an absurd
331348
// number into the ProgressPercentage
@@ -346,6 +363,8 @@ void upload_progress_complete(object sender, UploadValuesCompletedEventArgs e)
346363
new ListViewItem(new String[] {link, delete_hash})
347364
);
348365

366+
list_image_links.Items[list_image_links.Items.Count-1].EnsureVisible();
367+
349368
if(Settings.copy_links_to_clipboard)
350369
Clipboard.SetText(link);
351370

hyperdesktop2.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@
4242
</ItemGroup>
4343
<ItemGroup>
4444
<Compile Include="cls_Global_Func.cs" />
45-
<Compile Include="cls_Screen_Capture.cs" />
4645
<Compile Include="cls_Hotkeys.cs" />
46+
<Compile Include="cls_Screen_Capture.cs" />
4747
<Compile Include="cls_Settings.cs" />
4848
<Compile Include="cls_Snipper.cs" />
4949
<Compile Include="cls_Upload.cs" />

0 commit comments

Comments
 (0)