Пример #1
0
 public void Locate()
 {
     if (this.Info.PanelX > 0)
     {
         GroupBox g = GetTargetControl(this.Info.PanelX);
         if (g != null)
         {
             PlaceFeeder(this, g);
         }
         else
         {
             MessageBox.Show("Could not find Panel No: " + this.Info.PanelX.ToString());
         }
     }
     else
     {
         GroupBox g = GetTargetControl();
         if (g != null)
         {
             g.Controls.Add(this);
             PanelTag tag = g.Tag as PanelTag;
             tag.IsEmpty      = false;
             this.Info.PanelX = tag.Index;
             this.IsArranged  = true;
         }
         else
         {
             MessageBox.Show("Could not find Empty Panel");
         }
     }
 }
Пример #2
0
        private GroupBox GetTargetControl(int index)
        {
            foreach (Control control in PanelArranged.Controls)
            {
                if (control is GroupBox)
                {
                    PanelTag tag = control.Tag as PanelTag;
                    if (tag.Index == index)
                    {
                        return(control as GroupBox);
                    }
                }
            }

            return(null);
        }
Пример #3
0
        void PlaceFeeder(MvButton feeder, Control control)
        {
            if (feeder == null)
            {
                return;
            }

            if (control is GroupBox)
            {
                PanelTag tag = control.Tag as PanelTag;
                feeder.Info.PanelX = tag.Index;
                feeder.IsArranged  = true;
                this.Location      = LocationOnGroupBox;
                control.Controls.Add(feeder);
                feeder.BringToFront();
            }
        }
Пример #4
0
        private MvButton FlyToTheTarget(Control sourceGroupBox, Control targetControl)
        {
            MvButton sourceFeeder = GetFirstFeederInPanel(sourceGroupBox);
            MvButton targetFeeder = GetFirstFeederInPanel(targetControl);

            if (sourceFeeder == null)
            {
                return(targetFeeder);
            }

            if (targetControl is GroupBox)
            {
                Point targetLocation = new Point(targetControl.Location.X + LocationOnGroupBox.X, targetControl.Location.Y + LocationOnGroupBox.Y);
                Point feederLocation = new Point(sourceGroupBox.Location.X + LocationOnGroupBox.X, sourceGroupBox.Location.Y + LocationOnGroupBox.Y);
                sourceGroupBox.Controls.Remove(sourceFeeder);
                sourceFeeder.IsArranged = false;
                this.PanelArranged.Controls.Add(sourceFeeder);

                FlyTo(sourceFeeder, feederLocation, targetLocation, 50);

                PanelTag tag = targetControl.Tag as PanelTag;
                sourceFeeder.Info.PanelX = tag.Index;
                sourceFeeder.IsArranged  = true;
                sourceFeeder.Location    = LocationOnGroupBox;
                targetControl.Controls.Add(sourceFeeder);
            }
            else
            {
                Point feederLocation = new Point(sourceGroupBox.Location.X + sourceFeeder.Location.X, sourceGroupBox.Location.Y + sourceFeeder.Location.Y);
                Point targetLocation = new Point(sourceGroupBox.Location.X + 50, sourceGroupBox.Location.Y + 15);

                sourceGroupBox.Controls.Remove(sourceFeeder);
                sourceFeeder.IsArranged = false;
                this.PanelArranged.Controls.Add(sourceFeeder);

                FlyTo(sourceFeeder, feederLocation, targetLocation, 25);

                sourceFeeder.Location = targetLocation;
            }

            UnPlaceFeeder(targetFeeder);

            return(targetFeeder);
        }
Пример #5
0
        private void ShiftPanels()
        {
            PanelTag tag         = _sourceControl.Tag as PanelTag;
            int      sourceIndex = tag.Index;

            _targetControl = GetTargetControl(this.Location);
            if (_targetControl == null)
            {
                return;
            }

            tag = _targetControl.Tag as PanelTag;
            int targetIndex = tag.Index;

            if (targetIndex > sourceIndex)
            {
                for (int i = sourceIndex; i < targetIndex; i++)
                {
                    GroupBox sourceControl = GetTargetControl(i + 1);
                    GroupBox targetControl = GetTargetControl(i);

                    FlyToTheTarget(sourceControl, targetControl);
                }
            }
            else if (targetIndex < sourceIndex)
            {
                for (int i = sourceIndex; i > targetIndex; i--)
                {
                    GroupBox sourceControl = GetTargetControl(i - 1);
                    GroupBox targetControl = GetTargetControl(i);

                    FlyToTheTarget(sourceControl, targetControl);
                }
            }

            PlaceFeeder(this, _targetControl);
            return;
        }