示例#1
0
        private const int TimeShow             = 5000; //显示时间

        public static void NewNotification(string title, string content)
        {
            FancyBalloon balloon = new FancyBalloon();

            balloon.BalloonText = content;
            tb.ShowCustomBalloon(balloon, PopupAnimation.None, TimeShow);
        }
示例#2
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
        }
示例#3
0
        public void ShowScreenShotNotification(string FilePath)
        {
            if (!Settings.Instance.TrayNotify)
            {
                return;
            }

            var popup = new ScreenShotBalloon(FilePath);

            _trayIcon.ShowCustomBalloon(popup, PopupAnimation.Scroll, Settings.Instance.ScreenShotNotifyTimeout);
        }
示例#4
0
        private void ReadSocketMessage(object sender, MessageEventArgs e)
        {
            if (!e.Data.Contains("\"event_name\":\"MetagameEvent\""))
            {
                return;
            }

            Logs.Add(DateTime.Now + " reading socket message");
            try
            {
                Application.Current.Dispatcher.Invoke(delegate
                {
                    var json  = JObject.Parse(e.Data);
                    var alert = new Alert(
                        json["payload"]["instance_id"].Value <int>(),
                        json["payload"]["timestamp"].Value <int>(),
                        json["payload"]["world_id"].Value <int>(),
                        Events[json["payload"]["metagame_event_id"].Value <int>()],
                        json["payload"]["metagame_event_state_name"].Value <string>() == "started",
                        Factions[GetWinner(json["payload"])]
                        );
                    if (alert.IsFinished)
                    {
                        _ongoingEvents.Remove(_ongoingEvents.First(x => x.Value.Id == alert.Id).Key);
                    }
                    else if (!_ongoingEvents.ContainsKey(alert.Id))
                    {
                        _ongoingEvents.Add(alert.Id, alert);
                    }

                    Logs.Add(DateTime.Now + " new event: " + alert.Event.Name + " at " + alert.Server);

                    if (alert.Server.ToServerBit())
                    {
                        _notifyIcon.ShowCustomBalloon(
                            new AlertHolder(
                                new List <Alert>
                        {
                            alert
                        }),
                            (int)_popupPosition.X,
                            (int)_popupPosition.Y,
                            PopupAnimation.Slide,
                            PopupDuration);
                    }
                });
            }
            catch (Exception ex)
            {
                //and f**k it
            }
        }
示例#5
0
        public void ShowBaloonTip()
        {
            var wordPage = new WordPage();

            _taskBarIcon.ShowCustomBalloon(wordPage, System.Windows.Controls.Primitives.PopupAnimation.Slide, null);
            _taskBarIcon.CustomBalloon.Closed += CustomBalloon_Closed;
        }
示例#6
0
        public void ShowBalloonTip(string title, string message, object viewModel = null, int timeout = 6000)
        {
            var balloonTipViewModel = new DefaultBalloonTipViewModel()
            {
                Title     = title,
                Message   = message,
                ViewModel = viewModel
            };

            this.wasVisible = this.IsVisible;
            if (!wasVisible)
            {
                balloonTipViewModel.BalloonClosing += BalloonTipViewModelOnBalloonClosing;
                IsVisible = true;
            }

            Execute.OnUIThread(
                () =>
            {
                var balloonTip = new DefaultBalloonTip()
                {
                };
                ViewModelBinder.Bind(balloonTipViewModel, balloonTip, null);
                TaskbarIcon.ShowCustomBalloon(balloonTip, PopupAnimation.Slide, timeout);
            });
        }
    public void ShowBalloonTip(object rootModel, PopupAnimation animation, TimeSpan?timeout = null)
    {
        var view = ViewLocator.LocateForModel(rootModel, null, null);

        ViewModelBinder.Bind(rootModel, view, null);

        icon.ShowCustomBalloon(view, animation, timeout.HasValue ? (int)timeout.Value.TotalMilliseconds : (int?)null);
    }
示例#8
0
        /// <summary>
        /// ジョブ結果通知バルーンを表示します。
        /// </summary>
        /// <param name="executeResult">ジョブ実行結果</param>
        public void NotifyJobResult(IJobExecuteResult executeResult)
        {
            var balloon = new JobExecuteResultBalloonTip(executeResult);

            _taskbarIcon.ShowCustomBalloon(balloon,
                                           _config.NotifyConfiguration.PopupAnimationType,
                                           (int?)_config.NotifyConfiguration.PopupTimeout?.TotalMilliseconds);
        }
