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

Commit

Permalink
PixelFormat upped
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Tarkus committed May 23, 2014
1 parent 271ba83 commit b20848b
Show file tree
Hide file tree
Showing 11 changed files with 109 additions and 495 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
obj/
bin/
41 changes: 36 additions & 5 deletions cls_Global_Func.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
using System.IO;
using System.Media;
using System.Drawing;
using System.Drawing.Imaging;
using System.Windows.Forms;
using System.Drawing.Imaging;
using Microsoft.Win32;

namespace hyperdesktop2
Expand Down Expand Up @@ -48,17 +48,48 @@ public static String bmp_to_base64(Bitmap bmp, ImageFormat format)

public static void run_at_startup(Boolean run)
{
app_data_folder_create();

if(run)
reg_key.SetValue("Hyperdesktop2", Application.ExecutablePath.ToString());
reg_key.SetValue("Hyperdesktop2", Settings.exe_path);
else
reg_key.DeleteValue("Hyperdesktop2", false);
}

public static void app_data_folder_create() {
if(!Directory.Exists(Settings.app_data))
Directory.CreateDirectory(Settings.app_data);
}

public static void copy_files() {
if(!File.Exists(Settings.exe_path))
File.Copy(
Application.ExecutablePath,
Settings.exe_path
);

try {
if(!Directory.Exists(Settings.app_data + "\\sounds\\")) {
Directory.CreateDirectory(Settings.app_data + "\\sounds\\");
foreach(var file in Directory.GetFiles(Environment.CurrentDirectory + "\\sounds"))
File.Copy(file, Settings.app_data + "\\sounds\\" + Path.GetFileName(file));
}
} catch (Exception ex) {
Console.WriteLine("Couldn't copy sound files.");
Console.WriteLine(ex.Message);
}
}

public static void play_sound(String file)
{
if(Settings.sound_effects)
using (var sound_player = new SoundPlayer(file))
sound_player.Play();
try {

if(Settings.sound_effects)
using (var sound_player = new SoundPlayer("sounds\\" + file))
sound_player.Play();
} catch {
Console.WriteLine("Can't find audio file: " + file);
}
}
}
}
6 changes: 3 additions & 3 deletions cls_Screen_Capture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ struct POINTAPI { public int x; public int y; }
[DllImport("user32.dll")]
static extern bool GetWindowRect(IntPtr hwnd, ref Rectangle rectangle);

public static Bitmap region(Rectangle area, bool cursor = true, PixelFormat pixel_format = PixelFormat.Format16bppRgb555)
public static Bitmap region(Rectangle area, bool cursor = true, PixelFormat pixel_format = PixelFormat.Format32bppRgb)
{
Bitmap bmp;

Expand Down Expand Up @@ -52,12 +52,12 @@ public static Bitmap region(Rectangle area, bool cursor = true, PixelFormat pixe
return bmp;
}

public static Bitmap screen(bool cursor = true, PixelFormat pixel_format = PixelFormat.Format16bppRgb555)
public static Bitmap screen(bool cursor = true, PixelFormat pixel_format = PixelFormat.Format32bppRgb)
{
return region(Screen.PrimaryScreen.Bounds, cursor, pixel_format);
}

public static Bitmap window(bool cursor = true, PixelFormat pixel_format = PixelFormat.Format16bppRgb555)
public static Bitmap window(bool cursor = true, PixelFormat pixel_format = PixelFormat.Format32bppRgb)
{
var rect = new Rectangle();
GetWindowRect(GetForegroundWindow(), ref rect);
Expand Down
15 changes: 11 additions & 4 deletions cls_Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ namespace hyperdesktop2
{
public static class Settings
{
static String path = String.Format(@"{0}\hyperdesktop2.ini", Environment.CurrentDirectory);
// Unused
public static Int32 build = 1;
public static String build_url = "https://raw.githubusercontent.com/TheTarkus/Hyperdesktop2/master/BUILD";

public static String app_data = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\Hyperdesktop2\";
public static String exe_path = app_data + @"hyperdesktop2.exe";
public static String ini_path = app_data + @"hyperdesktop2.ini";

[DllImport("kernel32")]
static extern long WritePrivateProfileString(String section, String key, String val, String filePath);
Expand All @@ -15,14 +21,14 @@ public static class Settings

public static String Write(String section, String key, String value)
{
WritePrivateProfileString(section, key, value, path);
WritePrivateProfileString(section, key, value, ini_path);
return value;
}

public static String Read(String section, String key)
{
var temp = new StringBuilder(255);
int i = GetPrivateProfileString(section, key, "", temp, 255, path);
int i = GetPrivateProfileString(section, key, "", temp, 255, ini_path);
return temp.ToString();
}

Expand Down Expand Up @@ -52,10 +58,11 @@ public static String Exists(String section, String key, String value)

public static void get_settings()
{
Global_Func.app_data_folder_create();
imgur_client_id = Exists("upload", "imgur_client_id", "84c55d06b4c9686");

save_screenshots = Global_Func.str_to_bool(Exists("general", "save_screenshots", "false"));
save_folder = Exists("general", "save_folder", "/captures/");
save_folder = Exists("general", "save_folder", Environment.CurrentDirectory + "\\captures\\");
save_format = Exists("general", "save_format", "png");
save_quality = Convert.ToInt16(Exists("general", "save_quality", "100"));

Expand Down
19 changes: 14 additions & 5 deletions frm_Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,12 @@ void drag_drop(object sender, DragEventArgs e)
public frm_Main()
{
InitializeComponent();
Global_Func.app_data_folder_create();
Global_Func.copy_files();

if(!File.Exists(Environment.CurrentDirectory + "/hyperdesktop2.ini")) {
// Confirm if user wants to add to system startup
// on first rnu
if(!File.Exists(Settings.ini_path)) {
DialogResult result = MessageBox.Show(
"Do you want to run Hyperdesktop2 at Windows startup?",
"First time run",
Expand Down Expand Up @@ -130,10 +134,15 @@ void save_screenshot(Bitmap bmp, String name = null)
if(name == null)
name = DateTime.Now.ToString("yyyy-MM-dd_HHmmss");

bmp.Save(
String.Format("{0}/{1}.{2}", Settings.save_folder, name, Settings.save_format),
Global_Func.ext_to_imageformat(Settings.save_format)
);
try {
bmp.Save(
String.Format("{0}/{1}.{2}", Settings.save_folder, name, Settings.save_format),
Global_Func.ext_to_imageformat(Settings.save_format)
);
} catch (Exception ex) {
Console.WriteLine("Cannot save image.");
Console.WriteLine(ex.Message);
}
}

void work_image(Bitmap bmp) {
Expand Down
Loading

0 comments on commit b20848b

Please sign in to comment.