Пример #1
0
        private void UpdateBoxLocation(DragItem d)
        {
            this.dragActive = d;

            if (this.dragActive == null)
            {
                return;
            }
            int controlW = this.dragActive.Width;
            int controlH = this.dragActive.Height;

            int controlX = this.dragActive.Location.X;
            int controlY = this.dragActive.Location.Y;

            int resizeH = this.Height;
            int resizeW = this.Width;

            this.Visible = true;

            switch (PositionAnchor)
            {
            case DragHandleAnchor.None:
                break;

            case DragHandleAnchor.TopLeft:
                this.Location = new System.Drawing.Point(controlX - resizeW, controlY - resizeH);
                break;

            case DragHandleAnchor.TopCenter:
                this.Location = new System.Drawing.Point(controlW / 2 + controlX - (resizeW / 2), controlY - resizeH);
                break;

            case DragHandleAnchor.TopRight:
                this.Location = new System.Drawing.Point(controlX + controlW, controlY - resizeH);
                break;

            case DragHandleAnchor.MiddleLeft:
                this.Location = new System.Drawing.Point(controlX - resizeW, controlY + (controlH / 2) - (resizeH / 2));
                break;

            case DragHandleAnchor.MiddleRight:
                this.Location = new System.Drawing.Point(controlX + controlW, controlY + (controlH / 2) - (resizeH / 2));
                break;

            case DragHandleAnchor.BottomLeft:
                this.Location = new System.Drawing.Point(controlX - resizeW, controlY + controlH);
                break;

            case DragHandleAnchor.BottomCenter:
                this.Location = new System.Drawing.Point(controlW / 2 + controlX - (resizeW / 2), controlY + controlH);
                break;

            case DragHandleAnchor.BottomRight:
                this.Location = new System.Drawing.Point(controlX + controlW, controlY + controlH);
                break;

            default:
                break;
            }
        }
Пример #2
0
 public void RegisterDragActive(DragItem d, DragHandleAnchor excludePositionAnchor)
 {
     if (excludePositionAnchor != this.PositionAnchor)
     {
         this.UpdateBoxLocation(d);
     }
 }
Пример #3
0
        public DragItem CheckIsContainOtherObj(DragItem control)
        {
            control.CustomProperties.Top = 0;
            bool isCanPast = false;

            for (int Y = 0; Y <= this.Height; Y += grid)
            {
                control.CustomProperties.Left = 0;
                for (int X = 0; X <= this.Width; X += grid)
                {
                    #region :: Create Rectangrl Check ::
                    Rectangle rectangle1 = new Rectangle(control.CustomProperties.Left, control.CustomProperties.Top, 1, 1);
                    Rectangle rectangle2 = new Rectangle(control.CustomProperties.Left + control.Width - 1, control.CustomProperties.Top, 1, 1);
                    Rectangle rectangle3 = new Rectangle(control.CustomProperties.Left + control.Width - 1, control.CustomProperties.Top + control.Height - 1, 1, 1);
                    Rectangle rectangle4 = new Rectangle(control.CustomProperties.Left, control.CustomProperties.Top + control.Height - 1, 1, 1);
                    #endregion

                    bool isContains = false;
                    #region :: Check Contain Other obj ::

                    foreach (DragItem OtherObj in this.DragItem)
                    {
                        Rectangle recOtherObj = new Rectangle(OtherObj.CustomProperties.Left, OtherObj.CustomProperties.Top, OtherObj.Width, OtherObj.Height);
                        isContains = recOtherObj.Contains(rectangle1) || recOtherObj.Contains(rectangle2) || recOtherObj.Contains(rectangle3) || recOtherObj.Contains(rectangle4);
                        if (isContains)
                        {
                            break;
                        }
                    }
                    #endregion

                    if (!isContains && this.Width >= control.CustomProperties.Left + control.Width - 1 && this.Height >= control.CustomProperties.Top + control.Height - 1)
                    {
                        isCanPast = true;
                        break;
                    }

                    control.CustomProperties.Left += grid;
                }

                if (isCanPast)
                {
                    break;
                }
                control.CustomProperties.Top += grid;
            }

            #region :: Result ::

            if (isCanPast)
            {
                return(control);
            }
            else
            {
                return(null);
            }
            #endregion
        }
