コード例 #1
0
ファイル: ThisAddIn.cs プロジェクト: chrhodes/Office
        private void UnLoadXamlApplicationResources()
        {
            Int64 startTicks = Log.APPLICATION_END("Enter", Common.LOG_CATEGORY);

            try
            {
                if (null != _XamlApp)
                {
                    _XamlApp.Shutdown();
                    _XamlApp = null;
                }
                if (null != _prismApplication)
                {
                    _prismApplication.Shutdown();
                    _prismApplication = null;
                }
            }
            catch (Exception ex)
            {
                Common.DeveloperMode = true;
                Common.WriteToDebugWindow(ex.ToString());
                Common.DeveloperMode = false;
            }

            Log.APPLICATION_END("Exit", Common.LOG_CATEGORY, startTicks);
        }
コード例 #2
0
        static public void QuitWindowsEventLoop()
        {
            if (IsWindowsEventLoopQuitRequested)
            {
                return;
            }
            MainThreadSynchronizationContext.Send(delegate
            {
                if (IsWindowsEventLoopQuitRequested)
                {
                    return;
                }
                IsWindowsEventLoopQuitRequested = true;
#if SUPPORT_WPF
                if (LoopMode == EventLoopMode.WPF)
                {
                    _wpfapp?.Shutdown();
                }
#endif
                if (LoopMode == EventLoopMode.LibCef)
                {
                    LibCefInterop.cef_quit_message_loop();
                }
                if (LoopMode == EventLoopMode.WinForms)
                {
                    WF.Application.Exit();                                                      //This is not a good solution, hang
                }
            }, null);
        }
コード例 #3
0
 /// <summary>
 /// Threadsafe Application Shutdown.
 /// </summary>
 /// <param name="value">The <see cref="System.Windows.Application">Application Instance</see> to End.</param>
 /// <exception cref="System.NullReferenceException">Can occur when either the The <see cref="System.Windows.Application">Application Instance</see> or its The <see cref="System.Windows.Application">Application Instance</see> Dispatcher object is null.</exception>
 public static void Close(this System.Windows.Application value)
 {
     value.Invoke(delegate
     {
         value?.Shutdown();
     });
 }
コード例 #4
0
ファイル: ResourceHelperTest.cs プロジェクト: uzbekdev1/waf
            public void AddToApplicationResources()
            {
                var app = new System.Windows.Application();

                System.Windows.Threading.Dispatcher.CurrentDispatcher.BeginInvoke((Action)(() => app.Run()));

                AssertHelper.ExpectedException <ArgumentException>(() => ResourceHelper.AddToApplicationResources((string)null !, "test"));
                AssertHelper.ExpectedException <ArgumentException>(() => ResourceHelper.AddToApplicationResources("", "test"));
                AssertHelper.ExpectedException <ArgumentNullException>(() => ResourceHelper.AddToApplicationResources("test", null !));
                AssertHelper.ExpectedException <ArgumentException>(() => ResourceHelper.AddToApplicationResources("test", ""));
                AssertHelper.ExpectedException <ArgumentNullException>(() => ResourceHelper.AddToApplicationResources((Assembly)null !, "test"));
                AssertHelper.ExpectedException <ArgumentNullException>(() => ResourceHelper.AddToApplicationResources(typeof(ResourceHelperTest).Assembly, null !));
                AssertHelper.ExpectedException <ArgumentException>(() => ResourceHelper.AddToApplicationResources(typeof(ResourceHelperTest).Assembly, ""));

                Assert.AreEqual(0, app.Resources.MergedDictionaries.Count);
                ResourceHelper.AddToApplicationResources(typeof(ResourceHelperTest).Assembly,
                                                         "Presentation/Resources/BrushResources.xaml", "Presentation/Resources/LayoutResources.xaml");
                Assert.AreEqual(2, app.Resources.MergedDictionaries.Count);
                Assert.AreEqual("pack://application:,,,/System.Waf.Wpf.Test;Component/Presentation/Resources/BrushResources.xaml",
                                app.Resources.MergedDictionaries[0].Source.ToString());
                Assert.AreEqual("pack://application:,,,/System.Waf.Wpf.Test;Component/Presentation/Resources/LayoutResources.xaml",
                                app.Resources.MergedDictionaries[1].Source.ToString());

                app.Shutdown();
            }
コード例 #5
0
    public void openUI()
    {
        var application = new System.Windows.Application();
        var ui          = new Window();

        application.Run(ui);
        application.Shutdown();
    }
コード例 #6
0
        /// <summary>
        /// アプリケーションを実行可能にし、同期的に待機します。
        /// </summary>
        /// <param name="task">対応する非同期タスク</param>
        /// <returns>戻り値</returns>
        public int Run(Task <int> task)
        {
            // タスクの継続で、WPF Applicationをシャットダウンするようにセットアップする
            task.ContinueWith(t => wpfApplication.Shutdown(t.Result));

            // メッセージループの実行
            return(this.wpfApplication.Run());
        }
コード例 #7
0
        internal static void ShutDown(System.Windows.Application application)
        {
            Thread t = new Thread(() =>
            {
                application.Shutdown();
            });

            t.Start();
        }
コード例 #8
0
 /// <summary>
 /// Threadsafe Close the Window and Optionally End the Application.
 /// </summary>
 /// <param name="value">The <see cref="System.Windows.Application">Application Instance</see>.</param>
 /// <param name="window"><see cref="System.Windows.Window">Window</see> The <see cref="System.Windows.Window">Window</see> to Close.</param>
 /// <param name="endApplication">bool; If True, Shutdown the Application. Default is False.</param>
 /// <exception cref="System.NullReferenceException">Can occur when either the Application or its Dispatcher object is Null.</exception>
 public static void DisposeOf(this System.Windows.Application value, System.Windows.Window window, bool endApplication = false)
 {
     value.Invoke(delegate
     {
         window?.Close();
         if (endApplication)
         {
             value?.Shutdown();
         }
     });
 }
コード例 #9
0
        public void openUI()
        {
            var application = new System.Windows.Application();
            var ui          = new BackgroundManagerUI.MainWindow();

            ui.Data        = Handle.data;
            ui.DataContext = ui.Data;
            ui.loadNonBindings();

            application.Run(ui);
            application.Shutdown();
        }
コード例 #10
0
        public TrayIconHelper(ThemeSwitchService themeSwitchService, StartupHelper startupHelper, System.Windows.Application app)
        {
            _themeSwitchService = themeSwitchService;
            _startupHelper      = startupHelper;

            var notifyIcon = new NotifyIcon();

            notifyIcon.Icon             = Resource.TrayIcon;
            notifyIcon.Text             = "Auto Dark Mode";
            notifyIcon.MouseDown       += TrayIcon_Click;
            notifyIcon.ContextMenuStrip = new ContextMenuStrip();
            notifyIcon.ContextMenuStrip.Items.Add(_forceDarkMenuItem);
            notifyIcon.ContextMenuStrip.Items.Add(_forceLightMenuItem);
            notifyIcon.ContextMenuStrip.Items.Add(_openConfigMenuItem);
            notifyIcon.ContextMenuStrip.Items.Add(_exitMenuItem);

            _forceDarkMenuItem.Click  += (_, __) => ThemeSwitchHelper.Switch(ThemeSwitchHelper.Mode.Dark);
            _forceLightMenuItem.Click += (_, __) => ThemeSwitchHelper.Switch(ThemeSwitchHelper.Mode.Light);
            _openConfigMenuItem.Click += (_, __) => TrayIcon_Click(this, new MouseEventArgs(MouseButtons.Left, 0, 0, 0, 0));
            _exitMenuItem.Click       += (_, __) => app.Shutdown();

            notifyIcon.Visible = true;
        }
コード例 #11
0
ファイル: InProcessRunner.cs プロジェクト: orb1t/Nomad
        public void kill_application()
        {
            var watch = Stopwatch.StartNew();

            _dispatcher.Invoke(DispatcherPriority.SystemIdle, new ThreadStart(() => { _window.Close(); _app.Shutdown(0); }));
            _windowAutomation.WaitFor(c => _windowAutomation.IsClosed());
            watch.Stop();
            Console.WriteLine(watch.Elapsed.ToString());
        }
コード例 #12
0
 private void TriggerExit(object sender, EventArgs e)
 {
     _application.Shutdown();
 }
コード例 #13
0
 public override void Exit()
 {
     application.Shutdown();
 }
コード例 #14
0
ファイル: Core.cs プロジェクト: guidoquadrini/Chronos
        //[STAThread]
        //public static void Main()
        //{
        //    Application.EnableVisualStyles();
        //    try
        //    {
        //        new ChronosXPCore();
        //        Application.Run();
        //    }
        //    catch (Exception ex)
        //    {
        //        try
        //        {
        //            Application.Run(new ErrorReport(ex));
        //        }
        //        catch
        //        {
        //            new ErrorReport(ex).Show();
        //        }
        //    }
        //}

        public void Shutdown()
        {
            Entry.Shutdown();
            Application.Exit();
        }