public NotificationManager( IActivityRecordsRepository activityRecordsRepository, IUserActivityTracker userActivityTracker, IUnknownActivityNotificationPopupViewModel unknownActivityNotificationPopupViewModel) { _activityRecordsRepository = activityRecordsRepository; _userActivityTracker = userActivityTracker; _unknownActivityNotificationViewModel = unknownActivityNotificationPopupViewModel; _unknownActivityNotificationViewModel.AllRecordsUpdated += OnUnknownActivityAllRecordsUpdated; _unknownActivityNotificationViewModel.RecordUpdated += OnUnknownActivityRecordUpdated; Stream iconStream = IoC.Get<IResourceManager>() .GetStream( "Resources/UnknownActivityNotification.ico", Assembly.GetExecutingAssembly().GetAssemblyName()); _unknownActivityNotification = new TaskbarIcon { Icon = new Icon(iconStream), Popup = _unknownActivityNotificationViewModel, PopupActivation = PopupActivationMode.All, ToolTipText = "You've been missing too long. What've you been up to?" }; iconStream = IoC.Get<IResourceManager>() .GetStream("Resources/GoHome.ico", Assembly.GetExecutingAssembly().GetAssemblyName()); _workdayEndedNotification = new TaskbarIcon { Icon = new Icon(iconStream), ToolTipText = "You can go home now!" }; _userActivityTracker.UnknownActivityLogged += OnUnknownActivityLogged; Task.Run(() => CheckRemainingWorkTime()); }
public FancyBalloon() { InitializeComponent(); TaskbarIcon.AddBalloonClosingHandler(this, OnBalloonClosing); }
private void Application_Startup(object sender, StartupEventArgs e) { // Check if application is running by startup if (e.Args.Length > 0 && e.Args[0] == "/auto") { LaunchMinimized = true; } Configurations.Configuration.InitializeLocalFolder(); Configurations.Configuration.LoadSettingsFromFile(); InitalizeLocalizedEnvironment(); if (programInstancesCount > 1) { MessageBox.Show(LocalizedEnvironment.Translation.Application.DoNotRunMultipleInstances); Shutdown(); } InitializeIdleDetector(Configuration.SystemIdleDetectionEnabled); ToolTipService.ShowDurationProperty.OverrideMetadata( typeof(DependencyObject), new FrameworkPropertyMetadata(int.MaxValue)); if (Configuration.CustomShortMessages.Length == 0) { Configuration.CustomShortMessages = new string[] { "Stare far-off" }; } BasePrequirementsLoaded = true; // Ignore paused protecting state if (Configuration.ProtectionState == GuardStates.PausedProtecting) { Configuration.ProtectionState = GuardStates.Protecting; } if ((int)Configuration.ShortBreakGap.TotalMinutes < 1) { Configuration.ShortBreakGap = new TimeSpan(0, 1, 0); } if ((int)Configuration.LongBreakGap.TotalMinutes < 5) { Configuration.LongBreakGap = new TimeSpan(0, 5, 0); } if ((int)Configuration.ShortBreakDuration.TotalSeconds < 2) { Configuration.ShortBreakDuration = new TimeSpan(0, 0, 2); } if ((int)Configuration.LongBreakDuration.TotalSeconds < 5) { Configuration.LongBreakDuration = new TimeSpan(0, 0, 5); } Configuration.SaveSettingsToFile(); NextShortBreak = Configuration.ShortBreakGap; NextLongBreak = Configuration.LongBreakGap; ShortBreakVisibleTime = Configuration.ShortBreakDuration; LongBreakVisibleTime = Configuration.LongBreakDuration; if (Configuration.ProtectionState == GuardStates.Protecting) { ShortBreakHandler.Start(); LongBreakHandler.Start(); } UpdateShortTimeString(); UpdateLongTimeString(); UpdateKeyTimeVisible(); UpdateStats(); ShortBreakHandler.Tick += ShortBreakHandler_Tick; LongBreakHandler.Tick += LongBreakHandler_Tick; PauseHandler.Tick += PauseHandler_Tick; ShortDurationCounter.Tick += ShortDurationCounter_Tick; LongDurationCounter.Tick += LongDurationCounter_Tick; TaskbarIcon = "App.GlobalTaskbarIcon".Translate <TaskbarIcon>(); TaskbarIcon.DataContext = UIViewModels.NotifyIcon; UpdateTaskbarIcon(); if (TaskbarIcon != null && !Configuration.TrayNotificationSaidBefore) { TaskbarIcon.ShowBalloonTip( LocalizedEnvironment.Translation.Application.Notifications.FirstLaunch.Title, LocalizedEnvironment.Translation.Application.Notifications.FirstLaunch.Message, BalloonIcon.Info); Configuration.TrayNotificationSaidBefore = true; Configuration.SaveSettingsToFile(); } }
private void CloseBalloon(object sender, RoutedEventArgs e) { TaskbarIcon taskbarIcon = TaskbarIcon.GetParentTaskbarIcon(this); taskbarIcon.CloseBalloon(); }
public void showBallonTip(TaskbarIcon taskBarIcon, string title, string body) { taskBarIcon.ShowBalloonTip(title, body, Hardcodet.Wpf.TaskbarNotification.BalloonIcon.Info); }
protected void ClosePopup() { var taskbarIcon = TaskbarIcon.GetParentTaskbarIcon(this); taskbarIcon.CloseBalloon(); }
public static void RegisterView(TaskbarIcon view) { var serviceLocator = ServiceLocator.Default; serviceLocator.RegisterInstance(view); }
public ShellView() { InitializeComponent(); _notifyIcon = (TaskbarIcon)this.Resources["NotifyIcon"]; }
public TaskBarNotification() { InitializeComponent(); TaskbarIcon.AddBalloonClosingHandler(this, OnBalloonClosing); }
public TrayManager(TaskbarIcon ti) { TrayIcon = ti; }
public void SetToolbarTray(TaskbarIcon tbt) { _tbt = tbt; }
/// <summary> /// Called when an attached view's Loaded event fires. /// </summary> /// <param name="view"/> protected override void OnViewLoaded(object view) { base.OnViewLoaded(view); _window = Window.GetWindow((DependencyObject)view); if (_window == null) { return; } _window.StateChanged += OnWindowStateChanged; _previousWindowState = _window.WindowState; Stream iconStream = IoC.Get<IResourceManager>() .GetStream("Resources/GoHome.ico", Assembly.GetExecutingAssembly().GetAssemblyName()); _taskbarIcon = new TaskbarIcon { Icon = new Icon(iconStream), ToolTipText = "Show main window" }; _taskbarIcon.TrayMouseDoubleClick += OnTaskbarIconTrayMouseClick; _taskbarIcon.TrayLeftMouseDown += OnTaskbarIconTrayMouseClick; _taskbarIcon.TrayRightMouseDown += OnTaskbarIconTrayMouseClick; if (Settings.Default.StartHiddenToTray) { _window.WindowState = WindowState.Minimized; } }
private void UpdateUI() { if (Account.Account.Overcharge > 0) { imgAlert.Source = new BitmapImage(new Uri(@"pack://*****:*****@"pack://application:,,,/CIV;component/Images/Alert-User.png")); imgAlert.Visibility = System.Windows.Visibility.Visible; } else { imgAlert.Visibility = System.Windows.Visibility.Collapsed; } // Gestion de l'icône dans la barre système try { if (_account.SystrayDisplay) { if (MyNotifyIcon == null) { MyNotifyIcon = new TaskbarIcon() { Name = "MyNotifyIcon", VerticalAlignment = System.Windows.VerticalAlignment.Top, ContextMenu = new ContextMenu() }; MyNotifyIcon.DoubleClickCommand = new DashboardShowCommand(); MyNotifyIcon.DoubleClickCommandParameter = this.Parent; MyNotifyIcon.SetBinding(Hardcodet.Wpf.TaskbarNotification.TaskbarIcon.ToolTipTextProperty, new Binding("Account.DisplayName") { Source = _account }); // Menu MenuItem menu = new MenuItem() { Icon = new System.Windows.Controls.Image() { Source = new BitmapImage(new Uri("pack://application:,,,/CIV;component/Images/Exit.png", UriKind.RelativeOrAbsolute)), HorizontalAlignment = System.Windows.HorizontalAlignment.Center, VerticalAlignment = System.Windows.VerticalAlignment.Center, Stretch = Stretch.None } }; } else { MyNotifyIcon.Icon.Dispose(); } UsagePieChart pie = new UsagePieChart(_account.Account, ProgramSettings.Instance.CombinedColor.GetColor(), System.Drawing.Color.White); MyNotifyIcon.Icon = pie.GenerateIcon(); } else { if (MyNotifyIcon != null) { MyNotifyIcon.Icon.Dispose(); MyNotifyIcon.Dispose(); } } } catch (Exception e) { LogEngine.Instance.Add(e, false); } }
private void Application_Exit_1(object sender, ExitEventArgs e) { TaskbarIcon.Dispose(); }
public NotifyIconManager( IViewManager viewManager, NotifyIconViewModel viewModel, IApplicationState application, IApplicationWindowState applicationWindowState, ISyncThingManager syncThingManager) { this.viewManager = viewManager; this.viewModel = viewModel; this.application = application; this.applicationWindowState = applicationWindowState; this.syncThingManager = syncThingManager; this.taskbarIcon = (TaskbarIcon)this.application.FindResource("TaskbarIcon"); this.viewManager.BindViewToModel(this.taskbarIcon, this.viewModel); this.applicationWindowState.RootWindowActivated += this.RootViewModelActivated; this.applicationWindowState.RootWindowDeactivated += this.RootViewModelDeactivated; this.applicationWindowState.RootWindowClosed += this.RootViewModelClosed; this.viewModel.WindowOpenRequested += (o, e) => { this.applicationWindowState.EnsureInForeground(); }; this.viewModel.WindowCloseRequested += (o, e) => { // Always minimize, regardless of settings this.application.ShutdownMode = ShutdownMode.OnExplicitShutdown; this.applicationWindowState.CloseToTray(); }; this.viewModel.ExitRequested += (o, e) => this.application.Shutdown(); this.syncThingManager.FolderSyncStateChanged += (o, e) => { if (this.ShowSynchronizedBalloon && DateTime.UtcNow - this.syncThingManager.LastConnectivityEventTime > syncedDeadTime && DateTime.UtcNow - this.syncThingManager.StartedTime > syncedDeadTime && e.SyncState == FolderSyncState.Idle && e.PrevSyncState == FolderSyncState.Syncing) { Application.Current.Dispatcher.CheckAccess(); // Double-check this.taskbarIcon.ShowBalloonTip(Localizer.Translate("TrayIcon_Balloon_FinishedSyncing_Title"), Localizer.Translate("TrayIcon_Balloon_FinishedSyncing_Message", e.Folder.FolderId), BalloonIcon.Info); } }; this.syncThingManager.DeviceConnected += (o, e) => { if (this.ShowDeviceConnectivityBalloons && DateTime.UtcNow - this.syncThingManager.StartedTime > syncedDeadTime) { this.taskbarIcon.ShowBalloonTip(Localizer.Translate("TrayIcon_Balloon_DeviceConnected_Title"), Localizer.Translate("TrayIcon_Balloon_DeviceConnected_Message", e.Device.Name), BalloonIcon.Info); } }; this.syncThingManager.DeviceDisconnected += (o, e) => { if (this.ShowDeviceConnectivityBalloons && DateTime.UtcNow - this.syncThingManager.StartedTime > syncedDeadTime) { this.taskbarIcon.ShowBalloonTip(Localizer.Translate("TrayIcon_Balloon_DeviceDisconnected_Title"), Localizer.Translate("TrayIcon_Balloon_DeviceDisconnected_Message", e.Device.Name), BalloonIcon.Info); } }; }
private void Timer_Elapsed(object sender, ElapsedEventArgs e) { if (IsPaused) { PausedTime = PausedTime.Add(TimeSpan.FromMilliseconds(_timer.Interval)); if (_taskbarIcon == null) { _taskbarIcon = IoC.Get <TaskbarIcon>(); _sourceIcon = _taskbarIcon.Icon; } } else { PausedTime = new TimeSpan(); //游戏中,延迟 if (IsDelaying) { warned = false; IsDelaying = false; ResetCountDown(); } //正常运行中 else if (!IsResting) { //倒计时减1秒 Countdown = Countdown.Subtract(new TimeSpan(0, 0, 1)); CountdownPercent = Countdown.TotalSeconds / Setting.App.AlarmInterval.TotalSeconds * 100; //提前30秒警告一次 if (!warned && Countdown.TotalSeconds <= 30 && Countdown.TotalSeconds >= 20) { warned = true; ////游戏中不播放警告声音 //bool isMaximized = new OtherProgramChecker(_currentPID, true).CheckMaximized(); //if (!isMaximized) //还是加上提示,害怕突然说话过于惊悚 _eventAggregator.PublishOnUIThread(new PlayAudioEvent() { Source = @"Resources\Sounds\breakpre.mp3" }); } //判断休息 if (Countdown.TotalSeconds <= 0) { _timer.Stop(); new OtherProgramChecker(Process.GetCurrentProcess().Id, true).CheckMaximized(out List <System.Windows.Forms.Screen> maximizedScreens); bool isMaximized = maximizedScreens != null && maximizedScreens.Count > 0; // 正在全屏&&开启语音提示 if ((isMaximized && Setting.Speech.Enable)) { IsDelaying = true; PlaySpeech(); } else {//没有全屏玩游戏,立即休息 IsResting = true; //开启不锁屏 if (Setting.Speech.NeverLockScreen) { PlaySpeech(); } else {//锁屏 _lastLockScreenViewModel = IoC.Get <LockScreenViewModel>(); Execute.OnUIThread(() => { _windowManager.ShowWindow(_lastLockScreenViewModel); _lastLockScreenViewModel.Deactivated += _lastLockScreenViewModel_Deactivated; }); } PlayRestingAudio(IsResting); } RestTimeCountdown = Setting.App.RestTime; _timer.Start(); } } //休息中 else { warned = false; RestTimeCountdown = RestTimeCountdown.Subtract(new TimeSpan(0, 0, 1)); RestTimeCountdownPercent = RestTimeCountdown.TotalSeconds / Setting.App.RestTime.TotalSeconds * 100; if (RestTimeCountdown.TotalSeconds <= 0) { //休息完毕 ResetCountDown(); PlayRestingAudio(IsResting); _totalPlayTime = new TimeSpan(); } } } }
protected override async void OnStartup(StartupEventArgs e) { Instance = this; base.OnStartup(e); AttachErrorHandlers(); // Tooltip opened indefinitely until mouse is moved. ToolTipService.ShowDurationProperty.OverrideMetadata(typeof(DependencyObject), new FrameworkPropertyMetadata(int.MaxValue)); serviceProvider = Sidekick.Startup.InitializeServices(this); logger = serviceProvider.GetRequiredService <ILogger>(); nativeProcess = serviceProvider.GetRequiredService <INativeProcess>(); nativeBrowser = serviceProvider.GetRequiredService <INativeBrowser>(); leagueDataService = serviceProvider.GetRequiredService <ILeagueDataService>(); initializer = serviceProvider.GetRequiredService <IInitializer>(); viewLocator = serviceProvider.GetRequiredService <IViewLocator>(); settings = serviceProvider.GetRequiredService <SidekickSettings>(); trayIcon = (TaskbarIcon)FindResource("TrayIcon"); trayIcon.DataContext = serviceProvider.GetRequiredService <TrayIconViewModel>(); await RunAutoUpdate(); EnsureSingleInstance(); leagueDataService.OnNewLeagues += () => { Dispatcher.Invoke(() => { AdonisUI.Controls.MessageBox.Show(InitializerResources.Warn_NewLeagues, buttons: AdonisUI.Controls.MessageBoxButton.OK); }); }; if (settings.ShowSplashScreen) { initializer.OnProgress += (a) => { if (!viewLocator.IsOpened <SplashScreenView>()) { Dispatcher.Invoke(() => { viewLocator.Open <SplashScreenView>(); }); } }; } initializer.OnError += (error) => { AdonisUI.Controls.MessageBox.Show(InitializerResources.ErrorDuringInit, buttons: AdonisUI.Controls.MessageBoxButton.OK); base.Shutdown(1); }; await initializer.Initialize(); trayIcon.ShowBalloonTip( TrayResources.Notification_Title, string.Format(TrayResources.Notification_Message, settings.Key_CheckPrices.ToKeybindString(), settings.Key_CloseWindow.ToKeybindString()), trayIcon.Icon, largeIcon: true); serviceProvider.GetRequiredService <EventsHandler>(); }
public MainWindow() { InitializeComponent(); // Set up the content grids. contentGrids = new List <Grid> { StatusGrid, BackupsGrid }; // show only the status content grid. hideAllContentGrids(); contentGrids[0].Visibility = Visibility.Visible; // Set up the backupmanager. bm = new BackupManager(this); Thread bmthr = new Thread(() => bm.MainAsync()); bmthr.Priority = ThreadPriority.AboveNormal; bmthr.Start(); // Set up backuplist backupListContents = new ObservableCollection <backupListRow>(); backupList.ItemsSource = backupListContents; //Set up taskbar icon. taskbarIcon = new TaskbarIcon(); taskbarIcon.ToolTip = "SharpBackup"; taskbarIcon.Icon = SystemIcons.Application; taskbarIcon.Visibility = Visibility.Collapsed; taskbarIcon.DoubleClickCommand = new RelayCommand(this); bm.backups.CollectionChanged += (object sender, NotifyCollectionChangedEventArgs e) => { ObservableCollection <backupListRow> newBackupListContents = new ObservableCollection <backupListRow>(); for (int i = 0; i < bm.backups.Count; i++) { var item = bm.backups[i]; newBackupListContents.Add(new backupListRow() { Name = item.name, Path = item.url, LastBackup = item.lastBackup.ToLongDateString(), Status = item.StatusString, Progress = item.progressString, SizeProgress = item.sizeProgress, AllProgress = item.allProgress, paused = item.paused }); } Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate() { backupListContents.Clear(); for (int i = 0; i < newBackupListContents.Count; i++) { backupListContents.Add(newBackupListContents[i]); /*Button pauseButton = (Button)((ListViewItem)backupList.Items.GetItemAt(i)).FindName("pauseButton"); * if (newBackupListContents[i].paused) * { * pauseButton.Content = "Resume"; * } * else * { * pauseButton.Content = "Pause"; * }*/ } statusText.Text = String.Format("Loaded {0} backups.", bm.backups.Count()); })); }; }
private void InitializeTaskbarIcon() { taskbarIcon = (TaskbarIcon)FindResource("TaskbarIcon"); toggleMenuItem = (MenuItem)taskbarIcon.ContextMenu?.Items[0]; }
/// <summary> /// Initializes a new instance of the <see cref="BalloonHelper"/> class. /// </summary> /// <param name="tbi">The tbi.</param> public BalloonHelper(TaskbarIcon tbi) { _tbi = tbi; }
public void Initialize(FlyoutWindow flyoutWindow) { _flyoutWindow = flyoutWindow; FlyoutTimeout = AppDataHelper.FlyoutTimeout; MaxVerticalSessionControlsCount = AppDataHelper.MaxVerticalSessionControlsCount; SessionsPanelOrientation = AppDataHelper.SessionsPanelOrientation; themeResources = (ThemeResources)App.Current.Resources.MergedDictionaries.FirstOrDefault(x => x is ThemeResources); lightResources = themeResources.ThemeDictionaries["Light"]; darkResources = themeResources.ThemeDictionaries["Dark"]; FlyoutBackgroundOpacity = AppDataHelper.FlyoutBackgroundOpacity; #region Setup TaskbarIcon var settingsItem = new MenuItem() { Header = Properties.Strings.SettingsItem, ToolTip = Properties.Strings.SettingsItemDescription, Icon = new SymbolIcon() { Symbol = Symbol.Setting } }; settingsItem.Click += (_, __) => FlyoutHandler.ShowSettingsWindow(); var exitItem = new MenuItem() { Header = Properties.Strings.ExitItem, ToolTip = Properties.Strings.ExitItemDescription, Icon = new FontIcon() { Glyph = CommonGlyphs.PowerButton } }; exitItem.Click += (_, __) => FlyoutHandler.SafelyExitApplication(); TaskbarIconContextMenu = new ContextMenu() { Items = { settingsItem, exitItem } }; TaskbarIconToolTip = new ToolTip() { Content = Program.AppName }; TaskbarIcon = new TaskbarIcon() { TrayToolTip = TaskbarIconToolTip, ContextMenu = TaskbarIconContextMenu }; TaskbarIcon.TrayMouseDoubleClick += (_, __) => FlyoutHandler.ShowSettingsWindow(); #endregion UseColoredTrayIcon = AppDataHelper.UseColoredTrayIcon; SystemTheme.SystemThemeChanged += OnSystemThemeChange; SystemTheme.Initialize(); }
public MainWindow() { if (Settings.Default.UpdateSettings) { Settings.Default.Upgrade(); Settings.Default.UpdateSettings = false; Settings.Default.Save(); } if (Settings.Default.DarkMode2 == DarkMode.Unset) { Settings.Default.DarkMode2 = (DarkMode)Convert.ToInt32(Settings.Default.DarkMode); Settings.Default.Save(); } DarkModeHelper.Update(); _mainPage = new MainPage(this); _systemPage = new SystemPage(this); _selfTestPage = new SelfTestPage(this); _factoryResetPage = new FactoryResetPage(this); _findMyGearPage = new FindMyGearPage(this); _touchpadPage = new TouchpadPage(this); _customActionPage = new CustomActionPage(this); _ambientSoundPage = new AmbientSoundPage(this); _equalizerPage = new EqualizerPage(this); _connectionLostPage = new ConnectionLostPage(this); _deviceSelectPage = new DeviceSelectPage(this); _settingPage = new SettingPage(this); _updatePage = new UpdatePage(this); _advancedPage = new AdvancedPage(this); _unsupportedFeaturePage = new UnsupportedFeaturePage(this); _popupSettingPage = new PopupSettingPage(this); InitializeComponent(); _tbi = new TaskbarIcon(); Stream iconStream = Application.GetResourceStream(new Uri("pack://*****:*****@"CRITICAL: Unknown Win32 Bluetooth service error"); Console.WriteLine(e); } }
void App_Startup(object sender, StartupEventArgs e) { TaskbarIcon = (TaskbarIcon)FindResource("NotifyIcon"); }
public TaskbarService() { NotifyIcon = (TaskbarIcon)App.Current.FindResource("NotifyIcon"); }
public MainWindow(TaskbarIcon tb) : this() { taskBar = tb; tw = taskBar; }
public BasicSmsHandler(TaskbarIcon icon) { this.icon = icon; }
private void Grid_MouseEnter_1(object sender, MouseEventArgs e) { TaskbarIcon taskbarIcon = TaskbarIcon.GetParentTaskbarIcon(this); taskbarIcon.ResetBalloonCloseTimer(); }
private void imgClose_MouseDown(object sender, MouseButtonEventArgs e) { var taskbarIcon = TaskbarIcon.GetParentTaskbarIcon(this); taskbarIcon?.CloseBalloon(); }
public TrayIconViewModel(TaskbarIcon notifyIcon) { _notifyIcon = notifyIcon; this.AttachViewWithViewModel(_marketIndexesUserControl, _marketIndexesViewModel); }
protected override void OnStartup(StartupEventArgs e) { _taskbar = (TaskbarIcon)FindResource("taskbar"); base.OnStartup(e); }
protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); _notifyIcon = (TaskbarIcon)FindResource("NotifyIcon"); }
private void LayoutRoot_MouseDown(object sender, MouseButtonEventArgs e) { TaskbarIcon taskbarIcon = TaskbarIcon.GetParentTaskbarIcon(this); taskbarIcon.CloseBalloon(); }