From 466a2146f39c9b39d57886fe43b88fd7658b0a92 Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Tue, 6 Mar 2012 01:49:36 +0000 Subject: [PATCH] Don't use a separate Program.cs on Windows --- SparkleShare/Program.cs | 13 +++---- SparkleShare/Windows/Program.cs | 12 ------- SparkleShare/Windows/SparkleSetupWindow.cs | 16 +-------- SparkleShare/Windows/SparkleShare.csproj | 4 ++- SparkleShare/Windows/SparkleUIHelpers.cs | 42 ++++++++-------------- 5 files changed, 25 insertions(+), 62 deletions(-) diff --git a/SparkleShare/Program.cs b/SparkleShare/Program.cs index 9b64536d..92568169 100644 --- a/SparkleShare/Program.cs +++ b/SparkleShare/Program.cs @@ -16,13 +16,10 @@ using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Runtime.InteropServices; -using System.Text; +#if __MonoCS__ using Mono.Unix; +#endif using SparkleLib; namespace SparkleShare { @@ -36,8 +33,12 @@ namespace SparkleShare { // Short alias for the translations public static string _ (string s) - { + { + #if __MonoCS__ return Catalog.GetString (s); + #else + return Strings.T (s); + #endif } diff --git a/SparkleShare/Windows/Program.cs b/SparkleShare/Windows/Program.cs index 2e43ea4d..a867960b 100644 --- a/SparkleShare/Windows/Program.cs +++ b/SparkleShare/Windows/Program.cs @@ -49,19 +49,7 @@ namespace SparkleShare { #endif } -#if !__MonoCS__ - public static void TranslateWinForm (System.Windows.Forms.Form form) - { - form.Text = Program._ (form.Text); - foreach (var label in form.Controls.All ().OfType ()) { - label.Text = Program._ (label.Text); - } - foreach (var button in form.Controls.All ().OfType ()) { - button.Text = Program._ (button.Text); - } - } -#endif #if !__MonoCS__ [STAThread] diff --git a/SparkleShare/Windows/SparkleSetupWindow.cs b/SparkleShare/Windows/SparkleSetupWindow.cs index d80e1e7a..6bb334c6 100644 --- a/SparkleShare/Windows/SparkleSetupWindow.cs +++ b/SparkleShare/Windows/SparkleSetupWindow.cs @@ -73,23 +73,9 @@ namespace SparkleShare { Width = 150, Height = 482 }; - System.Reflection.Assembly thisExe; -thisExe = System.Reflection.Assembly.GetExecutingAssembly(); -string [] resources = thisExe.GetManifestResourceNames(); -string list = ""; - -// Build the string of resources. -foreach (string resource in resources) - list += resource + "\r\n"; - MessageBox.Show (list); - -; -Assembly thisassembly = Assembly.GetExecutingAssembly(); -System.IO.Stream imageStream= thisassembly.GetManifestResourceStream("SparkleShare.Pixmaps.side-splash.png"); -BitmapFrame bmp= BitmapFrame.Create(imageStream); - this.side_splash.Source = bmp; + this.side_splash.Source = SparkleUIHelpers.GetBitmap ("side-splash"); diff --git a/SparkleShare/Windows/SparkleShare.csproj b/SparkleShare/Windows/SparkleShare.csproj index f3e1353d..30c3a2d0 100644 --- a/SparkleShare/Windows/SparkleShare.csproj +++ b/SparkleShare/Windows/SparkleShare.csproj @@ -126,7 +126,6 @@ - @@ -141,6 +140,9 @@ SparkleEventLogController.cs + + Program.cs + diff --git a/SparkleShare/Windows/SparkleUIHelpers.cs b/SparkleShare/Windows/SparkleUIHelpers.cs index 91a905b0..7e2aa9e6 100644 --- a/SparkleShare/Windows/SparkleUIHelpers.cs +++ b/SparkleShare/Windows/SparkleUIHelpers.cs @@ -14,42 +14,28 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -using System.Collections.Generic; -using System.Windows.Forms; -using SparkleLib; + using System; +using System.Drawing; using System.IO; -using System.Net; -using System.Security.Cryptography; -using System.Text; +using System.Reflection; +using System.Windows.Media.Imaging; namespace SparkleShare { public static class SparkleUIHelpers { - - // Creates an MD5 hash of input - public static string GetMD5 (string s) + + public static string ToHex (this Color color) { - MD5 md5 = new MD5CryptoServiceProvider (); - Byte[] bytes = ASCIIEncoding.Default.GetBytes (s); - Byte[] encodedBytes = md5.ComputeHash (bytes); - return BitConverter.ToString (encodedBytes).ToLower ().Replace ("-", ""); + return string.Format ("#{0:X2}{1:X2}{2:X2}", color.R, color.G, color.B); } - public static string ToHex (this System.Drawing.Color color) - { - return String.Format ("#{0:X2}{1:X2}{2:X2}", color.R, color.G, color.B); - } - - //http://stackoverflow.com/a/1499161/33499 - public static IEnumerable All (this Control.ControlCollection controls) - { - foreach (Control control in controls) { - foreach (Control grandChild in control.Controls.All ()) - yield return grandChild; - - yield return control; - } - } + + public static BitmapFrame GetBitmap (string name) + { + Assembly assembly = Assembly.GetExecutingAssembly (); + Stream image_stream = assembly.GetManifestResourceStream ("SparkleShare.Pixmaps." + name + ".png"); + return BitmapFrame.Create (image_stream); + } } }