예제 #1
0
        private void Main_Load(object sender, EventArgs e)
        {
            if (Settings.Default.MinimizeToTray)
            {
                ThreadPool.QueueUserWorkItem((_) => {
                    Thread.Sleep(100);                     // HACK: Work around issue where minimizing to tray keeps icon in taskbar.
                    Invoke(new Action(() => {
                        this.WindowState         = FormWindowState.Minimized;
                        this.Visible             = false;
                        NotificationIcon.Visible = true;
                        NotificationIcon.ShowBalloonTip(2000, "Whisper Notifier Started Minimized", "PoEWhisperNotifier started minimized. Double click the icon to show the window.", ToolTipIcon.Info);
                    }));
                });
            }
            else if (Settings.Default.StartMinimized)
            {
                this.WindowState = FormWindowState.Minimized;
            }
            else
            {
                this.WindowState = FormWindowState.Normal;
            }

            StartMonitoring(true);
        }
예제 #2
0
 private void ThemeControl_Resize(object sender, EventArgs e)
 {
     if (WindowState == FormWindowState.Minimized)
     {
         NotificationIcon.ShowBalloonTip(500);
         Hide();
     }
 }
예제 #3
0
 /// <inheritdoc />
 public void ShowBalloonTipFor(int timeoutInMilliseconds, string title, string text, ToolTipIcon icon,
                               Action clickAction = null, Action closeAction = null)
 {
     lock (this)
     {
         _balloonTipClickHandlers = new BalloonTipClickHandlerRegistration(clickAction, closeAction);
     }
     NotificationIcon.ShowBalloonTip(timeoutInMilliseconds, title, text, icon);
 }
예제 #4
0
 internal void DisplayNotification(string name)
 {
     try
     {
         NotificationIcon.BalloonTipText = $"Wallpaper changed to {name}";
         NotificationIcon.ShowBalloonTip(1000);
     }
     catch (Exception ex)
     {
     }
 }
예제 #5
0
 private void OnResize(object sender, EventArgs e)
 {
     if (FormWindowState.Minimized == base.WindowState)
     {
         NotificationIcon.Visible = true;
         NotificationIcon.ShowBalloonTip(2);
         base.Hide();
     }
     else if (base.WindowState == FormWindowState.Normal)
     {
         NotificationIcon.Visible = false;
     }
 }
예제 #6
0
 private void HeadForm_Resize(object sender, EventArgs e)
 {
     NotificationIcon.BalloonTipTitle = "Onions";
     NotificationIcon.BalloonTipText  = "Service Database is working";
     if (FormWindowState.Minimized == this.WindowState)
     {
         NotificationIcon.Visible = true;
         NotificationIcon.ShowBalloonTip(500);
         this.ShowInTaskbar = false;
         this.Hide();
     }
     else if (FormWindowState.Normal == this.WindowState)
     {
         NotificationIcon.Visible = false;
     }
 }
예제 #7
0
        void ProcessMessage(MessageData obj)
        {
            if (obj.MessageType == LogMessageType.Party && !Settings.Default.LogPartyMessages)
            {
                return;
            }
            if (Settings.Default.NotifyMinimizedOnly && IsPoeActive())
            {
                if (!IdleManager.IsUserIdle)
                {
                    // If the user isn't idle, replay the message if they do go idle.
                    IdleManager.AddIdleAction(() => ProcessMessage(obj));
                    return;
                }
                // Otherwise, they are idle, so process the message anyways.
            }
            string StampedMessage = "[" + obj.Date.ToShortTimeString() + "]" + (obj.Sender == null ? "" : (" " + LogMonitor.ChatSymbolForMessageType(obj.MessageType) + obj.Sender)) + ": " + obj.Message;
            string Title          = "Path of Exile " + obj.MessageType;

            Invoke(new Action(() => AppendMessage(StampedMessage)));
            if (Settings.Default.TrayNotifications)
            {
                Invoke(new Action(() => {
                    NotificationIcon.Visible = true;
                    NotificationIcon.ShowBalloonTip(5000, Title, (obj.Sender == null ? "" : (obj.Sender + ": ")) + obj.Message, ToolTipIcon.Info);
                }));
            }
            if (Settings.Default.EnableSound)
            {
                try {
                    this.SoundPlayer.Play();
                } catch (Exception ex) {
                    AppendMessage("<Error playing sound. This usually occurs due to the Content folder being missing.\r\n  Additional Info: " + ex.Message + ">");
                }
            }
            if (Settings.Default.EnableSmtpNotifications)
            {
                // Feels wasteful to always reload, but really it should only take a millisecond or less.
                var SmtpSettings = SmtpDetails.LoadFromSettings();
                var SmtpAct      = CheckedAction("SMTP", () => SendSmtpNotification(SmtpSettings, StampedMessage));
                if (!SmtpSettings.NotifyOnlyIfIdle)
                {
                    SmtpAct();
                }
                else
                {
                    IdleManager.AddIdleAction(SmtpAct);
                }
            }
            if (Settings.Default.EnablePushbullet)
            {
                var PbSettings = PushBulletDetails.LoadFromSettings();
                var PbAct      = CheckedAction("PushBullet", () => {
                    var Client = new PushBulletClient(PbSettings);
                    Client.SendPush(Title, StampedMessage);
                });
                if (!PbSettings.NotifyOnlyIfIdle)
                {
                    PbAct();
                }
                else
                {
                    IdleManager.AddIdleAction(PbAct);
                }
            }
        }
예제 #8
0
 private void PlayNotificationsForMessage(MessageData Message, bool AssumeInactive)
 {
     if (Settings.Default.NotifyMinimizedOnly && IsPoeActive())
     {
         if (!IdleManager.IsUserIdle)
         {
             // If the user isn't yet idle, replay the message if they do go idle.
             IdleManager.AddIdleAction(() => PlayNotificationsForMessage(Message, AssumeInactive));
             return;
         }
         // Otherwise, they are idle, so process the message anyways.
     }
     if (Settings.Default.TrayNotifications)
     {
         NotificationIcon.Visible = true;
         NotificationIcon.ShowBalloonTip(5000, Message.Title, (Message.Sender == null ? "" : (Message.Sender + ": ")) + Message.Message, ToolTipIcon.Info);
     }
     if (Settings.Default.EnableSound)
     {
         try {
             this.SoundPlayer.Play();
         } catch (Exception ex) {
             LogMessage("<Error playing sound. This usually occurs due to the Content folder being missing.\r\n  Additional Info: " + ex.Message + ">", null, LogMessageType.Status);
         }
     }
     if (Settings.Default.EnableSmtpNotifications)
     {
         var SmtpSettings = SmtpDetails.LoadFromSettings();
         var SmtpAct      = CheckedAction("SMTP", () => SendSmtpNotification(SmtpSettings, Message.DisplayMessage));
         if (!SmtpSettings.NotifyOnlyIfIdle || AssumeInactive)
         {
             SmtpAct();
         }
         else
         {
             IdleManager.AddIdleAction(SmtpAct);
         }
     }
     if (Settings.Default.EnablePushbullet)
     {
         var   PbSettings = PushBulletDetails.LoadFromSettings();
         Regex Pattern    = null;
         Match Matches    = null;
         if (!String.IsNullOrWhiteSpace(PbSettings.NotifyOnlyIfMatches))
         {
             Pattern = new Regex(PbSettings.NotifyOnlyIfMatches);
             Matches = Pattern.Match(Message.Message);
         }
         if (Pattern == null || ((Pattern != null) && Matches.Success))
         {
             var PbAct = CheckedAction("PushBullet", () => {
                 var Client = new PushBulletClient(PbSettings);
                 Client.SendPush(Message.Title, Message.DisplayMessage);
             });
             if (AssumeInactive || !PbSettings.NotifyOnlyIfIdle)
             {
                 PbAct();
             }
             else
             {
                 IdleManager.AddIdleAction(PbAct);
             }
         }
     }
     if (Settings.Default.FlashTaskbar && (!IsPoeActive() || AssumeInactive))
     {
         var PoeProcess = GetPoeProcess();
         if (PoeProcess != null)
         {
             var FlashAct = CheckedAction("Taskbar Flash", () => WindowFlasher.FlashWindow(PoeProcess.MainWindowHandle, FlashStyle.All));
             FlashAct();
         }
         else
         {
             LogMessage("<Could not find the PoE process to flash the taskbar>", null, LogMessageType.Status);
         }
     }
 }