private MvButton GetFirstFeederInPanel(Control control) { if (control is GroupBox) { foreach (Control c in control.Controls) { MvButton button = c as MvButton; if (button != null) { return(button); } } } return(null); }
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(); } }
void UnPlaceFeeder(MvButton feeder) { if (feeder == null) { return; } if (feeder.Parent is GroupBox) { feeder.Location = new Point(feeder.Parent.Location.X + feeder.Location.X, feeder.Parent.Location.Y + feeder.Location.Y); feeder.Parent.Controls.Remove(feeder); PanelArranged.Controls.Add(feeder); this.IsArranged = false; } feeder.BringToFront(); }
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); }
public PanelTag(int index) { this.Index = index; this.IsEmpty = true; this.Feeder = null; }