/// <summary> /// Initializes the application. Override this method to perform custom initialization. /// </summary> /// <remarks> /// Initializes the application, including the session manager, application tools and root window. /// The GUI toolkit and application view have already been initialized prior to this method being /// called. /// </remarks> /// <param name="args">Arguments passed in from the command line.</param> /// <returns>True if initialization was successful, false if the application should terminate immediately.</returns> protected virtual bool Initialize(string[] args) { // initialize the application UI culture from local setting CurrentUICulture = InstalledLocales.Instance.Selected.GetCultureInfo(); // initialize session if (!InitializeSessionManager()) { return(false); } UserUpgradeProgressDialog.RunUpgradeAndShowProgress(); // load tools _toolSet = new ToolSet(new ApplicationToolExtensionPoint(), new ApplicationToolContext(this)); try { // create a root window _windows.AddNew("Root"); } catch (Exception e) { ExceptionHandler.ReportUnhandled(e); return(false); } return(true); }
/// <summary> /// Implements the logic to start up the desktop by running the GUI toolkit and creating the application view. /// </summary> private void Run(string[] args) { // load gui toolkit try { _guiToolkit = (IGuiToolkit)(new GuiToolkitExtensionPoint()).CreateExtension(); } catch (Exception ex) { ExceptionHandler.ReportUnhandled(ex); return; } _guiToolkit.Started += delegate { // load application view try { _synchronizationContext = SynchronizationContext.Current; _view = (IApplicationView)ViewFactory.CreateAssociatedView(this.GetType()); } catch (Exception ex) { ExceptionHandler.ReportUnhandled(ex); TerminateGuiToolkit(); return; } // initialize if (!Initialize(args)) { TerminateGuiToolkit(); return; } _initialized = true; PhoneHome.Startup(); // now that the desktop is fully initialized, take advantage of idle time to // load any outstanding plugins Platform.PluginManager.EnableBackgroundAssemblyLoading(true); }; // init windows collection _windows = new DesktopWindowCollection(this); _windows.ItemClosed += delegate { // terminate the app when the window count goes to 0 if the app isn't already quitting if (_windows.Count == 0 && !IsQuitting) { Quit(false); } }; // start message pump - this will block until _guiToolkit.Terminate() is called _guiToolkit.Run(); }
/// <summary> /// Initializes the application. Override this method to perform custom initialization. /// </summary> /// <remarks> /// Initializes the application, including the session manager, application tools and root window. /// The GUI toolkit and application view have already been initialized prior to this method being /// called. /// </remarks> /// <param name="args">Arguments passed in from the command line.</param> /// <returns>True if initialization was successful, false if the application should terminate immediately.</returns> protected virtual bool Initialize(string[] args) { #if CHECKDOG if (checkDog(1) == 0) { Platform.Log(LogLevel.Error, "无法检测到软件加密狗!!"); return(false); } #endif // initialize the application UI culture from local setting CurrentUICulture = InstalledLocales.Instance.Selected.GetCultureInfo(); // initialize session if (!InitializeSessionManager()) { return(false); } UserUpgradeProgressDialog.RunUpgradeAndShowProgress(); // load tools _toolSet = new ToolSet(new ApplicationToolExtensionPoint(), new ApplicationToolContext(this)); try { // create a root window // _windows.AddNew("Root"); _windows.AddNew("xxx"); } catch (Exception e) { ExceptionHandler.ReportUnhandled(e); return(false); } return(true); }
public override bool Handle(Exception exception) { ExceptionHandler.ReportUnhandled(exception); return(true); }
private void Run(string[] args) { if (args.Length == 0) { return; } //regmutou reg = new regmutou(); //try //{ // reg.checkValid(GlobalData.UsbKey, "aa"); //} //catch (Exception ex) //{ // Platform.Log(LogLevel.Error, "dont't have the key [{0}]", reg.GetCpuID()); // return; //} ConnectDataBase(); // //#if CHECKDOG try { if (DesDecrypt(GlobalData.UsbKey, "abc12345") != EnvironmentUtilities.MachineIdentifier) { if (checkDog(1) == 0) { Platform.Log(LogLevel.Error, "无法检测到软件加密狗!!" + "[" + EnvironmentUtilities.MachineIdentifier + "]"); Platform.ShowMessageBox("无法检测到加密狗!!"); return; } } } catch (Exception ex) { if (checkDog(1) == 0) { Platform.Log(LogLevel.Error, "无法检测到软件加密狗!!" + "[" + EnvironmentUtilities.MachineIdentifier + "]"); Platform.ShowMessageBox("无法检测到加密狗!!"); return; } } //#endif System.Configuration.Configuration config = System.Configuration.ConfigurationManager.OpenExeConfiguration(System.Configuration.ConfigurationUserLevel.PerUserRoamingAndLocal); // load gui toolkit try { _guiToolkit = (IGuiToolkit)(new GuiToolkitExtensionPoint()).CreateExtension(); } catch (Exception ex) { ExceptionHandler.ReportUnhandled(ex); return; } _guiToolkit.Started += delegate { // load application view try { _synchronizationContext = SynchronizationContext.Current; _view = (IApplicationView)ViewFactory.CreateAssociatedView(this.GetType()); } catch (Exception ex) { ExceptionHandler.ReportUnhandled(ex); TerminateGuiToolkit(); return; } // initialize if (!Initialize(args)) { TerminateGuiToolkit(); return; } _initialized = true; PhoneHome.Startup(); // now that the desktop is fully initialized, take advantage of idle time to // load any outstanding plugins Platform.PluginManager.EnableBackgroundAssemblyLoading(true); }; // init windows collection _windows = new DesktopWindowCollection(this); _windows.ItemClosed += delegate { // terminate the app when the window count goes to 0 if the app isn't already quitting if (_windows.Count == 0 && !IsQuitting) { Quit(false); } }; // start message pump - this will block until _guiToolkit.Terminate() is called _guiToolkit.Run(); }