Пример #4
0
        public void setCurentSelectDragItemProprty(CustromControlPropertyDTO prorpty)
        {
            DragItem dragItem = this.DragItem.Find(a => a.IsSelect == true && a.ControlCommand.ControlState != ObjectState.Delete);

            if (dragItem != null)
            {
                dragItem.ControlCommand = prorpty;
            }
        }
Пример #5
0
 public void UpdateLocationBoxResize(DragItem dragItem, DragHandleAnchor excludePositionAnchor)
 {
     rTopLeft.RegisterDragActive(dragItem, excludePositionAnchor);
     rTopCenter.RegisterDragActive(dragItem, excludePositionAnchor);
     rTopRight.RegisterDragActive(dragItem, excludePositionAnchor);
     rMiddleLeft.RegisterDragActive(dragItem, excludePositionAnchor);
     rMiddleRight.RegisterDragActive(dragItem, excludePositionAnchor);
     rBottomLeft.RegisterDragActive(dragItem, excludePositionAnchor);
     rBottomRight.RegisterDragActive(dragItem, excludePositionAnchor);
     rBottomCenter.RegisterDragActive(dragItem, excludePositionAnchor);
 }
Пример #6
0
        protected void control_SelectDragEvent(string controlNmae)
        {
            this.HideBoxResize();
            DragItem dragItem = this.DragItem.Find(a => a.Name == controlNmae && a.ControlCommand.ControlState != ObjectState.Delete);

            if (dragItem != null)
            {
                dragItem.IsSelect = true;
                this.UpdateLocationBoxResize(dragItem, DragHandleAnchor.None);
                this.onSelectDragEvent(dragItem);
            }
        }
Пример #7
0
        public void DuplicateDragItem()
        {
            DragItem dragItem = this.DragItem.Find(a => a.IsSelect == true && a.ControlCommand.ControlState != ObjectState.Delete);

            if (dragItem != null)
            {
                DragItem duplicate = new Control.DragItem(new Point(0, 0));
                duplicate = dragItem.CloneTo(duplicate);
                duplicate.ControlCommand.ControlState = ObjectState.Add;
                this.AddDragControl(duplicate);
            }
        }
Пример #8
0
        public CustromControlPropertyDTO getCurentSelectDragItemProprty()
        {
            DragItem dragItem = this.DragItem.Find(a => a.IsSelect == true && a.ControlCommand.ControlState != ObjectState.Delete);

            if (dragItem != null)
            {
                return(dragItem.ControlCommand);
            }
            else
            {
                return(null);
            }
        }
Пример #9
0
        public void AddDragControl(DragItem control)
        {

            if (control.CustomProperties.Top + control.CustomProperties.Left == 0)
                control = this.CheckIsContainOtherObj(control);

            if (control != null)
            {
                string controlName = string.Format("{0}_DragItem_{1}", this.Name, this.DragItem.Count());

                control.Name = controlName;
                control.SelectDragEvent += new DragItem.SelectDragItemHandler(control_SelectDragEvent);
                this.DragItem.Add(control);
                this.Controls.Add(control);
            }
        }
Пример #10
0
        public void AddDragControl(DragItem control)
        {
            if (control.CustomProperties.Top + control.CustomProperties.Left == 0)
            {
                control = this.CheckIsContainOtherObj(control);
            }

            if (control != null)
            {
                string controlName = string.Format("{0}_DragItem_{1}", this.Name, this.DragItem.Count());

                control.Name             = controlName;
                control.SelectDragEvent += new DragItem.SelectDragItemHandler(control_SelectDragEvent);
                this.DragItem.Add(control);
                this.Controls.Add(control);
            }
        }
Пример #11
0
        public void DeletCurrentItem()
        {
            DragItem dragItem = this.DragItem.Find(a => a.IsSelect == true && a.ControlCommand.ControlState != ObjectState.Delete);

            if (dragItem != null)
            {
                if (dragItem.ControlCommand.ControlState == ObjectState.Add)
                {
                    this.DragItem.Remove(dragItem);
                }
                else
                {
                    dragItem.ControlCommand.ControlState = ObjectState.Delete;
                }
                this.Controls.Remove(dragItem);
                this.HideBoxResize();
            }
        }
Пример #12
0
 public DragItem CloneTo(DragItem cloneItem)
 {
     cloneItem.Parent                      = null;
     cloneItem.SelectDragEvent             = null;
     cloneItem.ControlCommand.control_type = this.ControlCommand.control_type;
     cloneItem.Width     = this.Width;
     cloneItem.Height    = this.Height;
     cloneItem.Top       = this.Top;
     cloneItem.Left      = this.Left;
     cloneItem.BackColor = this.BackColor;
     cloneItem.ForeColor = this.ForeColor;
     cloneItem.Font      = this.Font;
     cloneItem.CustomProperties.BackGroundImage  = this.CustomProperties.BackGroundImage;
     cloneItem.CustomProperties.BackGroundLayout = this.CustomProperties.BackGroundLayout;
     cloneItem.BorderStyle           = this.BorderStyle;
     cloneItem.CustomProperties.Text = this.CustomProperties.Text;
     return(cloneItem);
 }
Пример #13
0
        public ControPropertiesDTO(DragItem dragItem)
        {
            // TODO: Complete member initialization
            this.dragItem = dragItem;

            /*
             * //Get Font Text
             * Font font1 = new Font("Arial", 12, FontStyle.Italic);
             * TypeConverter converter = TypeDescriptor.GetConverter(typeof(Font));
             * // Saving Font object as a string
             * string fontString = converter.ConvertToString(font1);
             * // Load an instance of Font from a string
             * Font font = (Font)converter.ConvertFromString(fontString);
             *
             *
             * //Get Color Int
             * int bC = this.dragItem.BackColor.ToArgb();
             * Color tBc = Color.FromArgb(bC);
             */
        }
Пример #14
0
        public DragItem CloneTo(DragItem cloneItem)
        {


            cloneItem.Parent = null;
            cloneItem.SelectDragEvent = null;
            cloneItem.ControlCommand.control_type = this.ControlCommand.control_type;
            cloneItem.Width = this.Width;
            cloneItem.Height = this.Height;
            cloneItem.Top = this.Top;
            cloneItem.Left = this.Left;
            cloneItem.BackColor = this.BackColor;
            cloneItem.ForeColor = this.ForeColor;
            cloneItem.Font = this.Font;
            cloneItem.CustomProperties.BackGroundImage = this.CustomProperties.BackGroundImage;
            cloneItem.CustomProperties.BackGroundLayout = this.CustomProperties.BackGroundLayout;
            cloneItem.BorderStyle = this.BorderStyle;
            cloneItem.CustomProperties.Text = this.CustomProperties.Text;
            return cloneItem;
        }
Пример #15
0
        public ControPropertiesDTO(DragItem dragItem)
        {
            // TODO: Complete member initialization
            this.dragItem = dragItem;

            /*
            //Get Font Text
            Font font1 = new Font("Arial", 12, FontStyle.Italic);
            TypeConverter converter = TypeDescriptor.GetConverter(typeof(Font));
            // Saving Font object as a string
            string fontString = converter.ConvertToString(font1);
            // Load an instance of Font from a string
            Font font = (Font)converter.ConvertFromString(fontString);


            //Get Color Int 
            int bC = this.dragItem.BackColor.ToArgb();
            Color tBc = Color.FromArgb(bC);
            */
        }
Пример #16
0
        private void UpdateBoxLocation(DragItem d)
        {
            this.dragActive = d;

            if (this.dragActive == null) return;
            int controlW = this.dragActive.Width;
            int controlH = this.dragActive.Height;

            int controlX = this.dragActive.Location.X;
            int controlY = this.dragActive.Location.Y;

            int resizeH = this.Height;
            int resizeW = this.Width;

            this.Visible = true;

            switch (PositionAnchor)
            {
                case DragHandleAnchor.None:
                    break;
                case DragHandleAnchor.TopLeft:
                    this.Location = new System.Drawing.Point(controlX - resizeW, controlY - resizeH);
                    break;
                case DragHandleAnchor.TopCenter:
                    this.Location = new System.Drawing.Point(controlW / 2 + controlX - (resizeW / 2), controlY - resizeH);
                    break;
                case DragHandleAnchor.TopRight:
                    this.Location = new System.Drawing.Point(controlX + controlW, controlY - resizeH);
                    break;
                case DragHandleAnchor.MiddleLeft:
                    this.Location = new System.Drawing.Point(controlX - resizeW, controlY + (controlH / 2) - (resizeH / 2));
                    break;
                case DragHandleAnchor.MiddleRight:
                    this.Location = new System.Drawing.Point(controlX + controlW, controlY + (controlH / 2) - (resizeH / 2));
                    break;
                case DragHandleAnchor.BottomLeft:
                    this.Location = new System.Drawing.Point(controlX - resizeW, controlY + controlH);
                    break;
                case DragHandleAnchor.BottomCenter:
                    this.Location = new System.Drawing.Point(controlW / 2 + controlX - (resizeW / 2), controlY + controlH);
                    break;
                case DragHandleAnchor.BottomRight:
                    this.Location = new System.Drawing.Point(controlX + controlW, controlY + controlH);
                    break;
                default:
                    break;
            }
        }
