コード例 #1
0
 protected override string[] GetInstantiatedAndRemaining(CustomListItem currentListItem)
 {
     if (forCount != null) 
     {
        XPathNodeIterator checkCountChildren = forCount.Select("Components/Component/Component[@ID='" + currentListItem.getID() + "']");
        return new String[] { checkCountChildren.Count.ToString(), (1-checkCountChildren.Count).ToString() }; // either 1 0 or 0 1
     }
     return new String[] { "n/a", "n/a" };
 }
コード例 #2
0
        protected override string[] GetInstantiatedAndRemaining(CustomListItem currentListItem)
        {
			return new String[] { "0", "1" };
        }
コード例 #3
0
ファイル: ProjectForm.cs プロジェクト: wshanshan/DDD
        private void RefreshList()
        {
            ComponentOptions compOptions = new ComponentOptions();
            IXPathNavigable iNavigator = rc.GetRootComponents(compOptions);

            XPathNavigator navigator = iNavigator.CreateNavigator();

            MD5CryptoServiceProvider x = new MD5CryptoServiceProvider();
            Byte[] bs = System.Text.Encoding.UTF8.GetBytes(navigator.OuterXml);
            bs = x.ComputeHash(bs);
            System.Text.StringBuilder s = new System.Text.StringBuilder();
            foreach (Byte b in bs)
            {
                s.Append(b.ToString("x2").ToLower());
            }
            String newCrc = s.ToString();

            if (!crc.Equals(newCrc)) // CRC check - see CustomTreeView and ParameterTable
            {
                DrawingUtility.SuspendDrawing(this);

                listView1.Items.Clear();

                crc = newCrc;

                XPathNodeIterator listofRootElements;
                listofRootElements = navigator.Select("//Components/Component");

                if (listofRootElements != null)
                {
                    string nodeName;
                    int nodeID;

                    foreach (XPathNavigator paramNav in listofRootElements)
                    {
                        //add the name/id paired item.
                        nodeName = paramNav.GetAttribute(NameAttribute, paramNav.NamespaceURI);
                        nodeID = Int32.Parse(paramNav.GetAttribute(IDAttribute, paramNav.NamespaceURI));

                        CustomListItem item = new CustomListItem(nodeName, "", nodeID, "");
                        if (listView1.SmallImageList != null && listView1.SmallImageList.Images.Count > 0)
                        {
                            item.ImageIndex = 0;
                        }
                        listView1.Items.Add(item);
                    }
                }

                DrawingUtility.ResumeDrawing(this);
            }

            listView1.SelectedItems.Clear();

            // delete / open display selected project
            if (MyProjectFormType == ProjectFormType.Delete || MyProjectFormType == ProjectFormType.Open)
            {
                System.Windows.Forms.ListView.ListViewItemCollection items = this.listView1.Items;

                foreach(ListViewItem anItem in items)
                {
                    CustomListItem theItem = (CustomListItem)anItem;

                    if (theItem.getID() == SelectedProjectID)
                    {
                        theItem.Selected = true;
                        this.listView1.Select();
                    }
                }
            }

            this.Show();
        }
コード例 #4
0
ファイル: ListDialog.cs プロジェクト: wshanshan/DDD
        public void UpdateViewComponent() // general update - uses subclass implementations
        {
            int restoreViewAtThisItem = -1;
            if (this.myScrollingListView.TopItem != null)
            {
                restoreViewAtThisItem = this.myScrollingListView.Items.IndexOf(this.myScrollingListView.TopItem);
            }

            DrawingUtility.SuspendDrawing(this);

            this.myScrollingListView.Items.Clear();

            XPathNodeIterator children = null;

            try
            {
                children = this.GetListChildren();
            }
            catch (Exception e)
            {
                MessageBox.Show("Could not read children for list dialog", e.Message);
            }

            if (children == null)
            {
                return;
            }

            // temp load in here, then sort
            List<CustomListItem> updatedListItems = new List<CustomListItem>();

            foreach (XPathNavigator child in children)
            {
                String childType = child.GetAttribute(XmlSchemaConstants.Display.Component.Type, child.NamespaceURI);

                if (childType.Equals(m_listItemType)) // filter by type
                {
                    int childID = Convert.ToInt32(child.GetAttribute(XmlSchemaConstants.Display.Component.Id, child.NamespaceURI));
                    String childName = child.GetAttribute(XmlSchemaConstants.Display.Component.Name, child.NamespaceURI);
                    String childDescription = child.GetAttribute(XmlSchemaConstants.Display.Component.Description, child.NamespaceURI);

                    List<Function> itemFunctions = FunctionHelper.GetFunctions(child); // update image list
                    String imagePath = FunctionHelper.ProcessNavForImage(this.Controller, this.myScrollingListView.SmallImageList, childType, child, itemFunctions);

                    CustomListItem temp = new CustomListItem(childName, childType, childID, childDescription, imagePath);

                    try
                    {
                        temp.SubItems.AddRange(this.GetInstantiatedAndRemaining(temp));
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show("Could not read children for list dialog", e.Message);
                    }
                    
                    updatedListItems.Add(temp);
                }
            }

            updatedListItems = ProcessItemsBeforeUpdate(updatedListItems, children);

            updatedListItems.Sort();

            foreach (CustomListItem item in updatedListItems)
            {
                this.myScrollingListView.Items.Add(item);
            }

            if (restoreViewAtThisItem != -1 && this.myScrollingListView.Items.Count > 0)
            {
                this.myScrollingListView.EnsureVisible(this.myScrollingListView.Items.Count - 1); // last item
                this.myScrollingListView.EnsureVisible(restoreViewAtThisItem); // top item   
            }

            // autosize columns
            bool skipFirst = true;
            int count = 0;
            foreach (ColumnHeader colHead in this.myScrollingListView.Columns)
            {
                if (skipFirst == true)
                {
                    skipFirst = false;
                }
                else
                {
                    if (useNoInstantiatedAndRemaining)
                    {
                        colHead.Width = -2;
                    }
                    else if (count > 2) // first is name, skip no instantiated and remaining
                    {
                        colHead.Width = -2;
                    }
                    else
                    {
                        colHead.Width = 0; // and make them 0
                    }
                }
                count++;
            }
            
            DrawingUtility.ResumeDrawing(this);
        }
コード例 #5
0
ファイル: ListDialog.cs プロジェクト: wshanshan/DDD
 protected abstract String[] GetInstantiatedAndRemaining(CustomListItem currentItem);
コード例 #6
0
ファイル: InstancingListDialog.cs プロジェクト: wshanshan/DDD
 protected override string[] GetInstantiatedAndRemaining(CustomListItem currentListItem)
 {
     XPathNodeIterator checkCountChildren = forCount.Select("Components/Component/Component[@ClassID='" + currentListItem.getID() + "']");
     return new String[] { checkCountChildren.Count.ToString(), amountToAddUpDown.Value.ToString() }; // use up down
 }