Пример #1
0
        public AppContext(string appData, string vendorName, string productName, string[] args)
        {
            ShutdownMode = ShutdownMode.OnExplicitShutdown;
            Logger       = LogManager.GetLogger(GetType());
            _AppDataPath = appData;
            Directory.CreateDirectory(_AppDataPath);

            _CloseTimer = new Timer((state) => _TaskbarIcon.CloseBalloon());

            var settingsProvider = new RegistrySettingsProvider(vendorName, productName);

            Settings.Default.Providers.Add(settingsProvider);
            foreach (SettingsProperty prop in Settings.Default.Properties)
            {
                prop.Provider = settingsProvider;
            }
            Settings.Default.Reload();
            Settings.Default.PropertyChanged += (sender, e) => Settings.Default.Save();

            var opts = new OptionSet()
            {
                { "startup", (opt) => _OnStartShowOptionsWindow = false }
            };

            opts.Parse(args);
        }
Пример #2
0
        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);
            }
        }
Пример #3
0
        /*
         * Show message with random word from database
         */
        private void OnMainTimerTick(object sender, EventArgs e)
        {
            logger.Trace("Main timer tick");
            taskbarIcon.CloseBalloon(); //force close balloon if it's already open

            DictionaryItem randomWord = GetRandomWord();

            if (randomWord != null)
            {
                FancyBalloon balloon = new FancyBalloon(mainTimer, randomWord, processAnswerFunction);
                //show balloon and close it after maxBalloonStayTime
                if (taskbarIcon != null)
                {
                    taskbarIcon.ShowCustomBalloon(balloon, PopupAnimation.Slide, maxBalloonStayTime);
                }
            }
            else
            {
                ErrorBaloon balloon = new ErrorBaloon();
                if (taskbarIcon != null)
                {
                    taskbarIcon.ShowCustomBalloon(balloon, PopupAnimation.Slide, maxBalloonStayTime);
                }
            }
            timeLeftCounter = config.ShowInterval;
            deleteOldLogFiles(); //delete log files older than 10 days
        }
Пример #4
0
 public void CloseBalloon()
 {
     if (_taskBarIcon != null)
     {
         _taskBarIcon.CloseBalloon();
     }
 }
Пример #5
0
        public void CloseBaloon()
        {
            //the tray icon assigned this attached property to simplify access
            TaskbarIcon taskbarIcon = TaskbarIcon.GetParentTaskbarIcon(this);

            taskbarIcon.CloseBalloon();
        }
Пример #6
0
        /// <summary>
        ///     Handles the MouseLeftButtonUp event of the grid control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="MouseButtonEventArgs" /> instance containing the event data.</param>
        private void grid_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            TaskbarIcon taskbarIcon = TaskbarIcon.GetParentTaskbarIcon(this);

            taskbarIcon.CloseBalloon( );
            e.Handled = true;
        }
Пример #7
0
 public void CloseBalloon()
 {
     TaskbarIcon.CloseBalloon();
     _lastTrayBalloon.Dispose();
     _trayIsReady = true;
     ProcessNotificationQueue();
 }
Пример #8
0
        private void cmdCancel_Click(object sender, RoutedEventArgs e)
        {
            //the tray icon assigned this attached property to simplify access
            TaskbarIcon taskbarIcon = TaskbarIcon.GetParentTaskbarIcon(this);

            taskbarIcon.CloseBalloon();
        }
Пример #9
0
        private void Close_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            TaskbarIcon taskbarIcon = TaskbarIcon.GetParentTaskbarIcon(this);

            taskbarIcon.CloseBalloon();
            e.Handled = true;
        }
Пример #10
0
        /// <summary>
        /// Resolves the <see cref="TaskbarIcon"/> that displayed
        /// the balloon and requests a close action.
        /// </summary>
        private void imgClose_MouseDown(object sender, MouseButtonEventArgs e)
        {
            //the tray icon assigned this attached property to simplify access
            TaskbarIcon taskbarIcon = TaskbarIcon.GetParentTaskbarIcon(this);

            taskbarIcon.CloseBalloon();
        }
Пример #11
0
        private void btnClosePopup_Click(object sender, RoutedEventArgs e)
        {
            TaskbarIcon taskbarIcon = TaskbarIcon.GetParentTaskbarIcon(this);

            taskbarIcon.CloseBalloon();
            NotifyContent.Clear();
        }
Пример #12
0
        private void closeThisBalloon()
        {
            TaskbarIcon taskbarIcon = TaskbarIcon.GetParentTaskbarIcon(this);

            if (taskbarIcon != null && taskbarIcon.CustomBalloon != null)
            {
                taskbarIcon.CloseBalloon();
            }
        }
Пример #13
0
        private void OnShowViewClicked(ShowTileViewModel obj)
        {
            if (ShowViewClicked != null)
            {
                ShowViewClicked(this, obj);
            }
            TaskbarIcon taskbarIcon = TaskbarIcon.GetParentTaskbarIcon(this);

            taskbarIcon.CloseBalloon();
        }
