예제 #1
0
        private void mmFileOpen_Click(object sender, EventArgs e)
        {
            openLogFileDialog.Title = "Open log file";
            if (openLogFileDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            PacketTabPage tp = new PacketTabPage();

            tp.lbPackets.DrawItem             += lbPackets_DrawItem;
            tp.lbPackets.SelectedIndexChanged += lbPackets_SelectedIndexChanged;
            tcPackets.TabPages.Add(tp);
            tp.Text = MakeTabName(openLogFileDialog.FileName);

            tp.PLLoaded.Clear();
            tp.PLLoaded.Filter.Clear();
            if (!tp.PLLoaded.LoadFromFile(openLogFileDialog.FileName))
            {
                MessageBox.Show("Error loading file: " + openLogFileDialog.FileName, "File Open Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                tp.PLLoaded.Clear();
                return;
            }
            Text = defaultTitle + " - " + openLogFileDialog.FileName;
            tp.LoadedFileTitle = openLogFileDialog.FileName;
            tp.PL.CopyFrom(tp.PLLoaded);
            FillListBox(tp.lbPackets, tp.PL);
        }
예제 #2
0
        private void MmAddFromClipboard_Click(object sender, EventArgs e)
        {
            if ((!Clipboard.ContainsText()) || (Clipboard.GetText() == string.Empty))
            {
                MessageBox.Show("Nothing to paste", "Paste from Clipboard", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            try
            {
                PacketTabPage tp       = GetCurrentOrNewPacketTabPage();
                var           cText    = Clipboard.GetText().Replace("\r", "");
                List <string> clipText = new List <string>();
                clipText.AddRange(cText.Split((char)10).ToList());

                tp.Text            = "Clipboard";
                tp.LoadedFileTitle = "Paste from Clipboard";

                if (!tp.PLLoaded.LoadFromStringList(clipText, PacketLogFileFormats.Unknown, PacketLogTypes.Unknown))
                {
                    MessageBox.Show("Error loading data from clipboard", "Clipboard Paste Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    tp.PLLoaded.Clear();
                    return;
                }
                Text = defaultTitle + " - " + tp.LoadedFileTitle;
                tp.PL.CopyFrom(tp.PLLoaded);
                FillListBox(tp.lbPackets, tp.PL);
            }
            catch (Exception x)
            {
                MessageBox.Show("Paste Failed, Exception: " + x.Message, "Paste from Clipboard", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #3
0
        private void CbShowBlock_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (!cbShowBlock.Enabled)
            {
                return;
            }

            if (!(tcPackets.SelectedTab is PacketTabPage))
            {
                return;
            }
            PacketTabPage tp = (tcPackets.SelectedTab as PacketTabPage);

            cbShowBlock.Enabled = false;
            if ((tp.lbPackets.SelectedIndex < 0) || (tp.lbPackets.SelectedIndex >= tp.PL.Count()))
            {
                rtInfo.SelectionColor     = rtInfo.ForeColor;
                rtInfo.SelectionBackColor = rtInfo.BackColor;
                rtInfo.Text = "Please select a valid item from the list";
                return;
            }
            PacketData pd = tp.PL.GetPacket(tp.lbPackets.SelectedIndex);
            var        sw = cbShowBlock.SelectedIndex;

            if (sw >= 0)
            {
                UpdatePacketDetails(tp, pd, cbShowBlock.Items[sw].ToString());
            }
            else
            {
                UpdatePacketDetails(tp, pd, "-");
            }
            cbShowBlock.Enabled = true;
            tp.lbPackets.Invalidate();
        }
        public void LoadFromPacketTapPage(PacketTabPage sourceTP)
        {
            tp = sourceTP;

            if (tp != null)
            {
                CreateVisualTags(tp.ProjectTags);
                tTagBox.Text        = "";
                tProjectFolder.Text = tp.ProjectFolder;
                cbOpenedLog.Text    = tp.LoadedLogFile;
                tSourceVideo.Text   = tp.LinkVideoFileName;
                tYoutubeURL.Text    = tp.LinkYoutubeURL;
                tPackedLogsURL.Text = tp.LinkPacketsDownloadURL;
                cbOpenedLog.Items.Clear();
                AddLogOption(tp.LoadedLogFile); // Current Log File
                cbOpenedLog.Text = tp.LoadedLogFile;
                var           logfiles = Directory.GetFiles(tp.ProjectFolder, "*.log", SearchOption.AllDirectories);
                var           txtfiles = Directory.GetFiles(tp.ProjectFolder, "*.txt", SearchOption.AllDirectories);
                var           sqlfiles = Directory.GetFiles(tp.ProjectFolder, "*.sqlite", SearchOption.AllDirectories);
                List <string> files    = new List <string>();
                files.AddRange(logfiles);
                files.AddRange(txtfiles);
                files.AddRange(sqlfiles);
                foreach (var f in files)
                {
                    if (!Path.GetFileName(f).ToLower().StartsWith("0x"))
                    {
                        AddLogOption(f);
                    }
                }

                gbProjectInfo.Text = "Project Information: " + Path.GetFileName(tp.ProjectFile);
            }
        }
예제 #5
0
        private void UpdatePacketDetails(PacketTabPage tp, PacketData pd, string SwitchBlockName)
        {
            if (tp == null)
            {
                return;
            }
            tp.CurrentSync = pd.PacketSync;
            lInfo.Text     = pd.OriginalHeaderText;
            rtInfo.Clear();

            PP = new PacketParser(pd.PacketID, pd.PacketLogType);
            PP.AssignPacket(pd);
            PP.ParseToDataGridView(dGV, SwitchBlockName);
            if (PP.SwitchBlocks.Count > 0)
            {
                cbShowBlock.Items.Clear();
                cbShowBlock.Items.Add("-");
                cbShowBlock.Items.AddRange(PP.SwitchBlocks.ToArray());
                cbShowBlock.Show();
            }
            else
            {
                cbShowBlock.Items.Clear();
                cbShowBlock.Hide();
            }
            for (int i = 0; i < cbShowBlock.Items.Count; i++)
            {
                if ((SwitchBlockName == "-") && (cbShowBlock.Items[i].ToString() == PP.LastSwitchedBlock))
                {
                    if (cbShowBlock.SelectedIndex != i)
                    {
                        cbShowBlock.SelectedIndex = i;
                    }
                    //break;
                }
                else
                if (cbShowBlock.Items[i].ToString() == SwitchBlockName)
                {
                    if (cbShowBlock.SelectedIndex != i)
                    {
                        cbShowBlock.SelectedIndex = i;
                    }
                    //break;
                }
            }

            if (cbOriginalData.Checked)
            {
                rtInfo.SelectionColor     = rtInfo.ForeColor;
                rtInfo.SelectionBackColor = rtInfo.BackColor;
                rtInfo.Text = "Source:\r\n" + string.Join("\r\n", pd.RawText.ToArray());
            }
            else
            {
                RawDataToRichText(PP, rtInfo);
            }
        }
예제 #6
0
        private PacketTabPage GetCurrentOrNewPacketTabPage()
        {
            PacketTabPage tp = GetCurrentPacketTabPage();

            if (tp == null)
            {
                tp = new PacketTabPage();
                tp.lbPackets.DrawItem             += lbPackets_DrawItem;
                tp.lbPackets.SelectedIndexChanged += lbPackets_SelectedIndexChanged;
                tcPackets.TabPages.Add(tp);
            }
            return(tp);
        }
예제 #7
0
        private void TcPackets_SelectedIndexChanged(object sender, EventArgs e)
        {
            TabControl tc = (sender as TabControl);

            if (!(tc.SelectedTab is PacketTabPage))
            {
                return;
            }
            PacketTabPage tp = (tc.SelectedTab as PacketTabPage);

            Text = defaultTitle + " - " + tp.LoadedFileTitle;
            PacketData pd = tp.PL.GetPacket(tp.lbPackets.SelectedIndex);

            cbShowBlock.Enabled = false;
            UpdatePacketDetails(tp, pd, "-");
            cbShowBlock.Enabled = true;
        }
        private void BtnTest_Click(object sender, EventArgs e)
        {
            PacketTabPage tp = MainForm.thisMainForm.GetCurrentPacketTabPage();

            if (tp == null)
            {
                return;
            }

            PacketData pd = tp.GetSelectedPacket();

            if (pd == null)
            {
                return;
            }

            MainForm.thisMainForm.CurrentPP.RawParseData.Clear();
            MainForm.thisMainForm.CurrentPP.RawParseData.AddRange(editBox.Lines);
            MainForm.thisMainForm.CurrentPP.ParsedView.Clear();
            MainForm.thisMainForm.UpdatePacketDetails(tp, pd, "-", true);
        }
예제 #9
0
        private void mmFileAppend_Click(object sender, EventArgs e)
        {
            openLogFileDialog.Title = "Append log file";
            if (openLogFileDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            PacketTabPage tp = GetCurrentOrNewPacketTabPage();

            tp.Text            = "Multi";
            tp.LoadedFileTitle = "Multiple Sources";

            if (!tp.PLLoaded.LoadFromFile(openLogFileDialog.FileName))
            {
                MessageBox.Show("Error loading file: " + openLogFileDialog.FileName, "File Append Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                tp.PLLoaded.Clear();
                return;
            }
            Text = defaultTitle + " - " + tp.LoadedFileTitle;
            tp.PL.CopyFrom(tp.PLLoaded);
            FillListBox(tp.lbPackets, tp.PL);
        }
예제 #10
0
        private void cbOriginalData_CheckedChanged(object sender, EventArgs e)
        {
            if (!(tcPackets.SelectedTab is PacketTabPage))
            {
                rtInfo.SelectionColor     = rtInfo.ForeColor;
                rtInfo.SelectionBackColor = rtInfo.BackColor;
                rtInfo.Text = "Please select open a list first";
                return;
            }
            PacketTabPage tp = (tcPackets.SelectedTab as PacketTabPage);
            ListBox       lb = tp.lbPackets;

            if ((lb.SelectedIndex < 0) || (lb.SelectedIndex >= tp.PL.Count()))
            {
                rtInfo.SelectionColor     = rtInfo.ForeColor;
                rtInfo.SelectionBackColor = rtInfo.BackColor;
                rtInfo.Text = "Please select a valid item from the list";
                return;
            }
            PacketData pd = tp.PL.GetPacket(lb.SelectedIndex);

            UpdatePacketDetails(tp, pd, "-");
        }
예제 #11
0
        private void VideoLinkForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            packetUpdateTimer.Enabled = false;
            if (sourceTP != null)
            {
                sourceTP.videoLink = null;
                sourceTP           = null;
            }

            if (media.IsPlaying)
            {
                try
                {
                    e.Cancel              = true;
                    closeOnStop           = true;
                    closeFixTimer.Enabled = true;
                    media.ResetMedia();
                }
                catch
                {
                }
            }
        }
예제 #12
0
 private void VideoLinkForm_Load(object sender, EventArgs e)
 {
     Left = MainForm.thisMainForm.Right - Width - 16;
     Top  = MainForm.thisMainForm.Bottom - Height - 16;
     if (sourceTP == null)
     {
         Text = "Video not attached to a packet list";
         btnSetOffset.Enabled       = false;
         cbFollowPacketList.Checked = false;
         cbFollowPacketList.Enabled = false;
         return;
     }
     if (!File.Exists(sourceTP.LoadedLogFile))
     {
         MessageBox.Show("Can only link video to complete log files", "Video Link", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         Text     = "Video not attached to a packet list";
         sourceTP = null;
         return;
     }
     Text = "Video - " + sourceTP.LoadedLogFile;
     sourceTP.videoLink = this;
     LoadVideoFromProjectFile();
 }
예제 #13
0
        public void lbPackets_SelectedIndexChanged(object sender, EventArgs e)
        {
            ListBox lb = (sender as ListBox);

            if (!(lb.Parent is PacketTabPage))
            {
                return;
            }
            PacketTabPage tp = (lb.Parent as PacketTabPage);

            if ((lb.SelectedIndex < 0) || (lb.SelectedIndex >= tp.PL.Count()))
            {
                rtInfo.SelectionColor     = rtInfo.ForeColor;
                rtInfo.SelectionBackColor = rtInfo.BackColor;
                rtInfo.Text = "Please select a valid item from the list";
                return;
            }
            PacketData pd = tp.PL.GetPacket(lb.SelectedIndex);

            cbShowBlock.Enabled = false;
            UpdatePacketDetails(tp, pd, "-");
            cbShowBlock.Enabled = true;
            lb.Invalidate();
        }
예제 #14
0
        public void lbPackets_DrawItem(object sender, DrawItemEventArgs e)
        {
            ListBox lb = (sender as ListBox);

            if (!(lb.Parent is PacketTabPage))
            {
                return;
            }
            PacketTabPage tp = (lb.Parent as PacketTabPage);
            PacketData    pd = null;

            if ((e.Index >= 0) && (e.Index < tp.PL.Count()))
            {
                pd = tp.PL.GetPacket(e.Index);
            }
            else
            {
                // Draw the background of the ListBox control for each item.
                e.DrawBackground();
                return;
            }

            bool  barOn      = (tp.CurrentSync == pd.PacketSync);
            bool  isSelected = (e.Index == lb.SelectedIndex);
            Color textCol;
            Color backCol;
            Color barCol;

            // Determine the color of the brush to draw each item based
            // on the index of the item to draw.
            switch (pd.PacketLogType)
            {
            case PacketLogTypes.Incoming:
                textCol = Properties.Settings.Default.ColFontIN;
                if (isSelected)
                {
                    backCol = Properties.Settings.Default.ColSelectIN;
                    textCol = Properties.Settings.Default.ColSelectedFontIN;
                }
                else
                if (barOn)
                {
                    backCol = Properties.Settings.Default.ColSyncIN;
                }
                else
                {
                    backCol = Properties.Settings.Default.ColBackIN;
                }
                barCol = Properties.Settings.Default.ColBarIN;
                break;

            case PacketLogTypes.Outgoing:
                textCol = Properties.Settings.Default.ColFontOUT;
                if (isSelected)
                {
                    backCol = Properties.Settings.Default.ColSelectOUT;
                    textCol = Properties.Settings.Default.ColSelectedFontOUT;
                }
                else
                if (barOn)
                {
                    backCol = Properties.Settings.Default.ColSyncOUT;
                }
                else
                {
                    backCol = Properties.Settings.Default.ColBackOUT;
                }
                barCol = Properties.Settings.Default.ColBarOUT;
                break;

            default:
                textCol = Properties.Settings.Default.ColFontUNK;
                if (isSelected)
                {
                    backCol = Properties.Settings.Default.ColSelectUNK;
                    textCol = Properties.Settings.Default.ColSelectedFontUNK;
                }
                else
                if (barOn)
                {
                    backCol = Properties.Settings.Default.ColSyncUNK;
                }
                else
                {
                    backCol = Properties.Settings.Default.ColBackUNK;
                }
                barCol = Properties.Settings.Default.ColBarUNK;
                break;
            }

            // Define the colors of our brushes.
            Brush textBrush = new SolidBrush(textCol);
            Brush backBrush = new SolidBrush(backCol);
            Brush barBrush  = new SolidBrush(barCol);

            // Draw the background of the ListBox control for each item.
            e.Graphics.FillRectangle(backBrush, e.Bounds);

            // Draw the current item text based on the current Font
            // and the custom brush settings.
            e.Graphics.DrawString(lb.Items[e.Index].ToString(),
                                  e.Font, textBrush, e.Bounds, StringFormat.GenericDefault);
            if (barOn)
            {
                var barSize = 8;
                if (isSelected)
                {
                    barSize = 16;
                }
                e.Graphics.FillRectangle(barBrush, new Rectangle(e.Bounds.Right - barSize, e.Bounds.Top, barSize, e.Bounds.Height));
            }
            // If the ListBox has focus, draw a focus rectangle around the selected item.
            e.DrawFocusRectangle();
        }