コード例 #1
0
ファイル: Timeline.cs プロジェクト: wshanshan/DDD
        private void BuildFilters(Graphics g)
        {
            if (filterPoint != null)
            {
                XPathNavigator timelineNavigator = navigator.SelectSingleNode("Timeline");

                Button filterButton = new Button();
                filterButton.Text = "Filter Asset-Task Schedule...";
                filterButton.BackColor = SystemColors.Control;
                filterButton.AutoSize = true;
                this.Controls.Add(filterButton);
                filterButton.Location = filterPoint;
                filterButton.UseVisualStyleBackColor = true;
                filterButton.Click += new EventHandler(filterButton_Click);

                Button paletteButton = new Button();
                paletteButton.Text = "Customize Colors...";
                paletteButton.BackColor = SystemColors.Control;
                paletteButton.AutoSize = true;
                this.Controls.Add(paletteButton);
                paletteButton.Location = new Point(filterButton.Location.X, filterButton.Location.Y + 30);
                paletteButton.UseVisualStyleBackColor = true;
                paletteButton.Click += new EventHandler(paletteButton_Click);

                sizeY = paletteButton.Location.Y + 50;

                //Button saveButton = new Button();
                //saveButton.Text = "Save Palette and Filter Settings";
                //saveButton.BackColor = SystemColors.Control;
                //saveButton.AutoSize = true;
                //this.Controls.Add(saveButton);
                //saveButton.Location = new Point(paletteButton.Location.X, paletteButton.Location.Y + 30);
                //saveButton.UseVisualStyleBackColor = true;

                dialogForm = new Form();
                dialogForm.AutoSize = true;
                dialogForm.FormClosed += new FormClosedEventHandler(dialogForm_FormClosed);

                colorForm = new Form();
                colorForm.AutoSize = true;
                colorForm.FormClosed += new FormClosedEventHandler(colorForm_FormClosed);
                colorList = new ListBox();
                colorList.Height = 100;
                colorList.Location = new Point(5, 10);
                colorList.Width = 150;

                colorSwatch = new Panel();
                colorSwatch.Size = new Size(20, 20);
                colorSwatch.Location = new Point(160, 10);

                Button colorPromptButton = new Button();
                colorPromptButton.Text = "Choose Color...";
                colorPromptButton.BackColor = SystemColors.Control;
                colorPromptButton.AutoSize = true;
                colorPromptButton.Location = new Point(185, 10);
                colorPromptButton.UseVisualStyleBackColor = true;
                colorPromptButton.Click += new EventHandler(colorPromptButton_Click);

                // Legend xpath
                XPathNodeIterator legendItemIterator = timelineNavigator.Select("Legend/LegendColumn/LegendItem");
                foreach (XPathNavigator legendItem in legendItemIterator)
                {
                    string filterItemName = legendItem.GetAttribute(nameAttribute, legendItem.NamespaceURI);
                    string filterItemID = legendItem.GetAttribute(idAttribute, legendItem.NamespaceURI);
                    string filterItemType = legendItem.GetAttribute(typeAttribute, legendItem.NamespaceURI);
                    string filterItemColor = legendItem.GetAttribute(colorAttribute, legendItem.NamespaceURI);
                    colorList.Items.Add(new TimelineListItem(filterItemName, Int32.Parse(filterItemID), filterItemType, filterItemColor));
                }

                colorList.SelectedIndexChanged += new EventHandler(colorList_SelectedIndexChanged);

                colorForm.Controls.Add(colorList);
                colorForm.Controls.Add(colorSwatch);
                colorForm.Controls.Add(colorPromptButton);

                GroupBox selectRadio = new GroupBox();

                selectRadio.Text = "Select a View";
                selectRadio.Size = new Size(10, 10);
                selectRadio.AutoSize = true;

                XPathNodeIterator orFilterIterator = timelineNavigator.Select(orFilterXPath);

                bool first = true;

                int radioX = 10;

                int orX = 10;

                foreach (XPathNavigator orFilterNavigator in orFilterIterator)
                {
                    TimelineRadioButton aFilterButton = new TimelineRadioButton();

                    string filterName = orFilterNavigator.GetAttribute(nameAttribute, orFilterNavigator.NamespaceURI);
                    string filterType = orFilterNavigator.GetAttribute(typeAttribute, orFilterNavigator.NamespaceURI);

                    aFilterButton.Text = filterName;
                    aFilterButton.AutoSize = true;
                    aFilterButton.Location = new Point(radioX, 20);
                    radioX += (int)g.MeasureString(filterName, textFont).Width + 25;

                    selectRadio.Controls.Add(aFilterButton);

                    CheckedListBox filterListBox = new CheckedListBox();
                    filterListBox.Height = 100;
                    filterListBox.Location = new Point(5, 50);
                    filterListBox.Width = 150;
                    filterListBox.CheckOnClick = true;

                    GroupBox filterBy = new GroupBox();

                    filterBy.Text = "Filter by: " + filterType;
                    filterBy.Size = new Size(10, 10);
                    filterBy.AutoSize = true;
                    filterBy.Location = new Point(orX, 60);

                    TimelineButton filterByButton = new TimelineButton();
                    filterByButton.Text = "All " + filterType + "s";
                    filterByButton.AutoSize = true;
                    filterByButton.Location = new Point(5, 20);
                    filterByButton.ListBox = filterListBox;
                    filterByButton.Click += new EventHandler(filterByButton_Click);

                    if (first)
                    {
                        aFilterButton.Checked = true;
                        filterListBox.Enabled = true;
                        first = false;
                    }
                    else
                    {
                        filterListBox.Enabled = false;
                    }

                    aFilterButton.ListBox = filterListBox;

                    orLists.Add(filterListBox);

                    aFilterButton.Click += new EventHandler(aFilterButton_Click);

                    filterBy.Controls.Add(filterByButton);

                    dialogForm.Controls.Add(filterBy);

                    orX += 175;

                    XPathNodeIterator orFilterItemIterator = timelineNavigator.Select("//TimelineRow[@type='" + filterType + "']");
                    foreach (XPathNavigator orFilterItemNavigator in orFilterItemIterator)
                    {
                        string filterItemName = orFilterItemNavigator.GetAttribute(nameAttribute, orFilterNavigator.NamespaceURI);
                        string filterItemID = orFilterItemNavigator.GetAttribute(idAttribute, orFilterNavigator.NamespaceURI);
                        string filterItemType = orFilterItemNavigator.GetAttribute(typeAttribute, orFilterNavigator.NamespaceURI);

                        filterListBox.Items.Add(new TimelineListItem(filterItemName, Int32.Parse(filterItemID), filterItemType));

                    }

                    filterBy.Controls.Add(filterListBox);
                }

                first = true;

                radioX = 10;

                orX = 10;

                XPathNodeIterator andFilterIterator = timelineNavigator.Select(andFilterXPath);

                foreach (XPathNavigator andFilterNavigator in andFilterIterator)
                {
                    string filterName = andFilterNavigator.GetAttribute(nameAttribute, andFilterNavigator.NamespaceURI);
                    string filterType = andFilterNavigator.GetAttribute(typeAttribute, andFilterNavigator.NamespaceURI);

                    radioX += (int)g.MeasureString(filterName, textFont).Width + 25;

                    CheckedListBox filterListBox = new CheckedListBox();
                    filterListBox.Height = 100;
                    filterListBox.Location = new Point(5, 50);
                    filterListBox.Width = 150;
                    filterListBox.CheckOnClick = true;

                    GroupBox filterBy = new GroupBox();

                    filterBy.Text = "Filter by: " + filterType;
                    filterBy.Size = new Size(10, 10);
                    filterBy.AutoSize = true;
                    filterBy.Location = new Point(orX, 250);

                    TimelineButton filterByButton = new TimelineButton();
                    filterByButton.Text = "All " + filterType + "s";
                    filterByButton.AutoSize = true;
                    filterByButton.Location = new Point(5, 20);
                    filterByButton.ListBox = filterListBox;
                    filterByButton.Click += new EventHandler(filterByButton_Click);

                    andLists.Add(filterListBox);

                    filterBy.Controls.Add(filterByButton);

                    dialogForm.Controls.Add(filterBy);

                    orX += 175;

                    // Legend xpath
                    XPathNodeIterator andFilterItemIterator = timelineNavigator.Select("Legend/LegendColumn[@type='" + filterType + "']/LegendItem");
                    foreach (XPathNavigator andFilterItemNavigator in andFilterItemIterator)
                    {
                        string filterItemName = andFilterItemNavigator.GetAttribute(nameAttribute, andFilterNavigator.NamespaceURI);
                        string filterItemID = andFilterItemNavigator.GetAttribute(idAttribute, andFilterNavigator.NamespaceURI);
                        string filterItemType = andFilterItemNavigator.GetAttribute(typeAttribute, andFilterNavigator.NamespaceURI);

                        filterListBox.Items.Add(new TimelineListItem(filterItemName, Int32.Parse(filterItemID), filterItemType));
                    }

                    filterBy.Controls.Add(filterListBox);
                }

                dialogForm.Controls.Add(selectRadio);
            }
        }
