/// <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 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; }
private void notifyIcon1_MouseClick(object sender, System.Windows.Forms.MouseEventArgs e) { if (Window == null) { return; } if (Window.WindowState == System.Windows.WindowState.Minimized) { Window.WindowState = System.Windows.WindowState.Normal; } Window.Activate(); }
private void ShowHelpForm() { if (helpForm == null) { helpForm = new WpfFormLibrary.HelpForm(); helpForm.Closed += close_HelpForm; // avoid reshowing a disposed form ElementHost.EnableModelessKeyboardInterop(helpForm); helpForm.Show(); } else { helpForm.Activate(); } }
/// <summary> /// Setup and show a window. /// </summary> /// <param name="window">window to set up</param> /// <param name="viewModel">view model to assign to the view model</param> /// <param name="closedViewMethod">request from the view model to close the view</param> /// <param name="closedMethod">method to run when the window closes</param> public void SetupWindow( System.Windows.Window window, ViewModelBase viewModel, EventHandler closeViewMethod, EventHandler closedMethod) { window.DataContext = viewModel; viewModel.ClosingRequest += closeViewMethod; window.Closed += closedMethod; window.Show(); window.Activate(); }
private void QRCodeItem_Click(object sender, EventArgs e) { if (serverSharingWindow == null) { serverSharingWindow = new System.Windows.Window() { Title = "Server Sharing", Height = 400, Width = 660, Content = new ServerSharingView() }; serverSharingWindow.Closed += ServerSharingWindow_Closed; serverSharingWindow.Show(); } serverSharingWindow.Activate(); }
private void QRCodeItem_Click(object sender, EventArgs e) { if (serverSharingWindow == null) { serverSharingWindow = new System.Windows.Window() { Title = LocalizationProvider.GetLocalizedValue <string>("ServerSharing"), Height = 400, Width = 660, MinHeight = 400, MinWidth = 660, Content = new ServerSharingView() }; serverSharingWindow.Closed += ServerSharingWindow_Closed; ElementHost.EnableModelessKeyboardInterop(serverSharingWindow); serverSharingWindow.Show(); } serverSharingWindow.Activate(); }
private void hotKeyItem_Click(object sender, EventArgs e) { if (hotkeysWindow == null) { hotkeysWindow = new System.Windows.Window() { Title = LocalizationProvider.GetLocalizedValue <string>("Hotkeys"), Height = 260, Width = 320, MinHeight = 260, MinWidth = 320, Content = new HotkeysView() }; hotkeysWindow.Closed += HotkeysWindow_Closed; ElementHost.EnableModelessKeyboardInterop(hotkeysWindow); hotkeysWindow.Show(); } hotkeysWindow.Activate(); }
private void OnlineConfig_Click(object sender, EventArgs e) { if (onlineConfigWindow == null) { onlineConfigWindow = new System.Windows.Window() { Title = LocalizationProvider.GetLocalizedValue <string>("OnlineConfigDelivery"), Height = 510, Width = 480, MinHeight = 510, MinWidth = 480, Content = new OnlineConfigView() }; onlineConfigWindow.Closed += OnlineConfigWindow_Closed; ElementHost.EnableModelessKeyboardInterop(onlineConfigWindow); onlineConfigWindow.Show(); } onlineConfigWindow.Activate(); }
private void proxyItem_Click(object sender, EventArgs e) { if (forwardProxyWindow == null) { forwardProxyWindow = new System.Windows.Window() { Title = LocalizationProvider.GetLocalizedValue <string>("ForwardProxy"), Height = 400, Width = 280, MinHeight = 400, MinWidth = 280, Content = new ForwardProxyView() }; forwardProxyWindow.Closed += ForwardProxyWindow_Closed; ElementHost.EnableModelessKeyboardInterop(forwardProxyWindow); forwardProxyWindow.Show(); } forwardProxyWindow.Activate(); }
/// <summary> /// Create <see cref="System.Windows.Window"/> and <see cref="IRenderHost"/> for it. /// </summary> private static IRenderHost CreateWindowWpf(System.Drawing.Size size, string title, Func <IntPtr, IRenderHost> ctorRenderHost) { var window = new System.Windows.Window { Width = size.Width, Height = size.Height, Title = title, }; var hostControl = new System.Windows.Controls.Grid { Background = System.Windows.Media.Brushes.Transparent, Focusable = true, }; window.Content = hostControl; // fix mouse wheel (although it's only for Windows.Forms, this is just OCD to make window active as well) hostControl.MouseEnter += (sender, args) => { if (!window.IsActive) { window.Activate(); } if (!hostControl.IsFocused) { hostControl.Focus(); } }; window.Closed += (sender, args) => System.Windows.Application.Current.Shutdown(); window.Show(); return(ctorRenderHost(hostControl.Handle())); }