示例#1
0
        public void ImageFromMsgLevel(PictureBox pic, MessageLevels msgLevel)
        {
            switch (msgLevel)
            {
            case MessageLevels.Error:
                pic.Image = Properties.Resources.Checkbox_Error;
                pic.Name  = "";
                break;

            case MessageLevels.Warning:
                pic.Image = Properties.Resources.Checkbox_Warning;
                pic.Name  = "";
                break;

            case MessageLevels.Ok:
                pic.Image = Properties.Resources.Checkbox_Ok;
                pic.Name  = "";
                break;

            case MessageLevels.Animate:
                if (pic.Name.StartsWith(_ctrlRoundRobinName))
                {
                    break;
                }
                pic.Image = Properties.Resources.Checkbox_Work0;
                pic.Name  = CreateAnimControlName(0);
                break;

            default:
                pic.Image = Properties.Resources.Checkbox_Ok;
                break;
            }
        }
示例#2
0
 public void GetFirstImage(PictureBox pic, string modkey, MessageLevels msgLevel)
 {
     //no mod key. no anime for you buddy.
     if (string.IsNullOrEmpty(modkey) && msgLevel == MessageLevels.Animate && Debugger.IsAttached)
     {
         throw new Exception("Developer mind melt. this is wrong");
     }
     ImageFromMsgLevel(pic, msgLevel);
 }
示例#3
0
        private bool MessageFilter(object item)
        {
            if (!(item is IMessage message))
            {
                return(false);
            }

            foreach (var level in MessageLevels.Where(l => l.Show))
            {
                if (message.Level == level.Level)
                {
                    return(true);
                }
            }
            return(false);
        }
示例#4
0
        private void Notify(string msg, MessageLevels msgLevel, string modKey = "")
        {
            if (picCheckbox.IsDisposed || picCheckbox.Disposing)
            {
                return;
            }

            picCheckbox.Invoke(new Action(() =>
            {
                try
                {
                    bool modKeyFound = false;
                    if (!string.IsNullOrEmpty(modKey))
                    {
                        foreach (Control ctrl in Controls)
                        {
                            if (ctrl.Tag?.ToString() == modKey)
                            {
                                if (ctrl is PictureBox inPic)
                                {
                                    _anime.ImageFromMsgLevel(inPic, msgLevel);
                                }
                                else if (ctrl is Label inLbl)
                                {
                                    inLbl.Text = msg;
                                }

                                modKeyFound = true;
                            }
                        }

                        if (modKeyFound)
                        {
                            return;
                        }
                    }

                    if (_lblLastCreatedPos == 0)
                    {
                        _lblLastCreatedPos = picCheckbox.Top;
                    }
                    _lblLastCreatedPos += 30;
                    var pic             = picCheckbox.Clone();
                    _anime.GetFirstImage(pic, modKey, msgLevel);
                    pic.Top     = _lblLastCreatedPos;
                    pic.Visible = true;
                    pic.Tag     = modKey + "";
                    var lbl     = lblMsg.Clone();
                    lbl.Top     = _lblLastCreatedPos;
                    lbl.Text    = msg;
                    lbl.Visible = true;
                    lbl.Tag     = modKey + "";
                    picCircles.SendToBack();
                    Log.Add($"Notified on:{msg}");
                }
                catch (Exception ex)
                {
                    Log.Add($"Notify failed  ex:{ex}");
                }
                finally
                {
                    Application.DoEvents();
                }
            }));
        }
示例#5
0
 public TranslationMessage(string text, MessageLevels level)
 {
     Text  = text;
     Level = level;
 }
示例#6
0
 public TranslationMessage(string Text, MessageLevels Level)
 {
     this.Text  = Text;
     this.Level = Level;
 }
示例#7
0
        public void Log(MessageLevels level, string text)
        {
            var a = new TranslationMessage(text, level);

            _logs.Add(a);
        }
示例#8
0
 public void Log(MessageLevels level, string text)
 {
     var a = new TranslationMessage(text, level);
     _logs.Add(a);
 }
示例#9
0
 public TranslationMessage(string Text, MessageLevels Level)
 {
     this.Text = Text;
     this.Level = Level;
 }