Ejemplo n.º 1
0
        public static void Init(Application app)
        {
            AppDomain.CurrentDomain.UnhandledException += (object sender, UnhandledExceptionEventArgs e) => {
                if (e.ExceptionObject is Exception exception)
                {
                    Handle(exception);
                }
            };

            app.DispatcherUnhandledException += (object sender, DispatcherUnhandledExceptionEventArgs e) => {
                Handle(e.Exception);
                e.Handled = true;
            };

            UIThread.InitializeWithDispatcher();
            Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("zh-CN");
        }
Ejemplo n.º 2
0
        public static void Init(Application app)
        {
            _app = app;
            AppDomain.CurrentDomain.UnhandledException += (object sender, UnhandledExceptionEventArgs e) => {
                if (e.ExceptionObject is Exception exception)
                {
                    Handle(exception);
                }
            };

            app.DispatcherUnhandledException += (object sender, DispatcherUnhandledExceptionEventArgs e) => {
                Handle(e.Exception);
                e.Handled = true;
            };

            UIThread.InitializeWithDispatcher(app.Dispatcher);
            RenderOptions.ProcessRenderMode       = RenderMode.SoftwareOnly;
            Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("zh-CN");
            ToolTipService.ShowDurationProperty.OverrideMetadata(typeof(DependencyObject), new FrameworkPropertyMetadata(60000));
            app.Exit += (sender, e) => {
                _mutexApp?.Dispose();
            };
            app.SessionEnding += (sender, e) => {
                SessionEndReasons reason;
                switch (e.ReasonSessionEnding)
                {
                case ReasonSessionEnding.Logoff:
                    reason = SessionEndReasons.Logoff;
                    break;

                case ReasonSessionEnding.Shutdown:
                    reason = SessionEndReasons.SystemShutdown;
                    break;

                default:
                    reason = SessionEndReasons.Logoff;
                    break;
                }
                SessionEndingEventArgs args = new SessionEndingEventArgs(reason)
                {
                    Cancel = e.Cancel
                };
                VirtualRoot.SessionEndingEventHandler?.Invoke(sender, args);
            };
        }
Ejemplo n.º 3
0
        public App()
        {
            AppDomain.CurrentDomain.UnhandledException += (object sender, UnhandledExceptionEventArgs e) => {
                if (e.ExceptionObject is Exception exception)
                {
                    Handle(exception);
                }
            };

            DispatcherUnhandledException += (object sender, DispatcherUnhandledExceptionEventArgs e) => {
                Handle(e.Exception);
                e.Handled = true;
            };

            UIThread.InitializeWithDispatcher();
            UIThread.StartTimer();
            Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("zh-CN");
            InitializeComponent();
        }
Ejemplo n.º 4
0
        public App()
        {
            VirtualRoot.SetOut(NotiCenterWindowViewModel.Instance);
            AppDomain.CurrentDomain.UnhandledException += (object sender, UnhandledExceptionEventArgs e) => {
                if (e.ExceptionObject is Exception exception)
                {
                    Handle(exception);
                }
            };

            DispatcherUnhandledException += (object sender, DispatcherUnhandledExceptionEventArgs e) => {
                Handle(e.Exception);
                e.Handled = true;
            };

            Write.UIThreadId = Dispatcher.Thread.ManagedThreadId;
            UIThread.InitializeWithDispatcher();
            UIThread.StartTimer();
            Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("zh-CN");
            InitializeComponent();
        }
Ejemplo n.º 5
0
        public static void Init(Application app)
        {
            _app = app;
            AppDomain.CurrentDomain.UnhandledException += (object sender, UnhandledExceptionEventArgs e) => {
                if (e.ExceptionObject is Exception exception)
                {
                    Handle(exception);
                }
            };

            app.DispatcherUnhandledException += (object sender, DispatcherUnhandledExceptionEventArgs e) => {
                Handle(e.Exception);
                e.Handled = true;
            };

            UIThread.InitializeWithDispatcher(app.Dispatcher);
            Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("zh-CN");
            app.SessionEnding += (sender, e) => {
                OsSessionEndingEvent.ReasonSessionEnding reason;
                switch (e.ReasonSessionEnding)
                {
                case ReasonSessionEnding.Logoff:
                    reason = OsSessionEndingEvent.ReasonSessionEnding.Logoff;
                    break;

                case ReasonSessionEnding.Shutdown:
                    reason = OsSessionEndingEvent.ReasonSessionEnding.Shutdown;
                    break;

                default:
                    reason = OsSessionEndingEvent.ReasonSessionEnding.Unknown;
                    break;
                }
                VirtualRoot.RaiseEvent(new OsSessionEndingEvent(reason));
            };
        }