Пример #1
0
        /// <summary>
        /// Constructor</summary>
        public StringTagSearchInputUI(TagLabelListControl tagListControl)
        {
            m_tagListControl = tagListControl;

            Visible    = true;
            GripStyle  = ToolStripGripStyle.Hidden;
            RenderMode = ToolStripRenderMode.System;

            ToolStripDropDownButton dropDownButton = new ToolStripDropDownButton();

            dropDownButton.DisplayStyle          = ToolStripItemDisplayStyle.Image;
            dropDownButton.Image                 = ResourceUtil.GetImage16(Resources.SearchImage);
            dropDownButton.ImageTransparentColor = System.Drawing.Color.Magenta;
            dropDownButton.Name = "SearchButton";
            dropDownButton.Size = new System.Drawing.Size(29, 22);
            dropDownButton.Text = "Search".Localize("'Search' is a verb");


            m_patternTextBox                         = new ToolStripAutoFitTextBox();
            m_patternTextBox.KeyDown                += patternTextBox_KeyDown;
            m_patternTextBox.TextChanged            += patternTextBox_TextChanged;
            m_patternTextBox.TextBox.PreviewKeyDown += textBox_PreviewKeyDown;
            m_patternTextBox.MaximumWidth            = 1080;

            Items.AddRange(new ToolStripItem[] {
                dropDownButton,
                m_patternTextBox,
                //clearSearchButton
            });
        }
Пример #2
0
        /// <summary>
        /// Create and configure TreeControl</summary>
        /// <param name="treeControl">New TreeControl</param>
        /// <param name="treeControlAdapter">Adapter for TreeControl</param>
        protected override void Configure(out TreeControl treeControl, out TreeControlAdapter treeControlAdapter)
        {
            base.Configure(out treeControl, out treeControlAdapter);

            m_control      = new UserControl();
            m_control.Dock = DockStyle.Fill;
            m_control.SuspendLayout();
            m_control.Name = "Tree View".Localize();
            m_control.Text = "Tree View".Localize();


            // create tag panel
            m_TagPanel                   = new TagLabelListControl();
            m_TagPanel.Dock              = DockStyle.Top;
            m_TagPanel.OnTagListUpdated += UpdateFiltering;
            m_control.Controls.Add(m_TagPanel);

            m_TagInput = new StringTagSearchInputUI(m_TagPanel);
            m_control.Controls.Add(m_TagInput);

            m_control.Controls.Add(TreeControl);
            m_control.Layout += controls_Layout;
            m_control.ResumeLayout();

            TreeControl.PreviewKeyDown       += TreeControl_PreviewKeyDown;
            TreeControl.NodeExpandedChanging += TreeControl_NodeExpandedChanging;
            TreeControl.NodeExpandedChanged  += TreeControl_NodeExpandedChanged;
            TreeControl.ItemRendererChanged  += (sender, e) => UpdateTreeItemRenderer();
        }