Пример #14
0
 /// <summary>
 /// 关闭托盘图标
 /// </summary>
 public void CloseNotifyIcon()
 {
     if (_taskbarIcon == null)
     {
         return;
     }
     _taskbarIcon.CloseBalloon();
     _taskbarIcon.Dispose();
     _taskbarIcon = null;
 }
Пример #15
0
 /// <summary>
 /// 关闭托盘图标
 /// </summary>
 public void CloseNotifyIcon()
 {
     if (PART_TaskbarIcon == null)
     {
         return;
     }
     PART_TaskbarIcon.CloseBalloon();
     PART_TaskbarIcon.Dispose();
     PART_TaskbarIcon = null;
 }
Пример #16
0
        private void BaloonLinkRun_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            //the tray icon assigned this attached property to simplify access
            TaskbarIcon taskbarIcon = TaskbarIcon.GetParentTaskbarIcon(this);

            taskbarIcon.CloseBalloon();
            if (BaloonLinkClicked != null)
            {
                BaloonLinkClicked(this, new BaloonClickedEventArgs(Mode));
            }
        }
        private void notifiWindowCloseBUtton_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            if (isClosing)
            {
                return;
            }
            TaskbarIcon taskbarIcon = TaskbarIcon.GetParentTaskbarIcon(this);

            taskbarIcon.ResetBalloonCloseTimer();
            taskbarIcon.CloseBalloon();
        }
Пример #18
0
        private void ShowNotifyMessage(string message, int second)
        {
            soundPlayer.PlaySync();

            TaskbarMessage element = new TaskbarMessage()
            {
                Text = message, actionClick = () => taskbar.CloseBalloon()
            };

            taskbar.ShowCustomBalloon(element, System.Windows.Controls.Primitives.PopupAnimation.Slide, second * 1000);
        }
Пример #19
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            //Process.Start(SiteUri);
            ResponseViewer rv = new ResponseViewer();

            rv.SiteId = SiteId;
            rv.Show();
            //the tray icon assigned this attached property to simplify access
            TaskbarIcon taskbarIcon = TaskbarIcon.GetParentTaskbarIcon(this);

            taskbarIcon.CloseBalloon();
        }
Пример #20
0
		public void CloseMessagesListLater(bool setAliveTime)
		{
			// Sync across threads by invoking it on the dispatcher
			_myDispatcher.BeginInvoke(DispatcherPriority.Normal, (Action)(() =>
			{
				if (setAliveTime)
				{
					_messageListAliveUntil = DateTime.Now + MessageListCloseDelay;
				}

				DispatcherInvokeLater(MessageListCloseDelay, () =>
				{
					if (_messageListAliveUntil <= DateTime.Now)
					{
						_taskbarIcon.CloseBalloon();
					}
					else if (_messageListAliveUntil != DateTime.MaxValue)
					{
						CloseMessagesListLater(false);
					}
				});
			}));
		}
Пример #21
0
        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            var btn          = (Button)sender;
            var notifyObject = (NotifyObject)btn.Tag;

            notifyObject.DeleteEvent(notifyObject);
            NotifyContent.Remove(notifyObject);
            if (NotifyContent.Count == 0)
            {
                //if we removed last item then we can close this popup
                TaskbarIcon taskbarIcon = TaskbarIcon.GetParentTaskbarIcon(this);
                taskbarIcon.CloseBalloon();
            }
        }
Пример #22
0
 //点击弹出通知列表
 private void btnMessage_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         TaskbarIcon taskbarIcon = TaskbarIcon.GetParentTaskbarIcon(this);
         taskbarIcon.CloseBalloon();
     }
     catch (Exception ex)
     {
         MethodLb.CreateLog(this.GetType().FullName, "btnMessage_Click", ex.ToString(), sender, e);
     }
     finally
     {
     }
 }
        private void BalloonContainer_OnClosing(object sender, RoutedEventArgs e)
        {
            var balloon  = e.OriginalSource as AuctionAlertBalloon;
            var bMessage = balloon?.DataContext as IBalloonMessage;

            e.Handled = true; //suppresses the popup from being closed immediately
            if (bMessage != null)
            {
                var lst = this.BalloonList;
                lst.Remove(bMessage);
                if (lst.Count == 0)
                {
                    TaskbarIcon taskbarIcon = TaskbarIcon.GetParentTaskbarIcon(this);
                    taskbarIcon.CloseBalloon();
                }
            }
        }
Пример #24
0
        protected override async void OnContentRendered(EventArgs e)
        {
            base.OnContentRendered(e);

            Hide();

            var notificationView = new NotificationView()
            {
                Title   = "WPFApp",
                Message = "The application window has been minimized to tray."
            };

            TaskbarIcon.ShowCustomBalloon(notificationView, PopupAnimation.Slide, 4000);

            await Task.Delay(4000);

            TaskbarIcon.CloseBalloon();
        }