Пример #17
0
 public void RegisterDragActive(DragItem d, DragHandleAnchor excludePositionAnchor)
 {
     if (excludePositionAnchor != this.PositionAnchor)
         this.UpdateBoxLocation(d);
 }
Пример #18
0
 public void RegisterDragActive(DragItem d)
 {
     this.UpdateBoxLocation(d);
 }
Пример #19
0
 public void UnRegisterDragActive()
 {
     this.dragActive = null;
     this.Visible = false;
 }
Пример #20
0
 public void RegisterDragActive(DragItem d)
 {
     this.UpdateBoxLocation(d);
 }
Пример #21
0
 public void UnRegisterDragActive()
 {
     this.dragActive = null;
     this.Visible    = false;
 }
Пример #22
0
        public DragItem CheckIsContainOtherObj(DragItem control)
        {
            control.CustomProperties.Top = 0;
            bool isCanPast = false;
            for (int Y = 0; Y <= this.Height; Y += grid)
            {
                control.CustomProperties.Left = 0;
                for (int X = 0; X <= this.Width; X += grid)
                {

                    #region :: Create Rectangrl Check ::
                    Rectangle rectangle1 = new Rectangle(control.CustomProperties.Left, control.CustomProperties.Top, 1, 1);
                    Rectangle rectangle2 = new Rectangle(control.CustomProperties.Left + control.Width - 1, control.CustomProperties.Top, 1, 1);
                    Rectangle rectangle3 = new Rectangle(control.CustomProperties.Left + control.Width - 1, control.CustomProperties.Top + control.Height - 1, 1, 1);
                    Rectangle rectangle4 = new Rectangle(control.CustomProperties.Left, control.CustomProperties.Top + control.Height - 1, 1, 1);
                    #endregion

                    bool isContains = false;
                    #region :: Check Contain Other obj ::

                    foreach (DragItem OtherObj in this.DragItem)
                    {

                        Rectangle recOtherObj = new Rectangle(OtherObj.CustomProperties.Left, OtherObj.CustomProperties.Top, OtherObj.Width, OtherObj.Height);
                        isContains = recOtherObj.Contains(rectangle1) || recOtherObj.Contains(rectangle2) || recOtherObj.Contains(rectangle3) || recOtherObj.Contains(rectangle4);
                        if (isContains)
                        {
                            break;
                        }

                    }
                    #endregion

                    if (!isContains && this.Width >= control.CustomProperties.Left + control.Width - 1 && this.Height >= control.CustomProperties.Top + control.Height - 1)
                    {
                        isCanPast = true;
                        break;
                    }

                    control.CustomProperties.Left += grid;
                }

                if (isCanPast)
                {
                    break;
                }
                control.CustomProperties.Top += grid;

            }

            #region :: Result ::

            if (isCanPast)
            {
                return control;
            }
            else
            {
                return null;
            }
            #endregion
        }
Пример #23
0
        public void UpdateLocationBoxResize(DragItem dragItem, DragHandleAnchor excludePositionAnchor)
        {

            rTopLeft.RegisterDragActive(dragItem, excludePositionAnchor);
            rTopCenter.RegisterDragActive(dragItem, excludePositionAnchor);
            rTopRight.RegisterDragActive(dragItem, excludePositionAnchor);
            rMiddleLeft.RegisterDragActive(dragItem, excludePositionAnchor);
            rMiddleRight.RegisterDragActive(dragItem, excludePositionAnchor);
            rBottomLeft.RegisterDragActive(dragItem, excludePositionAnchor);
            rBottomRight.RegisterDragActive(dragItem, excludePositionAnchor);
            rBottomCenter.RegisterDragActive(dragItem, excludePositionAnchor);
        }