Beispiel #1
0
        private const int redoIndex = 1;   //重复菜单在编辑菜单中的索引值

        public UndoEngineImplication(IServiceContainer provider)
            : base(provider)
        {
            service = provider;
            editToolStripMenuItem = (ToolStripMenuItem)service.GetService(typeof(ToolStripMenuItem));
            cassPropertyGrid      = (FilteredPropertyGrid)service.GetService(typeof(FilteredPropertyGrid));
        }
Beispiel #2
0
        /// <summary>
        /// 初始化具有HostDesign类的对象,加载当前所选控件变化时的事件服务和消息处理。
        /// 得到的服务:属性控件、上下文菜单、状态栏、标签控件(TabControl)、菜单栏、
        /// 添加的服务:撤消/重复
        /// </summary>
        internal void Initialize()
        {
            host = (IDesignerHost)this.GetService(typeof(IDesignerHost));

            if (host == null)
            {
                return;
            }
            try
            {
                selectionService = (ISelectionService)(this.GetService(typeof(ISelectionService)));
                selectionService.SelectionChanged += new EventHandler(selectionService_SelectionChanged);
                if (host.RootComponent != null)
                {
                    ((Control)host.RootComponent).Resize += new EventHandler(CassView_Resize);
                }
                cassPropertyGrid    = (FilteredPropertyGrid)(this.GetService(typeof(FilteredPropertyGrid)));
                operateMenu         = (ContextMenuStrip)(this.GetService(typeof(ContextMenuStrip)));
                designMousePosition = (ToolStripStatusLabel)(this.GetService(typeof(ToolStripStatusLabel)));
                editToolMenuItem    = (ToolStripMenuItem)this.GetService(typeof(ToolStripMenuItem));

                //添加撤消/重复操作服务
                IServiceContainer serviceContainer = host.GetService(typeof(ServiceContainer)) as IServiceContainer;
                undoEngine         = new UndoEngineImplication(serviceContainer);
                undoEngine.Enabled = false;    //关闭撤消和重复功能
                host.AddService(typeof(UndoEngineImplication), undoEngine);
            }
            catch (Exception ex) { }
        }
        public void HiddenPropertiesListCanHandleNonExistentProperties()
        {
            var grid = new FilteredPropertyGrid();
            var obj  = new { Prop1 = "hello" };

            grid.SelectedObject = obj;

            Assert.DoesNotThrow(() => grid.HiddenProperties = new[] { "NonExistantProperty" });
        }
        public void AllPropertiesVisibleByDefault()
        {
            var grid = new FilteredPropertyGrid();
            var obj  = new { Prop1 = "hello" };

            grid.SelectedObject = obj;

            Assert.That(grid.VisibleProperties, Is.EquivalentTo(new [] { nameof(obj.Prop1) }));
        }
        public void ExceptionThrownWhenNonExistantPropertyFoundInBrowsablePropertiesList()
        {
            var grid = new FilteredPropertyGrid();
            var obj  = new { Prop1 = "hello" };

            grid.SelectedObject = obj;

            Assert.Throws <InvalidOperationException>(() =>
                                                      grid.BrowsableProperties = new[] { "NonExistantProperty" });
        }
        public void OnlyPropertiesOnTheBrowsablePropertiesListAreShown()
        {
            var grid = new FilteredPropertyGrid();
            var obj  = new { Prop1 = "hello", Prop2 = "world" };

            grid.BrowsableProperties = new[] { nameof(obj.Prop1) };
            grid.SelectedObject      = obj;

            Assert.That(grid.VisibleProperties, Is.EquivalentTo(new[] { nameof(obj.Prop1) }));
        }
        public void APropertyOnBothTheBrowsableAndHiddenListWillNotBeShown()
        {
            var grid = new FilteredPropertyGrid();
            var obj  = new { Prop1 = "hello", Prop2 = "world", Prop3 = "!" };

            grid.BrowsableProperties = new[] { nameof(obj.Prop1), nameof(obj.Prop2) };
            grid.HiddenProperties    = new[] { nameof(obj.Prop1) };
            grid.SelectedObject      = obj;

            Assert.That(grid.VisibleProperties, Is.EquivalentTo(new[] { nameof(obj.Prop2) }));
        }
        public void CanSelectGridItem()
        {
            var grid = new FilteredPropertyGrid();
            var obj  = new { Prop1 = "hello", Prop2 = "world" };

            grid.SelectedObject = obj;

            grid.SelectGridItem(nameof(obj.Prop2));

            Assert.That(grid.SelectedGridItem.PropertyDescriptor?.Name,
                        Is.EqualTo(nameof(obj.Prop2)));
        }
        public void FindPreviousGridItemPropertyReturnsTheCorrectItem()
        {
            var grid = new FilteredPropertyGrid();
            var obj  = new { Prop1 = "hello", Prop2 = "world", Prop3 = "!" };

            grid.SelectedObject = obj;

            grid.SelectGridItem(nameof(obj.Prop3));
            var nextGridItem = grid.FindPreviousGridItemProperty(grid.SelectedGridItem);

            Assert.That(nextGridItem?.PropertyDescriptor?.Name,
                        Is.EqualTo(nameof(obj.Prop2)));
        }
        public void GetVisibleGridItemsReturnsAllExpandedItems()
        {
            var grid = new FilteredPropertyGrid();
            var obj  = new { Prop1 = "hello", Prop2 = new{ Prop3 = "world" } };

            grid.SelectedObject = obj;

            var visibleGridItems = grid.GetVisibleGridItems();

            Assert.That(visibleGridItems.Select(i => i.Label),
                        Is.EquivalentTo(new[]
            {
                nameof(obj.Prop1),
                nameof(obj.Prop2)
            }));
        }
