Пример #1
0
        public ServerTab()
        {
            Font = Config.ChatFont;
            InitializeComponent();
            if (Process.GetCurrentProcess().ProcessName == "devenv" && !Debugger.IsAttached) return;
            textBox = new ChatBox { Dock = DockStyle.Fill };
            Controls.Add(textBox);
            filterBox = new SendBox { Dock = DockStyle.Bottom, Text = "Filter (press enter)" };
            Controls.Add(filterBox);
            sendBox = new SendBox { Dock = DockStyle.Bottom, Text = "Raw Send" };
            Controls.Add(sendBox);
            Program.TasClient.Input += TasClient_Input;
            Program.TasClient.Output += TasClient_Output;
            sendBox.LineEntered += (s, e) => Program.TasClient.SendRaw(e.Data);
            filterBox.LineEntered += (s, e) =>
                {
                    textBox.ClearTextWindow();
                    
                    textBox.TextFilter = e.Data;
                    var filtered = entries.Where(x => textBox.PassesFilter(x)).ToList();
                    foreach (var chatLine in filtered.Skip(Math.Max(filtered.Count - DisplayLines, 0)).Take(DisplayLines)) textBox.AddLine(chatLine);
                    
                };
            VisibleChanged += (sender, args) =>
                {
                    if (prevVis != Visible && Visible) {
                        textBox.ClearTextWindow();
                        foreach (var chatLine in entries.Skip(Math.Max(entries.Count - DisplayLines, 0)).Take(DisplayLines)) textBox.AddLine(chatLine);
                    }
                    prevVis = Visible;
                };

            textBox.ChatBackgroundColor = TextColor.background; //same as Program.Conf.BgColor but TextWindow.cs need this.
            textBox.IRCForeColor = 14; //mirc grey. Unknown use
        }
Пример #2
0
 void TasClient_Input(object sender, TasInputArgs e)
 {
     if (e != null && e.Command != null)
     {
         var entry = new FromServerLine(e.Command, e.Args);
         entries.Add(entry);
         if (prevVis)
         {
             Program.MainWindow.InvokeFunc(() => textBox.AddLine(entry));
         }
     }
 }
Пример #3
0
 void TasClient_Input(object sender, string o)
 {
     if (o != null)
     {
         var entry = new FromServerLine(o);
         entries.Add(entry);
         if (prevVis)
         {
             Program.MainWindow.InvokeFunc(() => textBox.AddLine(entry));
         }
     }
 }
Пример #4
0
        public ServerTab()
        {
            InitializeComponent();
            if (Process.GetCurrentProcess().ProcessName == "devenv" && !Debugger.IsAttached)
            {
                return;
            }
            textBox = new ChatBox {
                Dock = DockStyle.Fill
            };
            Controls.Add(textBox);
            filterBox = new SendBox {
                Dock = DockStyle.Bottom, Text = "Filter (press enter)"
            };
            Controls.Add(filterBox);
            sendBox = new SendBox {
                Dock = DockStyle.Bottom, Text = "Raw Send"
            };
            Controls.Add(sendBox);
            Program.TasClient.Input  += TasClient_Input;
            Program.TasClient.Output += TasClient_Output;
            sendBox.LineEntered      += (s, e) => Program.TasClient.SendRaw(e.Data);
            filterBox.LineEntered    += (s, e) =>
            {
                textBox.ClearTextWindow();

                textBox.TextFilter = e.Data;
                var filtered = entries.Where(x => textBox.PassesFilter(x)).ToList();
                foreach (var chatLine in filtered.Skip(Math.Max(filtered.Count - DisplayLines, 0)).Take(DisplayLines))
                {
                    textBox.AddLine(chatLine);
                }
            };
            VisibleChanged += (sender, args) =>
            {
                if (prevVis != Visible && Visible)
                {
                    textBox.ClearTextWindow();
                    foreach (var chatLine in entries.Skip(Math.Max(entries.Count - DisplayLines, 0)).Take(DisplayLines))
                    {
                        textBox.AddLine(chatLine);
                    }
                }
                prevVis = Visible;
            };

            textBox.ChatBackgroundColor = TextColor.background; //same as Program.Conf.BgColor but TextWindow.cs need this.
            textBox.IRCForeColor        = 14;                   //mirc grey. Unknown use
        }
Пример #5
0
        public void AddLine([NotNull] IChatLine line)
        {
            if (line == null)
            {
                throw new ArgumentNullException("line");
            }
            if ((line is SaidLine && Program.Conf.IgnoredUsers.Contains(((SaidLine)line).AuthorName)) ||
                (line is SaidExLine && Program.Conf.IgnoredUsers.Contains(((SaidExLine)line).AuthorName)))
            {
                return;
            }

            ChatBox.AddLine(line);
            HistoryManager.LogLine(UserName, line);
            var saidLine = line as SaidLine;

            if (saidLine != null && WindowsApi.IdleTime.TotalMinutes > Program.Conf.IdleTime &&
                (DateTime.Now - lastAnsweringMessageTime).TotalMinutes > Program.Conf.IdleTime)
            {
                if (saidLine.AuthorName != Program.TasClient.UserName)
                {
                    Program.TasClient.Say(SayPlace.User,
                                          UserName,
                                          String.Format("Answering machine: I have been idle for {0} minutes.", (int)WindowsApi.IdleTime.TotalMinutes),
                                          false);
                    lastAnsweringMessageTime = DateTime.Now;
                }
            }
        }
Пример #6
0
 public virtual void AddLine(IChatLine line)
 {
     if (ChannelName != "zkadmin" &&
         ((line is SaidLine && Program.Conf.IgnoredUsers.Contains(((SaidLine)line).AuthorName)) ||
          (line is SaidExLine && Program.Conf.IgnoredUsers.Contains(((SaidExLine)line).AuthorName))))
     {
         return;
     }
     ChatBox.AddLine(line);
     ChannelLineAdded(this, new ChannelLineArgs()
     {
         Channel = ChannelName, Line = line
     });
     HistoryManager.LogLine(ChannelName, line);
 }
 public static void InsertLastLines(string channelName, ChatBox control)
 {
     try
     {
         var historyFileName = channelName + ".txt";
         if (!File.Exists(Path.Combine(GetHistoryFolder(), historyFileName))) return;
         var lines = GetLines(historyFileName);
         for (var i = Math.Max(0, lines.Length - HistoryLines); i < lines.Length; i++)
         {
             control.AddLine(new HistoryLine(lines[i].StripAllCodes()));
         }
     }
     catch (Exception e)
     {
         Trace.WriteLine("History manager: " + e);
     }
 }
Пример #8
0
 public static void InsertLastLines(string channelName, ChatBox control)
 {
     try
     {
         var historyFileName = channelName + ".txt";
         if (!File.Exists(Path.Combine(GetHistoryFolder(), historyFileName)))
         {
             return;
         }
         var lines = GetLines(historyFileName);
         for (var i = Math.Max(0, lines.Length - HistoryLines); i < lines.Length; i++)
         {
             control.AddLine(new HistoryLine(lines[i].StripAllCodes()));
         }
     }
     catch (Exception e)
     {
         Trace.WriteLine("History manager: " + e);
     }
 }