public void InitializeTest()
        {
            Button button = (Button)_helper.CreateControl(typeof(TestButton), null);

            Assert.IsFalse((bool)_helper.GetValue(button, "Locked"), "#1");
            Assert.IsTrue((bool)_helper.GetValue(button, "Visible"), "#2");
            Assert.IsTrue((bool)_helper.GetValue(button, "Enabled"), "#3");
            Assert.IsFalse((bool)_helper.GetValue(button, "AllowDrop"), "#4");
            Assert.IsTrue(button.Enabled, "#5");
            Assert.IsTrue(button.Visible, "#6");
            Assert.IsFalse(button.AllowDrop, "#7");
#if NET_2_0
            ControlDesigner buttonDesigner = _helper.IDesignerHost.GetDesigner(button) as ControlDesigner;
            Assert.AreEqual(null, buttonDesigner.InternalControlDesigner(20));
            Assert.AreEqual(0, buttonDesigner.NumberOfInternalControlDesigners());
#endif
        }
Example #2
0
        private void Initialize(ArrayList dragComponents, IDesignerHost host)
        {
            Control c = null;

            if ((dragComponents != null) && (dragComponents.Count > 0))
            {
                c = dragComponents[0] as Control;
            }
            Control   rootComponent = host.RootComponent as Control;
            Rectangle clipBounds    = new Rectangle(0, 0, rootComponent.ClientRectangle.Width, rootComponent.ClientRectangle.Height);

            clipBounds.Inflate(-1, -1);
            if (c != null)
            {
                this.dragOffset = this.behaviorService.ControlToAdornerWindow(c);
            }
            else
            {
                this.dragOffset = this.behaviorService.MapAdornerWindowPoint(rootComponent.Handle, Point.Empty);
                if ((rootComponent.Parent != null) && rootComponent.Parent.IsMirrored)
                {
                    this.dragOffset.Offset(-rootComponent.Width, 0);
                }
            }
            if (c != null)
            {
                ControlDesigner controlDesigner = host.GetDesigner(c) as ControlDesigner;
                bool            flag            = false;
                if (controlDesigner == null)
                {
                    controlDesigner = TypeDescriptor.CreateDesigner(c, typeof(IDesigner)) as ControlDesigner;
                    if (controlDesigner != null)
                    {
                        controlDesigner.ForceVisible = false;
                        controlDesigner.Initialize(c);
                        flag = true;
                    }
                }
                this.AddSnapLines(controlDesigner, this.targetHorizontalSnapLines, this.targetVerticalSnapLines, true, c != null);
                if (flag)
                {
                    controlDesigner.Dispose();
                }
            }
            foreach (IComponent component in host.Container.Components)
            {
                if (this.AddChildCompSnaplines(component, dragComponents, clipBounds, c))
                {
                    ControlDesigner designer = host.GetDesigner(component) as ControlDesigner;
                    if (designer != null)
                    {
                        if (this.AddControlSnaplinesWhenResizing(designer, component as Control, c))
                        {
                            this.AddSnapLines(designer, this.horizontalSnapLines, this.verticalSnapLines, false, c != null);
                        }
                        int num = designer.NumberOfInternalControlDesigners();
                        for (int i = 0; i < num; i++)
                        {
                            ControlDesigner designer3 = designer.InternalControlDesigner(i);
                            if (((designer3 != null) && this.AddChildCompSnaplines(designer3.Component, dragComponents, clipBounds, c)) && this.AddControlSnaplinesWhenResizing(designer3, designer3.Component as Control, c))
                            {
                                this.AddSnapLines(designer3, this.horizontalSnapLines, this.verticalSnapLines, false, c != null);
                            }
                        }
                    }
                }
            }
            this.verticalDistances   = new int[this.verticalSnapLines.Count];
            this.horizontalDistances = new int[this.horizontalSnapLines.Count];
        }