-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
77 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,82 @@ | ||
using System; | ||
using Gtk; | ||
using Gtk; | ||
using NewLife; | ||
using NewLife.Log; | ||
using NewLife.Model; | ||
using Stardust; | ||
|
||
namespace XCoder | ||
namespace XCoder; | ||
|
||
static class Program | ||
{ | ||
static class Program | ||
/// <summary> | ||
/// The main entry point for the application. | ||
/// </summary> | ||
[STAThread] | ||
static void Main() | ||
{ | ||
/// <summary> | ||
/// The main entry point for the application. | ||
/// </summary> | ||
[STAThread] | ||
static void Main() | ||
{ | ||
XTrace.UseConsole(); | ||
MachineInfo.RegisterAsync(); | ||
XTrace.UseConsole(); | ||
MachineInfo.RegisterAsync(); | ||
|
||
StartClient(); | ||
|
||
GLib.ExceptionManager.UnhandledException += ExceptionManager_UnhandledException; | ||
|
||
// 检查环境 | ||
GtkHelper.CheckRuntime(); | ||
|
||
Application.Init(); | ||
var window = new SharpApp(); | ||
window.ShowAll(); | ||
// Window.InteractiveDebugging = true; | ||
//XTrace2.UseWinForm(window); | ||
Application.Run(); | ||
} | ||
|
||
private static void ExceptionManager_UnhandledException(GLib.UnhandledExceptionArgs args) | ||
{ | ||
if (args.ExceptionObject is Exception ex) XTrace.WriteException(ex); | ||
} | ||
|
||
GLib.ExceptionManager.UnhandledException += ExceptionManager_UnhandledException; | ||
static StarFactory _factory; | ||
static StarClient _Client; | ||
private static void StartClient() | ||
{ | ||
var set = XConfig.Current; | ||
var server = set.Server; | ||
if (server.IsNullOrEmpty()) return; | ||
|
||
// 检查环境 | ||
GtkHelper.CheckRuntime(); | ||
XTrace.WriteLine("初始化服务端地址:{0}", server); | ||
|
||
Application.Init(); | ||
var window = new SharpApp(); | ||
window.ShowAll(); | ||
// Window.InteractiveDebugging = true; | ||
//XTrace2.UseWinForm(window); | ||
Application.Run(); | ||
} | ||
_factory = new StarFactory(server, "XCoderLinux", null) | ||
{ | ||
Log = XTrace.Log, | ||
}; | ||
|
||
private static void ExceptionManager_UnhandledException(GLib.UnhandledExceptionArgs args) | ||
var client = new StarClient(server) | ||
{ | ||
if (args.ExceptionObject is Exception ex) XTrace.WriteException(ex); | ||
} | ||
Code = set.Code, | ||
Secret = set.Secret, | ||
ProductCode = "XCoderLinux", | ||
|
||
Tracer = _factory.Tracer, | ||
Log = XTrace.Log, | ||
}; | ||
|
||
// 登录后保存证书 | ||
client.OnLogined += (s, e) => | ||
{ | ||
if (client.Logined && !client.Code.IsNullOrEmpty()) | ||
{ | ||
set.Code = client.Code; | ||
set.Secret = client.Secret; | ||
set.Save(); | ||
} | ||
}; | ||
|
||
client.Open(); | ||
|
||
Host.RegisterExit(() => client.Logout("ApplicationExit")); | ||
|
||
_Client = client; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters