lu
2025-02-24 81c71369f5e61917324c427b35cc5849b3aaa136
DevApp/Gs.DevApp/ToolBox/DragResizeHelp.cs
@@ -1,4 +1,5 @@
using System;
using DevExpress.XtraCharts;
using System;
using System.Drawing;
using System.Windows.Forms;
@@ -90,19 +91,29 @@
            dragBox2_Container.Show();
        }
        #region Public Method
        public static void RegisterControl(DevExpress.XtraEditors.XtraForm frm, Control control, Control box1, Label lbMsg)
        public static void RegisterControl(DevExpress.XtraEditors.XtraForm frm, Control box1, Label lbMsg)
        {
            InitializeComponent(frm);
            if (control != null)
            foreach (Control control in box1.Controls)
            {
                sbMsg = lbMsg;
                dragBox1 = box1;
                dragCurrent_Name = box1.Name;
                control.MouseDown += new MouseEventHandler(control_MouseDown);
                control.MouseLeave += new EventHandler(control_MouseLeave);
                control.MouseMove += new MouseEventHandler(control_MouseMove);
                control.Resize += myPanel_Resize;
                if (control != null)
                {
                    sbMsg = lbMsg;
                    dragBox1 = box1;
                    dragCurrent_Name = box1.Name;
                    control.MouseDown += new MouseEventHandler(control_MouseDown);
                    control.MouseLeave += new EventHandler(control_MouseLeave);
                    control.MouseMove += new MouseEventHandler(control_MouseMove);
                    control.MouseUp += Control_MouseUp;
                    control.Resize += myPanel_Resize;
                }
            }
        }
        private static void Control_MouseUp(object sender, MouseEventArgs e)
        {
            (sender as Control).Refresh();
        }
        public static void UnRegisterControl(Control control)
@@ -123,6 +134,8 @@
            p1.Y = e.Y;
            isDragging = true;
            dragCurrent_Name = (sender as Control).Parent.Name;
        }
        private static void myPanel_Resize(object sender, EventArgs e)
@@ -136,6 +149,8 @@
                    childControl.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
                    int newY = (panel.ClientSize.Height - childControl.Height) / 2;
                    childControl.Location = new Point(childControl.Location.X, newY);
                }
            }
@@ -249,6 +264,16 @@
                    default:
                        break;
                }
                control.Refresh();
                Graphics g = control.CreateGraphics();
                int width = control.Width;
                int height = control.Height;
                Point[] ps =  { new Point(0, 0),new Point(width - 1, 0),
    new Point(width - 1, height - 1),new Point(0, height - 1),new Point(0, 0) };
                g.DrawLines(new Pen(Color.LightCoral), ps);
            }