private void Notify_MouseClick(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { window.Show(); } }
protected override void OnDisposing() { if (interaction != null) { interaction.Dispose(); } if (window != null) { window.Show(); } }
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); }
/// <summary> /// Make a smooth transition between two windows using Lerp. /// </summary> /// <param name="WFade">Window to fade.</param> /// <param name="WShow">Window to reveal.</param> /// <param name="Delay">Delay in ms.</param> /// <param name="shouldClose ">Close if true, Hide if false.</param> public static void Switch(System.Windows.Window WFade, System.Windows.Window WShow, int Delay = 1, bool shouldClose = true) { __shouldClose = shouldClose; SWITCH_LerpFade = new Core.Lerp(1, 0, 0.01f, 0.05f, 1); SWITCH_LerpShow = new Core.Lerp(0, 1, 0.01f, 0.05f, 1); SWITCH_LerpFade.delay = Delay; SWITCH_LerpShow.delay = Delay; _WFade = WFade; _WShow = WShow; _WShow.Hide(); _WFade.Show(); SWITCH_LerpShow.LStart += LerpShow_LerpStart; SWITCH_LerpShow.LTick += LerpShow_LerpTick; SWITCH_LerpShow.LDone += LerpShow_LerpDone; SWITCH_LerpFade.LStart += LerpFade_LerpStart; SWITCH_LerpFade.LTick += LerpFade_LerpTick; SWITCH_LerpFade.LDone += LerpFade_LerpDone; SWITCH_LerpFade.Start(); SWITCH_LerpShow.Start(); }
/// <summary> /// Make a smooth transition between two windows using Smooth Step. /// </summary> /// <param name="WFade">Window to fade.</param> /// <param name="WShow">Window to reveal.</param> /// <param name="Delay">Delay in ms.</param> /// <param name="shouldHideAfterSwitch">Close if true, Hide if false.</param> public static void Switch(System.Windows.Window WFade, System.Windows.Window WShow, int Delay = 1, bool shouldClose = true) { __shouldClose = shouldClose; SWITCH_StepFade = new Core.SmoothStep(0, 1, 1.00f, -0.001f, 0.01f, 1); SWITCH_StepShow = new Core.SmoothStep(0, 1, 0.00f, +0.001f, 0.01f, 1); SWITCH_StepFade.delay = Delay; SWITCH_StepShow.delay = Delay; _WFade = WFade; _WShow = WShow; _WFade.Show(); _WShow.Hide(); SWITCH_StepShow.SmoothStepStart += SWITCH_StepShow_SmoothStepStart;; SWITCH_StepShow.SmoothStepTick += SWITCH_StepShow_SmoothStepTick;; SWITCH_StepShow.SmoothStepDone += SWITCH_StepShow_SmoothStepDone;; SWITCH_StepFade.SmoothStepStart += SWITCH_StepFade_SmoothStepStart;; SWITCH_StepFade.SmoothStepTick += SWITCH_StepFade_SmoothStepTick;; SWITCH_StepFade.SmoothStepDone += SWITCH_StepFade_SmoothStepDone;; SWITCH_StepFade.Start(); SWITCH_StepShow.Start(); }
internal static void ShowOptionWindow() { IntPtr hWnd = FindWindow(null, OPTION_WINDOW_TITLE); if (hWnd.ToInt64() > 0) { SetForegroundWindow(hWnd); } else { if (optionsWindow == null) { optionsWindow = new System.Windows.Window { Title = OPTION_WINDOW_TITLE, MinWidth = 450, MinHeight = 350, Width = 600, Height = 500, Content = new OptionsWindowContent(), }; optionsWindow.Closed += OptionsWindow_Closed; } } optionsWindow.Show(); SetWindowLong(new WindowInteropHelper(optionsWindow).Handle, (int)WindowLongFlags.GWLP_HWNDPARENT, PluginBase.nppData._nppHandle); SetLayeredWindowAttributes(new WindowInteropHelper(optionsWindow).Handle, 0, 128, LWA_ALPHA); }
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; }
/// <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 = CreateHostControl(); // create forms host (wrapper for wpf) var windowsFormsHost = new System.Windows.Forms.Integration.WindowsFormsHost { Child = hostControl, }; window.Content = windowsFormsHost; window.Closed += (sender, args) => System.Windows.Application.Current.Shutdown(); window.Show(); return(ctorRenderHost(hostControl.Handle())); }
private static IRenderHost CreateWindowWpf(Size size, string title, Func <IRenderHostSetup, IRenderHost> constructorForRenderHost) { var window = new System.Windows.Window() { Width = size.Width, Height = size.Height, Title = title }; var hostControl = CreateHostControl(); // create forms host which is basically a wrapper for the WPF to function properly var windowsFormsHost = new System.Windows.Forms.Integration.WindowsFormsHost() { Child = hostControl, // Here, if need be, you can add necessary properties for the WPF //Width = 300, //Height = 200, //HorizontalAlignment = System.Windows.HorizontalAlignment.Left, //VerticalAlignment = System.Windows.VerticalAlignment.Top, //Margin = new System.Windows.Thickness(200, 100, 0, 0) }; window.Content = windowsFormsHost; window.Closed += (sender, args) => System.Windows.Application.Current.Shutdown(); window.Show(); var renderHostSetup = new RenderHostSetup(hostControl.Handle(), new Inputs.InputForms(hostControl)); // TODO: change default to IInput var renderHostToReturn = constructorForRenderHost(renderHostSetup); return(renderHostToReturn); }
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); }
/// <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 AssemblyInitialize(TestContext context) { var waitForApplicationRun = new TaskCompletionSource <bool>(); System.Threading.Thread t = new System.Threading.Thread(new System.Threading.ThreadStart(() => //Task.Run(() => { var application = new System.Windows.Application(); application.Startup += (s, e) => { application.Dispatcher.Invoke(() => { application.MainWindow = window = new System.Windows.Window(); application.MainWindow.Background = new SolidColorBrush(Colors.Black); window.Content = new System.Windows.Controls.ContentControl(); window.Show(); waitForApplicationRun.SetResult(true); }); }; application.Run(); return; })); t.SetApartmentState(System.Threading.ApartmentState.STA); t.Start(); UIThread = t; waitForApplicationRun.Task.Wait(); }
public void Run(System.Windows.Window window) { var reactorWindow = new ReactorWindow(RootHost, window); reactorWindow.Run(); window.Show(); }
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(); }
public static void BringToTop(System.Windows.Window form) { form.Show(); form.BringIntoView(); IntPtr hwnd = new WindowInteropHelper(form).Handle; SetForegroundWindow(hwnd); }
/// <summary> /// Start Qlip /// </summary> private void ShowConfigForm() { if (qlipConfigForm == null) { qlipConfigForm = new QlipPreferences.QlipPreferencesWindow(); qlipConfigForm.Closed += qlipConfig_Closed; // avoid reshowing a disposed form ElementHost.EnableModelessKeyboardInterop(qlipConfigForm); qlipConfigForm.Show(); } }
//Program configWindow = new Program(); public TrayApplicationContext() { System.Windows.Window window = new System.Windows.Window { Title = "My User Control Dialog", Content = new UserControl1(), AllowsTransparency = true, WindowStyle = System.Windows.WindowStyle.None }; window.Show(); // Onboarding if (!Settings.Default.FirstRun) { //Settings.Default.FirstRun = true; //_mainWindow.Show(); //Settings.Default.Save(); } Application.ApplicationExit += Application_ApplicationExit; MenuItem about = new MenuItem("Visit website", showAbout); MenuItem updates = new MenuItem("Check for updates...", ShowConfig); MenuItem openScripts = new MenuItem("Scripts Folder", BrowseScripts); MenuItem packages = new MenuItem("Packages Folder", BrowsePackages); MenuItem reload = new MenuItem("Reload Scripts", ReloadScripts); MenuItem exitMenuItem = new MenuItem("Exit", Exit); var cm = new ContextMenu(); cm.MenuItems.Add(about); cm.MenuItems.Add(reload); cm.MenuItems.Add(packages); cm.MenuItems.Add(openScripts); cm.MenuItems.Add(exitMenuItem); _icon = new NotifyIcon { Icon = Resources.favicon, ContextMenu = cm, Visible = true, Text = Resources.ExitMenuText, }; PluginManager.EnablePlugins(); _serverThread = new Thread(RunServer); _serverThread.Start(); _luaThread = new Thread(LuaScripting.LuaThread); _luaThread.Start(); _mainWindow = new Form1(); }
public override void ShowWindow(object rootModel, object context = null, IDictionary <string, object> settings = null) { System.Windows.Window window = CreateWindow(rootModel, true, context, settings); if (window != null) { System.Windows.Interop.WindowInteropHelper helper = new System.Windows.Interop.WindowInteropHelper(window); helper.Owner = Autodesk.Windows.ComponentManager.ApplicationWindow; window.SourceInitialized += Window_SourceInitialized; window.SizeChanged += Window_SizeChanged; window.LocationChanged += Window_LocationChanged; } window.Show(); }
/// <summary> /// Helper method used to dock a Wpf window inside a Vst Window. /// All UI chrome is hidden away (borders, close/minimize/maximize buttons) /// and the window becomes embedded inside the parent window /// </summary> /// <param name="WpfWindow"></param> /// <param name="vstWindow"></param> public static void DockWpfWindow(System.Windows.Window WpfWindow, IntPtr vstWindow) { WpfWindow.Top = 0; WpfWindow.Left = 0; WpfWindow.ShowInTaskbar = false; WpfWindow.WindowStyle = System.Windows.WindowStyle.None; WpfWindow.ResizeMode = System.Windows.ResizeMode.NoResize; WpfWindow.Show(); var windowHwnd = new System.Windows.Interop.WindowInteropHelper(WpfWindow); IntPtr hWnd = windowHwnd.Handle; SetParent(hWnd, vstWindow); }
/// <summary> /// Smoothly reveals a window. /// </summary> /// <param name="WReveal">Window to reveal.</param> /// <param name="delay">Delay in ms.</param> public static void Reveal(System.Windows.Window WReveal, int delay = 1) { SINGLE_StepShow = new Core.SmoothStep(0, 1, 0.01f, 0.05f, 1); SINGLE_StepShow.SmoothStepStart += SINGLE_StepShow_SmoothStepStart;; SINGLE_StepShow.SmoothStepTick += SINGLE_StepShow_SmoothStepTick;; SINGLE_StepShow.SmoothStepDone += SINGLE_StepShow_SmoothStepDone;; HWND = WReveal; HWND.Opacity = 0; HWND.Show(); SINGLE_StepShow.delay = delay; SINGLE_StepShow.Start(); }
/// <summary> /// Smoothly reveals a window. /// </summary> /// <param name="WReveal">Window to reveal.</param> /// <param name="delay">Delay in ms.</param> public static void Reveal(System.Windows.Window WReveal, int delay = 1) { SINGLE_LerpShow = new Core.Lerp(0, 1, 0.01f, 0.05f, 1); SINGLE_LerpShow.LStart += SINGLE_LerpShow_LerpStart; SINGLE_LerpShow.LTick += SINGLE_LerpShow_LerpTick; SINGLE_LerpShow.LDone += SINGLE_LerpShow_LerpDone; HWND = WReveal; HWND.Opacity = 0; HWND.Show(); SINGLE_LerpShow.delay = delay; SINGLE_LerpShow.Start(); }
/// <summary> /// Smoothly hides/closes a window. /// </summary> /// <param name="WHide">Window to Hide/Close.</param> /// <param name="delay">Delay in ms.</param> /// <param name="shouldClose">Close if true, Hide if false.</param> public static void Hide(System.Windows.Window WHide, int delay = 1, bool shouldClose = false) { _shouldClose = shouldClose; SINGLE_StepFade = new Core.SmoothStep(1, 0, 0.01f, 0.05f, 1); SINGLE_StepFade.SmoothStepStart += SINGLE_StepFade_SmoothStepStart;; SINGLE_StepFade.SmoothStepTick += SINGLE_StepFade_SmoothStepTick;; SINGLE_StepFade.SmoothStepDone += SINGLE_StepFade_SmoothStepDone;; HWND = WHide; HWND.Opacity = 1; HWND.Show(); SINGLE_StepFade.delay = delay; SINGLE_StepFade.Start(); }
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(); }
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 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; }; }
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 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 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(); }
public void ShowStoredJson() { var json = File.Exists(_filename) ? File.ReadAllText(_filename) : "<empty>"; #if NETSTANDARD1_3 Console.WriteLine($"Stored JSON: {json}"); #elif NET461 var window = new System.Windows.Window { Title = "Stored Json", Content = json, WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen, FontSize = 20, Width = 300, Height = 300 }; window.Show(); #endif }
private void ShowIntroForm() { if (introForm == null) { introForm = new WpfWindows.IntroWindow(notifyIcon); introForm.Closed += mainForm_Closed; ElementHost.EnableModelessKeyboardInterop(introForm); introForm.Show(); } else { introForm.Activate(); } }
private void ShowIntroForm() { if (introForm == null) { introForm = new WpfFormLibrary.IntroForm(); introForm.Closed += mainForm_Closed; // avoid reshowing a disposed form ElementHost.EnableModelessKeyboardInterop(introForm); introForm.Show(); } else { introForm.Activate(); } }