public void BambooPlanChanged(object sender, PlanEventArgs e) { if (e.Plan.IsBuilding) { _trayIcon.ShowBalloonTip("Building", $"{e.Plan.ProjectName} {e.Plan.BuildName} is building", BambooTray.App.Properties.Resources.icon_building_06); } else { switch (e.Plan.BuildState) { case BuildState.Failed: _trayIcon.ShowBalloonTip("Build Failed", $"{e.Plan.ProjectName} {e.Plan.BuildName} failed", BambooTray.App.Properties.Resources.icon_build_failed); break; case BuildState.Successful: _trayIcon.ShowBalloonTip("Build succeeded", $"{e.Plan.ProjectName} {e.Plan.BuildName} was successful", BambooTray.App.Properties.Resources.icon_build_successful); break; case BuildState.Unknown: _trayIcon.ShowBalloonTip("Build stopped", $"{e.Plan.ProjectName} {e.Plan.BuildName} was stopped", BambooTray.App.Properties.Resources.icon_build_unknown); break; default: throw new ArgumentOutOfRangeException(); } } }
public void InitIcon() { NPIcon = Application.Current.FindResource("NPIcon") as TaskbarIcon; (LogicalTreeHelper.FindLogicalNode(NPIcon.ContextMenu, "OnOpenSetting") as MenuItem).Click += (sender, e) => { UI.MainWindow.OpenSigletonWindow(); }; (LogicalTreeHelper.FindLogicalNode(NPIcon.ContextMenu, "OnAppExit") as MenuItem).Click += (sender, e) => { Application.Current.Shutdown(); }; (LogicalTreeHelper.FindLogicalNode(NPIcon.ContextMenu, "OnTweetDialog") as MenuItem).Click += (sender, e) => { (new TweetDialog()).Show(); }; (LogicalTreeHelper.FindLogicalNode(NPIcon.ContextMenu, "IsAutoTweetEnabledMenuItem") as MenuItem) .DataContext = Core.ConfigStore.StaticConfig; (LogicalTreeHelper.FindLogicalNode(NPIcon.ContextMenu, "OnTweetNow") as MenuItem).Click += async(sender, e) => { try { await ManualTweet.RunManualTweet(ConfigStore.StaticConfig); var song = PipeListener.staticpipelistener.LastPlayedSong; NPIcon.ShowBalloonTip("投稿完了", $"{song.Title}\n{song.Artist}\n{song.Album}", BalloonIcon.Info); } catch (Exception exception) { NPIcon.ShowBalloonTip("エラー", exception.Message, BalloonIcon.Info); } }; }
private void OnReminder(string title, string informativeText) { if (_parentWindow.TryBeginInvoke(OnReminder, title, informativeText)) { return; } void StartButtonClick() { _taskbarIcon.CloseBalloon(); var guid = Toggl.Start("", "", 0, 0, "", "", true); _parentWindow.ShowOnTop(); if (guid != null) { Toggl.Edit(guid, true, Toggl.Description); } } var reminder = new ReminderNotification(_taskbarIcon.CloseBalloon, _parentWindow.ShowOnTop, StartButtonClick) { Title = title, Message = informativeText }; if (!_taskbarIcon.ShowNotification(reminder, PopupAnimation.Slide, TimeSpan.FromSeconds(10))) { _taskbarIcon.ShowBalloonTip(title, informativeText, Properties.Resources.toggl, largeIcon: true); } }
public void Check(TaskbarIcon MyNotifyIcon, string email, string word) { var inbox = client.Inbox; inbox.Open(FolderAccess.ReadOnly); MimeMessage message; foreach (var uid in inbox.Search(SearchQuery.NotSeen)) { message = inbox.GetMessage(uid); if (email != null) { foreach (var mailbox in message.From.Mailboxes) { if (mailbox.Address == email) { MyNotifyIcon.ShowBalloonTip("Email Delivered", "Delivered your email with sender email adress " + email, BalloonIcon.Info); } } } } if (word != null) { for (int i = 0; i < inbox.Count; i++) { message = inbox.GetMessage(i); if (message.TextBody.Contains(word)) { MyNotifyIcon.ShowBalloonTip("Email Delivered", "Delivered your email with key word " + word, BalloonIcon.Info); } } } }
private void CheckUSBMedia() { lock (lockObject) { if (CopyExecuting || BaloonTipDisplayed) { return; } DriveInfo[] drives = System.IO.DriveInfo.GetDrives(); foreach (DriveInfo drive in drives) { if (!drive.IsReady) { continue; } if (Directory.Exists(System.IO.Path.Combine(drive.RootDirectory.FullName, "USBBackup", ApplicationConfiguration.UniqueIdentifyer))) { // USB-Media has valid Backup-Folder for this computer // Notify user if he whishes to perform a backup BaloonTipDisplayed = true; taskbarIcon.TrayBalloonTipClicked += PerformBackup; System.Timers.Timer timer = new System.Timers.Timer(10000); timer.Elapsed += delegate(object o, System.Timers.ElapsedEventArgs e) { BaloonTipDisplayed = false; taskbarIcon.TrayBalloonTipClicked -= PerformBackup; }; timer.AutoReset = false; timer.Start(); taskbarIcon.ShowBalloonTip("Backup bereit", "USB-Backup hat ein Backup-Laufwerk erkannt und kann das Backup nun starten.\r\nZum Starten hier klicken.", BalloonIcon.Info); System.Media.SystemSounds.Asterisk.Play(); } } } }
public void NFCDetected() { tb.HideBalloonTip(); string text = "NFC Tag Detected, starting programs"; callCMD(""); tb.ShowBalloonTip(title, text, BalloonIcon.Info); }
/// <summary> /// Initialize the TrackerManager /// (prepares the settings, starts every tracker, creates a connection to the database, etc.) /// </summary> public void Start() { // show unified first start screens ShowFirstStartScreens(); // Start all registered trackers. Create db tables only for trackers that are running. This implies that trackers that are turned on have to verify that the tables are created. foreach (var tracker in _trackers.Where(t => t.IsEnabled())) { // if tracker is disabled - don't start it if (!tracker.IsEnabled()) { continue; } // else: create tables & start tracker tracker.CreateDatabaseTablesIfNotExist(); tracker.Start(); } // run database updates for trackers PerformDatabaseUpdatesIfNecessary(); // Communication var trackersString = string.Join(", ", _trackers.Where(t => t.IsRunning).ToList().ConvertAll(t => t.Name + " (" + t.GetVersion() + ")").ToArray()); Database.GetInstance().LogInfo(string.Format(CultureInfo.InvariantCulture, "TrackerManager (V{0}) started with {1} trackers: {2}.", _publishedAppVersion, _trackers.Where(t => t.IsRunning).ToList().Count, trackersString)); SetTaskbarIconTooltip("Tracker started"); Application.Current.Dispatcher.Invoke(() => TaskbarIcon.ShowBalloonTip(Dict.ToolName, Dict.ToolName + " is running with " + _trackers.Where(t => t.IsRunning).ToList().Count + " data trackers.", BalloonIcon.Info)); // Initialize & start the timer to update the taskbaricon toolitp _taskbarIconTimer = new DispatcherTimer(); _taskbarIconTimer.Interval = Settings.TooltipIconUpdateInterval; _taskbarIconTimer.Tick += UpdateTooltipIcon; _taskbarIconTimer.Start(); // Initialize & start the timer to check for updates _checkForUpdatesTimer = new DispatcherTimer(); _checkForUpdatesTimer.Interval = Settings.CheckForToolUpdatesInterval; _checkForUpdatesTimer.Tick += UpdateApplicationIfNecessary; _checkForUpdatesTimer.Start(); // Initialize & start the timer to remind to share study data if (Settings.IsUploadEnabled && Settings.IsUploadReminderEnabled) { _remindToShareStudyDataTimer = new DispatcherTimer(); _remindToShareStudyDataTimer.Interval = Settings.CheckForStudyDataSharedReminderInterval; _remindToShareStudyDataTimer.Tick += CheckForStudyDataSharedReminder; _remindToShareStudyDataTimer.Start(); } // track time zone changes Database.GetInstance().CreateTimeZoneTable(); SaveCurrentTimeZone(null, null); SystemEvents.TimeChanged += SaveCurrentTimeZone; // update taskbar icons (e.g. menu items that are added later) SetContextMenuOptions(); }
private void Window_StateChanged(object sender, EventArgs e) { if (this.WindowState == System.Windows.WindowState.Minimized) { taskbarIcon.Visibility = System.Windows.Visibility.Visible; taskbarIcon.ShowBalloonTip("3DBean", "I'm here", BalloonIcon.Info); this.ShowInTaskbar = false; } }
private void MainWindow_OnStateChanged(object sender, EventArgs e) { if (WindowState == System.Windows.WindowState.Minimized) { this.Hide(); NotifyIcon.Visibility = Visibility.Visible; NotifyIcon.ShowBalloonTip("Copy++", "软件已最小化至托盘,点击图标显示主界面,右键可退出", BalloonIcon.Info); } }
private void OnItemErrorCopy(Tuple <ReplicationItem, Exception> payload) { var title = GetBalloonTipTitle(payload.Item1.Fileset); _taskbarIcon.HideBalloonTip(); _taskbarIcon.ShowBalloonTip( title, "Unable to copy " + payload.Item1.FileName + ".\n" + payload.Item2.Message, BalloonIcon.Error); }
/// <summary> /// Handle NotificationMessage /// </summary> /// <param name="message"></param> public void Handle(INotificationMessage message) { if (message != null) { var icon = message.NotificationStatus == Enumerations.NotificationStatus.Error ? BalloonIcon.Error : BalloonIcon.Info; if (!this._shellWindow.IsActive) { _tray.ShowBalloonTip(Properties.Settings.Default.ApplicationFullName, message.Message, icon); } } }
private void NextWallpaper_Executed(object sender, ExecutedRoutedEventArgs e) { // не можем вынести его как поле, т.к. если изменим обои кнопкой + обновим их, список не изменится, а нужно string[] images = Directory.GetFiles($"{Directory.GetCurrentDirectory()}\\Images").OrderByDescending(f => File.GetCreationTime(f)).ToArray(); // получаем список пикч упорядоченный по дате создания if (Properties.Settings.Default.InstalledWallpaperIndex != 0) { Wallpaper.SetWallpaper(images[--Properties.Settings.Default.InstalledWallpaperIndex]); Properties.Settings.Default.Save(); } else { icon.ShowBalloonTip("Wallpapers Everyday", "Достигнуты новейшие обои!", BalloonIcon.Info); } }
//下载v2ray core文件 private void CoreDownloader_DoWork(object sender, DoWorkEventArgs e) { try { DownloadCore(); Dispatcher.Invoke(() => { notifyIcon.ShowBalloonTip("", Strings.messagedownloadsuccess, BalloonIcon.Info); (mainMenu.Items[1] as MenuItem).IsEnabled = true; }); } catch { Dispatcher.Invoke(() => { MessageBox.Show(Strings.messagefilecreatefail); Application.Current.Shutdown(); }); } }
private void initMqtt() { mqttClient = new MqttClient(this.mqttCfg["host"].ToString(), int.Parse(this.mqttCfg["port"].ToString()), false, null, null, MqttSslProtocols.None); mqttClient.MqttMsgPublishReceived += (s, e) => { try { string payload = System.Text.Encoding.UTF8.GetString(e.Message); JObject payloadObj = (JObject)JsonConvert.DeserializeObject(payload); string deviceId = payloadObj["deviceId"].ToString(); string propertyId = payloadObj["propertyId"].ToString(); string newValue = payloadObj["newValue"].ToString(); string oldValue = payloadObj["oldValue"].ToString(); mSyncContext.Post(updateValue, new string[] { deviceId, propertyId, newValue, oldValue }); if (this.notifyDeviceIdList != null && this.notifyDeviceIdList.Contains(deviceId)) { string deviceFriendlyName = this.deviceFriendlyName.ContainsKey(deviceId) ? this.deviceFriendlyName[deviceId] : deviceId; string dpKey = deviceId + "_" + propertyId; string propertyFriendlyName = this.propertyFriendlyName.ContainsKey(dpKey) ? this.propertyFriendlyName[dpKey] : propertyId; string newValueFriendlyName = this.propertyValueFriendlyName.ContainsKey(dpKey) ? this.propertyValueFriendlyName[dpKey].ContainsKey(newValue.ToUpper()) ? this.propertyValueFriendlyName[dpKey][newValue.ToUpper()] : newValue : newValue; string oldValueFriendlyName = this.propertyValueFriendlyName.ContainsKey(dpKey) ? this.propertyValueFriendlyName[dpKey].ContainsKey(oldValue.ToUpper()) ? this.propertyValueFriendlyName[dpKey][oldValue.ToUpper()] : oldValue : oldValue; _taskbar.ShowBalloonTip(deviceFriendlyName, propertyFriendlyName + ": " + oldValueFriendlyName + " -> " + newValueFriendlyName, Icon.ExtractAssociatedIcon(Assembly.GetExecutingAssembly().Location), true); } } catch (Exception e2) { } }; string username = this.mqttCfg["username"].ToString(); string password = this.mqttCfg["password"].ToString(); string clientId = this.mqttCfg["clientId"].ToString(); if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password)) { mqttClient.Connect(clientId); } else { mqttClient.Connect(clientId, username, password); } string topic = this.mqttCfg["topic"].ToString(); mqttClient.Subscribe(new string[] { topic }, new byte[] { MqttMsgBase.QOS_LEVEL_EXACTLY_ONCE }); }
public MainViewModel(TaskExecutionService taskExecutionService, HistoryService historyService, WindowService windowService) { // Commands WindowShownCommand = new RelayCommand <Window>(w => { _taskbarIcon = (w as MainWindow)?.MainTaskbarIcon; // HACK: slightly MVVM breaking Locator.StartServicesAsync().Forget(); // Start services after the main window is loaded }); WindowClosingCommand = new RelayCommand <CancelEventArgs>(args => { args.Cancel = true; windowService.MainWindowHide(); }); ShowHideWindowCommand = new RelayCommand(windowService.MainWindowToggleShowHide); ShowAboutCommand = new RelayCommand(async() => await windowService.ShowAboutWindowAsync()); ShowHelpCommand = new RelayCommand(ShowHelp); SubmitBugReportCommand = new RelayCommand(async() => await windowService.ShowBugReportWindowAsync()); ExitComand = new RelayCommand(() => Application.Current.ShutdownSafe(ExitCode.UserExit)); // Events taskExecutionService.TaskAddedToQueue += (sender, args) => windowService.MainWindowShow(); historyService.HistoryEntryRecorded += (sender, args) => { if (!Settings.ShowNotifications) { return; } _taskbarIcon?.ShowBalloonTip("Modboy", Localization.Localize(args.Entry), args.Entry.Success ? BalloonIcon.Info : BalloonIcon.Error); }; }
private void _dispatcherTimer_Tick(object sender, EventArgs e) { _dispatcherTimer.Stop(); var latestStatuses = _statusProvider.GetStatusList(_uriList); foreach (var newStatus in latestStatuses) { var oldStatus = _buildStatuses.Single(b => b.Key == newStatus.Key); if (newStatus.BuildId != oldStatus.BuildId) { var title = newStatus.BuildName; _taskbarIcon.ShowBalloonTip(title, MenuItemHelper.BuildBallonBody(newStatus), ResourceHelper.GetIcon(newStatus), true); foreach (var contextMenuItem in _contextMenu.Items) { var menuItem = contextMenuItem as MenuItem; var tag = menuItem?.Tag as Uri; if (tag == null || tag != oldStatus.Key) { continue; } MenuItemHelper.ConfigureMenuItem(menuItem, newStatus); } } oldStatus.Status = newStatus.Status; oldStatus.BuildId = newStatus.BuildId; oldStatus.RequestedBy = newStatus.RequestedBy; } _dispatcherTimer.Start(); }
protected override void OnStartup(StartupEventArgs e) { // Initialise the Tray Icon TB = (TaskbarIcon)FindResource("tbNotifyIcon"); TB.ShowBalloonTip("WiiTUIO", "WiiTUIO is running", BalloonIcon.Info); base.OnStartup(e); }
private void ShowToolTip() { _taskTaskbarIcon.ShowBalloonTip("CallWall", "CallWall has started", BalloonIcon.Info); //Works _schedulerProvider.Dispatcher.Schedule(TimeSpan.FromSeconds(5), () => _taskTaskbarIcon.HideBalloonTip()); }
public void ShowNotification(string title, string content, BalloonIcon icon) { taskbarIcon.ShowBalloonTip( title, content, icon); }
/// <summary> /// Handles the tray event if the active window responds to any of the flag /// Only one event should be passed in at a time! /// </summary> /// <param name="flags"></param> public void handleTrayEvent(TrayFlags.PopValues flag, User targUser = null, string keyword = null) { if (!SettingsManager.getMgr().isNotifyEnabled(flag)) { return; } foreach (Window w in activeWindow) { if (!TrayFlags.handlesEvent(w, flag)) { log.Info("Received event: " + flag.ToString() + ". Ignoring - " + activeWindow.ToString() + " does not accept event"); continue; } currEvent = flag; this.targUser = targUser; this.keyword = keyword; string message = TrayFlags.trayLang[currEvent]; message = message.Replace("#", targUser.Name); message = message.Replace("$", keyword); log.Info("Recieved tray event: " + flag.ToString() + ", with targUser: "******", message: " + message); kIcon.ShowBalloonTip("Kaillera Event", message, BalloonIcon.Info); return; } }
protected internal async Task WelcomeUser() { string msgTitle = ""; string msgWelcome = $"Important updates related to RApID will show up here."; if (DateTime.Now.Hour >= 4 && DateTime.Now.Hour < 12) { msgTitle = "Good Morning"; } else if (DateTime.Now.ToLocalTime().Hour >= 12 && DateTime.Now.ToLocalTime().Hour < 17) { msgTitle = "Good Afternoon"; } else // DateTime.Now is between 17 and 4 { msgTitle = "Good Evening"; } await Task.Factory.StartNew(new Action(() => { Notify.ShowBalloonTip(msgTitle, msgWelcome, Properties.Resources.RApID, true); /*var uName = UserPrincipal.Current.DisplayName.Trim().Split(','); * FullName = uName[1].Trim() + " " + uName[0].Trim(); * Notify.ShowBalloonTip(msgTitle + $", {FullName}!", msgWelcome, BalloonIcon.Info);*/ }), RApIDCancelSource.Token, TaskCreationOptions.LongRunning, TaskScheduler.Current) .ConfigureAwait(true); }
public MainWindow() { InitializeComponent(); // Get the taskbar icon object Tb = this.ProcessNotifyIcon; Tb.ToolTipText = Properties.Resources.ProgramName; // Set window title this.Title = Properties.Resources.ProgramName; // Initial setting CurrentStatus = ProcessStatus.Stopped; UpdateIcon(); // Don't show window SetWindowVisibility(true); // Load the settings LoadSettings(); // Start the checking process StartCheckProcess(); if (ShowBalloonMessageOnStart) { Tb.ShowBalloonTip(Properties.Resources.ProgramName, "Started", BalloonIcon.Info); } }
private static void InitializeTaskBarIcon(TaskbarIcon taskbarIcon) { var taskbarViewModel = new TaskbarViewModel(); taskbarIcon.DataContext = taskbarViewModel; taskbarIcon.ToolTipText = $"Catapult [{AssemblyVersionInformation.AssemblyVersion}]"; using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("Catapult.App.Icon.ico")) { if (stream != null) { taskbarIcon.Icon = new Icon(stream); } } if (File.Exists(CatapultPaths.NewVersionPath)) { string newVersion = File.ReadAllText(CatapultPaths.NewVersionPath); taskbarIcon.ShowBalloonTip("Catapult", $"Updated to new version: {newVersion}", BalloonIcon.None); File.Delete(CatapultPaths.NewVersionPath); } SquirrelIntegration.OnUpdateFound += version => { taskbarViewModel.UpgradeVisibility = Visibility.Visible; SquirrelIntegration.Instance.UpgradeToNewVersion(); }; }
protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); if (Environment.OSVersion.Version.Major < 6 || Environment.OSVersion.Version.Major == 6 && Environment.OSVersion.Version.Minor < 1) { MessageBox.Show( "This Tool can only run under Windows 7 or newer.\n\rSorry, blame Microsoft for not implementing the Enumeration API.", "Wrong Operating System", MessageBoxButton.OK, MessageBoxImage.Error); Application.Current.Shutdown(); } //create the notifyicon (it's a resource declared in NotifyIconResources.xaml _notifyIcon = (TaskbarIcon)Application.Current.FindResource("NotifyIcon"); NotifyIconViewModel nivm = _notifyIcon.DataContext as NotifyIconViewModel; _bootstrapper = new Bootstrapper(); _bootstrapper.Hook.KeyPressed += nivm.HotkeyPressed; _bootstrapper.Hook.DevicesChanged += nivm.RefreshMicList; _bootstrapper.RegistrationException += (s, ex) => { _notifyIcon.ShowBalloonTip("Hotkey registration error", ((System.Exception)ex.ExceptionObject).Message, BalloonIcon.Error); if (nivm.OpenSettingsWindowCommand.CanExecute(null)) { nivm.OpenSettingsWindowCommand.Execute(null); } }; _bootstrapper.Init(); }
public void Refresh_Data() { CSDataContext dc = new CSDataContext(); // 20200522 add Companion Log in and out Admin = (from p in dc.log_Adm where p.operation_name != "Log in" && p.operation_name != "Log out" && p.operation_name != "update opd" && p.operation_name != "update opd order" && p.operation_name != "OPD file format" && p.operation_name != "Change order data" && p.operation_name != "Add a new order" && p.operation_name != "Lab file format" && p.operation_name != "Change patient data" && p.operation_name != "Add a new patient" && p.operation_name != "Companion Log out" && p.operation_name != "Companion Log in" orderby p.regdate descending select new { p.regdate, p.operation_name, p.description }).Take(100); Err = (from p in dc.log_Err orderby p.error_date descending select new { p.error_date, p.error_message }).Take(100); OPD = (from p in dc.log_Adm where p.operation_name == "update opd" || p.operation_name == "update opd order" orderby p.regdate descending select new { p.regdate, p.description }).Take(100); Order = (from p in dc.log_Adm where p.operation_name == "Change order data" || p.operation_name == "Add a new order" orderby p.regdate descending select new { p.regdate, p.description }).Take(100); PT = (from p in dc.log_Adm where p.operation_name == "Change patient data" || p.operation_name == "Add a new patient" orderby p.regdate descending select new { p.regdate, p.description }).Take(100); tb.ShowBalloonTip("完成", "訊息頁資料已更新", BalloonIcon.Info); }
private void NotifyBalloon(object sender, Notification notification) { string format = ""; switch (notification.Type) { case "follow": format = "{0} has followed you"; break; case "mention": format = "{0} has mentioned you"; break; case "reblog": format = "{0} has reblogged your toot"; break; case "favourite": format = "{0} has favourited your toot"; break; } string title = string.Format(format, notification.Account.DisplayName); string message = notification.Status?.Content ?? ""; TaskbarIcon.ShowBalloonTip(title, message, BalloonIcon.Info); }
public void DoWork() { byte[] bytes = new byte[1024]; string line; try { while (true) { int bytesRead = ns.Read(bytes, 0, bytes.Length); line = Encoding.ASCII.GetString(bytes, 0, bytesRead); if (line.EndsWith("===")) { TaskbarIcon.ShowBalloonTip("Alert!", "There is an emergency...", BalloonIcon.Error); //Label.Visibility = Visibility.Visible; string[] s = line.Substring(0, line.Length - 3).Split('/'); origin = s[0]; destination = s[1]; //Visibility=Visibility.Visible; } } } catch (Exception e) { Environment.Exit(0); } }
private void InitIcon() { Stream LoadIcon() { var streamResourceInfo = Application.GetResourceStream( new Uri( "pack://*****:*****@"{_curAssembly.GetName().Name} v{_curAssembly.GetName().Version}"; _notifyIcon.Icon = icon; _notifyIcon.ToolTipText = title; _notifyIcon.ShowBalloonTip(title, "已經最小化", BalloonIcon.Info); AddInfoMenu(contextMenu); AddAutoStartMenu(contextMenu); AddPunchCardWorkMenu(contextMenu); AddCloseMenu(contextMenu); AddLogMenu(contextMenu); _notifyIcon.ContextMenu = contextMenu; }
private void menuStartup_Click(object sender, RoutedEventArgs e) { using (RegistryKey key = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true)) { if (key.GetValue("SLTConsole", null) != null) { key.DeleteValue("SLTConsole", false); tbi.ShowBalloonTip("Automatic Startup - Disabled", "SLT Console will not startup with windows.", BalloonIcon.Info); } else { key.SetValue("SLTConsole", "\"" + System.Reflection.Assembly.GetExecutingAssembly().Location + "\""); tbi.ShowBalloonTip("Automatic Startup - Enabled", "SLT Console will startup with windows.", BalloonIcon.Info); } } }
/// <inheritdoc /> public void ShowNotification(string title, string message, PackIconKind icon) { Execute.OnUIThread(() => { // Convert the PackIcon to an icon by drawing it on a visual DrawingVisual drawingVisual = new(); DrawingContext drawingContext = drawingVisual.RenderOpen(); PackIcon packIcon = new() { Kind = icon }; Geometry geometry = Geometry.Parse(packIcon.Data); // Scale the icon up to fit a 256x256 image and draw it geometry = Geometry.Combine(geometry, Geometry.Empty, GeometryCombineMode.Union, new ScaleTransform(256 / geometry.Bounds.Right, 256 / geometry.Bounds.Bottom)); drawingContext.DrawGeometry(new SolidColorBrush(Colors.White), null, geometry); drawingContext.Close(); // Render the visual and add it to a PNG encoder (we want opacity in our icon) RenderTargetBitmap renderTargetBitmap = new(256, 256, 96, 96, PixelFormats.Pbgra32); renderTargetBitmap.Render(drawingVisual); PngBitmapEncoder encoder = new(); encoder.Frames.Add(BitmapFrame.Create(renderTargetBitmap)); // Save the PNG and get an icon handle using MemoryStream stream = new(); encoder.Save(stream); Icon convertedIcon = Icon.FromHandle(new Bitmap(stream).GetHicon()); // Show the 'balloon' _taskBarIcon.ShowBalloonTip(title, message, convertedIcon, true); }); }