private void Window_Loaded(object?sender, RoutedEventArgs e) { CommandLine parser = new(false); parser.AddHeader(CommandLine.ExecutableFileName + " [/BringToFront]"); bool bringToFront = false; parser.AddSwitch("BringToFront", "Makes the app attempt to force its way to the foreground when launched.", value => bringToFront = value); switch (parser.Parse()) { case CommandLineParseResult.Valid: if (bringToFront) { this.ExecuteWhenIdle(() => WindowsUtility.BringToFront(this)); } break; case CommandLineParseResult.HelpRequested: this.ExecuteWhenIdle(() => WindowsUtility.ShowInfo(this, parser.CreateMessage())); break; default: this.ExecuteWhenIdle(() => WindowsUtility.ShowError(this, parser.CreateMessage())); break; } }
private void NotifyIconViewMenuClick(object sender, EventArgs e) { if (!this.ShowInTaskbar) { this.Show(); } WindowsUtility.BringToFront(this); }
public void Alert( Window window, string notificationMessage, NotifyIcon notifyIcon, ref MediaPlayer mediaPlayer) { if (window != null) { if (this.ShowWindow) { WindowsUtility.BringToFront(window); } else if (this.ColorInactiveTaskbarItem && !ApplicationInfo.IsActivated) { TaskbarItemInfo taskbarItem = window.TaskbarItemInfo; if (taskbarItem == null) { taskbarItem = new TaskbarItemInfo(); window.TaskbarItemInfo = taskbarItem; } taskbarItem.ProgressState = this.IsFailure ? TaskbarItemProgressState.Error : TaskbarItemProgressState.Normal; taskbarItem.ProgressValue = 1; } } if (notifyIcon != null && this.ShowNotification) { const int IgnoredTimeout = 5000; notifyIcon.ShowBalloonTip(IgnoredTimeout, nameof(WirePeep), notificationMessage, this.IsFailure ? ToolTipIcon.Error : ToolTipIcon.Info); } if (this.PlaySound) { PlaySoundFile(this.SoundFileName, ref mediaPlayer); } }