| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -55,8 +55,6 @@ | |||
| 55 | 55 | </PropertyGroup> | |
| 56 | 56 | <ItemGroup> | |
| 57 | 57 | <Reference Include="System" /> | |
| 58 | - <Reference Include="System.Data" /> | ||
| 59 | - <Reference Include="System.Deployment" /> | ||
| 60 | 58 | <Reference Include="System.Drawing" /> | |
| 61 | 59 | <Reference Include="System.Windows.Forms" /> | |
| 62 | 60 | <Reference Include="System.Xml" /> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,23 +1,21 @@ | |||
| 1 | 1 | using System; | |
| 2 | - using System.Collections.Generic; | ||
| 3 | - using System.Runtime.InteropServices; | ||
| 4 | 2 | using System.Windows.Forms; | |
| 5 | 3 | using System.Threading; | |
| 6 | 4 | ||
| 7 | 5 | namespace AppMan | |
| 8 | 6 | { | |
| 9 | - static class Program | ||
| 7 | + internal static class Program | ||
| 10 | 8 | { | |
| 11 | 9 | /// <summary> | |
| 12 | 10 | /// SIA Mutex entry | |
| 13 | 11 | /// </summary> | |
| 14 | - private static Mutex mutex = new Mutex(true, "{2A46BA9B-F8DA-40AA-904F-4C1630BA4428}"); | ||
| 12 | + static readonly Mutex mutex = new Mutex(true, "{2A46BA9B-F8DA-40AA-904F-4C1630BA4428}"); | ||
| 15 | 13 | ||
| 16 | 14 | /// <summary> | |
| 17 | 15 | /// The main entry point for the application. | |
| 18 | 16 | /// </summary> | |
| 19 | 17 | [STAThread] | |
| 20 | - static void Main(String[] args) | ||
| 18 | + static void Main(string[] args) | ||
| 21 | 19 | { | |
| 22 | 20 | try | |
| 23 | 21 | { | |
@@ -39,7 +37,5 @@ static void Main(String[] args) | |||
| 39 | 37 | MessageBox.Show("Error while starting AppMan:\n" + ex.ToString()); | |
| 40 | 38 | } | |
| 41 | 39 | } | |
| 42 | - | ||
| 43 | 40 | } | |
| 44 | - | ||
| 45 | - } | ||
| 41 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,6 +1,4 @@ | |||
| 1 | 1 | using System.Reflection; | |
| 2 | - using System.Runtime.CompilerServices; | ||
| 3 | - using System.Runtime.InteropServices; | ||
| 4 | 2 | ||
| 5 | 3 | // Information about this assembly is defined by the following attributes. | |
| 6 | 4 | // Change them to the information which is associated with the assembly you compile. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,26 +1,24 @@ | |||
| 1 | 1 | using System; | |
| 2 | - using System.Collections.Generic; | ||
| 3 | - using System.Text; | ||
| 4 | 2 | using System.IO; | |
| 5 | 3 | ||
| 6 | 4 | namespace AppMan.Utilities | |
| 7 | 5 | { | |
| 8 | 6 | public class ArgProcessor | |
| 9 | 7 | { | |
| 10 | 8 | /// <summary> | |
| 11 | - /// Processes the internal argruments in a string. | ||
| 9 | + /// Processes the internal arguments in a string. | ||
| 12 | 10 | /// </summary> | |
| 13 | - public static String ProcessArguments(String data) | ||
| 11 | + public static string ProcessArguments(string data) | ||
| 14 | 12 | { | |
| 15 | 13 | data = data.Replace("$(Quote)", "\""); | |
| 16 | 14 | data = data.Replace("$(AppDir)", PathHelper.GetExeDirectory()); | |
| 17 | 15 | #if FLASHDEVELOP | |
| 18 | - String local = Path.Combine(PathHelper.GetExeDirectory(), @"..\..\.local"); | ||
| 16 | + var local = Path.Combine(PathHelper.GetExeDirectory(), @"..\..\.local"); | ||
| 19 | 17 | local = Path.GetFullPath(local); /* Fix weird path */ | |
| 20 | 18 | if (!File.Exists(local)) | |
| 21 | 19 | { | |
| 22 | - String userAppDir = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); | ||
| 23 | - String fdUserPath = Path.Combine(userAppDir, MainForm.DISTRO_NAME); | ||
| 20 | + var userAppDir = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); | ||
| 21 | + var fdUserPath = Path.Combine(userAppDir, MainForm.DISTRO_NAME); | ||
| 24 | 22 | data = data.Replace("$(BaseDir)", fdUserPath); | |
| 25 | 23 | } | |
| 26 | 24 | else data = data.Replace("$(BaseDir)", Path.GetDirectoryName(local)); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,7 +1,4 @@ | |||
| 1 | - using System; | ||
| 2 | - using System.IO; | ||
| 3 | - using System.Text; | ||
| 4 | - using System.Collections.Generic; | ||
| 1 | + using System.IO; | ||
| 5 | 2 | using System.Windows.Forms; | |
| 6 | 3 | ||
| 7 | 4 | namespace AppMan.Utilities | |
@@ -11,12 +8,12 @@ public class DialogHelper | |||
| 11 | 8 | /// <summary> | |
| 12 | 9 | /// Shows an error dialog to the user. | |
| 13 | 10 | /// </summary> | |
| 14 | - public static void ShowError(String message) | ||
| 11 | + public static void ShowError(string message) | ||
| 15 | 12 | { | |
| 16 | 13 | MessageBox.Show(message, " Error", MessageBoxButtons.OK, MessageBoxIcon.Error); | |
| 17 | 14 | try | |
| 18 | 15 | { | |
| 19 | - String logFile = Path.Combine(PathHelper.LOG_DIR, "Exceptions.log"); | ||
| 16 | + var logFile = Path.Combine(PathHelper.LOG_DIR, "Exceptions.log"); | ||
| 20 | 17 | File.AppendAllText(logFile, message + "\n\r\n\r"); | |
| 21 | 18 | } | |
| 22 | 19 | catch { /* NO ERRORS */ } | |
@@ -25,19 +22,11 @@ public static void ShowError(String message) | |||
| 25 | 22 | /// <summary> | |
| 26 | 23 | /// Shows a warning dialog to the user. | |
| 27 | 24 | /// </summary> | |
| 28 | - public static void ShowWarning(String message) | ||
| 29 | - { | ||
| 30 | - MessageBox.Show(message, " Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); | ||
| 31 | - } | ||
| 25 | + public static void ShowWarning(string message) => MessageBox.Show(message, " Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); | ||
| 32 | 26 | ||
| 33 | 27 | /// <summary> | |
| 34 | - /// Shows an infromation dialog to the user. | ||
| 28 | + /// Shows an information dialog to the user. | ||
| 35 | 29 | /// </summary> | |
| 36 | - public static void ShowInformation(String message) | ||
| 37 | - { | ||
| 38 | - MessageBox.Show(message, " Information", MessageBoxButtons.OK, MessageBoxIcon.Information); | ||
| 39 | - } | ||
| 40 | - | ||
| 30 | + public static void ShowInformation(string message) => MessageBox.Show(message, " Information", MessageBoxButtons.OK, MessageBoxIcon.Information); | ||
| 41 | 31 | } | |
| 42 | - | ||
| 43 | - } | ||
| 32 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,7 +2,6 @@ | |||
| 2 | 2 | using System.IO; | |
| 3 | 3 | using System.Text; | |
| 4 | 4 | using System.Xml.Serialization; | |
| 5 | - using System.Windows.Forms; | ||
| 6 | 5 | ||
| 7 | 6 | namespace AppMan.Utilities | |
| 8 | 7 | { | |
@@ -11,13 +10,13 @@ public class ObjectSerializer | |||
| 11 | 10 | /// <summary> | |
| 12 | 11 | /// Serializes the specified object to a xml file. | |
| 13 | 12 | /// </summary> | |
| 14 | - public static void Serialize(String file, Object obj) | ||
| 13 | + public static void Serialize(string file, object obj) | ||
| 15 | 14 | { | |
| 16 | 15 | try | |
| 17 | 16 | { | |
| 18 | 17 | using (TextWriter writer = new StreamWriter(file, false, Encoding.UTF8)) | |
| 19 | 18 | { | |
| 20 | - XmlSerializer serializer = new XmlSerializer(obj.GetType()); | ||
| 19 | + var serializer = new XmlSerializer(obj.GetType()); | ||
| 21 | 20 | serializer.Serialize(writer, obj); | |
| 22 | 21 | } | |
| 23 | 22 | } | |
@@ -30,23 +29,21 @@ public static void Serialize(String file, Object obj) | |||
| 30 | 29 | /// <summary> | |
| 31 | 30 | /// Deserializes the specified object from a xml file. Optionally exposes commented groups. | |
| 32 | 31 | /// </summary> | |
| 33 | - public static Object Deserialize(String file, Object obj) | ||
| 34 | - { | ||
| 35 | - return Deserialize(file, obj, String.Empty); | ||
| 36 | - } | ||
| 37 | - public static Object Deserialize(String file, Object obj, String groups) | ||
| 32 | + public static object Deserialize(string file, object obj) => Deserialize(file, obj, string.Empty); | ||
| 33 | + | ||
| 34 | + public static object Deserialize(string file, object obj, string groups) | ||
| 38 | 35 | { | |
| 39 | 36 | try | |
| 40 | 37 | { | |
| 41 | 38 | using (TextReader reader = new StreamReader(file, Encoding.UTF8, false)) | |
| 42 | 39 | { | |
| 43 | - String xmlData = reader.ReadToEnd(); | ||
| 44 | - String[] exGroups = groups.Split(new char[] { ',' }); | ||
| 45 | - foreach (String group in exGroups) | ||
| 40 | + var xmlData = reader.ReadToEnd(); | ||
| 41 | + var exGroups = groups.Split(','); | ||
| 42 | + foreach (var group in exGroups) | ||
| 46 | 43 | { | |
| 47 | 44 | xmlData = xmlData.Replace("<!--" + group, "").Replace(group + "-->", ""); | |
| 48 | 45 | } | |
| 49 | - XmlSerializer serializer = new XmlSerializer(obj.GetType()); | ||
| 46 | + var serializer = new XmlSerializer(obj.GetType()); | ||
| 50 | 47 | return serializer.Deserialize(new StringReader(xmlData)); | |
| 51 | 48 | } | |
| 52 | 49 | } | |
@@ -56,7 +53,5 @@ public static Object Deserialize(String file, Object obj, String groups) | |||
| 56 | 53 | return null; | |
| 57 | 54 | } | |
| 58 | 55 | } | |
| 59 | - | ||
| 60 | 56 | } | |
| 61 | - | ||
| 62 | - } | ||
| 57 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,7 +1,4 @@ | |||
| 1 | - using System; | ||
| 2 | - using System.IO; | ||
| 3 | - using System.Text; | ||
| 4 | - using System.Collections.Generic; | ||
| 1 | + using System.IO; | ||
| 5 | 2 | using System.Windows.Forms; | |
| 6 | 3 | ||
| 7 | 4 | namespace AppMan.Utilities | |
@@ -11,31 +8,26 @@ public class PathHelper | |||
| 11 | 8 | /// <summary> | |
| 12 | 9 | /// Default path to the log dir. | |
| 13 | 10 | /// </summary> | |
| 14 | - public static String LOG_DIR = ArgProcessor.ProcessArguments("$(AppDir)"); | ||
| 11 | + public static string LOG_DIR = ArgProcessor.ProcessArguments("$(AppDir)"); | ||
| 15 | 12 | ||
| 16 | 13 | /// <summary> | |
| 17 | 14 | /// Default path to the apps directory. | |
| 18 | 15 | /// </summary> | |
| 19 | - public static String APPS_DIR = ArgProcessor.ProcessArguments("$(AppDir)/Apps"); | ||
| 16 | + public static string APPS_DIR = ArgProcessor.ProcessArguments("$(AppDir)/Apps"); | ||
| 20 | 17 | ||
| 21 | 18 | /// <summary> | |
| 22 | 19 | /// Default path to the app help. | |
| 23 | 20 | /// </summary> | |
| 24 | - public static String HELP_ADR = ArgProcessor.ProcessArguments("$(AppDir)/Help.html"); | ||
| 21 | + public static string HELP_ADR = ArgProcessor.ProcessArguments("$(AppDir)/Help.html"); | ||
| 25 | 22 | ||
| 26 | 23 | /// <summary> | |
| 27 | 24 | /// Default path to the config xml file. | |
| 28 | 25 | /// </summary> | |
| 29 | - public static String CONFIG_ADR = ArgProcessor.ProcessArguments("$(AppDir)/Config.xml"); | ||
| 26 | + public static string CONFIG_ADR = ArgProcessor.ProcessArguments("$(AppDir)/Config.xml"); | ||
| 30 | 27 | ||
| 31 | 28 | /// <summary> | |
| 32 | 29 | /// Gets the directory of the app. | |
| 33 | 30 | /// </summary> | |
| 34 | - public static String GetExeDirectory() | ||
| 35 | - { | ||
| 36 | - return Path.GetDirectoryName(Application.ExecutablePath); | ||
| 37 | - } | ||
| 38 | - | ||
| 31 | + public static string GetExeDirectory() => Path.GetDirectoryName(Application.ExecutablePath); | ||
| 39 | 32 | } | |
| 40 | - | ||
| 41 | - } | ||
| 33 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -19,7 +19,7 @@ public enum TaskbarStates | |||
| 19 | 19 | [ComImportAttribute()] | |
| 20 | 20 | [GuidAttribute("ea1afb91-9e28-4b86-90e9-9e9f8a5eefaf")] | |
| 21 | 21 | [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)] | |
| 22 | - private interface ITaskbarList3 | ||
| 22 | + interface ITaskbarList3 | ||
| 23 | 23 | { | |
| 24 | 24 | // ITaskbarList | |
| 25 | 25 | [PreserveSig] | |
@@ -37,18 +37,18 @@ private interface ITaskbarList3 | |||
| 37 | 37 | void MarkFullscreenWindow(IntPtr hwnd, [MarshalAs(UnmanagedType.Bool)] bool fFullscreen); | |
| 38 | 38 | // ITaskbarList3 | |
| 39 | 39 | [PreserveSig] | |
| 40 | - void SetProgressValue(IntPtr hwnd, UInt64 ullCompleted, UInt64 ullTotal); | ||
| 40 | + void SetProgressValue(IntPtr hwnd, ulong ullCompleted, ulong ullTotal); | ||
| 41 | 41 | [PreserveSig] | |
| 42 | 42 | void SetProgressState(IntPtr hwnd, TaskbarStates state); | |
| 43 | 43 | } | |
| 44 | 44 | ||
| 45 | 45 | [GuidAttribute("56FDF344-FD6D-11d0-958A-006097C9A090")] | |
| 46 | 46 | [ClassInterfaceAttribute(ClassInterfaceType.None)] | |
| 47 | 47 | [ComImportAttribute()] | |
| 48 | - private class TaskbarInstance {} | ||
| 48 | + class TaskbarInstance {} | ||
| 49 | 49 | ||
| 50 | - private static ITaskbarList3 taskbarInstance; | ||
| 51 | - private static Boolean taskbarSupported = (Environment.OSVersion.Version >= new Version(6, 1)) && !Win32.IsRunningOnMono; | ||
| 50 | + static ITaskbarList3 taskbarInstance; | ||
| 51 | + static readonly bool taskbarSupported = (Environment.OSVersion.Version >= new Version(6, 1)) && !Win32.IsRunningOnMono; | ||
| 52 | 52 | ||
| 53 | 53 | public static void SetState(IntPtr windowHandle, TaskbarStates taskbarState) | |
| 54 | 54 | { | |
@@ -67,7 +67,5 @@ public static void SetValue(IntPtr windowHandle, double progressValue, double pr | |||
| 67 | 67 | taskbarInstance.SetProgressValue(windowHandle, (ulong)progressValue, (ulong)progressMax); | |
| 68 | 68 | } | |
| 69 | 69 | } | |
| 70 | - | ||
| 71 | 70 | } | |
| 72 | - | ||
| 73 | - } | ||
| 71 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,9 +1,6 @@ | |||
| 1 | 1 | using System; | |
| 2 | 2 | using System.IO; | |
| 3 | - using System.Text; | ||
| 4 | - using System.Collections.Generic; | ||
| 5 | 3 | using ICSharpCode.SharpZipLib.Zip; | |
| 6 | - using System.Globalization; | ||
| 7 | 4 | ||
| 8 | 5 | namespace AppMan.Utilities | |
| 9 | 6 | { | |
@@ -12,34 +9,33 @@ public class ZipHelper | |||
| 12 | 9 | /// <summary> | |
| 13 | 10 | /// Extracts a zip file to specified directory. | |
| 14 | 11 | /// </summary> | |
| 15 | - public static void ExtractZip(String file, String path) | ||
| 12 | + public static void ExtractZip(string file, string path) | ||
| 16 | 13 | { | |
| 17 | 14 | // Save current directory | |
| 18 | - String curDir = Environment.CurrentDirectory; | ||
| 15 | + var curDir = Environment.CurrentDirectory; | ||
| 19 | 16 | try | |
| 20 | 17 | { | |
| 21 | - ZipEntry entry = null; | ||
| 22 | - ZipInputStream zis = new ZipInputStream(new FileStream(file, FileMode.Open, FileAccess.Read)); | ||
| 18 | + ZipEntry entry; | ||
| 19 | + var zis = new ZipInputStream(new FileStream(file, FileMode.Open, FileAccess.Read)); | ||
| 23 | 20 | Environment.CurrentDirectory = path; // Used to work around long path issue | |
| 24 | 21 | while ((entry = zis.GetNextEntry()) != null) | |
| 25 | 22 | { | |
| 26 | - Int32 size = 4096; | ||
| 27 | - Byte[] data = new Byte[4096]; | ||
| 23 | + var data = new byte[4096]; | ||
| 28 | 24 | if (entry.IsFile) | |
| 29 | 25 | { | |
| 30 | - String ext = Path.GetExtension(entry.Name); | ||
| 31 | - String dirPath = Path.GetDirectoryName(entry.Name); | ||
| 32 | - if (!String.IsNullOrEmpty(dirPath) && !Directory.Exists(dirPath)) | ||
| 26 | + var dirPath = Path.GetDirectoryName(entry.Name); | ||
| 27 | + if (!string.IsNullOrEmpty(dirPath) && !Directory.Exists(dirPath)) | ||
| 33 | 28 | { | |
| 34 | 29 | Directory.CreateDirectory(dirPath); | |
| 35 | 30 | } | |
| 36 | - FileStream extracted; | ||
| 37 | - String fullPath = Path.Combine(path, entry.Name); | ||
| 38 | - if (Win32.IsRunningOnMono) extracted = File.Open(fullPath, FileMode.Create, FileAccess.Write); | ||
| 39 | - else extracted = Win32.LongPathFileOpen(fullPath); | ||
| 31 | + | ||
| 32 | + var fullPath = Path.Combine(path, entry.Name); | ||
| 33 | + var extracted = Win32.IsRunningOnMono | ||
| 34 | + ? File.Open(fullPath, FileMode.Create, FileAccess.Write) | ||
| 35 | + : Win32.LongPathFileOpen(fullPath); | ||
| 40 | 36 | while (true) | |
| 41 | 37 | { | |
| 42 | - size = zis.Read(data, 0, data.Length); | ||
| 38 | + var size = zis.Read(data, 0, data.Length); | ||
| 43 | 39 | if (size > 0) extracted.Write(data, 0, size); | |
| 44 | 40 | else break; | |
| 45 | 41 | } | |
@@ -59,7 +55,5 @@ public static void ExtractZip(String file, String path) | |||
| 59 | 55 | // Restore current directory | |
| 60 | 56 | Environment.CurrentDirectory = curDir; | |
| 61 | 57 | } | |
| 62 | - | ||
| 63 | 58 | } | |
| 64 | - | ||
| 65 | - } | ||
| 59 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments