Improvements in application initialization
When initializing XWT, the backend can now be specified using an enumeration. XWT now loads backends which match the version number of Xwt.dll.
This commit is contained in:
Родитель
9cb8174814
Коммит
bf96a8fdb5
|
@ -25,6 +25,7 @@
|
|||
// THE SOFTWARE.
|
||||
using System;
|
||||
using Samples;
|
||||
using Xwt;
|
||||
|
||||
namespace GtkTest
|
||||
{
|
||||
|
@ -32,7 +33,7 @@ namespace GtkTest
|
|||
{
|
||||
public static void Main (string[] args)
|
||||
{
|
||||
App.Run ("Xwt.GtkBackend.GtkEngine, Xwt.Gtk, Version=1.0.0.0");
|
||||
App.Run (ToolkitType.Gtk);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>MacTest</RootNamespace>
|
||||
<AssemblyName>MacTest</AssemblyName>
|
||||
<SuppressXamMacMigration>True</SuppressXamMacMigration>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>True</DebugSymbols>
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace MacTest
|
|||
{
|
||||
static void Main (string [] args)
|
||||
{
|
||||
App.Run ("Xwt.Mac.MacEngine, Xwt.Mac, Version=1.0.0.0");
|
||||
App.Run (ToolkitType.Cocoa);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,9 +7,9 @@ namespace Samples
|
|||
{
|
||||
public class App
|
||||
{
|
||||
public static void Run (string engineType)
|
||||
public static void Run (ToolkitType type)
|
||||
{
|
||||
Application.Initialize (engineType);
|
||||
Application.Initialize (type);
|
||||
|
||||
MainWindow w = new MainWindow ();
|
||||
w.Title = "Xwt Demo Application";
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
|
||||
using System;
|
||||
using Samples;
|
||||
using Xwt;
|
||||
|
||||
namespace WpfTest
|
||||
{
|
||||
|
@ -33,7 +34,7 @@ namespace WpfTest
|
|||
[STAThread]
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
App.Run ("Xwt.WPFBackend.WPFEngine, Xwt.WPF, Version=1.0.0.0");
|
||||
App.Run (ToolkitType.Wpf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
<OutputType>Library</OutputType>
|
||||
<RootNamespace>Xwt.Mac</RootNamespace>
|
||||
<AssemblyName>Xwt.Mac</AssemblyName>
|
||||
<SuppressXamMacMigration>True</SuppressXamMacMigration>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>True</DebugSymbols>
|
||||
|
|
|
@ -58,6 +58,11 @@ namespace Xwt
|
|||
Initialize (null);
|
||||
}
|
||||
|
||||
public static void Initialize (ToolkitType type)
|
||||
{
|
||||
Initialize (GetBackendType (type));
|
||||
}
|
||||
|
||||
public static void Initialize (string backendType)
|
||||
{
|
||||
InitBackend (backendType);
|
||||
|
@ -202,18 +207,25 @@ namespace Xwt
|
|||
if (type != null && LoadBackend (type))
|
||||
return;
|
||||
|
||||
if (LoadBackend ("Xwt.GtkBackend.GtkEngine, Xwt.Gtk, Version=1.0.0.0"))
|
||||
return;
|
||||
|
||||
if (LoadBackend ("Xwt.Mac.MacEngine, Xwt.Mac, Version=1.0.0.0"))
|
||||
return;
|
||||
|
||||
if (LoadBackend ("Xwt.WPFBackend.WPFEngine, Xwt.WPF, Version=1.0.0.0"))
|
||||
return;
|
||||
|
||||
throw new InvalidOperationException ("Xwt engine not found");
|
||||
}
|
||||
|
||||
|
||||
internal static string GetBackendType (ToolkitType type)
|
||||
{
|
||||
string version = typeof(Application).Assembly.GetName ().Version.ToString ();
|
||||
|
||||
switch (type) {
|
||||
case ToolkitType.Gtk:
|
||||
return "Xwt.GtkBackend.GtkEngine, Xwt.Gtk, Version=" + version;
|
||||
case ToolkitType.Cocoa:
|
||||
return "Xwt.Mac.MacEngine, Xwt.Mac, Version=" + version;
|
||||
case ToolkitType.Wpf:
|
||||
return "Xwt.WPFBackend.WPFEngine, Xwt.WPF, Version=" + version;
|
||||
default:
|
||||
throw new ArgumentException ("Invalid toolkit type");
|
||||
}
|
||||
}
|
||||
|
||||
internal static void NotifyException (Exception ex)
|
||||
{
|
||||
var unhandledException = UnhandledException;
|
||||
|
@ -227,5 +239,12 @@ namespace Xwt
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum ToolkitType
|
||||
{
|
||||
Gtk,
|
||||
Cocoa,
|
||||
Wpf
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче