Example #1
0
        public void CalculatePercentage()
        {
            foreach (KeyValuePair <UInt16, PidProfile> pair in pidList)
            {
                PidProfile pidProfile = pair.Value;

                pidProfile.Percentage = (float)pidProfile.PacketCount * 100 / (float)totalPacketCount;
            }
        }
Example #2
0
        private void toolStripMenuItemSearch_Click(object sender, EventArgs e)
        {
            TreeNode selectedNode = treeViewParser.SelectedNode;

            if (selectedNode != null)
            {
                if (selectedNode.Tag is PidProfile)
                {
                    PidProfile currentPidProfile = (PidProfile)selectedNode.Tag;
                    RequestToSearch(currentPidProfile);
                }
            }
        }
Example #3
0
        }         //buttonRemove_Click

        private int AddPidProfile(PidProfile oldPidProfile)
        {
            int index = 0;

            foreach (PidProfile pidProfile in listBoxPidIn.Items)
            {
                if (pidProfile.PID > oldPidProfile.PID)
                {
                    break;
                }

                index++;
            }

            listBoxPidIn.Items.Insert(index, oldPidProfile);

            return(index);
        }//AddPidProfile
Example #4
0
        private void RequestToSearch(PidProfile currentPidProfile)
        {
            //Create search form.
            FormSearch searchForm = new FormSearch();

            //Pass PID list to the search form so that it can display the PID for user selection.
            searchForm.PidList = this.pidList;
            searchForm.SetSelectedPidProfile(currentPidProfile);

            DialogResult dialogResult = searchForm.ShowDialog();

            if (dialogResult == DialogResult.OK)
            {
                searchRequest = searchForm.GetSearchRequest();
                //Call the start to notify the plugin that we have started the search.
                searchRequest.SelectedParser.Start();

                //Create a new node to indicate the search.
                CreateSearchNode(searchRequest);

                WorkerFileDataSearch dataSearcher = new WorkerFileDataSearch(this, ProcessWorkerMessage, searchRequest);

                //On stream start. Initialize the environment.
                OnStreamStart();

                Result result = dataSearcher.StartParse(streamFile);

                if (result.Fine)
                {
                }
                else
                {
                    //Something unexpected happened, we will cancel the search.
                    searchRequest.SelectedParser.Stop();

                    //On stream stop. Finalize the environment.
                    OnStreamStop();
                }
            }
        }
Example #5
0
        private void SetPidType(UInt16 pidValue, DataType dataType, String description)
        {
            PidProfile pidProfile = null;

            if (pidList.TryGetValue(pidValue, out pidProfile))
            {
                //We have find an existing item in the list.
            }
            else
            {
                //Create a new one.
                pidProfile = new PidProfile();

                //Add it into the list.
                pidList.Add(pidValue, pidProfile);

                //Save the value.
                pidProfile.PID = pidValue;
            }

            pidProfile.Type        = dataType;
            pidProfile.Description = description;
        }
Example #6
0
        public void AddPacket(UInt16 pidValue)
        {
            PidProfile pidProfile = null;

            if (pidList.TryGetValue(pidValue, out pidProfile))
            {
                //We have find an existing item in the list.
            }
            else
            {
                //Create a new one.
                pidProfile = new PidProfile();

                //Add it into the list.
                pidList.Add(pidValue, pidProfile);

                //Save the value.
                pidProfile.PID = pidValue;
            }

            pidProfile.PacketCount++;
            totalPacketCount++;
        }
Example #7
0
 public void SetSelectedPidProfile(PidProfile pidProfile)
 {
     selectedPidProfile = pidProfile;
 }
Example #8
0
 private void listBoxPid_SelectedIndexChanged(object sender, EventArgs e)
 {
     selectedPidProfile = (PidProfile)listBoxPid.SelectedItem;
 }
Example #9
0
 public PidUpdate(PidProfile oldPidInfo, UInt16 newPidValue, bool enforceNewPid)
 {
     this.oldPid        = oldPidInfo;
     this.newPid        = newPidValue;
     this.enforceNewPid = enforceNewPid;
 }
Example #10
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            Result     result                = new Result();
            PidProfile selectedItem          = (PidProfile)listBoxPidIn.SelectedItem;
            int        leftSideSelectedIndex = listBoxPidIn.SelectedIndex;

            if (result.Fine)
            {
                if (null == selectedItem)
                {
                    MessageBox.Show("Please select one PID one the left side.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    result.SetResult(ResultCode.INVALID_DATA);
                }
            }

            UInt16 newPid = 0;

            if (result.Fine)
            {
                //Force the user to enter a new PID.
                if (enforceNewPid)
                {
                    try
                    {
                        //Get the new PID from user input.
                        newPid = UInt16.Parse(maskedTextBoxNewPid.Text);

                        Console.WriteLine("New PID is " + newPid);
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("Invalid PID. Please enter a valid UInt16 PID.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        result.SetResult(ResultCode.INVALID_DATA);
                        maskedTextBoxNewPid.Focus();
                    }
                }
                else
                {
                    //New PID in fact is the same with the old PID on left side. Just to reuse the same structurer to make the code simple.
                    newPid = selectedItem.PID;
                }
            }

            if (result.Fine)
            {
                ListBox.SelectedObjectCollection selectedProfileCollection = listBoxPidIn.SelectedItems;
                Array selectedProfileArray = Array.CreateInstance(typeof(PidProfile), listBoxPidIn.SelectedItems.Count);
                selectedProfileCollection.CopyTo(selectedProfileArray, 0);//Make a copy of all the selected items.

                foreach (PidProfile pidProfile in selectedProfileArray)
                {
                    int leftIndex = listBoxPidIn.Items.IndexOf(pidProfile);
                    //Remove the left item.
                    listBoxPidIn.Items.Remove(pidProfile);

                    //Add to the right side.
                    int rightIndex = listBoxPidOut.Items.Add(new PidUpdate(pidProfile, newPid, enforceNewPid));
                    listBoxPidOut.SelectedIndex = rightIndex;

                    //Select the next item.
                    if (listBoxPidIn.Items.Count > 0)
                    {
                        if (leftIndex < listBoxPidIn.Items.Count)
                        {
                            listBoxPidIn.SelectedIndex = leftIndex;
                        }
                        else
                        {
                            if ((leftIndex - 1) >= 0)
                            {
                                listBoxPidIn.SelectedIndex = leftIndex - 1;
                            }
                        }
                    } //if (listBoxPid.Items.Count > 0)
                }     //foreach (PidProfile pidProfile in selectedProfileArray)
            }
        }