コード例 #2
0
ファイル: GanttChart.cs プロジェクト: wshanshan/DDD
        private void BuildFilters()
        {
            XPathNavigator timelineNavigator = navigator.SelectSingleNode("Timeline");

            dialogForm = new Form();
            dialogForm.AutoSize = true;
            dialogForm.FormClosed += new FormClosedEventHandler(dialogForm_FormClosed);

            colorForm = new Form();
            colorForm.AutoSize = true;
            colorList = new ListBox();
            colorList.Height = 100;
            colorList.Location = new Point(5, 10);
            colorList.Width = 150;
            colorList.Sorted = true;

            colorSwatch = new Panel();
            colorSwatch.Size = new Size(20, 20);
            colorSwatch.Location = new Point(160, 10);

            Button colorPromptButton = new Button();
            colorPromptButton.Text = "Choose Color...";
            colorPromptButton.BackColor = SystemColors.Control;
            colorPromptButton.AutoSize = true;
            colorPromptButton.Location = new Point(185, 10);
            colorPromptButton.UseVisualStyleBackColor = true;
            colorPromptButton.Click += new EventHandler(colorPromptButton_Click);

            // Legend xpath
            //XPathNodeIterator legendItemIterator = timelineNavigator.Select("Legend/LegendColumn/LegendItem");
            //foreach (XPathNavigator legendItem in legendItemIterator)
            //{
            //    string filterItemName = legendItem.GetAttribute(nameAttribute, legendItem.NamespaceURI);
            //    string filterItemID = legendItem.GetAttribute(idAttribute, legendItem.NamespaceURI);
            //    string filterItemType = legendItem.GetAttribute(typeAttribute, legendItem.NamespaceURI);
            //    string filterItemColor = legendItem.GetAttribute(colorAttribute, legendItem.NamespaceURI);
            //    //colorList.Items.Add(new TimelineListItem(filterItemName, Int32.Parse(filterItemID), filterItemType, filterItemColor));
            //}

            // find blocks without filters, filters, 'DMs', and Milestones
            XPathNodeIterator colorIterator = timelineNavigator.Select("//TimelineBlock | /Timeline/TimelineRow | //TimelineMilestone");
            foreach (XPathNavigator colorItem in colorIterator)
            {
                colorItem.MoveToChild("TimelineFilter", ""); // skip blocks with filter

                string filterItemName = colorItem.GetAttribute(nameAttribute, colorItem.NamespaceURI);
                string filterItemID = colorItem.GetAttribute(idAttribute, colorItem.NamespaceURI);
                string filterItemType = colorItem.GetAttribute(typeAttribute, colorItem.NamespaceURI);
                string filterItemColor = colorItem.GetAttribute(colorAttribute, colorItem.NamespaceURI);

                // also replace milestones with filters (if one exists)
                if (colorItem.Name.Equals("TimelineMilestone"))
                {
                    XPathNavigator filterCheck = timelineNavigator.SelectSingleNode("//TimelineFilter[" +
                                                                                    "@id = '" + filterItemID + "'] [" +
                                                                                    "@name = '" + filterItemName + "'] [" +
                                                                                    "@type = '" + filterItemType + "']");
                    if (filterCheck != null)
                    {
                        filterItemName = filterCheck.GetAttribute(nameAttribute, filterCheck.NamespaceURI);
                        filterItemID = filterCheck.GetAttribute(idAttribute, filterCheck.NamespaceURI);
                        filterItemType = filterCheck.GetAttribute(typeAttribute, filterCheck.NamespaceURI);
                        filterItemColor = filterCheck.GetAttribute(colorAttribute, filterCheck.NamespaceURI);
                    }
                }

                int iParse = Int32.Parse(filterItemID);

                if (!ListObjectCollectionContains(colorList.Items, iParse))
                {
                    colorList.Items.Add(new TimelineListItem(filterItemName, iParse, filterItemType, filterItemColor));
                }
            }

            colorList.SelectedIndexChanged += new EventHandler(colorList_SelectedIndexChanged);

            colorForm.Controls.Add(colorList);
            colorForm.Controls.Add(colorSwatch);
            colorForm.Controls.Add(colorPromptButton);

            colorForm.FormClosed += new FormClosedEventHandler(colorForm_FormClosed);

            orLists = new List<CheckedListBox>();
            andLists = new List<CheckedListBox>();

            List<Int32> orIDs = PopulateOrFilters();

            List<Int32> andIDs = PopulateAndFilters();

            GroupBox selectRadio = new GroupBox();

            selectRadio.Text = "Select a View";
            selectRadio.Size = new Size(10, 10);
            selectRadio.AutoSize = true;

            XPathNodeIterator orFilterIterator = timelineNavigator.Select(orFilterXPath);

            int radioX = 10;

            int orX = 10;

            foreach (XPathNavigator orFilterNavigator in orFilterIterator)
            {
                TimelineRadioButton aFilterButton = new TimelineRadioButton();

                string filterName = orFilterNavigator.GetAttribute(nameAttribute, orFilterNavigator.NamespaceURI);
                string filterType = orFilterNavigator.GetAttribute(typeAttribute, orFilterNavigator.NamespaceURI);

                aFilterButton.Text = filterName;
                aFilterButton.AutoSize = true;
                aFilterButton.Location = new Point(radioX, 20);
                radioX += (int)MeasureWidth(filterName, textFont).Width + 25;

                selectRadio.Controls.Add(aFilterButton);

                CheckedListBox filterListBox = new CheckedListBox();
                filterListBox.Height = 100;
                filterListBox.Location = new Point(5, 50);
                filterListBox.Width = 150;
                filterListBox.CheckOnClick = true;
                filterListBox.Sorted = true;

                GroupBox filterBy = new GroupBox();

                filterBy.Text = "Filter by: " + filterType;
                filterBy.Size = new Size(10, 10);
                filterBy.AutoSize = true;
                filterBy.Location = new Point(orX, 70);

                TimelineButton filterByButton = new TimelineButton();
                filterByButton.Text = "All " + filterType + "s";
                filterByButton.AutoSize = true;
                filterByButton.Location = new Point(5, 20);
                filterByButton.ListBox = filterListBox;
                filterByButton.Click += new EventHandler(filterByButton_Click);

                aFilterButton.Checked = false;
                filterListBox.Enabled = false;

                aFilterButton.ListBox = filterListBox;

                orLists.Add(filterListBox);

                aFilterButton.Click += new EventHandler(orButton_Click);

                filterBy.Controls.Add(filterByButton);

                dialogForm.Controls.Add(filterBy);

                orX += 175;

                XPathNodeIterator orFilterItemIterator = timelineNavigator.Select("//TimelineRow[@type='" + filterType + "']");
                foreach (XPathNavigator orFilterItemNavigator in orFilterItemIterator)
                {
                    string filterItemName = orFilterItemNavigator.GetAttribute(nameAttribute, orFilterNavigator.NamespaceURI);
                    string filterItemID = orFilterItemNavigator.GetAttribute(idAttribute, orFilterNavigator.NamespaceURI);
                    string filterItemType = orFilterItemNavigator.GetAttribute(typeAttribute, orFilterNavigator.NamespaceURI);

                    int iParse = Int32.Parse(filterItemID);

                    if (!ListObjectCollectionContains(filterListBox.Items, iParse))
                    {
                        int at = filterListBox.Items.Add(new TimelineListItem(filterItemName, iParse, filterItemType));

                        if (orIDs.Contains(Int32.Parse(filterItemID)))
                        {
                            filterListBox.SetItemChecked(at, true);

                            if (!orType.Equals(filterItemType))
                            {
                                orType = filterItemType;
                            }

                            if (aFilterButton.Checked == false || filterListBox.Enabled == false)
                            {
                                aFilterButton.Checked = true;
                                filterListBox.Enabled = true;
                            }
                        }
                    }
                }

                filterBy.Controls.Add(filterListBox);
            }

            Button clearAllButton = new Button();
            clearAllButton.Text = "Clear All";
            clearAllButton.AutoSize = true;
            clearAllButton.Location = new Point(radioX - 5, 20);
            selectRadio.Controls.Add(clearAllButton);
            clearAllButton.Click += new EventHandler(clearAllButton_Click);


            radioX = 10;

            orX = 10;

            XPathNodeIterator andFilterIterator = timelineNavigator.Select(andFilterXPath);

            foreach (XPathNavigator andFilterNavigator in andFilterIterator)
            {
                string filterName = andFilterNavigator.GetAttribute(nameAttribute, andFilterNavigator.NamespaceURI);
                string filterType = andFilterNavigator.GetAttribute(typeAttribute, andFilterNavigator.NamespaceURI);

                radioX += (int)MeasureWidth(filterName, textFont).Width + 25;

                CheckedListBox filterListBox = new CheckedListBox();
                filterListBox.Height = 100;
                filterListBox.Location = new Point(5, 50);
                filterListBox.Width = 150;
                filterListBox.CheckOnClick = true;
                filterListBox.Sorted = true;

                GroupBox filterBy = new GroupBox();

                filterBy.Text = "Filter by: " + filterType;
                filterBy.Size = new Size(10, 10);
                filterBy.AutoSize = true;
                filterBy.Location = new Point(orX, 250);

                TimelineButton filterByButton = new TimelineButton();
                filterByButton.Text = "All " + filterType + "s";
                filterByButton.AutoSize = true;
                filterByButton.Location = new Point(5, 20);
                filterByButton.ListBox = filterListBox;
                filterByButton.Click += new EventHandler(filterByButton_Click);

                andLists.Add(filterListBox);

                filterBy.Controls.Add(filterByButton);

                dialogForm.Controls.Add(filterBy);

                orX += 175;

                // filter xpath
                XPathNodeIterator andFilterItemIterator = timelineNavigator.Select("//TimelineFilter[@type='" + filterType + "']");
                foreach (XPathNavigator andFilterItemNavigator in andFilterItemIterator)
                {
                    string filterItemName = andFilterItemNavigator.GetAttribute(nameAttribute, andFilterNavigator.NamespaceURI);
                    string filterItemID = andFilterItemNavigator.GetAttribute(idAttribute, andFilterNavigator.NamespaceURI);
                    string filterItemType = andFilterItemNavigator.GetAttribute(typeAttribute, andFilterNavigator.NamespaceURI);

                    int iParse = Int32.Parse(filterItemID);

                    if (!ListObjectCollectionContains(filterListBox.Items, iParse))
                    {
                        int at = filterListBox.Items.Add(new TimelineListItem(filterItemName, iParse, filterItemType));

                        if (andIDs.Contains(Int32.Parse(filterItemID)))
                        {
                            filterListBox.SetItemChecked(at, true);
                        }
                    }
                }

                filterBy.Controls.Add(filterListBox);
            }

            dialogForm.Controls.Add(selectRadio);
        }