コード例 #1
0
ファイル: Application.cs プロジェクト: vkleper/source_cc
        /// <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();
        }
コード例 #2
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();
        }