// Methods
            public ListBoxItem(DataGridViewColumn column, ExtDataGridColumnCollectionDialog owner, ComponentDesigner compDesigner)
            {
                this.column       = column;
                this.owner        = owner;
                this.compDesigner = compDesigner;
                if (this.compDesigner != null)
                {
                    this.compDesigner.Initialize(column);
                    TypeDescriptor.CreateAssociation(this.column, this.compDesigner);
                }
                ToolboxBitmapAttribute attribute = TypeDescriptor.GetAttributes(column)[ExtDataGridColumnCollectionDialog.toolboxBitmapAttributeType] as ToolboxBitmapAttribute;

                if (attribute != null)
                {
                    this.toolboxBitmap = attribute.GetImage(column, false);
                }
                else
                {
                    //this.toolboxBitmap = this.owner.SelectedColumnsItemBitmap;
                }
                DataGridViewColumnDesigner designer = compDesigner as DataGridViewColumnDesigner;

                if (designer != null)
                {
                    //designer.LiveDataGridView = this.owner.liveDataGridView;
                }
            }
        public override void Initialize(IComponent component) {
            // Debug.WriteLine("ObjectListViewDesigner.Initialize");

            // Use reflection to bypass the "internal" marker on ListViewDesigner
            // If we can't get the unversioned designer, look specifically for .NET 4.0 version of it.
            Type tListViewDesigner = Type.GetType("System.Windows.Forms.Design.ListViewDesigner, System.Design") ??
                                     Type.GetType("System.Windows.Forms.Design.ListViewDesigner, System.Design, " +
                                                  "Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
            if (tListViewDesigner == null) throw new ArgumentException("Could not load ListViewDesigner");

            this.listViewDesigner = (ControlDesigner)Activator.CreateInstance(tListViewDesigner, BindingFlags.Instance | BindingFlags.Public, null, null, null);
            this.designerFilter = this.listViewDesigner;

            // Fetch the methods from the ListViewDesigner that we know we want to use
            this.listViewDesignGetHitTest = tListViewDesigner.GetMethod("GetHitTest", BindingFlags.Instance | BindingFlags.NonPublic);
            this.listViewDesignWndProc = tListViewDesigner.GetMethod("WndProc", BindingFlags.Instance | BindingFlags.NonPublic);

            Debug.Assert(this.listViewDesignGetHitTest != null, "Required method (GetHitTest) not found on ListViewDesigner");
            Debug.Assert(this.listViewDesignWndProc != null, "Required method (WndProc) not found on ListViewDesigner");

            // Tell the Designer to use properties of default designer as well as the properties of this class (do before base.Initialize)
            TypeDescriptor.CreateAssociation(component, this.listViewDesigner);

            IServiceContainer site = (IServiceContainer)component.Site;
            if (site != null && GetService(typeof(DesignerCommandSet)) == null) {
                site.AddService(typeof(DesignerCommandSet), new CDDesignerCommandSet(this));
            } else {
                Debug.Fail("site != null && GetService(typeof (DesignerCommandSet)) == null");
            }

            this.listViewDesigner.Initialize(component);
            base.Initialize(component);

            RemoveDuplicateDockingActionList();
        }
예제 #3
0
        public void GetAssociationReturnsExpectedObject()
        {
            var primaryObject   = new DescriptorTestComponent();
            var secondaryObject = new MockEventDescriptor();

            TypeDescriptor.CreateAssociation(primaryObject, secondaryObject);

            var associatedObject = TypeDescriptor.GetAssociation(secondaryObject.GetType(), primaryObject);

            Assert.IsType(secondaryObject.GetType(), associatedObject);
            Assert.Equal(secondaryObject, associatedObject);
        }
예제 #4
0
        public void RemoveSingleAssociation()
        {
            var primaryObject          = new DescriptorTestComponent();
            var firstAssociatedObject  = new MockEventDescriptor();
            var secondAssociatedObject = new MockPropertyDescriptor();

            TypeDescriptor.CreateAssociation(primaryObject, firstAssociatedObject);
            TypeDescriptor.CreateAssociation(primaryObject, secondAssociatedObject);

            TypeDescriptor.RemoveAssociation(primaryObject, firstAssociatedObject);

            // the second association should remain
            var secondAssociation = TypeDescriptor.GetAssociation(secondAssociatedObject.GetType(), primaryObject);

            Assert.Equal(secondAssociatedObject, secondAssociation);

            // the first association should not
            var firstAssociation = TypeDescriptor.GetAssociation(firstAssociatedObject.GetType(), primaryObject);

            Assert.NotEqual(firstAssociatedObject, firstAssociation);
        }
예제 #5
0
        public void RemoveAssociationsRemovesAllAssociations()
        {
            var primaryObject          = new DescriptorTestComponent();
            var firstAssociatedObject  = new MockEventDescriptor();
            var secondAssociatedObject = new MockPropertyDescriptor();

            TypeDescriptor.CreateAssociation(primaryObject, firstAssociatedObject);
            TypeDescriptor.CreateAssociation(primaryObject, secondAssociatedObject);

            TypeDescriptor.RemoveAssociations(primaryObject);

            // GetAssociation never returns null. The default implementation returns the
            // primary object when an association doesn't exist. This isn't documented,
            // however, so here we only verify that the formerly associated objects aren't returned.
            var firstAssociation = TypeDescriptor.GetAssociation(firstAssociatedObject.GetType(), primaryObject);

            Assert.NotEqual(firstAssociatedObject, firstAssociation);
            var secondAssociation = TypeDescriptor.GetAssociation(secondAssociatedObject.GetType(), primaryObject);

            Assert.NotEqual(secondAssociatedObject, secondAssociation);
        }
        public override void Initialize(IComponent component)
        {
            // Debug.WriteLine("ObjectListViewDesigner.Initialize");

            // Use reflection to bypass the "internal" marker on ListViewDesigner
            Type tListViewDesigner = Type.GetType("System.Windows.Forms.Design.ListViewDesigner, System.Design");

            this.listViewDesigner = (ControlDesigner)Activator.CreateInstance(tListViewDesigner,
                                                                              BindingFlags.Instance | BindingFlags.Public, null, null, null);
            this.designerFilter = this.listViewDesigner;

            // Fetch the methods from the ListViewDesigner that we know we want to use
            this.listViewDesignGetHitTest =
                tListViewDesigner.GetMethod("GetHitTest", BindingFlags.Instance | BindingFlags.NonPublic);
            this.listViewDesignWndProc =
                tListViewDesigner.GetMethod("WndProc", BindingFlags.Instance | BindingFlags.NonPublic);

            Debug.Assert(this.listViewDesignGetHitTest != null, "Required method (GetHitTest) not found");
            Debug.Assert(this.listViewDesignWndProc != null, "Required method (WndProc) not found");

            // Tell the Designer to use properties of default designer as well as the properties of this class (do before base.Initialize)
            TypeDescriptor.CreateAssociation(component, this.listViewDesigner);

            IServiceContainer site = (IServiceContainer)component.Site;

            if (site != null && GetService(typeof(DesignerCommandSet)) == null)
            {
                site.AddService(typeof(DesignerCommandSet), new CDDesignerCommandSet(this));
            }
            else
            {
                Debug.Fail("site != null && GetService(typeof (DesignerCommandSet)) == null");
            }

            this.listViewDesigner.Initialize(component);
            base.Initialize(component);

            RemoveDuplicateDockingActionList();
        }
예제 #7
0
        private void SetCustomReportItem(PropertyDescriptorCollection pdc)
        {
            ICustomReportItem cri = null;

            try
            {
                string t = _Draw.GetElementValue(this.Node, "Type", "");

                cri = RdlEngineConfig.CreateCustomReportItem(t);

                _custom = cri.GetPropertiesInstance(_Draw.GetNamedChildNode(this.Node, "CustomProperties"));
                TypeDescriptor.CreateAssociation(this, _custom);

                PropertyDescriptorCollection bProps =
                    TypeDescriptor.GetProperties(_custom, true);

                foreach (PropertyDescriptor p in bProps)
                {
                    // create our custom property descriptor and add it to the collection

                    pdc.Add(p);
                }
            }
            catch
            {
            }
            finally
            {
                if (cri != null)
                {
                    cri.Dispose();
                }
            }

            return;
        }