Beispiel #11
0
 /// <summary>
 /// Required method for Designer support - do not modify
 /// the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     this.propertyGrid    = new EIBFormDesigner.Properties.FilteredPropertyGrid();
     this.propertToolBox  = new System.Windows.Forms.Panel();
     this.splitContainer1 = new System.Windows.Forms.SplitContainer();
     this.controlList     = new System.Windows.Forms.ComboBox();
     this.helpProvider1   = new System.Windows.Forms.HelpProvider();
     this.propertToolBox.SuspendLayout();
     this.splitContainer1.Panel1.SuspendLayout();
     this.splitContainer1.Panel2.SuspendLayout();
     this.splitContainer1.SuspendLayout();
     this.SuspendLayout();
     //
     // propertyGrid
     //
     this.propertyGrid.Dock = System.Windows.Forms.DockStyle.Fill;
     this.helpProvider1.SetHelpKeyword(this.propertyGrid, "Property Editor Window");
     this.helpProvider1.SetHelpNavigator(this.propertyGrid, System.Windows.Forms.HelpNavigator.KeywordIndex);
     this.propertyGrid.Location = new System.Drawing.Point(0, 0);
     this.propertyGrid.Margin   = new System.Windows.Forms.Padding(2);
     this.propertyGrid.Name     = "propertyGrid";
     this.helpProvider1.SetShowHelp(this.propertyGrid, true);
     this.propertyGrid.Size     = new System.Drawing.Size(219, 168);
     this.propertyGrid.TabIndex = 0;
     //
     // propertToolBox
     //
     this.propertToolBox.Controls.Add(this.splitContainer1);
     this.propertToolBox.Dock     = System.Windows.Forms.DockStyle.Fill;
     this.propertToolBox.Location = new System.Drawing.Point(0, 0);
     this.propertToolBox.Margin   = new System.Windows.Forms.Padding(2);
     this.propertToolBox.Name     = "propertToolBox";
     this.propertToolBox.Size     = new System.Drawing.Size(219, 207);
     this.propertToolBox.TabIndex = 0;
     //
     // splitContainer1
     //
     this.splitContainer1.Dock        = System.Windows.Forms.DockStyle.Fill;
     this.splitContainer1.FixedPanel  = System.Windows.Forms.FixedPanel.Panel1;
     this.splitContainer1.Location    = new System.Drawing.Point(0, 0);
     this.splitContainer1.Margin      = new System.Windows.Forms.Padding(2);
     this.splitContainer1.Name        = "splitContainer1";
     this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal;
     //
     // splitContainer1.Panel1
     //
     this.splitContainer1.Panel1.Controls.Add(this.controlList);
     this.helpProvider1.SetHelpKeyword(this.splitContainer1.Panel1, "Tool Window");
     this.helpProvider1.SetHelpNavigator(this.splitContainer1.Panel1, System.Windows.Forms.HelpNavigator.KeywordIndex);
     this.helpProvider1.SetShowHelp(this.splitContainer1.Panel1, true);
     //
     // splitContainer1.Panel2
     //
     this.splitContainer1.Panel2.Controls.Add(this.propertyGrid);
     this.splitContainer1.Size             = new System.Drawing.Size(219, 207);
     this.splitContainer1.SplitterDistance = 36;
     this.splitContainer1.SplitterWidth    = 3;
     this.splitContainer1.TabIndex         = 1;
     //
     // controlList
     //
     this.controlList.Dock = System.Windows.Forms.DockStyle.Fill;
     this.controlList.Font = new System.Drawing.Font("Microsoft Sans Serif", 10.2F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
     this.controlList.FormattingEnabled = true;
     this.helpProvider1.SetHelpKeyword(this.controlList, "Property Editor Window");
     this.helpProvider1.SetHelpNavigator(this.controlList, System.Windows.Forms.HelpNavigator.KeywordIndex);
     this.controlList.Location = new System.Drawing.Point(0, 0);
     this.controlList.Margin   = new System.Windows.Forms.Padding(2);
     this.controlList.Name     = "controlList";
     this.helpProvider1.SetShowHelp(this.controlList, true);
     this.controlList.Size                  = new System.Drawing.Size(219, 25);
     this.controlList.TabIndex              = 0;
     this.controlList.SelectedIndexChanged += new System.EventHandler(this.controlList_SelectedIndexChanged);
     //
     // helpProvider1
     //
     this.helpProvider1.HelpNamespace = "C:\\AD_help\\Application_Designer.chm";
     //
     // PropertyWindow
     //
     this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
     this.AutoScaleMode       = System.Windows.Forms.AutoScaleMode.Font;
     this.ClientSize          = new System.Drawing.Size(219, 207);
     this.Controls.Add(this.propertToolBox);
     this.helpProvider1.SetHelpKeyword(this, "Property Editor Window");
     this.helpProvider1.SetHelpNavigator(this, System.Windows.Forms.HelpNavigator.KeywordIndex);
     this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
     this.Name   = "PropertyWindow";
     this.helpProvider1.SetShowHelp(this, true);
     this.ShowHint = WeifenLuo.WinFormsUI.Docking.DockState.DockRight;
     this.Text     = "PropertyWindow";
     this.propertToolBox.ResumeLayout(false);
     this.splitContainer1.Panel1.ResumeLayout(false);
     this.splitContainer1.Panel2.ResumeLayout(false);
     this.splitContainer1.ResumeLayout(false);
     this.ResumeLayout(false);
 }