Exemplo n.º 1
0
        /// <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();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Implements the logic to terminate the desktop, including closing all windows and terminating the session.
        /// </summary>
        /// <returns>True if the application is really going to terminate, false otherwise.</returns>
        private void DoQuit(bool force)
        {
            if (IsQuitting)
            {
                return;
            }

            PhoneHome.ShutDown();

            if (!force)
            {
                _quitState = QuitState.QuittingNormally;
                if (!CloseAllWindows())
                {
                    _quitState = QuitState.NotQuitting;
                    return;
                }

                // send quitting event
                QuittingEventArgs args = new QuittingEventArgs();
                OnQuitting(args);

                // ensure the action model is disposed - this will cause it to be written out to the store
                ActionModelSettings.Default.Dispose();
            }
            else
            {
                _quitState = QuitState.QuittingForcefully;
            }

            try
            {
                SessionManager.Current.TerminateSession();
            }
            catch (Exception e)
            {
                Platform.Log(LogLevel.Error, e);
            }

            // shut down the GUI message loop
            TerminateGuiToolkit();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Implements the logic to terminate the desktop, including closing all windows and terminating the session.
        /// </summary>
        /// <returns>True if the application is really going to terminate, false otherwise.</returns>
        private void DoQuit(bool force)
        {
            if (IsQuitting)
            {
                return;
            }

            PhoneHome.ShutDown();

            if (!force)
            {
                _quitState = QuitState.QuittingNormally;
                if (!CloseAllWindows())
                {
                    _quitState = QuitState.NotQuitting;
                    return;
                }

                // send quitting event
                QuittingEventArgs args = new QuittingEventArgs();
                OnQuitting(args);
            }
            else
            {
                _quitState = QuitState.QuittingForcefully;
            }

            try
            {
                SessionManager.Current.TerminateSession();
            }
            catch (Exception e)
            {
                Platform.Log(LogLevel.Error, e);
            }

            // shut down the GUI message loop
            TerminateGuiToolkit();
        }
Exemplo n.º 4
0
        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();
        }