示例#9
0
 static public void Notificar(string Titulo, string msg)
 {
     MsgBox.Notificacao balloon = new MsgBox.Notificacao();
     balloon.BalloonText = Titulo;
     balloon.BallonMsg   = msg;
     // MyNotifyIcon.ShowBalloonTip(Titulo, msg, BalloonIcon.Info);
     MyNotifyIcon.ShowCustomBalloon(balloon, PopupAnimation.Slide, 6000);
 }
示例#10
0
 private void ShowStandardBalloon(string text)                // this shows the notification from the taskbar
 {
     if ((DataContainer.notifications == true) && (m_data.notifycount > 0))
     {
         FancyBalloon balloon = new FancyBalloon();
         balloon.BalloonText    = "You Have A New Message";
         balloon.BalloonMessage = text + " Notifications: " + m_data.notifycount;
         tb.ShowCustomBalloon(balloon, PopupAnimation.Slide, 4000);                   //show and close after 2.5 seconds (5000)
     }
 }
示例#11
0
        public void Notify(Toast toast)
        {
            var toastUi = new ToastUi(toast);

            if (toast.OnActivated != null)
            {
                toastUi.Activated += (s, e) => toast.OnActivated();
            }
            _taskbar.ShowCustomBalloon(toastUi, PopupAnimation.Slide, 4000);
        }
示例#12
0
        private void btn_Click(object sender, RoutedEventArgs e)
        {
            FancyBalloon balloon = new FancyBalloon();

            balloon.BalloonText = "天气转凉,注意保暖!";
            //show and close after 2.5 seconds
            TaskbarIcon tb = new TaskbarIcon();

            tb.ShowCustomBalloon(balloon, PopupAnimation.None, 2000);
        }
 void Notify(ITrayNotificationViewModel notification)
 {
     Dispatcher.InvokeAsync(
         () => TaskbarIcon.ShowCustomBalloon(
             new TrayNotification {
         ViewModel = notification
     },
             PopupAnimation.Fade,
             notification.CloseIn == null ? null : (int?)notification.CloseIn.Value.TotalMilliseconds));
     // TODO: configurable delay etc
 }
示例#14
0
 private void OnNewMessageArrived(object sender, MessageHeaderViewModel newMessageHeaderViewModel)
 {
     Dispatcher.Invoke(() => {
         var balloon    = new NewMessageBalloon(newMessageHeaderViewModel);
         TaskbarIcon tb = Application.Current.Resources["TbIcon"] as TaskbarIcon;
         if (tb != null)
         {
             tb.ShowCustomBalloon(balloon, PopupAnimation.Fade, 10000);
         }
     });
 }
示例#15
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);
        }
示例#16
0
 void Process2Choice(TwoChoiceTrayNotification current2ChoiceEvent)
 {
     _lastTrayBalloon = CreateBalloon(current2ChoiceEvent.Title,
                                      current2ChoiceEvent.Message,
                                      TrayNotificationButtons.tnbYesNo,
                                      new[] {
         current2ChoiceEvent.YesCommand,
         current2ChoiceEvent.NoCommand
     });
     TaskbarIcon.ShowCustomBalloon(_lastTrayBalloon, PopupAnimation.Slide, null);
 }
示例#17
0
        void timerTest_Elapsed(object sender, ElapsedEventArgs e)
        {
            PopupNotificationModel model_test = new PopupNotificationModel()
            {
                SiteId   = 1,
                SiteName = "test",
                SiteUri  = "http://www.gmail.com/",
                TextDiff = "<br><br><br><br><br><br><p class='added'><a name='anchor'>+</a> added</p>" +
                           "<br><br><br><br><p class='notchanged'>Not changed</p>" +
                           "<br><br><br><br><p class='removed'>- removed</p>" +
                           "<br><br><br><br><br><br><br><br><br>"
            };

            Action del = () => {
                PopupNotificationUC notification = new PopupNotificationUC(model_test);
                _notifyIcon.ShowCustomBalloon(notification, PopupAnimation.Slide, null);
            };

            _notifyIcon.Dispatcher.BeginInvoke(del);
            timerTest.Stop();
        }
