Don't use a separate Program.cs on Windows
This commit is contained in:
parent
1e6cba4baa
commit
466a2146f3
|
@ -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
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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<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__
|
||||
[STAThread]
|
||||
|
|
|
@ -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");
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -126,7 +126,6 @@
|
|||
<Compile Include="SparkleController.cs" />
|
||||
<Compile Include="SparkleEventLog.cs" />
|
||||
<Compile Include="SparkleSetup.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="SparkleStatusIcon.cs" />
|
||||
<Compile Include="SparkleUIHelpers.cs" />
|
||||
<Compile Include="controls\TablessControl.cs">
|
||||
|
@ -141,6 +140,9 @@
|
|||
<Link>SparkleEventLogController.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="SparkleSetupWindow.cs" />
|
||||
<Compile Include="..\Program.cs">
|
||||
<Link>Program.cs</Link>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\SparkleLib\windows\SparkleLib.csproj">
|
||||
|
|
|
@ -14,42 +14,28 @@
|
|||
// You should have received a copy of the GNU General Public License
|
||||
// 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.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<Control> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue