/// <summary> /// Start Qlip /// </summary> private void ShowQlipForm() { if (qlipForm == null) { if (model != null) { model.Reset(); } qlipForm = new Qlip.MainWindow(model); qlipForm.Closed += qlipProcess_Closed; // avoid reshowing a disposed form ElementHost.EnableModelessKeyboardInterop(qlipForm); qlipForm.Show(); StartStopText = "Stop"; } else if (StartStopText.Equals("Start")) { qlipForm.Activate(); StartStopText = "Stop"; } else { qlipForm.Close(); StartStopText = "Start"; } }
public static void AssemblyCleanup() { window?.Dispatcher?.Invoke(() => { window?.Close(); }); // UIThread.Abort(); var app = System.Windows.Application.Current; if (app != null) { var d = app.Dispatcher; if (d != null && !(d.HasShutdownStarted || d.HasShutdownFinished)) { try { d.Invoke(() => { if (!(d.HasShutdownStarted || d.HasShutdownFinished)) { app.Shutdown(); } }); } catch (TaskCanceledException) { } } } }
private ContextMenuStrip createMenu() { ContextMenuStrip menu = new ContextMenuStrip(); ToolStripMenuItem hideToolStripMenuItem = new ToolStripMenuItem("Ukryj"); hideToolStripMenuItem.Click += (s, e) => { window.Hide(); }; menu.Items.Add(hideToolStripMenuItem); ToolStripMenuItem restoreToolStripMenuItem = new ToolStripMenuItem("Przywróć"); restoreToolStripMenuItem.Click += (s, e) => { window.Show(); }; menu.Items.Add(restoreToolStripMenuItem); ToolStripMenuItem closeToolStripMenuItem = new ToolStripMenuItem("Zamknij"); closeToolStripMenuItem.Click += (s, e) => { window.Close(); }; menu.Items.Add(closeToolStripMenuItem); menu.Items.Add(new ToolStripSeparator()); ToolStripMenuItem aboutTheAutorToolStripMenuItem = new ToolStripMenuItem("O..."); aboutTheAutorToolStripMenuItem.Click += (s, e) => { System.Windows.SplashScreen splashScreen = new System.Windows.SplashScreen("SplashScreen.png"); splashScreen.Show(false, true); System.Threading.Thread.Sleep(1000); splashScreen.Close(new TimeSpan(0, 0, 1)); }; menu.Items.Add(aboutTheAutorToolStripMenuItem); return(menu); }
private void imgLogout_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { System.Windows.MessageBoxResult mresult = Xceed.Wpf.Toolkit.MessageBox.Show("Do you want to Logout?", "", System.Windows.MessageBoxButton.YesNo, System.Windows.MessageBoxImage.Question); if (mresult == System.Windows.MessageBoxResult.Yes) { var login = new Login(); System.Windows.Window parentWindow = System.Windows.Window.GetWindow(this); parentWindow.Close(); var loginVM = new LoginViewModel(); loginVM.LoginCompleted += (sender1, e1) => { if (loginVM.Theme == 1) { HomeWindow main = new HomeWindow(); main.Show(); } else { MainWindow main = new MainWindow(); main.Show(); } login.Close(); }; login.DataContext = loginVM; login.ShowDialog(); } }
private static void ShowMenuByID(string productID) { if (menuPalette.Visible) { menuPalette.Close(); menuPalette.Dispose(); } Product product = ProductManager.GetProductRecordByID(productID); string title = ProductManager.GetProductTitle(); menuWindow.Close(); menuWindow = product.GetProductMenuWindow(); Application.MainWindow.Text = title; menuPalette = new PaletteSet(title); System.Windows.Controls.ScrollViewer root = menuWindow.Content as System.Windows.Controls.ScrollViewer; root.Width = 240; root.Height = 2000; root.Margin = new System.Windows.Thickness(0); menuPalette.AddVisual("菜单", root); menuPalette.Size = new System.Drawing.Size(200, 640); menuPalette.MinimumSize = new System.Drawing.Size(200, 640); menuPalette.SizeChanged += (sender, e) => root.Width = menuPalette.Size.Width; menuPalette.Visible = true; menuPalette.Dock = DockSides.Right; menuPalette.DockEnabled = DockSides.Right; }
private async void DoWork() { if (IsNewUser) { _user = new User(); } _user.UserName = this.UserName; _user.IsAdmin = this.IsAdmin; _user.Email = this.Email; _user.Password = this.Password; bool result = false; if (IsNewUser) { result = await QuerryHandler.CreateUser(_user); } else { result = await QuerryHandler.UpdateUser(_user); } String message = result ? "User was saved" : "User was NOT saved"; MessageBoxIcon icon = result ? MessageBoxIcon.Information : MessageBoxIcon.Error; MessageBox.Show(message, "Save result", MessageBoxButtons.OK); parentwin?.Close(); }
public async void main(System.Windows.Window win) { if (!hasInternet()) { return; } var client = new HttpClient(); var uri = new Uri("https://raw.githubusercontent.com/Big-Yoda/YmtEditor/master/version.json"); Stream respStream = await client.GetStreamAsync(uri); versionData = new JsonSerializer().Deserialize <VersionData>(new JsonTextReader(new StreamReader(respStream))); Debug.WriteLine(float.Parse(Properties.Resources.version, CultureInfo.InvariantCulture.NumberFormat).ToString()); isLatest = float.Parse(Properties.Resources.version.ToString(), CultureInfo.InvariantCulture.NumberFormat) == float.Parse(versionData.version.ToString(), CultureInfo.InvariantCulture.NumberFormat); if (isLatest) { return; } DialogResult diaRes = MessageBox.Show($"New version found! Do you want to update now?\nChangelog v{versionData.version}:\n{versionData.message}\n\nYour Version: {Properties.Resources.version}, {Properties.Resources.stage}", $"Update, Version: {versionData.version}, {versionData.stage}", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly); if (diaRes == DialogResult.Yes) { win.Close(); Process.Start("https://discord.gg/t4CFXBn"); } }
public static void CloseDialog(System.Windows.Window dialog) { if (Message.Question("Are you sure you want to exit the Install Wizard?")) { dialog.Close(); } }
private void CloseWindow(System.Windows.Window window) { if (window != null) { window.Close(); } }
private ContextMenuStrip tworzMenu() { ContextMenuStrip menu = new ContextMenuStrip(); ToolStripMenuItem ukryjToolStripMenuItem = new ToolStripMenuItem("Ukryj"); ukryjToolStripMenuItem.Click += (s, e) => { okno.Hide(); }; menu.Items.Add(ukryjToolStripMenuItem); ToolStripMenuItem przywrocToolStripMenuItem = new ToolStripMenuItem("Przywróć"); przywrocToolStripMenuItem.Click += (s, e) => { okno.Show(); }; menu.Items.Add(przywrocToolStripMenuItem); ToolStripMenuItem zamknijToolStripMenuItem = new ToolStripMenuItem("Zamknij"); zamknijToolStripMenuItem.Click += (s, e) => { okno.Close(); }; menu.Items.Add(zamknijToolStripMenuItem); menu.Items.Add(new ToolStripSeparator()); ToolStripMenuItem oAutorzeToolStripMenuItem = new ToolStripMenuItem("O..."); oAutorzeToolStripMenuItem.Click += (s, e) => { System.Windows.SplashScreen splashScreen = new System.Windows.SplashScreen("SplashScreen.png"); splashScreen.Show(false, true); System.Threading.Thread.Sleep(1000); splashScreen.Close(new TimeSpan(0, 0, 1)); }; menu.Items.Add(oAutorzeToolStripMenuItem); return(menu); }
public NotifyIconProxy(Uri iconPath, string text, System.Windows.Controls.ContextMenu menu) { // 各種プロパティを初期化 _notify = new System.Windows.Forms.NotifyIcon(); IconPath = iconPath; Text = text; ContextMenu = menu; // マウス右ボタンUpのタイミングで、ContextMenuの表示を行う // ダミーの透明ウィンドウを表示し、このウィンドウのアクティブ状態を用いてContextMenuの表示/非表示を切り替える _notify.MouseUp += (s, e) => { if (e.Button != System.Windows.Forms.MouseButtons.Right) { return; } var win = new System.Windows.Window() { WindowStyle = System.Windows.WindowStyle.None, ShowInTaskbar = false, AllowsTransparency = true, Background = System.Windows.Media.Brushes.Transparent, Content = new System.Windows.Controls.Grid(), ContextMenu = ContextMenu }; var isClosed = false; win.Activated += (_, __) => { if (win.ContextMenu != null) { win.ContextMenu.IsOpen = true; } }; win.Closing += (_, __) => { isClosed = true; }; win.Deactivated += (_, __) => { if (win.ContextMenu != null) { win.ContextMenu.IsOpen = false; } if (!isClosed) { win.Close(); } }; // ダミーウィンドウ表示&アクティブ化をする。 // ⇒これがActivatedイベントで、ContextMenuが表示される win.Show(); win.Activate(); }; _notify.Visible = true; }
void win_History_Click(object sender, EventArgs e) { System.Windows.Window window = win as System.Windows.Window; Tests.TestHistory history = new Tests.TestHistory(userId, window.Left, window.Top); history.WindowState = window.WindowState; history.Show(); window.Close(); }
public void Execute(object parameter) { System.Windows.Window window = parameter as System.Windows.Window; if (window == null) { return; } window.Close(); }
public static Task <Microsoft.SharePoint.Client.ClientContext> GetAuthenticatedContext(string sharepointSiteUrl) { // see: https://stackoverflow.com/questions/15316613/when-should-taskcompletionsourcet-be-used var promise = new TaskCompletionSource <Microsoft.SharePoint.Client.ClientContext>(); UseWPFThread(() => { var win = new System.Windows.Window(); var webBrowser = new WebBrowser(); win.Content = webBrowser; webBrowser.Navigated += (_s, _args) => { var cookies = CookieReader.GetCookieCollection(_args.Uri) .OfType <Cookie>(); var FedAuth = cookies.FirstOrDefault(c => string.Equals("FedAuth", c.Name, StringComparison.OrdinalIgnoreCase)); var rtfa = cookies.FirstOrDefault(c => string.Equals("rtFa", c.Name, StringComparison.OrdinalIgnoreCase)); if (FedAuth != null && rtfa != null) { // from: http://jcardy.co.uk/creating-a-sharepoint-csom-clientcontext-with-an-authentication-cookie/ var context = new Microsoft.SharePoint.Client.ClientContext(_args.Uri); context.ExecutingWebRequest += (sender, e) => { e.WebRequestExecutor.WebRequest.Headers[HttpRequestHeader.Cookie] = "FedAuth=" + FedAuth.Value + ";rtFa=" + rtfa.Value; }; if (!promise.Task.IsCompleted) { promise.SetResult(context); } win.Close(); // we are done so close the window } }; win.Closed += (_s, _args) => { if (!promise.Task.IsCompleted) { throw new Exception("Window closed before got authentication"); } }; // make this one of the last things that happens webBrowser.Navigate(sharepointSiteUrl); win.ShowDialog(); });// end of wpf thread return(promise.Task); }
async Task ProcessAction(System.Windows.Window w, System.Action a) { await Task.Run(() => { a(); Globals.DynamicsCRMExcelAddIn.SyncContext.Post(new System.Threading.SendOrPostCallback((o) => { w.Close(); }), null); }); }
static public void ReopenWindow(this System.Windows.Window window, System.Windows.Window windowToOpen) { windowToOpen.Top = window.Top; windowToOpen.Left = window.Left; windowToOpen.Width = window.Width; windowToOpen.Height = window.Height; windowToOpen.Show(); window.Close(); }
private void Aceptar(System.Windows.Window o) { this.Resultado = true; ConfiguracionView view = (ConfiguracionView)o; this.PasswordText = view.PasswordText.Password; //acciones o.Close(); }
private void Close() { if (startServiceMenuItem != null) { startServiceMenuItem.Dispose(); startServiceMenuItem = null; } if (stopServiceMenuItem != null) { stopServiceMenuItem.Dispose(); stopServiceMenuItem = null; } if (exitMenuItem != null) { exitMenuItem.Dispose(); exitMenuItem = null; } if (notifyIcon != null) { notifyIcon.ContextMenuStrip.Opening -= ContextMenuStrip_Opening; notifyIcon.DoubleClick -= NotifyIcon_DoubleClick; notifyIcon.MouseUp -= NotifyIcon_MouseUp; notifyIcon.Dispose(); notifyIcon = null; } if (aboutViewModel != null) { aboutViewModel.Dispose(); aboutViewModel = null; } if (statusViewModel != null) { statusViewModel.Dispose(); statusViewModel = null; } if (hiddenWindow != null) { hiddenWindow.Close(); hiddenWindow = null; } if (components != null) { components.Dispose(); components = null; } }
private static void LerpFade_LerpDone(object sender, LerpArgs e) { if (__shouldClose) { _WFade.Close(); } else { _WFade.Opacity = 1; _WFade.Hide(); } }
/// <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(); } }); }
// - - - - static bool WPFDefaultConstructorTestCleaner(object Instance) { // Serializer instanciates the default constructor (when available) once to ensure it does not throw an exception. Unfortunately, that instanciation can lead to problems. Example: each WPF Window have to be closed properly before closing the application. // The solution is to close the temporary Window. System.Windows.Window I = Instance as System.Windows.Window; if (I != null) { I.Close(); // Let the Application close. return(true); } return(false); }
private static void SINGLE_StepFade_SmoothStepDone(object sender, SmoothStepArgs e) { HWND.Opacity = 0; if (_shouldClose) { HWND.Close(); } else { HWND.Hide(); HWND.Opacity = 1; } }
private static void SINGLE_LerpFade_LerpDone(object sender, LerpArgs e) { HWND.Opacity = 0; if (_shouldClose) { HWND.Close(); } else { HWND.Hide(); HWND.Opacity = 1; } }
private static void SWITCH_StepFade_SmoothStepDone(object sender, Arguments.SmoothStepArgs e) { _WFade.Opacity = 0; if (__shouldClose) { _WFade.Close(); } else { _WFade.Hide(); _WFade.Opacity = 1; } }
public MainWindowVM(System.Windows.Window w) { //this.conexion = new ConexionBD(EConexionBDTipoConexion.PostgreSQL, "localhost", "postgres", "postgres", "123"); //this.conexion = new ConexionBD(EConexionBDTipoConexion.MSSQLServer, "localhost", "Refaccionaria", "sa", "123"); ConfiguracionVM vm = new ConfiguracionVM(); if (!vm.Show()) { w.Close(); } this.conexion = new ConexionBD(vm.TipoConexion, vm.ServidorText, vm.BDText, vm.UsuarioText, vm.PasswordText); }
public static void ShowWindow() { System.Windows.Window win = new System.Windows.Window() { ShowInTaskbar = false, Left = -10000, Top = -10000, Width = 0, Height = 0, }; win.Show(); win.Close(); }
/// <summary> /// If we are presently showing a form, clean it up. /// </summary> protected override void ExitThreadCore() { // before we exit, let forms clean themselves up. if (qlipForm != null) { qlipForm.Close(); } if (qlipConfigForm != null) { qlipConfigForm.Close(); } notifyIcon.Visible = false; // should remove lingering tray icon base.ExitThreadCore(); }
private NotifyIconManager() { NotifyIcon = new NotifyIcon { Text = "Snap Desktop", Icon = Resources.SnapNewIcon, Visible = true, ContextMenu = new ContextMenu(new[] { new MenuItem("壁纸", (sender, e) => WindowManager.GetOrAddWindow <WallpaperWindow>().Show()), itemCenterTask, MenuItemSeparator, new MenuItem("更新", new[] { new MenuItem("检查更新", async(sender, e) => await UpdateService.GetInstance().HandleUpdateCheckAsync(false)), new MenuItem("手动下载", (sender, e) => Process.Start("https://github.com/DGP-Studio/DGP.Snap/releases")), }), itemAutorun,//自动启动 MenuItemSeparator, new MenuItem("关于", (sender, e) => WindowManager.GetOrAddWindow <AboutWindow>().Show()), new MenuItem("退出", (sender, e) => LifeCycleService.Application_ExitAsync()) }) }; NotifyIcon.Click += (sender, e) => { if (((MouseEventArgs)e).Button == MouseButtons.Left) { System.Windows.Window sideWindow = WindowManager.GetOrAddWindow <SideWindow>(); if (sideWindow.IsVisible) { sideWindow.Close(); } else { sideWindow.Show(); } } }; //设置check NotifyIcon.ContextMenu.Popup += (sender, e) => { itemAutorun.Checked = AutoStartupService.IsAutorun(); itemCenterTask.Checked = TaskBarService.GetInstance().Applied; }; }
//TODO: Remove window dependency public DocumentTypeSelectorViewModel(Window w) { DrawingTypes = new List <string>(); DrawingTypes.Add("Civil Xref"); OkCommand = new DelegateCommand(() => { switch (SelectedType) { case "Civil Xref": int i = 1; break; } w.Close(); }); }
private void OnShutdownTimerTick(object sender, EventArgs e) { this.playbackTimer.Stop(); this.playbackTimer = null; ChangeStateInternal(State.Stopped); // This causes the main window to close (and exit application). mainWindow.Close(); // If there is an exception as the result of command playback, // then rethrow it here after closing the main window so that // calls like NUnit test cases can properly display the exception. // if (this.PlaybackException != null) { throw this.PlaybackException; } }