/// <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;
            }
        }
Example #2
0
        /// <summary>
        /// Reads through the buddy and ignore files and properly assigns status
        /// </summary>
        public void assignCategory()
        {
            if (SettingsManager.getMgr().isBuddy(Name))
            {
                Category = "Buddies";
            }

            if (SettingsManager.getMgr().isIgnored(Name))
            {
                Category = "Ignored";
            }
        }
Example #3
0
        /// <summary>
        /// Processes a PM - writes to file and triggers balloon popup
        /// </summary>
        /// <param name="userInfo"></param>
        /// <param name="msg"></param>
        private void processPM(string userInfo, string msg, string completeStr)
        {
            var settingsMgr = SettingsManager.getMgr();
            int userEndInd  = userInfo.LastIndexOf('>');

            User targUser = users.GetUserFromName(userInfo.Substring(1, userEndInd - 1));

            settingsMgr.writePM(DateTime.Now.ToString() + ": " + completeStr);
            if (TrayMgr != null)
            {
                TrayMgr.handleTrayEvent(Util.TrayFlags.PopValues.pmRecieved, targUser, msg);
            }
        }
Example #4
0
        /// <summary>
        /// Updates the window - calls dispatcher so correct thread is invoked
        /// </summary>
        /// <param name="bundle"></param>
        public void WindowUpdate(GUIBundle bundle)
        {
            if (bundle.Users != null)
            {
                listBox1.Dispatcher.Invoke(Userup, bundle.Users.users);
            }
            if (bundle.ChatText != null)
            {
                Dispatcher.BeginInvoke((Action)(() =>
                {
                    //The message will not appear if ignored
                    if (SettingsManager.getMgr().isIgnored(bundle.TargetUserString))
                    {
                        return;
                    }


                    //Stupid text coloring!  Better way to do this using flow documents?

                    Random rand = new Random();

                    var dateText = new TextRange(richTextBox1.Document.ContentEnd, richTextBox1.Document.ContentEnd);

                    dateText.Text = "(" + DateTime.Now.ToShortTimeString() + ") ";

                    dateText.ApplyPropertyValue(TextElement.ForegroundProperty, ColorUtil.txtColors[0]);
                    dateText.ApplyPropertyValue(TextElement.FontWeightProperty, FontWeights.Normal);

                    TextRange username = new TextRange(richTextBox1.Document.ContentEnd, richTextBox1.Document.ContentEnd);

                    username.Text = bundle.TargetUserString;

                    var randColor = ColorUtil.txtColors[rand.Next(0, ColorUtil.txtColors.Count)];

                    username.ApplyPropertyValue(TextElement.ForegroundProperty, randColor);
                    username.ApplyPropertyValue(TextElement.FontWeightProperty, FontWeights.Bold);

                    var chatText = new TextRange(richTextBox1.Document.ContentEnd, richTextBox1.Document.ContentEnd);

                    chatText.Text = ": " + bundle.ChatText + Environment.NewLine;

                    chatText.ApplyPropertyValue(TextElement.ForegroundProperty, ColorUtil.txtColors[0]);
                    chatText.ApplyPropertyValue(TextElement.FontWeightProperty, FontWeights.Normal);

                    Logger.logChat(bundle.TargetUserString + " - " + bundle.ChatText);

                    //We only want the textbox to autoscroll when the scrollbar is at the bottom, otherwise no autoscroll
                    //Code adopted from MSDN: http://social.msdn.microsoft.com/Forums/en-AU/wpf/thread/25a08bda-dc5e-4689-a6b0-7d4d78aff06b

                    //Get vertical scroll position
                    double dVer = richTextBox1.VerticalOffset;

                    //Get vertical size of scrollable content area
                    double dViewport = richTextBox1.ViewportHeight;

                    //Get vertical size of visible content area
                    double dExtent = richTextBox1.ExtentHeight;

                    if (dVer != 0)
                    {
                        if (dVer + dViewport == dExtent)
                        {
                            // richTextBox1.Focus();
                            richTextBox1.ScrollToEnd();
                            // textBox1.Focus();
                        }
                    }
                }
                                                ));
            }
            if (bundle.MOTDText != null)
            {
                Dispatcher.BeginInvoke((Action)(() => {
                    var motd = new TextRange(richTextBox1.Document.ContentEnd, richTextBox1.Document.ContentEnd);

                    motd.Text = "(" + DateTime.Now.ToShortTimeString() + ") " + bundle.MOTDText + Environment.NewLine;

                    motd.ApplyPropertyValue(TextElement.ForegroundProperty, ColorUtil.txtColors[0]);
                    motd.ApplyPropertyValue(TextElement.FontWeightProperty, FontWeights.Bold);


                    //We only want the textbox to autoscroll when the scrollbar is at the bottom, otherwise no autoscroll
                    //Code adopted from MSDN: http://social.msdn.microsoft.com/Forums/en-AU/wpf/thread/25a08bda-dc5e-4689-a6b0-7d4d78aff06b

                    //Get vertical scroll position
                    double dVer = richTextBox1.VerticalOffset;

                    //Get vertical size of scrollable content area
                    double dViewport = richTextBox1.ViewportHeight;

                    //Get vertical size of visible content area
                    double dExtent = richTextBox1.ExtentHeight;

                    if (dVer != 0)
                    {
                        if (dVer + dViewport == dExtent)
                        {
                            //richTextBox1.Focus();
                            richTextBox1.ScrollToEnd();
                            //textBox1.Focus();
                        }
                    }
                }
                                                ));
            }
        }