Skip to content

Commit 796c9a0

Browse files
committed
fix broken logins, move size limits to settings file
1 parent 46b747b commit 796c9a0

18 files changed

+249
-117
lines changed

ScreenShotterWPF/App.config

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,6 @@
6161
<setting name="puush_key" serializeAs="String">
6262
<value />
6363
</setting>
64-
<setting name="upload_site" serializeAs="String">
65-
<value>0</value>
66-
</setting>
6764
<setting name="editorEnabled" serializeAs="String">
6865
<value>False</value>
6966
</setting>
@@ -175,6 +172,21 @@
175172
<setting name="imageUploadSite" serializeAs="String">
176173
<value>Imgur</value>
177174
</setting>
175+
<setting name="fileSizeImgur" serializeAs="String">
176+
<value>10</value>
177+
</setting>
178+
<setting name="fileSizeGyazo" serializeAs="String">
179+
<value>40</value>
180+
</setting>
181+
<setting name="fileSizePuush" serializeAs="String">
182+
<value>20</value>
183+
</setting>
184+
<setting name="fileSizeGDrive" serializeAs="String">
185+
<value>300</value>
186+
</setting>
187+
<setting name="fileSizeDropbox" serializeAs="String">
188+
<value>150</value>
189+
</setting>
178190
</ScreenShotterWPF.Properties.Settings>
179191
</userSettings>
180192
<runtime>

ScreenShotterWPF/BalloonMessage.cs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
using System.Threading.Tasks;
6-
using Hardcodet.Wpf.TaskbarNotification;
1+
using Hardcodet.Wpf.TaskbarNotification;
2+
using System;
3+
using System.Drawing;
74

85
namespace ScreenShotterWPF
96
{
107
internal static class BalloonMessage
118
{
129
public static TaskbarIcon Notification { private get; set; }
13-
10+
private static Icon defaulticon = new Icon(App.GetResourceStream(new Uri($"pack://application:,,,/Resources/Hoshimemo5.ico", UriKind.Absolute)).Stream, 48, 48);
11+
1412
public static void ShowMessage(string s, BalloonIcon icon)
1513
{
1614
Notification?.ShowBalloonTip("LXtory", s, icon);
1715
}
16+
17+
public static void ShowMessage(string s)
18+
{
19+
Notification?.ShowBalloonTip("LXtory", s, defaulticon, true);
20+
}
1821
}
1922
}

