コード例 #1
0
        public void RemoveOrphans()
        {
            CCProjectsView allProjects = m_projectViews[0];
            int            i;

            for (i = 1; i < m_projectViews.Count; i++)
            {
                CCProjectsView view  = m_projectViews[i];
                int            count = view.ListView.Items.Count;
                ListViewItem[] array = new ListViewItem[count];
                view.ListView.Items.CopyTo(array, 0);
                int j;
                for (j = 0; j < count; j++)
                {
                    ListViewItem item = array[j];
                    if (allProjects.Contains(item) == false)
                    {
                        view.ListView.Items.Remove(item);
                    }
                }
            }
        }
コード例 #2
0
        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());
            }
        }