示例#18
0
        private void popup_Closed(object sender, EventArgs e)
        {
            var popup = sender as PerfGraphPopup;

            if (popup != null)
            {
                popup.Closed -= popup_Closed;
            }

            if (PopupViewModel != null)
            {
                var perfGraphPopup = new PerfGraphPopup
                {
                    DataContext = PopupViewModel
                };

                PopupViewModel = null;

                _notifyIcon.ShowCustomBalloon(perfGraphPopup, PopupAnimation.Scroll, _popupTimeout);
            }
        }
        public void DisplayPopup(string message)
        {
            if (message == null)
            {
                return;
            }

            try {
                FancyBalloon balloon = new FancyBalloon(_appName, message);
                _myTaskbarIcon.ShowCustomBalloon(balloon, PopupAnimation.Fade, 3500);
            } catch (Exception) { }
        }
示例#20
0
 void Process3Choice(ThreeChoiceTrayNotification current3ChoiceEvent)
 {
     _lastTrayBalloon = CreateBalloon(current3ChoiceEvent.Title,
                                      current3ChoiceEvent.Message,
                                      TrayNotificationButtons.tnbAcceptDeclineIgnore,
                                      new[] {
         current3ChoiceEvent.AcceptCommand,
         current3ChoiceEvent.DeclineCommand,
         current3ChoiceEvent.IgnoreCommand
     });
     TaskbarIcon.ShowCustomBalloon(_lastTrayBalloon, PopupAnimation.Slide, null);
 }
示例#21
0
        public void NotifyCustom(string title, string message, TimeSpan?timeout)
        {
            var balloon = new CustomBalloon(_taskbarIcon)
            {
                Title   = title,
                Message = message,
            };

            //
            // 複数の通知を表示したりとかはできないみたい。
            //
            _taskbarIcon.ShowCustomBalloon(balloon, PopupAnimation.Fade, (int?)timeout?.TotalMilliseconds);
        }
示例#22
0
        //****************************************************************************************************************************************************************************************************

        private void _globalKeyboardHook_KeyboardPressed(object sender, GlobalKeyboardHookEventArgs e)
        {
            if (_notifyIcon == null)
            {
                _notifyIcon = ((App)Application.Current).NotifyIcon;
            }

            if (e.KeyType == KeyTypes.Lock && Properties.Settings.Default.ShowLockKeys && (e.KeyboardState == KeyboardState.KeyDown || e.KeyboardState == KeyboardState.SysKeyDown)) // using key down because key up doesn't work for NUM and SCROLL lock keys. Negate all states is neccessary.
            {
                if (e.KeyboardData.VirtualCode == VirtualKeyCodes.VK_CAPITAL)                                                                                                        //CAPS Lock
                {
                    _lockInfoBalloon.IsLocked    = !System.Windows.Forms.Control.IsKeyLocked(System.Windows.Forms.Keys.CapsLock);
                    _lockInfoBalloon.LockKeyText = _lockInfoBalloon.IsLocked ? "A" : "a";
                }
                else if (e.KeyboardData.VirtualCode == VirtualKeyCodes.VK_NUMLOCK)  //NUM Lock
                {
                    _lockInfoBalloon.LockKeyText = "1";
                    _lockInfoBalloon.IsLocked    = !System.Windows.Forms.Control.IsKeyLocked(System.Windows.Forms.Keys.NumLock);
                }
                else if (e.KeyboardData.VirtualCode == VirtualKeyCodes.VK_SCROLL)  //SCROLL Lock
                {
                    _lockInfoBalloon.LockKeyText = "R";
                    _lockInfoBalloon.IsLocked    = !System.Windows.Forms.Control.IsKeyLocked(System.Windows.Forms.Keys.Scroll);
                }

                _notifyIcon.ShowCustomBalloon(_lockInfoBalloon, System.Windows.Controls.Primitives.PopupAnimation.Fade, 2000);
            }
            else if (e.KeyType != KeyTypes.Lock && (e.KeyboardState == KeyboardState.KeyUp || e.KeyboardState == KeyboardState.SysKeyUp))
            {
                if (e.KeyType == KeyTypes.Letter && Properties.Settings.Default.ShowLetterKeys || e.KeyType == KeyTypes.Numeric && Properties.Settings.Default.ShowNumericKeys || e.KeyType == KeyTypes.System && Properties.Settings.Default.ShowSystemKeys)
                {
                    _infoBalloon.KeyType  = e.KeyType;
                    _infoBalloon.InfoText = e.KeyName;

                    _notifyIcon.ShowCustomBalloon(_infoBalloon, System.Windows.Controls.Primitives.PopupAnimation.Fade, 2000);
                }
            }
        }
示例#23
0
        private void showNotification(string messagetext)
        {
            Dispatcher.Invoke(new Action(() =>
            {
                TaskbarIcon MyNotifyIcon;
                BaloonNotification balloon;
                balloon             = new BaloonNotification();
                balloon.BalloonText = "A leave requested !";
                balloon.InfoText    = "Please check your TMS web portal,\nYou have a pending leave approval. ";

                MyNotifyIcon = new TaskbarIcon();
                MyNotifyIcon.ShowCustomBalloon(balloon, PopupAnimation.Slide, null);
            }));
        }
        /// <summary>
        /// Internal method for balloon creation
        /// </summary>
        /// <param name="msg">The MSG.</param>
        private void DisplayBalloon(IBalloonMessage msg)
        {
            _tbi.Dispatcher.Invoke(() =>
            {
                if (_container == null)
                {
                    _container = new BalloonContainer();
                    _tbi.ShowCustomBalloon(_container, PopupAnimation.None, null);
                    _tbi.CustomBalloon.Closed += this.CustomBalloon_Closed;
                }

                _container.AddBalloon(msg);
            });
        }
        private void onReminder(string title, string informative_text)
        {
            if (this.TryBeginInvoke(onReminder, title, informative_text))
            {
                return;
            }

            Title   = title;
            Message = informative_text;

            this.RemoveFromParent();

            icon.ShowCustomBalloon(this, PopupAnimation.Slide, 6000);
        }
示例#26
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            //App.Current.NotifyIcon.
            TaskbarIcon tbIcon = ((App)Application.Current).GetIcon();
            string      msg    = "Message";

            FlitzBalloon balloon = new FlitzBalloon();

            balloon.BalloonText(msg);
            balloon.ShowText($"{DateTime.Now.ToShortTimeString()}: The show begins ...");

            //show and close after 2.5 seconds
            tbIcon.ShowCustomBalloon(balloon, PopupAnimation.Slide, 5000);
        }
示例#27
0
        public static bool ShowNotification(this TaskbarIcon icon, UIElement element, PopupAnimation animation,
                                            TimeSpan?timeout = null)
        {
            try
            {
                icon.ShowCustomBalloon(element, animation, (int?)timeout?.TotalMilliseconds);
            }
            catch (Exception e)
            {
                BugsnagService.NotifyBugsnag(new Exception("Failed to show a custom notification", e));
                return(false);
            }

            return(true);
        }
示例#28
0
        private void ClientServiceOnRecievedNotificationEvent(NotificationObservable notificationObservable)
        {
            Current.Dispatcher.Invoke(delegate
            {
                var notification = new NotificationControl
                {
                    Sender         = notificationObservable.Sender.Substring(5) + " - " + notificationObservable.DateSent,
                    Subject        = notificationObservable.Subject,
                    NotificationId = notificationObservable.Id
                };

                _notifyIcon.ShowCustomBalloon(notification, PopupAnimation.Slide, 6000);
                _clientService.ConfirmNotified(notificationObservable.Id);
            });
        }
示例#29
0
        public void showTryIcon(IconType iconType, string title, String msg, int?sleep)
        {
            ShowTrayIcon balloon = new ShowTrayIcon();

            balloon.TrayIconTitle             = title;
            balloon.TrayIconMessage           = msg;
            balloon.TypeIcon                  = ConvertTypeToSourcePath(iconType);
            balloon.TrayIconBackground        = ConvertTypeToColor(iconType).ToString();
            balloon.TrayIconMessageForeground = ConvertTypeToColorMessage(iconType).ToString();
            balloon.TrayIconTitleForeground   = ConvertTypeToColorMessage(iconType).ToString();
            //show and close after sleep seconds
            TaskbarIcon tb = (TaskbarIcon)FindResource("MyNotifyIcon");;

            tb.ShowCustomBalloon(balloon, PopupAnimation.Slide, sleep);
        }
示例#30
0
 public void ShowNotification(string title, string message)
 {
     Current.Dispatcher.BeginInvoke(new Action(() =>
     {
         Logger.Info("Notification: {0}: {1}", title, message);
         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);
         };
         Notification notification = new Notification(origin, title, message);
         TaskbarIcon.ShowCustomBalloon(notification, PopupAnimation.Slide, null);
     }));
 }