Esempio n. 1
0
        public override void Initialize(IComponent component)
        {
            base.Initialize(component);

            BaseDesigner = (ControlDesigner)Activator.CreateInstance(BaseDesignerType);
            BaseDesigner.Initialize(Control);
        }
Esempio n. 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];
        }