void TabControl_DragDrop(object sender, DragEventArgs e)
        {
            Point p = m_tabControl.PointToClient(new Point(e.X, e.Y));

            // probably shouldn't need to do this
            TabPage t = FindTabControl(p);

            if (t != null)
            {
                if (m_tabControl.SelectedTab != t)
                {
                    Console.WriteLine("Ouch trying to drop onto a tab which isn't selected!!!");
                }
            }

            e.Effect = DragDropEffects.Copy;

            if (e.Data.GetDataPresent(typeof(ListView.SelectedListViewItemCollection)) == false)
            {
                Console.WriteLine("no data");
            }

            ListView.SelectedListViewItemCollection items = (ListView.SelectedListViewItemCollection)e.Data.GetData(typeof(ListView.SelectedListViewItemCollection));
            foreach (ListViewItem lvi in items)
            {
                IProjectMonitor monitor = (IProjectMonitor)lvi.Tag;
                ListViewItem    item    = mainForm.MainFormController.CopyBoundProject(monitor);
                m_current.AddProject(item);
            }
        }
        // callback for when user has entered a pattern to create a new tablist from
        void doneTextEdit(Control[] t)
        {
            string pattern = t[0].Text.ToUpper();

            CCProjectsView view = new CCProjectsView(this, string.Empty);

            AddView(view);
            foreach (ListViewItem lvi in m_current.ListView.Items)
            {
                string s = lvi.SubItems[0].Text.ToUpper() + lvi.SubItems[1].Text.ToUpper();
                if (s.Contains(pattern))
                {
                    IProjectMonitor monitor = (IProjectMonitor)lvi.Tag;
                    ListViewItem    item    = mainForm.MainFormController.CopyBoundProject(monitor);
                    view.AddProject(item);
                }
            }

            TabControl.SelectedTab = view.TabPage;
            view.TabPage.Text      = t[0].Text;
            view.Text = t[0].Text;
            m_current = view;

            Rectangle rect = TabControl.GetTabRect(TabControl.SelectedIndex);

            Point p = new Point(rect.Left, rect.Top);

            if (m_bUsingTextBox == false)
            {
                RenameView(p, view.TabPage.Text, new Control[] { view, view.TabPage }, null);
            }
        }
        private void ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ToolStripMenuItem tsi  = (ToolStripMenuItem)sender;
            CCProjectsView    ccpv = (CCProjectsView)tsi.Tag;

            foreach (ListViewItem lvi in m_current.ListView.SelectedItems)
            {
                IProjectMonitor monitor = (IProjectMonitor)lvi.Tag;
                ListViewItem    item    = mainForm.MainFormController.CopyBoundProject(monitor);
                ccpv.AddProject(item);
            }
        }
        void mnuCreateTabFromCategory_Click(object sender, EventArgs e)
        {
            // clear existing user views



            for (int ccpvcounter = m_projectViews.Count - 1; ccpvcounter >= 0; ccpvcounter--)
            {
                CCProjectsView ccpv = m_projectViews[ccpvcounter];

                if (ccpv.IsUserView)
                {
                    ccpv.ListView.Items.Clear();
                    m_tabControl.TabPages.Remove(ccpv.TabPage);
                    ccpv.TabPage.Dispose();
                    m_projectViews.Remove(ccpv);
                }
            }



            // get all categories of the monitored projects
            System.Collections.Generic.List <string> Categories = new List <string>();

            foreach (IProjectMonitor project in this.mainForm.MainFormController.Monitors)
            {
                if (!Categories.Contains(project.Detail.Category))
                {
                    Categories.Add(project.Detail.Category);
                }
            }

            // for each category, create a tab and enter the corresponding projects to it
            foreach (string category in Categories)
            {
                CCProjectsView categoryTab = new CCProjectsView(this, category);
                categoryTab.IsUserView = true;

                AddView(categoryTab);

                // get the projects from this category
                foreach (IProjectMonitor project in this.mainForm.MainFormController.Monitors)
                {
                    if (project.Detail.Category == category)
                    {
                        ListViewItem item = mainForm.MainFormController.CopyBoundProject(project);
                        categoryTab.AddProject(item);
                    }
                }
            }
        }
        void mnuSendToNewTab_Click(object sender, EventArgs e)
        {
            CCProjectsView view = new CCProjectsView(this, string.Empty);

            AddView(view);
            foreach (ListViewItem lvi in m_current.ListView.SelectedItems)
            {
                IProjectMonitor monitor = (IProjectMonitor)lvi.Tag;
                ListViewItem    item    = mainForm.MainFormController.CopyBoundProject(monitor);
                view.AddProject(item);
            }

            TabControl.SelectedTab = view.TabPage;
            m_current = view;

            Rectangle rect = TabControl.GetTabRect(TabControl.SelectedIndex);

            Point p = new Point(rect.Left, rect.Top);

            if (m_bUsingTextBox == false)
            {
                RenameView(p, view.TabPage.Text, new Control[] { view, view.TabPage }, null);
            }
        }
        public void LoadViewConfiguration()
        {
            string fname = GetConfigFilename();
            if (!File.Exists(fname))
                return;

            FileStream reader = new FileStream(fname, FileMode.Open, FileAccess.Read, FileShare.Read);
            System.Xml.XmlTextReader xmlReader = new XmlTextReader(reader);

            try
            {
                xmlReader.ReadStartElement("Views");
                while (xmlReader.Read())
                {
                    if (xmlReader.AttributeCount > 0)
                    {
                        string viewName = xmlReader.GetAttribute(0);

                        bool bViewAdded = false;

                        // skip "View"
                        xmlReader.Read();
                        xmlReader.Read();

                        CCProjectsView view = new CCProjectsView(this, viewName);

                        while (xmlReader.Name == "Project")
                        {

                            string ProjectName = xmlReader.GetAttribute(0);
                            xmlReader.Read();
                            xmlReader.Read();

                            string ServerName = xmlReader.GetAttribute(0);
                            xmlReader.Read();
                            xmlReader.Read();

                            CCProjectsView viewAll = m_projectViews[0];

                            ListViewItem lvi = viewAll.Contains(ProjectName);

                            if (lvi != null)
                            {
                                IProjectMonitor monitor = (IProjectMonitor)lvi.Tag;
                                ListViewItem item = mainForm.MainFormController.CopyBoundProject(monitor);

                                if (!bViewAdded)
                                {
                                    AddView(view);
                                    bViewAdded = true;
                                }

                                view.AddProject(item);

                            }
                        }
                    }
                }


                xmlReader.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
        void mnuSendToNewTab_Click(object sender, EventArgs e)
        {
            CCProjectsView view = new CCProjectsView(this, string.Empty);
            AddView(view);
            foreach (ListViewItem lvi in m_current.ListView.SelectedItems)
            {
                IProjectMonitor monitor = (IProjectMonitor)lvi.Tag;
                ListViewItem item = mainForm.MainFormController.CopyBoundProject(monitor);
                view.AddProject(item);
            }

            TabControl.SelectedTab = view.TabPage;
            m_current = view;

            Rectangle rect = TabControl.GetTabRect(TabControl.SelectedIndex);

            Point p = new Point(rect.Left, rect.Top);
            if (m_bUsingTextBox == false)
                RenameView(p, view.TabPage.Text, new Control[] { view, view.TabPage }, null);
        }
        void mnuCreateTabFromCategory_Click(object sender, EventArgs e)
        {
            // clear existing user views



            for (int ccpvcounter = m_projectViews.Count - 1; ccpvcounter >= 0; ccpvcounter--)
            {
                CCProjectsView ccpv = m_projectViews[ccpvcounter];
                
                if (ccpv.IsUserView)
                {
                    ccpv.ListView.Items.Clear();
                    m_tabControl.TabPages.Remove(ccpv.TabPage);
                    ccpv.TabPage.Dispose();
                    m_projectViews.Remove(ccpv);
                }
            }



            // get all categories of the monitored projects
            System.Collections.Generic.List<string> Categories = new List<string>();

            foreach (IProjectMonitor project in this.mainForm.MainFormController.Monitors)
            {
                if (!Categories.Contains(project.Detail.Category)) Categories.Add(project.Detail.Category);
            }

            // for each category, create a tab and enter the corresponding projects to it
            foreach (string category in Categories)
            {
                CCProjectsView categoryTab = new CCProjectsView(this, category);
                categoryTab.IsUserView = true;

                AddView(categoryTab);

                // get the projects from this category
                foreach (IProjectMonitor project in this.mainForm.MainFormController.Monitors)
                {
                    if (project.Detail.Category == category)
                    {
                        ListViewItem item = mainForm.MainFormController.CopyBoundProject(project);
                        categoryTab.AddProject(item);
                    }
                }
            }
        }
        // callback for when user has entered a pattern to create a new tablist from
        void doneTextEdit(Control[] t)
        {
            string pattern = t[0].Text.ToUpper();

            CCProjectsView view = new CCProjectsView(this, string.Empty);
            AddView(view);
            foreach (ListViewItem lvi in m_current.ListView.Items)
            {
                string s = lvi.SubItems[0].Text.ToUpper() + lvi.SubItems[1].Text.ToUpper();
                if (s.Contains(pattern))
                {
                    IProjectMonitor monitor = (IProjectMonitor)lvi.Tag;
                    ListViewItem item = mainForm.MainFormController.CopyBoundProject(monitor);
                    view.AddProject(item);
                }
            }

            TabControl.SelectedTab = view.TabPage;
            view.TabPage.Text = t[0].Text;
            view.Text = t[0].Text;
            m_current = view;

            Rectangle rect = TabControl.GetTabRect(TabControl.SelectedIndex);

            Point p = new Point(rect.Left, rect.Top);
            if (m_bUsingTextBox == false)
                RenameView(p, view.TabPage.Text, new Control[] { view, view.TabPage }, null);
        }
        public void LoadViewConfiguration()
        {
            string fname = GetConfigFilename();

            if (!File.Exists(fname))
            {
                return;
            }

            FileStream reader = new FileStream(fname, FileMode.Open, FileAccess.Read, FileShare.Read);

            System.Xml.XmlTextReader xmlReader = new XmlTextReader(reader);

            try
            {
                xmlReader.ReadStartElement("Views");
                while (xmlReader.Read())
                {
                    if (xmlReader.AttributeCount > 0)
                    {
                        string viewName = xmlReader.GetAttribute(0);

                        bool bViewAdded = false;

                        // skip "View"
                        xmlReader.Read();
                        xmlReader.Read();

                        CCProjectsView view = new CCProjectsView(this, viewName);

                        while (xmlReader.Name == "Project")
                        {
                            string ProjectName = xmlReader.GetAttribute(0);
                            xmlReader.Read();
                            xmlReader.Read();

                            string ServerName = xmlReader.GetAttribute(0);
                            xmlReader.Read();
                            xmlReader.Read();

                            CCProjectsView viewAll = m_projectViews[0];

                            ListViewItem lvi = viewAll.Contains(ProjectName);

                            if (lvi != null)
                            {
                                IProjectMonitor monitor = (IProjectMonitor)lvi.Tag;
                                ListViewItem    item    = mainForm.MainFormController.CopyBoundProject(monitor);

                                if (!bViewAdded)
                                {
                                    AddView(view);
                                    bViewAdded = true;
                                }

                                view.AddProject(item);
                            }
                        }
                    }
                }


                xmlReader.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }