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

Commit

Permalink
Snipper overhaul
Browse files Browse the repository at this point in the history
Snipper overhaul, optimizations
Move functions around
Rename variables
  • Loading branch information
Mike committed Jul 21, 2014
1 parent 8e0e71a commit cd93199
Show file tree
Hide file tree
Showing 16 changed files with 1,975 additions and 1,779 deletions.
62 changes: 62 additions & 0 deletions cls_Imgur.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Drawing;
using System.Net;
using System.Text;

namespace hyperdesktop2
{
class Imgur
{
public static WebClient web_client = new WebClient();

public static Boolean upload(Bitmap bmp)
{
try
{
var data = new NameValueCollection();

var image = Global_Func.bmp_to_base64(bmp, Global_Func.ext_to_imageformat(Settings.upload_format));
data.Add("image", image);

web_client.Headers.Add("Authorization", "Client-ID " + Settings.imgur_client_id);
web_client.UploadValuesAsync(
new Uri("https://api.imgur.com/3/image/"),
"POST",
data
);

web_client.Dispose();
}
catch
{
return false;
}

return true;
}

public static Boolean delete(String delete_hash)
{
try
{
var web_client = new WebClient();

web_client.Headers.Add("Authorization", "Client-ID " + Settings.imgur_client_id);
web_client.UploadData(
new Uri("https://api.imgur.com/3/image/" + delete_hash),
"DELETE",
new Byte[] { 0x0 }
);

web_client.Dispose();
return true;
}
catch
{
return false;
}
}
}
}
39 changes: 39 additions & 0 deletions cls_Screen_Bounds.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;

namespace hyperdesktop2
{
class Screen_Bounds
{
public static Rectangle bounds;

public static void load()
{
String[] bounds_arr = Settings.screen_res.Split(',');
bounds = new Rectangle(
Convert.ToInt32(bounds_arr[0]),
Convert.ToInt32(bounds_arr[1]),
Convert.ToInt32(bounds_arr[2]),
Convert.ToInt32(bounds_arr[3])
);
}
public static String reset()
{
var screen_bounds_temp = new Rectangle(0, 0, 0, 0);

foreach (var screen in Screen.AllScreens)
if (screen != Screen.PrimaryScreen)
screen_bounds_temp = Rectangle.Union(screen.Bounds, screen_bounds_temp);

return String.Format(
"{0},{1},{2},{3}",
screen_bounds_temp.Left,
screen_bounds_temp.Top,
SystemInformation.VirtualScreen.Width,
SystemInformation.VirtualScreen.Height
);
}
}
}
5 changes: 2 additions & 3 deletions cls_Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ namespace hyperdesktop2
{
public static class Settings
{
// Unused
public static Int32 build = 5;
public static Int32 build = 6;
public static String build_url = "https://raw.githubusercontent.com/TheTarkus/Hyperdesktop2/master/BUILD";
public static String release_url = "https://github.com/TheTarkus/Hyperdesktop2/releases";

Expand Down Expand Up @@ -84,7 +83,7 @@ public static void get_settings()
launch_browser = Global_Func.str_to_bool(Exists("behavior", "launch_browser", "false"));
edit_screenshot = Global_Func.str_to_bool(Exists("behavior", "edit_screenshot", "true"));

screen_res = Exists("screen", "screen_res", Snipper.reset_screen_bounds());
screen_res = Exists("screen", "screen_res", Screen_Bounds.reset());
}

public static void write_settings()
Expand Down
135 changes: 0 additions & 135 deletions cls_Snipper.cs

This file was deleted.

Loading

0 comments on commit cd93199

Please sign in to comment.