示例#1
0
 private void WriteHighlight(string message, Color highlight)
 {
     LoggerTxt.SelectionStart  = LoggerTxt.TextLength;
     LoggerTxt.SelectionLength = 0;
     LoggerTxt.SelectionColor  = highlight;
     LoggerTxt.AppendText(message);
 }
示例#2
0
        public void Write(InterceptedEventArgs e)
        {
            if (InvokeRequired)
            {
                Invoke(_write, e);
            }
            else
            {
                bool toServer = (e.Packet.Destination == HDestination.Server);

                string directionArrow = (toServer ? "->" : "<-");
                string packetType     = (toServer ? "Outgoing" : "Incoming");
                string dataLog        = $"{packetType}({e.Replacement.Header}, {e.Replacement.Length}) {directionArrow} {e.Replacement}";

                Color highlight = toServer ?
                                  OutgoingHighlight : IncomingHighlight;

                if (e.IsBlocked)
                {
                    WriteHighlight("Blocked | ", BlockHighlight);
                }
                else if (e.WasReplaced)
                {
                    WriteHighlight("Replaced | ", ReplaceHighlight);
                }

                string splitter = (DisplaySplitter ? "\n--------------------\n" : "\n");
                WriteHighlight(dataLog + splitter, highlight);
                LoggerTxt.SelectionStart = LoggerTxt.TextLength;
                LoggerTxt.ScrollToCaret();

                Application.DoEvents();
            }
        }
示例#3
0
 public void Halt()
 {
     _wasClosed = true;
     ToggleItem(ViewIncomingBtn, false);
     ToggleItem(ViewOutgoingBtn, false);
     ToggleItem(DisplaySplitterBtn, false);
     _dataQueue.Clear();
     LoggerTxt.Clear();
 }
示例#4
0
        protected override void OnFormClosing(FormClosingEventArgs e)
        {
            e.Cancel = IsHalted = true;
            Intercepted.Clear();

            LoggerTxt.Clear();
            base.OnFormClosing(e);

            WindowState = FormWindowState.Minimized;
        }
示例#5
0
 protected override void OnActivated(EventArgs e)
 {
     if (!IsReceiving)
     {
         LoggerTxt.Clear();
         IsReceiving = true;
     }
     LogMessageQueue();
     base.OnActivated(e);
 }
示例#6
0
 private void Display(string message, Color highlight)
 {
     LoggerTxt.SelectionStart  = LoggerTxt.TextLength;
     LoggerTxt.SelectionLength = 0;
     LoggerTxt.SelectionColor  = highlight;
     LoggerTxt.AppendText(message + (DisplayVisualSplit ? "\n--------------------\n" : "\n"));
     LoggerTxt.SelectionStart = LoggerTxt.TextLength;
     LoggerTxt.ScrollToCaret();
     Application.DoEvents();
 }
示例#7
0
 public void Halt()
 {
     _wasClosed = true;
     ToggleItem(ToggleIncomingBtn, false);
     ToggleItem(ToggleOutgoingBtn, false);
     ToggleItem(DisplayFiltersBtn, false);
     ToggleItem(DisplayVisualSplitBtn, false);
     _displayQueue.Clear();
     LoggerTxt.Clear();
 }
示例#8
0
        protected override void OnFormClosing(FormClosingEventArgs e)
        {
            IsLoaded    = false;
            e.Cancel    = IsHalted = true;
            WindowState = FormWindowState.Minimized;

            Intercepted.Clear();
            _readQueueTask?.Wait();

            LoggerTxt.Clear();
        }
示例#9
0
 protected override void OnActivated(EventArgs e)
 {
     if (IsHalted)
     {
         IsHalted           = false;
         IsHandlingOutgoing = ViewOutgoingBtn.Checked;
         IsHandlingIncoming = ViewIncomingBtn.Checked;
         LoggerTxt.Clear();
     }
     LogMessageQueue();
     base.OnActivated(e);
 }
示例#10
0
 private void RefreshLog()
 {
     if (InvokeRequired)
     {
         Invoke(_refreshLog);
     }
     else
     {
         LoggerTxt.SelectionStart = LoggerTxt.TextLength;
         LoggerTxt.ScrollToCaret();
     }
 }
示例#11
0
        protected override void OnFormClosing(FormClosingEventArgs e)
        {
            IsReceiving = false;

            e.Cancel = true;
            Intercepted.Clear();

            LoggerTxt.Clear();
            WindowState = FormWindowState.Minimized;

            base.OnFormClosing(e);
        }
示例#12
0
        protected override void OnFormClosing(FormClosingEventArgs e)
        {
            e.Cancel = IsHalted = true;
            Intercepted.Clear();

            IsHandlingOutgoing     =
                IsHandlingIncoming = false;

            LoggerTxt.Clear();
            WindowState = FormWindowState.Minimized;

            base.OnFormClosing(e);
        }
示例#13
0
 public void WriteHighlight(string value, Color highlight)
 {
     if (InvokeRequired)
     {
         Invoke(_writeHighlight, value, highlight);
     }
     else
     {
         LoggerTxt.SelectionStart  = LoggerTxt.TextLength;
         LoggerTxt.SelectionLength = 0;
         LoggerTxt.SelectionColor  = highlight;
         LoggerTxt.AppendText(value);
     }
 }
示例#14
0
        private void Display(string message, DataToEventArgs e)
        {
            Color highlight = (e.Packet.Destination == HDestination.Client
                ? IncomingHighlight : OutgoingHighlight);

            if (e.IsBlocked)
            {
                WriteHighlight("Blocked | ", BlockHighlight);
            }
            else if (e.IsReplaced)
            {
                WriteHighlight("Replaced | ", ReplaceHighlight);
            }

            WriteHighlight(message + (DisplaySplitter ? "\n--------------------\n" : "\n"), highlight);
            LoggerTxt.SelectionStart = LoggerTxt.TextLength;
            LoggerTxt.ScrollToCaret();

            Application.DoEvents();
        }
示例#15
0
 private void EmptyLogBtn_Click(object sender, EventArgs e)
 {
     LoggerTxt.Clear();
 }