Пример #3
0
        /// <summary>
        /// Constructor using given PropertyGridView and mode flags</summary>
        /// <param name="mode">The flags specifying the PropertyGrid's features and appearance</param>
        /// <param name="propertyGridView">The customized PropertyGridView</param>
        public PropertyGrid(PropertyGridMode mode, PropertyGridView propertyGridView)
        {
            m_propertyGridView                        = propertyGridView;
            m_propertyGridView.BackColor              = SystemColors.Window;
            m_propertyGridView.Dock                   = DockStyle.Fill;
            m_propertyGridView.EditingContextChanged += propertyGrid_EditingContextChanged;
            m_propertyGridView.MouseUp               += propertyGrid_MouseUp;
            m_propertyGridView.DragOver              += propertyGrid_DragOver;
            m_propertyGridView.DragDrop              += propertyGrid_DragDrop;
            m_propertyGridView.MouseHover            += propertyGrid_MouseHover;
            m_propertyGridView.MouseLeave            += propertyGrid_MouseLeave;
            if (m_descriptionTextBox != null)
            {
                m_propertyGridView.DescriptionSetter = p =>
                {
                    if (p != null)
                    {
                        m_descriptionTextBox.SetDescription(p.DisplayName, p.Description);
                    }
                    else
                    {
                        m_descriptionTextBox.ClearDescription();
                    }
                };
            }

            m_toolStrip           = new ToolStrip();
            m_toolStrip.GripStyle = ToolStripGripStyle.Hidden;
            m_toolStrip.Dock      = DockStyle.Top;

            if ((mode & PropertyGridMode.PropertySorting) != 0)
            {
                m_propertyOrganization             = new ToolStripDropDownButton(null, s_categoryImage);
                m_propertyOrganization.ToolTipText = "Property Organization".Localize(
                    "Could be rephrased as 'How do you want these properties to be organized?'");
                m_propertyOrganization.ImageTransparentColor = Color.Magenta;
                m_propertyOrganization.DropDownItemClicked  += organization_DropDownItemClicked;

                var item1 = new ToolStripMenuItem("Unsorted".Localize());
                item1.Tag = PropertySorting.None;

                var item2 = new ToolStripMenuItem("Alphabetical".Localize());
                item2.Tag = PropertySorting.Alphabetical;

                var item3 = new ToolStripMenuItem("Categorized".Localize());
                item3.Tag = PropertySorting.Categorized;

                var item4 = new ToolStripMenuItem("Categorized Alphabetical Properties".Localize());
                item4.Tag = PropertySorting.Categorized | PropertySorting.Alphabetical;

                var item5 = new ToolStripMenuItem("Alphabetical Categories".Localize());
                item5.Tag = PropertySorting.Categorized | PropertySorting.CategoryAlphabetical;

                var item6 = new ToolStripMenuItem("Alphabetical Categories And Properties".Localize());
                item6.Tag = PropertySorting.ByCategory;

                m_propertyOrganization.DropDownItems.Add(item1);
                m_propertyOrganization.DropDownItems.Add(item2);
                m_propertyOrganization.DropDownItems.Add(item3);
                m_propertyOrganization.DropDownItems.Add(item4);
                m_propertyOrganization.DropDownItems.Add(item5);
                m_propertyOrganization.DropDownItems.Add(item6);

                m_toolStrip.Items.Add(m_propertyOrganization);
                m_toolStrip.Items.Add(new ToolStripSeparator());
            }

            if ((mode & PropertyGridMode.DisableSearchControls) == 0)
            {
                var dropDownButton = new ToolStripDropDownButton();
                dropDownButton.DisplayStyle          = ToolStripItemDisplayStyle.Image;
                dropDownButton.Image                 = ResourceUtil.GetImage16(Resources.SearchImage);
                dropDownButton.ImageTransparentColor = System.Drawing.Color.Magenta;
                dropDownButton.Name = "PropertyGridSearchButton";
                dropDownButton.Size = new System.Drawing.Size(29, 22);
                dropDownButton.Text = "Search".Localize("'Search' is a verb");

                m_patternTextBox                         = new ToolStripAutoFitTextBox();
                m_patternTextBox.Name                    = "patternTextBox";
                m_patternTextBox.MaximumWidth            = 1080;
                m_patternTextBox.KeyUp                  += patternTextBox_KeyUp;
                m_patternTextBox.TextBox.PreviewKeyDown += patternTextBox_PreviewKeyDown;

                var clearSearchButton = new ToolStripButton();
                clearSearchButton.DisplayStyle       = ToolStripItemDisplayStyle.Image;
                clearSearchButton.Image              = ResourceUtil.GetImage16(Resources.DeleteImage);
                dropDownButton.ImageTransparentColor = System.Drawing.Color.Magenta;
                clearSearchButton.Name   = "PropertyGridClearSearchButton";
                clearSearchButton.Size   = new System.Drawing.Size(29, 22);
                clearSearchButton.Text   = "Clear Search".Localize("'Clear' is a verb");
                clearSearchButton.Click += clearSearchButton_Click;

                m_toolStrip.Items.AddRange(
                    new ToolStripItem[] {
                    dropDownButton,
                    m_patternTextBox,
                    clearSearchButton
                });
            }

            if ((mode & PropertyGridMode.HideResetAllButton) == 0)
            {
                // Reset all button.
                var resetAllButton = new ToolStripButton();
                resetAllButton.DisplayStyle          = ToolStripItemDisplayStyle.Image;
                resetAllButton.Image                 = ResourceUtil.GetImage16(Resources.ResetImage);
                resetAllButton.ImageTransparentColor = System.Drawing.Color.Magenta;
                resetAllButton.Name        = "PropertyGridResetAllButton";
                resetAllButton.Size        = new Size(29, 22);
                resetAllButton.ToolTipText = "Reset all properties".Localize();
                resetAllButton.Click      += (sender, e) =>
                {
                    ITransactionContext transaction = m_propertyGridView.EditingContext.As <ITransactionContext>();
                    transaction.DoTransaction(delegate
                    {
                        ResetAll();
                    },
                                              "Reset All Properties".Localize("'Reset' is a verb and this is the name of a command"));
                };
                m_toolStrip.Items.Add(resetAllButton);
            }

            if ((mode & PropertyGridMode.AllowEditingComposites) != 0)
            {
                m_navigateOut             = new ToolStripButton(null, s_navigateOutImage, navigateOut_Click);
                m_navigateOut.Enabled     = true;
                m_navigateOut.ToolTipText = "Navigate back to parent of selected object".Localize();

                m_toolStrip.Items.Add(m_navigateOut);

                m_propertyGridView.AllowEditingComposites = true;
            }

            SuspendLayout();


            if ((mode & PropertyGridMode.DisplayTooltips) != 0)
            {
                m_propertyGridView.AllowTooltips = true;
            }

            if ((mode & PropertyGridMode.DisplayDescriptions) == 0)
            {
                Controls.Add(m_propertyGridView);
            }
            else
            {
                m_splitContainer.Orientation   = Orientation.Horizontal;
                m_splitContainer.BackColor     = SystemColors.InactiveBorder;
                m_splitContainer.FixedPanel    = FixedPanel.Panel2;
                m_splitContainer.SplitterWidth = 8;
                m_splitContainer.Dock          = DockStyle.Fill;

                m_splitContainer.Panel1.Controls.Add(m_propertyGridView);

                m_descriptionTextBox           = new DescriptionControl(this);
                m_descriptionTextBox.BackColor = SystemColors.Window;
                m_descriptionTextBox.Dock      = DockStyle.Fill;

                m_splitContainer.Panel2.Controls.Add(m_descriptionTextBox);
                Controls.Add(m_splitContainer);

                m_propertyGridView.SelectedPropertyChanged += propertyGrid_SelectedRowChanged;
                m_descriptionTextBox.ClearDescription();
            }

            // create tag panel
            m_TagPanel      = new TagLabelListControl();
            m_TagPanel.Dock = DockStyle.Top;
            // Use same filter pattern list
            m_propertyGridView.FilterPatterns = m_TagPanel.TagList;
            m_TagPanel.OnTagListUpdated      += m_propertyGridView.OnFilterPatternUpdated;
            Controls.Add(m_TagPanel);

            if (m_toolStrip.Items.Count > 0)
            {
                UpdateToolstripItems();
                Controls.Add(m_toolStrip);
            }
            else
            {
                m_toolStrip.Dispose();
                m_toolStrip = null;
            }

            Name         = "PropertyGrid";
            Font         = m_propertyGridView.Font;
            FontChanged += (sender, e) => m_propertyGridView.Font = Font;
            ResumeLayout(false);
            PerformLayout();
        }