Пример #25
0
        private bool ShowPopup(PerfGraphMessage perfMessage)
        {
            lock ( _syncRoot )
            {
                var viewModel = _userInterface.DataContext as PerfGraphViewModel;
                if (viewModel != null)
                {
                    PerfGraphPopup popup = null;
                    if (_notifyIcon.CustomBalloon != null && _notifyIcon.CustomBalloon.Child != null)
                    {
                        popup = _notifyIcon.CustomBalloon.Child as PerfGraphPopup;
                    }

                    var popupViewModel = new PerfGraphPopupViewModel
                    {
                        Message = perfMessage.Content
                    };

                    popupViewModel.ShowPerfLog += popupViewModel_ShowPerfLog;

                    if (popup != null)
                    {
                        PopupViewModel = popupViewModel;

                        popup.Closed += popup_Closed;

                        _notifyIcon.CloseBalloon( );

                        return(true);
                    }

                    var perfGraphPopup = new PerfGraphPopup
                    {
                        DataContext = popupViewModel
                    };

                    _notifyIcon.ShowCustomBalloon(perfGraphPopup, PopupAnimation.Scroll, _popupTimeout);

                    return(true);
                }
            }

            return(false);
        }
Пример #26
0
        public void ShowSnapPane(bool animate = true)
        {
            if (m_ConnectTask == null)
            {
                return;
            }
            if (m_ConnectTask.Status == TaskStatus.Running || m_ConnectTask.Status == TaskStatus.WaitingForActivation)
            {
                // wait for it to complete...
                Task.Run(async() =>
                {
                    while (m_ConnectTask.Status == TaskStatus.Running || m_ConnectTask.Status == TaskStatus.WaitingForActivation)
                    {
                        await Task.Delay(10);
                    }
                    await Current.Dispatcher.BeginInvoke(new Action <bool>(ShowSnapPane), animate);
                }).ConfigureAwait(false);

                return;
            }

            if (m_SnapcastClient.ServerData == null)
            {
                ShowNotification("Connection error", string.Format("Unable to connect to snapserver at {0}:{1}", SnapSettings.Server, SnapSettings.ControlPort));
                return;
            }

            if (TaskbarIcon.CustomBalloon == null || TaskbarIcon.CustomBalloon.IsOpen == false)
            {
                Hardcodet.Wpf.TaskbarNotification.Interop.Point origin = TaskbarIcon.GetPopupTrayPosition();
                origin.Y += 9; // spawn it as close to the taskbar as we can
                TaskbarIcon.CustomPopupPosition = () =>
                {
                    return(origin);
                };
                SnapControl.SnapControl sc        = new SnapControl.SnapControl(origin, m_SnapcastClient);
                PopupAnimation          animation = animate ? PopupAnimation.Slide : PopupAnimation.None;
                TaskbarIcon.ShowCustomBalloon(sc, animation, null);
            }
            else
            {
                TaskbarIcon.CloseBalloon();
            }
        }
Пример #27
0
        private void btnMoreDetails_Click(object sender, RoutedEventArgs e)
        {
            //Process.Start(SiteUri);
            ResponseViewer rv = new ResponseViewer();

            rv.SiteId = Model.SiteId;
            rv.Show();
            //brings window to top
            rv.Activate();
            rv.Topmost = true;  // important
            rv.Topmost = false; // important
            rv.Focus();         // important


            //the tray icon assigned this attached property to simplify access
            TaskbarIcon taskbarIcon = TaskbarIcon.GetParentTaskbarIcon(this);

            taskbarIcon.CloseBalloon();
        }
Пример #28
0
 /// <summary>
 ///关闭通知
 /// </summary>
 private void imgClose_MouseDown(object sender, MouseButtonEventArgs e)
 {
     try
     {
         var window = Common.CommonMethod.GetRootParent(30, this);
         if (window is Popup)
         {
             (window as Popup).IsOpen = false;
         }
         TaskbarIcon taskbarIcon = TaskbarIcon.GetParentTaskbarIcon(this);
         taskbarIcon.CloseBalloon();
     }
     catch (Exception ex)
     {
         MethodLb.CreateLog(this.GetType().FullName, "imgClose_MouseDown", ex.ToString(), sender, e);
     }
     finally
     {
     }
 }
        private void Close()
        {
            timer.Stop();

            if (Application.Current == null)
            {
                return;
            }

            if (Application.Current.Dispatcher.CheckAccess())
            {
                //the tray icon assigned this attached property to simplify access
                TaskbarIcon taskbarIcon = TaskbarIcon.GetParentTaskbarIcon(this);
                taskbarIcon.CloseBalloon();
            }
            else
            {
                Application.Current.Dispatcher.Invoke(new Action(Close));
            }
        }
Пример #30
0
        /// <summary>
        /// Updated
        /// </summary>
        private void PrepareShutdown()
        {
#if TRACE
            INFO("PrepareShutdown");
#endif
            // Refresh "Heute"
            WARNME_CONFIG.WORKINGDAYS[TODAY].EndZeit = NOW;

            // Commit Values
            NewDataAvailable();

            // Close Forms
            WorkTable.window.Close();

            // Clean up Taskbar Icon
            notifyWorkDay?.Close();
            icon.CloseBalloon();
            icon.Icon.Dispose();
            icon.Icon = null;
            icon.Dispose();
        }