public AnalysisWindow()
 {
     InitializeComponent();
     currentTag            = "";
     tagsAnalysisInstances = new Dictionary <string, List <int> >();
     currentHeader         = new InstanceHeader("", "", DateTime.Now);
     currentSelectedIndex  = -1;
     showingIndividual     = false;
     filterLabel.Visible   = false;
     filterCB.Visible      = false;
 }
        private AnalysisInstance[] ConvertRawInstancesToAnalysisInstances(string[] rawInstances)
        {
            List <AnalysisInstance> allInstances = new List <AnalysisInstance>();

            //split entire data

            progressBar.Increment(1);
            //if currentHeader == null, get header from first packet
            if (currentHeader.fromComputer == "")
            {
                string workingString = rawInstances[0];
                int    pFrom         = workingString.IndexOf("[") + 1;
                int    pTo           = workingString.IndexOf("]", 2);
                string time          = workingString.Substring(pFrom, pTo - pFrom);
                //MessageBox.Show(time);

                pFrom = workingString.IndexOf("FROM: ") + 6;
                pTo   = workingString.IndexOf(" | ");
                string computer = workingString.Substring(pFrom, pTo - pFrom);
                //MessageBox.Show(computer);

                pFrom = workingString.IndexOf("User: "******"\n");
                string user = workingString.Substring(pFrom, pTo - pFrom);
                //MessageBox.Show(user);

                currentHeader = new InstanceHeader(computer, user, DateTime.Parse(time));
            }

            for (int i = 1; i < rawInstances.Length; i++)
            {
                try {
                    debugText.Text = "Converting Raw Instances to Analysis Instances ( " + (convertedFilesCount + 1).ToString() + " out of " + (rawInstances.Length - 1).ToString() + " )";
                    progressBar.Increment(1);
                    int currentIndex = 0;

                    string   workingString = rawInstances[i];
                    int      pFrom         = workingString.IndexOf("---*[") + 5;
                    int      pTo           = workingString.IndexOf("]*---");
                    string   allTags       = workingString.Substring(pFrom, pTo - pFrom);
                    string[] tagsArray     = allTags.Split(new string[] { ", " }, StringSplitOptions.None);
                    currentIndex = pFrom + allTags.Length + 5 + 2;

                    pFrom = workingString.IndexOf("TIME=", currentIndex) + 5;
                    pTo   = workingString.IndexOf("\r\n", currentIndex);
                    string   time  = workingString.Substring(pFrom, pTo - pFrom);
                    DateTime dTime = DateTime.Parse(time);

                    currentIndex += time.Length + 5 + 2;

                    pFrom = workingString.IndexOf("[LMB]Current Window: ", currentIndex) + 21;
                    pTo   = workingString.IndexOf("\r\n", currentIndex);
                    string currentWindow = workingString.Substring(pFrom, pTo - pFrom);
                    currentIndex += currentWindow.Length + 5 + 2 + 16;

                    pFrom = currentIndex;
                    pTo   = workingString.IndexOf("Click Count Detected", currentIndex);
                    string currentContent = workingString.Substring(pFrom, pTo - pFrom);
                    currentIndex += currentContent.Length - 2;

                    pFrom = workingString.IndexOf("Click Count Detected: ", currentIndex) + 22;
                    pTo   = workingString.IndexOf("\r\n", pFrom);
                    string clickCount = "";
                    // MessageBox.Show(pTo.ToString() + " " +pFrom.ToString());
                    if (pTo != -1)
                    {
                        clickCount = workingString.Substring(pFrom, pTo - pFrom);
                    }
                    else
                    {
                        clickCount = workingString.Substring(pFrom);
                    }
                    int clickCountInt = int.Parse(clickCount);

                    allInstances.Add(new AnalysisInstance(tagsArray, dTime, currentWindow, currentContent, clickCountInt));

                    convertedFilesCount++;
                    totalData.Text = "Total Data Instance: " + (allAnalysisInstances.Length + allInstances.Count).ToString();
                } catch (Exception ex)
                {
                    MessageBox.Show("Error Errored at Index: " + i.ToString() + " : " + rawInstances[i] + " " + ex.Message);
                }
                // MessageBox.Show("New Instance:\nTagCount: " + allInstances[i-1].allTags.Length.ToString() + "\nTime: " + allInstances[i - 1].instanceTime.ToString() + "\nCurrent Window: " + allInstances[i - 1].currentWindow + "\nCurrent Content: " + allInstances[i - 1].instanceContent + "\nClick Count: " + allInstances[i - 1].clickCounts.ToString());
            }

            //MessageBox.Show("Header:\nTime: " + currentHeader.sentDateTime.ToString() + " \nComputer: " + currentHeader.fromComputer + "\nUser: " + currentHeader.fromUser);
            //analyze these datas

            return(allInstances.ToArray());
        }