|
1 | | -using System; |
2 | | -using System.Runtime.InteropServices; |
3 | | -using System.Text; |
4 | | - |
5 | | -namespace hyperdesktop2 |
6 | | -{ |
7 | | - public static class Settings |
8 | | - { |
9 | | - public static Int32 build = 6; |
10 | | - public static String build_url = "https://raw.githubusercontent.com/TheTarkus/Hyperdesktop2/master/BUILD"; |
11 | | - public static String release_url = "https://github.com/TheTarkus/Hyperdesktop2/releases"; |
12 | | - |
13 | | - public static String app_data = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\Hyperdesktop2\"; |
14 | | - public static String exe_path = app_data + @"hyperdesktop2.exe"; |
15 | | - public static String ini_path = app_data + @"hyperdesktop2.ini"; |
16 | | - |
17 | | - [DllImport("kernel32")] |
18 | | - static extern long WritePrivateProfileString(String section, String key, String val, String filePath); |
19 | | - [DllImport("kernel32")] |
20 | | - static extern int GetPrivateProfileString(String section, String key, String def, StringBuilder retVal, Int32 size, String filePath); |
21 | | - |
22 | | - public static String Write(String section, String key, String value) |
23 | | - { |
24 | | - WritePrivateProfileString(section, key, value, ini_path); |
25 | | - return value; |
26 | | - } |
27 | | - |
28 | | - public static String Read(String section, String key) |
29 | | - { |
30 | | - var temp = new StringBuilder(255); |
31 | | - int i = GetPrivateProfileString(section, key, "", temp, 255, ini_path); |
32 | | - return temp.ToString(); |
33 | | - } |
34 | | - |
35 | | - public static String Exists(String section, String key, String value) |
36 | | - { |
37 | | - String str = Read(section, key); |
38 | | - return (str.Length > 0) ? Read(section, key) : Write(section, key, value); |
39 | | - } |
40 | | - |
41 | | - public static String settings_build; |
42 | | - |
43 | | - public static String imgur_client_id; |
44 | | - |
45 | | - public static Boolean save_screenshots; |
46 | | - public static String save_folder; |
47 | | - public static String save_format; |
48 | | - public static Int16 save_quality; |
49 | | - |
50 | | - public static String upload_method; |
51 | | - public static String upload_format; |
52 | | - |
53 | | - public static Boolean run_at_system_startup; |
54 | | - public static Boolean copy_links_to_clipboard; |
55 | | - public static Boolean show_cursor; |
56 | | - public static Boolean sound_effects; |
57 | | - public static Boolean balloon_messages; |
58 | | - public static Boolean launch_browser; |
59 | | - public static Boolean edit_screenshot; |
60 | | - |
61 | | - public static Boolean auto_detect_screen_res; |
62 | | - public static String screen_res; |
63 | | - |
64 | | - public static void get_settings() |
65 | | - { |
66 | | - Global_Func.app_data_folder_create(); |
67 | | - settings_build = Exists("hyperdesktop2", "build", Convert.ToString(build)); |
68 | | - |
69 | | - imgur_client_id = Exists("upload", "imgur_client_id", "84c55d06b4c9686"); |
70 | | - |
71 | | - save_screenshots = Global_Func.str_to_bool(Exists("general", "save_screenshots", "false")); |
72 | | - save_folder = Exists("general", "save_folder", Environment.CurrentDirectory + "\\captures\\"); |
73 | | - save_format = Exists("general", "save_format", "png"); |
74 | | - save_quality = Convert.ToInt16(Exists("general", "save_quality", "100")); |
75 | | - |
76 | | - upload_method = Exists("upload", "upload_method", "imgur"); |
77 | | - upload_format = Exists("upload", "upload_format", "png"); |
78 | | - |
79 | | - copy_links_to_clipboard = Global_Func.str_to_bool(Exists("behavior", "copy_links_to_clipboard", "true")); |
80 | | - show_cursor = Global_Func.str_to_bool(Exists("behavior", "show_cursor", "false")); |
81 | | - sound_effects = Global_Func.str_to_bool(Exists("behavior", "sound_effects", "true")); |
82 | | - balloon_messages = Global_Func.str_to_bool(Exists("behavior", "balloon_messages", "true")); |
83 | | - launch_browser = Global_Func.str_to_bool(Exists("behavior", "launch_browser", "false")); |
84 | | - edit_screenshot = Global_Func.str_to_bool(Exists("behavior", "edit_screenshot", "true")); |
85 | | - |
86 | | - screen_res = Exists("screen", "screen_res", Screen_Bounds.reset()); |
87 | | - } |
88 | | - |
89 | | - public static void write_settings() |
90 | | - { |
91 | | - Write("upload", "imgur_client_id", imgur_client_id); |
92 | | - |
93 | | - Write("general", "save_screenshots", save_screenshots.ToString()); |
94 | | - Write("general", "save_folder", save_folder); |
95 | | - Write("general", "save_format", save_format); |
96 | | - Write("general", "save_quality", save_quality.ToString()); |
97 | | - |
98 | | - Write("behavior", "copy_links_to_clipboard", copy_links_to_clipboard.ToString()); |
99 | | - Write("behavior", "show_cursor", show_cursor.ToString()); |
100 | | - Write("behavior", "sound_effects", sound_effects.ToString()); |
101 | | - Write("behavior", "balloon_messages", balloon_messages.ToString()); |
102 | | - Write("behavior", "launch_browser", launch_browser.ToString()); |
103 | | - Write("behavior", "edit_screenshot", edit_screenshot.ToString()); |
104 | | - |
105 | | - Write("screen", "screen_res", screen_res); |
106 | | - } |
107 | | - |
108 | | - } |
109 | | -} |
| 1 | +using System; |
| 2 | +using System.Runtime.InteropServices; |
| 3 | +using System.Text; |
| 4 | + |
| 5 | +namespace hyperdesktop2 |
| 6 | +{ |
| 7 | + public static class Settings |
| 8 | + { |
| 9 | + public static Int32 build = 7; |
| 10 | + public static String build_url = "https://raw.githubusercontent.com/TheTarkus/Hyperdesktop2/master/BUILD"; |
| 11 | + public static String release_url = "https://github.com/TheTarkus/Hyperdesktop2/releases"; |
| 12 | + |
| 13 | + public static String app_data = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\Hyperdesktop2\"; |
| 14 | + public static String exe_path = app_data + @"hyperdesktop2.exe"; |
| 15 | + public static String ini_path = app_data + @"hyperdesktop2.ini"; |
| 16 | + |
| 17 | + [DllImport("kernel32")] |
| 18 | + static extern long WritePrivateProfileString(String section, String key, String val, String filePath); |
| 19 | + [DllImport("kernel32")] |
| 20 | + static extern int GetPrivateProfileString(String section, String key, String def, StringBuilder retVal, Int32 size, String filePath); |
| 21 | + |
| 22 | + public static String Write(String section, String key, String value) |
| 23 | + { |
| 24 | + WritePrivateProfileString(section, key, value, ini_path); |
| 25 | + return value; |
| 26 | + } |
| 27 | + |
| 28 | + public static String Read(String section, String key) |
| 29 | + { |
| 30 | + var temp = new StringBuilder(255); |
| 31 | + int i = GetPrivateProfileString(section, key, "", temp, 255, ini_path); |
| 32 | + return temp.ToString(); |
| 33 | + } |
| 34 | + |
| 35 | + public static String Exists(String section, String key, String value) |
| 36 | + { |
| 37 | + String str = Read(section, key); |
| 38 | + return (str.Length > 0) ? Read(section, key) : Write(section, key, value); |
| 39 | + } |
| 40 | + |
| 41 | + public static String settings_build; |
| 42 | + |
| 43 | + public static String imgur_client_id; |
| 44 | + |
| 45 | + public static Boolean save_screenshots; |
| 46 | + public static String save_folder; |
| 47 | + public static String save_format; |
| 48 | + public static Int16 save_quality; |
| 49 | + |
| 50 | + public static String upload_method; |
| 51 | + public static String upload_format; |
| 52 | + |
| 53 | + public static Boolean run_at_system_startup; |
| 54 | + public static Boolean copy_links_to_clipboard; |
| 55 | + public static Boolean show_cursor; |
| 56 | + public static Boolean sound_effects; |
| 57 | + public static Boolean balloon_messages; |
| 58 | + public static Boolean launch_browser; |
| 59 | + public static Boolean edit_screenshot; |
| 60 | + |
| 61 | + public static Boolean auto_detect_screen_res; |
| 62 | + public static String screen_res; |
| 63 | + |
| 64 | + public static void get_settings() |
| 65 | + { |
| 66 | + Global_Func.app_data_folder_create(); |
| 67 | + settings_build = Exists("hyperdesktop2", "build", Convert.ToString(build)); |
| 68 | + |
| 69 | + imgur_client_id = Exists("upload", "imgur_client_id", "84c55d06b4c9686"); |
| 70 | + |
| 71 | + save_screenshots = Global_Func.str_to_bool(Exists("general", "save_screenshots", "false")); |
| 72 | + save_folder = Exists("general", "save_folder", Environment.CurrentDirectory + "\\captures\\"); |
| 73 | + save_format = Exists("general", "save_format", "png"); |
| 74 | + save_quality = Convert.ToInt16(Exists("general", "save_quality", "100")); |
| 75 | + |
| 76 | + upload_method = Exists("upload", "upload_method", "imgur"); |
| 77 | + upload_format = Exists("upload", "upload_format", "png"); |
| 78 | + |
| 79 | + copy_links_to_clipboard = Global_Func.str_to_bool(Exists("behavior", "copy_links_to_clipboard", "true")); |
| 80 | + show_cursor = Global_Func.str_to_bool(Exists("behavior", "show_cursor", "false")); |
| 81 | + sound_effects = Global_Func.str_to_bool(Exists("behavior", "sound_effects", "true")); |
| 82 | + balloon_messages = Global_Func.str_to_bool(Exists("behavior", "balloon_messages", "true")); |
| 83 | + launch_browser = Global_Func.str_to_bool(Exists("behavior", "launch_browser", "false")); |
| 84 | + edit_screenshot = Global_Func.str_to_bool(Exists("behavior", "edit_screenshot", "true")); |
| 85 | + |
| 86 | + screen_res = Exists("screen", "screen_res", Screen_Bounds.reset()); |
| 87 | + } |
| 88 | + |
| 89 | + public static void write_settings() |
| 90 | + { |
| 91 | + Write("upload", "imgur_client_id", imgur_client_id); |
| 92 | + |
| 93 | + Write("general", "save_screenshots", save_screenshots.ToString()); |
| 94 | + Write("general", "save_folder", save_folder); |
| 95 | + Write("general", "save_format", save_format); |
| 96 | + Write("general", "save_quality", save_quality.ToString()); |
| 97 | + |
| 98 | + Write("behavior", "copy_links_to_clipboard", copy_links_to_clipboard.ToString()); |
| 99 | + Write("behavior", "show_cursor", show_cursor.ToString()); |
| 100 | + Write("behavior", "sound_effects", sound_effects.ToString()); |
| 101 | + Write("behavior", "balloon_messages", balloon_messages.ToString()); |
| 102 | + Write("behavior", "launch_browser", launch_browser.ToString()); |
| 103 | + Write("behavior", "edit_screenshot", edit_screenshot.ToString()); |
| 104 | + |
| 105 | + Write("screen", "screen_res", screen_res); |
| 106 | + } |
| 107 | + |
| 108 | + } |
| 109 | +} |
0 commit comments