Пример #1
0
        public CustomControl AddCustomControl(int x, int y)
        {
            //Add new cimage control
            CustomControl picture = new CustomControl();

            picture.ControlType = CustomControlType.Button;

            picture.OnActivate = ControlActivate;
            picture.OnSelected = ControlSelected;
            picture.KeyDown += (s, e) => OnKeyDown(e);

            picture.OnDelete += (s) => ControlRemoveSelected();
            picture.MouseDoubleClick += (s, e) => OnMouseDoubleClick(e);

            picture.OnPropertyRefresh += OnPropertyRefresh;

            picture.MouseDown += (s, even) =>
            {
                var element = (s as CustomControl);
                if (even.Button == System.Windows.Forms.MouseButtons.Left && element.CanMove)
                    MouseDownLocation = even.Location;

                InfoElement(element);

                element.Focus();

            };

            picture.MouseMove += (s, even) =>
            {
                var element = (s as CustomControl);
                if (even.Button == System.Windows.Forms.MouseButtons.Left && element.CanMove)
                {
                    element.Left = element.Element.X = even.X + element.Left - MouseDownLocation.X;
                    element.Top = element.Element.Y = even.Y + element.Top - MouseDownLocation.Y;
                }

                InfoElement(element);
            };

            picture.X = x;
            picture.Y = y;

            picture.Width = 300;
            picture.Height = 300;
            picture.BackColor = Color.Black;
            PanelContainer.Controls.Add(picture);
            picture.BringToFront();

            return picture;
        }
Пример #2
0
 public void SelectControl(CustomControl s)
 {
     if (SelectedControl != null && SelectedControl != s)
     {
         SelectedControl.IsSelected = false;
     }
     FillProperties(s);
     SelectedControl = s;
 }
Пример #3
0
 public void InfoElement(CustomControl control)
 {
     //stripstatus_info.Text = control.Name;
     stripstatus_info.Text = string.Format("Position: ({0},{1})", control.Left, control.Top);
 }
Пример #4
0
 public void FillProperties(CustomControl s)
 {
     if (s != null)
     {
         propertyControl.SelectedObject = s.Element;
     }
     else
     {
         propertyControl.SelectedObject = null;
     }
 }
Пример #5
0
 public void ControlSelected(CustomControl control, bool value)
 {
     SelectControl(value ? control : null);
 }
Пример #6
0
        public void ControlRemoveSelected()
        {
            if (SelectedControl != null)
            {

                PanelContainer.Controls.Remove(SelectedControl);
                SelectedControl = null;
            }
        }
Пример #7
0
 public void ControlActivate(CustomControl control, bool value)
 {
     control.Focus();
     control.BringToFront();
     control.Dock = (value) ? DockStyle.Fill : DockStyle.None;
 }