Don't use a separate Program.cs on Windows

This commit is contained in:
Hylke Bons 2012-03-06 01:49:36 +00:00
parent 1e6cba4baa
commit 466a2146f3
5 changed files with 25 additions and 62 deletions

View file

@ -16,13 +16,10 @@
using System; using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
#if __MonoCS__
using Mono.Unix; using Mono.Unix;
#endif
using SparkleLib; using SparkleLib;
namespace SparkleShare { namespace SparkleShare {
@ -36,8 +33,12 @@ namespace SparkleShare {
// Short alias for the translations // Short alias for the translations
public static string _ (string s) public static string _ (string s)
{ {
#if __MonoCS__
return Catalog.GetString (s); return Catalog.GetString (s);
#else
return Strings.T (s);
#endif
} }

View file

@ -49,19 +49,7 @@ namespace SparkleShare {
#endif #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<System.Windows.Forms.Label> ()) {
label.Text = Program._ (label.Text);
}
foreach (var button in form.Controls.All ().OfType<System.Windows.Forms.Button> ()) {
button.Text = Program._ (button.Text);
}
}
#endif
#if !__MonoCS__ #if !__MonoCS__
[STAThread] [STAThread]

View file

@ -73,23 +73,9 @@ namespace SparkleShare {
Width = 150, Width = 150,
Height = 482 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");

View file

@ -126,7 +126,6 @@
<Compile Include="SparkleController.cs" /> <Compile Include="SparkleController.cs" />
<Compile Include="SparkleEventLog.cs" /> <Compile Include="SparkleEventLog.cs" />
<Compile Include="SparkleSetup.cs" /> <Compile Include="SparkleSetup.cs" />
<Compile Include="Program.cs" />
<Compile Include="SparkleStatusIcon.cs" /> <Compile Include="SparkleStatusIcon.cs" />
<Compile Include="SparkleUIHelpers.cs" /> <Compile Include="SparkleUIHelpers.cs" />
<Compile Include="controls\TablessControl.cs"> <Compile Include="controls\TablessControl.cs">
@ -141,6 +140,9 @@
<Link>SparkleEventLogController.cs</Link> <Link>SparkleEventLogController.cs</Link>
</Compile> </Compile>
<Compile Include="SparkleSetupWindow.cs" /> <Compile Include="SparkleSetupWindow.cs" />
<Compile Include="..\Program.cs">
<Link>Program.cs</Link>
</Compile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\SparkleLib\windows\SparkleLib.csproj"> <ProjectReference Include="..\..\SparkleLib\windows\SparkleLib.csproj">

View file

@ -14,42 +14,28 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
using System.Collections.Generic;
using System.Windows.Forms;
using SparkleLib;
using System; using System;
using System.Drawing;
using System.IO; using System.IO;
using System.Net; using System.Reflection;
using System.Security.Cryptography; using System.Windows.Media.Imaging;
using System.Text;
namespace SparkleShare { namespace SparkleShare {
public static class SparkleUIHelpers { public static class SparkleUIHelpers {
// Creates an MD5 hash of input public static string ToHex (this Color color)
public static string GetMD5 (string s)
{ {
MD5 md5 = new MD5CryptoServiceProvider (); return string.Format ("#{0:X2}{1:X2}{2:X2}", color.R, color.G, color.B);
Byte[] bytes = ASCIIEncoding.Default.GetBytes (s);
Byte[] encodedBytes = md5.ComputeHash (bytes);
return BitConverter.ToString (encodedBytes).ToLower ().Replace ("-", "");
} }
public static string ToHex (this System.Drawing.Color color)
{ public static BitmapFrame GetBitmap (string name)
return String.Format ("#{0:X2}{1:X2}{2:X2}", color.R, color.G, color.B); {
} Assembly assembly = Assembly.GetExecutingAssembly ();
Stream image_stream = assembly.GetManifestResourceStream ("SparkleShare.Pixmaps." + name + ".png");
//http://stackoverflow.com/a/1499161/33499 return BitmapFrame.Create (image_stream);
public static IEnumerable<Control> All (this Control.ControlCollection controls) }
{
foreach (Control control in controls) {
foreach (Control grandChild in control.Controls.All ())
yield return grandChild;
yield return control;
}
}
} }
} }