ScreenShotterWPF/DesktopDuplication.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using SharpDX;
33
using System;
44
using System.Collections.Generic;
5-
using SharpDX.Direct3D;
65
using SharpDX.Direct3D11;
76
using System.Drawing;
87
using System.Drawing.Imaging;
@@ -141,11 +140,11 @@ private static Bitmap GetScreenBitmap(Output output)
141140
{
142141
try
143142
{
144-
SharpDX.DXGI.Resource screenResource;
145-
OutputDuplicateFrameInformation duplicateFrameInformation;
146-
147143
// Try to get duplicated frame within given time
148-
duplicatedOutput.AcquireNextFrame(500, out duplicateFrameInformation, out screenResource);
144+
duplicatedOutput.AcquireNextFrame(
145+
500,
146+
out OutputDuplicateFrameInformation duplicateFrameInformation,
147+
out SharpDX.DXGI.Resource screenResource);
149148

150149
if (j > 0)
151150
{

ScreenShotterWPF/ImageFileTypes.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ public static IEnumerable<string> SupportedTypes
1010
{
1111
get { return supportedTypes;}
1212
}
13-
1413
}
1514

1615
public enum UploadSite

ScreenShotterWPF/MainLogic.cs

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -173,16 +173,17 @@ public static bool ReadCommandLineArgs(IList<string> args)
173173
img.datetime = DateTime.Now;
174174
string d = DateTime.Now.ToString(p);
175175
img.date = d;
176-
img.anonupload = settings.anonUpload;
176+
img.Anonupload = settings.anonUpload;
177177
//if (extension != null && ImageExtensions.Contains(extension.ToLowerInvariant()))
178178
if (extension != null && ImageFileTypes.SupportedTypes.Contains(extension.ToLowerInvariant()))
179179
{
180-
img.uploadsite = settings.imageUploadSite;
180+
img.Uploadsite = settings.imageUploadSite;
181181
AddToQueue(img);
182182
}
183183
else if (settings.fileUploadSite != UploadSite.None)
184184
{
185-
img.uploadsite = settings.fileUploadSite;
185+
img.IsImage = false;
186+
img.Uploadsite = settings.fileUploadSite;
186187
AddToQueue(img);
187188
}
188189
}
@@ -260,8 +261,7 @@ private async void Upload()
260261
while (!queue.IsCompleted)
261262
{
262263
CancelEnabled = false;
263-
XImage currentUpload;
264-
if (queue.TryTake(out currentUpload, Timeout.Infinite))
264+
if (queue.TryTake(out XImage currentUpload, Timeout.Infinite))
265265
{
266266
try
267267
{
@@ -278,20 +278,20 @@ private async void Upload()
278278
Tuple<string, string> result = null;
279279
string response;
280280
dynamic json;
281-
switch (currentUpload.uploadsite)
281+
switch (currentUpload.Uploadsite)
282282
{
283283
case UploadSite.Imgur:
284284
default:
285285
// check if filesize exceeds service limitations
286-
if (CheckFileSizeLimit(filesize, 10))
286+
if (CheckFileSizeLimit(filesize, settings.fileSizeImgur))
287287
{
288288
currentUpload.image = null;
289289
SetStatusBarText("File too large. Skipping.");
290290
continue;
291291
}
292292

293293
// refresh imgur token if using account
294-
if (TokenNeedsRefresh(UploadSite.Imgur) && currentUpload.anonupload == false)
294+
if (TokenNeedsRefresh(UploadSite.Imgur) && currentUpload.Anonupload == false)
295295
{
296296
SetStatusBarText("Refreshing Imgur login..");
297297
ChangeTrayIcon("R");
@@ -317,7 +317,7 @@ private async void Upload()
317317
continue;
318318
}
319319

320-
if(CheckFileSizeLimit(filesize, 40))
320+
if(CheckFileSizeLimit(filesize, settings.fileSizeGyazo))
321321
{
322322
currentUpload.image = null;
323323
SetStatusBarText("File too large. Skipping.");
@@ -339,7 +339,7 @@ private async void Upload()
339339
continue;
340340
}
341341

342-
if(CheckFileSizeLimit(filesize, 20))
342+
if(CheckFileSizeLimit(filesize, settings.fileSizePuush))
343343
{
344344
currentUpload.image = null;
345345
SetStatusBarText("File too large. Skipping.");
@@ -348,6 +348,10 @@ private async void Upload()
348348
response = await Uploader.HttpPuushUpload(currentUpload, cancelUpload.Token);
349349

350350
string[] split = response.Split(',');
351+
if (split.Length < 3)
352+
{
353+
throw new Exception($"Puush error\r\n{response}");
354+
}
351355
string t = $"http://puush.me/{split[2]}";
352356

353357
result = new Tuple<string, string>(split[1], t);
@@ -359,7 +363,7 @@ private async void Upload()
359363
MessageBoxResult.None, MessageBoxOptions.DefaultDesktopOnly);
360364
continue;
361365
}
362-
if(CheckFileSizeLimit(filesize, 150))
366+
if(CheckFileSizeLimit(filesize, settings.fileSizeDropbox))
363367
{
364368
currentUpload.image = null;
365369
SetStatusBarText("File too large. Skipping.");
@@ -381,7 +385,7 @@ private async void Upload()
381385
continue;
382386
}
383387

384-
if(CheckFileSizeLimit(filesize, 300))
388+
if(CheckFileSizeLimit(filesize, settings.fileSizeGDrive))
385389
{
386390
currentUpload.image = null;
387391
SetStatusBarText("File too large. Skipping.");
@@ -420,7 +424,8 @@ private async void Upload()
420424
}
421425
uiContext.Post(x => AddXimageToList(currentUpload, result.Item1, result.Item2), null);
422426
ChangeTrayIcon("F");
423-
BalloonMessage.ShowMessage("Upload complete", Hardcodet.Wpf.TaskbarNotification.BalloonIcon.Info);
427+
//BalloonMessage.ShowMessage("Upload complete", Hardcodet.Wpf.TaskbarNotification.BalloonIcon.Info);
428+
BalloonMessage.ShowMessage("Upload complete");
424429

425430
if (queue.Count == 0)
426431
{
@@ -621,8 +626,7 @@ private void HookMouseAction(bool b)
621626
{
622627
if (b)
623628
{
624-
NativeMethods.POINT p;
625-
NativeMethods.GetCursorPos(out p);
629+
NativeMethods.GetCursorPos(out NativeMethods.POINT p);
626630
CapWindowFromPoint(p.X, p.Y);
627631
}
628632
MouseKeyHook.Unhook();
@@ -635,18 +639,18 @@ public void D3DCapPrimaryScreen()
635639
MessageBox.Show("DirectX capture requires Windows 8 or higher.", "Fail", MessageBoxButton.OK, MessageBoxImage.Exclamation);
636640
return;
637641
}
638-
642+
var title = GetActiveWindowTitle();
639643
try
640644
{
641645
if (!settings.d3dAllScreens)
642646
{
643647
//DesktopDuplication.DuplicatePrimaryScreen();
644648
//GC.Collect();
645-
ImageManager(DesktopDuplication.DuplicatePrimaryScreen(), "D3DScreenshot");
649+
ImageManager(DesktopDuplication.DuplicatePrimaryScreen(), title);
646650
}
647651
else
648652
{
649-
ImageManager(DesktopDuplication.DuplicateAllScreens(), "D3DScreenshot");
653+
ImageManager(DesktopDuplication.DuplicateAllScreens(), title);
650654
}
651655
}
652656
catch (Exception e)
@@ -806,10 +810,10 @@ public async void CapGif()
806810
img.datetime = DateTime.Now;
807811
string date = DateTime.Now.ToString(p);
808812
img.date = date;
809-
img.uploadsite = settings.imageUploadSite;
813+
img.Uploadsite = settings.imageUploadSite;
810814
if (settings.gifUpload)
811815
{
812-
img.anonupload = settings.anonUpload;
816+
img.Anonupload = settings.anonUpload;
813817
AddToQueue(img);
814818
}
815819
else
@@ -858,7 +862,7 @@ private static string GetActiveWindowTitle()
858862
StringBuilder buff = new StringBuilder(nChars);
859863
var handle = NativeMethods.GetForegroundWindow();
860864

861-
return NativeMethods.GetWindowText(handle, buff, nChars) > 0 ? buff.ToString() : "null";
865+
return NativeMethods.GetWindowText(handle, buff, nChars) > 0 ? buff.ToString() : "image";
862866
}
863867

864868
// convert image into png encoded byte array
@@ -941,7 +945,7 @@ private void ImageManager(byte[] image, string filename)
941945
filename = $"{f}.png",
942946
url = "",
943947
filepath = "",
944-
uploadsite = settings.imageUploadSite
948+
Uploadsite = settings.imageUploadSite
945949
};
946950
const string p = "dd.MM.yy HH:mm:ss";
947951
x.datetime = DateTime.Now;
@@ -961,7 +965,7 @@ private void ImageManager(byte[] image, string filename)
961965

962966
if (settings.autoUpload)
963967
{
964-
x.anonupload = settings.anonUpload;
968+
x.Anonupload = settings.anonUpload;
965969
AddToQueue(x);
966970
}
967971
else
@@ -1010,7 +1014,7 @@ private void AddXimageToList(XImage x, string url, string thumbnail)
10101014
}
10111015
}
10121016
}
1013-
if (url.Length > 0)
1017+
if (url.Length > 0 && x.IsImage)
10141018
{
10151019
if (settings.openInBrowser)
10161020
{
@@ -1089,8 +1093,7 @@ public void ReadXML()
10891093

10901094
private static NativeMethods.USERNOTIFICATIONSTATE NotificationState()
10911095
{
1092-
NativeMethods.USERNOTIFICATIONSTATE state;
1093-
var value = NativeMethods.SHQueryUserNotificationState(out state);
1096+
var value = NativeMethods.SHQueryUserNotificationState(out NativeMethods.USERNOTIFICATIONSTATE state);
10941097
return state;
10951098
}
10961099
}

ScreenShotterWPF/MainWindow.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
xmlns:scm="clr-namespace:System.ComponentModel;assembly=WindowsBase"
77
xmlns:views="clr-namespace:ScreenShotterWPF.Views"
88
xmlns:p="clr-namespace:ScreenShotterWPF.Properties"
9-
Title="LXtory 0.96"
9+
Title="LXtory 0.961"
1010
Height="{Binding Source={x:Static p:Settings.Default}, Path=windowHeight, Mode=TwoWay}"
1111
Width="{Binding Source={x:Static p:Settings.Default}, Path=windowWidth, Mode=TwoWay}"
1212
Top="{Binding Source={x:Static p:Settings.Default}, Path=windowTop, Mode=TwoWay}"

ScreenShotterWPF/Notifications/GifEditorNotification.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class GifEditorNotification : Confirmation
77
public Gif Gif { get; set; }
88

99
public GifEditorNotification()
10-
{
10+
{
1111
}
1212
}
1313
}

ScreenShotterWPF/Notifications/SettingsNotification.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
using System.Threading.Tasks;
6-
using Prism.Interactivity.InteractionRequest;
1+
using Prism.Interactivity.InteractionRequest;
72

83
namespace ScreenShotterWPF.Notifications
94
{

ScreenShotterWPF/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
// You can specify all the values or you can default the Build and Revision Numbers
5252
// by using the '*' as shown below:
5353
// [assembly: AssemblyVersion("1.0.*")]
54-
[assembly: AssemblyVersion("0.9.5.0")]
55-
[assembly: AssemblyFileVersion("0.9.5.0")]
54+
[assembly: AssemblyVersion("0.9.6.1")]
55+
[assembly: AssemblyFileVersion("0.9.6.1")]
5656
[assembly: NeutralResourcesLanguage("en")]
5757

0 commit comments

Comments
 (0)