Exemplo n.º 1
0
        public void Initialize()
        {
            OneThreadView otv;
            var           threads_panel = this.splitContainer2.Panel2;

            threads_panel.Controls.Clear();
            var threadlist = this.listView1;

            threadlist.Items.Clear();

            if (num_threads == 0)
            {
                return;
            }

            SplitContainer splitcontainer = new SplitContainer();

            if (num_threads != 1)
            {
                threads_panel.Controls.Add(splitcontainer);
                splitcontainer.Orientation = Orientation.Vertical;
                splitcontainer.Dock        = System.Windows.Forms.DockStyle.Fill;
                splitcontainer.Location    = new System.Drawing.Point(0, 0);
            }

            for (int i = 0; i < num_threads; i++)
            {
                otv = new OneThreadView();
                threads.Add(otv);

                if (num_threads == 1)
                {
                    threads_panel.Controls.Add(otv);
                    otv.Dock         = DockStyle.Fill;
                    otv.AutoSize     = true;
                    otv.AutoSizeMode = AutoSizeMode.GrowAndShrink;
                }

                otv.SetTitle(column_to_name[index_to_column[i]]);

                otv.BackColor = Palette.getTaskColor(index_to_tid[i]);
                otv.ForeColor = Color.White;

                var row = new ListViewItem(column_to_name[index_to_column[i]]);
                row.Checked   = true;
                row.ForeColor = Color.White;
                row.BackColor = Palette.getTaskColor(index_to_tid[i]);
                row.SubItems.Add(index_to_tid[i].ToString());
                row.SubItems.Add("file: none");
                row.SubItems.Add("proc: none");
                row.SubItems.Add("op: none");
                listView1.Items.Add(row);

                otv.Dock         = DockStyle.Fill;
                otv.AutoSize     = true;
                otv.AutoSizeMode = AutoSizeMode.GrowAndShrink;
                if (num_threads != 1)
                {
                    if (i == num_threads - 1)
                    {
                        splitcontainer.Panel2.Controls.Add(otv);
                    }
                    else
                    {
                        splitcontainer.Panel1.Controls.Add(otv);
                        if (i < num_threads - 2)
                        {
                            // create new split container
                            var newsplitcontainer = new SplitContainer();
                            newsplitcontainer.Orientation = Orientation.Vertical;
                            newsplitcontainer.Dock        = System.Windows.Forms.DockStyle.Fill;
                            newsplitcontainer.Location    = new System.Drawing.Point(0, 0);
                            splitcontainer.Panel2.Controls.Add(newsplitcontainer);
                            splitcontainer = newsplitcontainer;
                        }
                    }
                }
            }

            pc_list = new int[tvo_list.Count][];
            var curr = new int[num_threads];

            for (int i = 0; i < num_threads; i++)
            {
                curr[i] = -1;
            }
            for (int i = tvo_list.Count - 1; i >= 0; i--)
            {
                // track the index in tvo_list of the tid at i
                curr[this.tid_to_index[tvo_list[i].entry.record.tid]] = i;
                pc_list[i] = new int[num_threads];
                curr.CopyTo(pc_list[i], 0);
            }

            row_to_item = new int[tvo_list.Count];
            item_to_row = new int[tvo_list.Count];
            for (int i = 0; i < tvo_list.Count; i++)
            {
                row_to_item[i] = i;
                item_to_row[i] = i;
            }
            orig_items = new ListViewItem[listView2.Items.Count];
            listView2.Items.CopyTo(orig_items, 0);

            initialized = true;

            show_all_pcs(0);

            // TODO: this is fragile. If we do this too early then toggles are sent to the model from listView2
            listView2.ItemChecked += new ItemCheckedEventHandler(listView2_ItemChecked);
            listView1.ItemChecked += new ItemCheckedEventHandler(listView1_ItemChecked);
        }