public void OnDragDrop(object sender, DragEventArgs e) { MpeLog.Debug("OnDragDrop()"); if (sender == null || !(sender is MpeContainer)) { MpeLog.Warn("Could not locate parent MpeContainer... Cancelling DragDrop operation."); return; } MpeContainer mpc = (MpeContainer)sender; if (e.Data.GetDataPresent(typeof(MpeControlType))) { MpeControlType type = (MpeControlType)e.Data.GetData(typeof(MpeControlType)); MpeLog.Debug("DragDrop: " + type.ToString()); MpeControl c = Parser.CreateControl(type); c.Id = ResourceList.GenerateUniqueId(); c.Location = mpc.PointToClient(new Point(e.X, e.Y)); mpc.Controls.Add(c); c.BringToFront(); Mask.SelectedControl = c; UpdatePropertyManager(); } else if (e.Data.GetDataPresent(typeof(FileInfo))) { FileInfo image = (FileInfo)e.Data.GetData(typeof(FileInfo)); MpeImage mpi = (MpeImage)Parser.CreateControl(MpeControlType.Image); mpi.Id = ResourceList.GenerateUniqueId(); mpc.Controls.Add(mpi); mpi.Texture = image; mpi.AutoSize = true; mpi.Location = mpc.PointToClient(new Point(e.X, e.Y)); mpi.BringToFront(); Mask.SelectedControl = mpi; UpdatePropertyManager(); } else { MpeLog.Debug("Unknown DataType... Cancelling DragDrop"); return; } Focus(); }
public virtual void CutControl() { if (AllowDeletions) { if (mask.SelectedControl != screen && mask.SelectedControl.MpeParent != null) { try { MpeControl control = mask.SelectedControl; MpeContainer parent = control.MpeParent; parent.Controls.Remove(control); mpe.Clipboard = control; mask.SelectedControl = null; UpdatePropertyManager(); } catch (Exception ee) { MpeLog.Debug(ee); MpeLog.Error(ee); } } } }
protected override bool ProcessCmdKey(ref Message msg, Keys keyData) { if (mask.SelectedControl == null) { return(false); } if (msg.Msg == WM_KEYDOWN || msg.Msg == WM_SYSKEYDOWN) { MpeContainer parent = mask.SelectedControl.MpeParent; switch (keyData) { case Keys.Right: if (parent.LayoutStyle == MpeLayoutStyle.Grid) { if (mask.LocationLocked == false) { mask.Hide(); mask.SelectedControl.Left += (mask.GridSize.Width - (mask.SelectedControl.Left % mask.GridSize.Width)); } else { mpe.StatusBar.Warn( "The selected control is LocationLocked and cannot be moved using the keyboard or mouse"); } } else if (parent.LayoutStyle == MpeLayoutStyle.HorizontalFlow) { mask.SelectedControl.SendBack(); } break; case Keys.Right | Keys.Shift: if (parent.LayoutStyle == MpeLayoutStyle.Grid) { if (mask.LocationLocked == false) { mask.Hide(); mask.SelectedControl.Left++; } else { mpe.StatusBar.Warn( "The selected control is LocationLocked and cannot be moved using the keyboard or mouse"); } } break; case Keys.Right | Keys.Control: if (parent.Spring == false) { if (mask.SizeLocked == false) { mask.Hide(); mask.SelectedControl.Width += (mask.GridSize.Width - (mask.SelectedControl.Width % mask.GridSize.Width)); } else { mpe.StatusBar.Warn( "The selected control is SizeLocked and cannot be resized using the keyboard or mouse"); } } break; case Keys.Right | Keys.Control | Keys.Shift: if (parent.Spring == false) { if (mask.SizeLocked == false) { mask.Hide(); mask.SelectedControl.Width++; } else { mpe.StatusBar.Warn( "The selected control is SizeLocked and cannot be resized using the keyboard or mouse"); } } break; case Keys.Left: if (parent.LayoutStyle == MpeLayoutStyle.Grid) { if (mask.LocationLocked == false) { mask.Hide(); mask.SelectedControl.Left -= (mask.GridSize.Width - (mask.SelectedControl.Left % mask.GridSize.Width)); } else { mpe.StatusBar.Warn( "The selected control is LocationLocked and cannot be moved using the keyboard or mouse"); } } else if (parent.LayoutStyle == MpeLayoutStyle.HorizontalFlow) { mask.SelectedControl.BringForward(); } break; case Keys.Left | Keys.Shift: if (parent.LayoutStyle == MpeLayoutStyle.Grid) { if (mask.LocationLocked == false) { mask.Hide(); mask.SelectedControl.Left--; } else { mpe.StatusBar.Warn( "The selected control is LocationLocked and cannot be moved using the keyboard or mouse"); } } break; case Keys.Left | Keys.Control: if (parent.Spring == false) { if (mask.SizeLocked == false) { mask.Hide(); mask.SelectedControl.Width -= (mask.GridSize.Width - (mask.SelectedControl.Width % mask.GridSize.Width)); if (mask.SelectedControl.Width < mask.MinControlSize.Width) { mask.SelectedControl.Width = mask.MinControlSize.Width; } } else { mpe.StatusBar.Warn( "The selected control is SizeLocked and cannot be resized using the keyboard or mouse"); } } break; case Keys.Left | Keys.Control | Keys.Shift: if (parent.Spring == false) { if (mask.SizeLocked == false) { mask.Hide(); mask.SelectedControl.Width--; if (mask.SelectedControl.Width < mask.MinControlSize.Width) { mask.SelectedControl.Width = mask.MinControlSize.Width; } } else { mpe.StatusBar.Warn( "The selected control is SizeLocked and cannot be resized using the keyboard or mouse"); } } break; case Keys.Up: if (parent.LayoutStyle == MpeLayoutStyle.Grid) { if (mask.LocationLocked == false) { mask.Hide(); mask.SelectedControl.Top -= (mask.GridSize.Height - (mask.SelectedControl.Top % mask.GridSize.Height)); } else { mpe.StatusBar.Warn( "The selected control is LocationLocked and cannot be moved using the keyboard or mouse"); } } else if (parent.LayoutStyle == MpeLayoutStyle.VerticalFlow) { mask.SelectedControl.BringForward(); } break; case Keys.Up | Keys.Shift: if (parent.LayoutStyle == MpeLayoutStyle.Grid) { if (mask.LocationLocked == false) { mask.Hide(); mask.SelectedControl.Top--; } else { mpe.StatusBar.Warn( "The selected control is LocationLocked and cannot be moved using the keyboard or mouse"); } } break; case Keys.Up | Keys.Control: if (parent.Spring == false) { if (mask.SizeLocked == false) { mask.Hide(); mask.SelectedControl.Height -= (mask.GridSize.Height - (mask.SelectedControl.Height % mask.GridSize.Height)); if (mask.SelectedControl.Height < mask.MinControlSize.Height) { mask.SelectedControl.Height = mask.MinControlSize.Height; } } else { mpe.StatusBar.Warn( "The selected control is SizeLocked and cannot be resized using the keyboard or mouse"); } } break; case Keys.Up | Keys.Control | Keys.Shift: if (parent.Spring == false) { if (mask.SizeLocked == false) { mask.Hide(); mask.SelectedControl.Height--; if (mask.SelectedControl.Height < mask.MinControlSize.Height) { mask.SelectedControl.Height = mask.MinControlSize.Height; } } else { mpe.StatusBar.Warn( "The selected control is SizeLocked and cannot be resized using the keyboard or mouse"); } } break; case Keys.Down: if (parent.LayoutStyle == MpeLayoutStyle.Grid) { if (mask.LocationLocked == false) { mask.Hide(); mask.SelectedControl.Top += (mask.GridSize.Height - (mask.SelectedControl.Top % mask.GridSize.Height)); } else { mpe.StatusBar.Warn( "The selected control is LocationLocked and cannot be moved using the keyboard or mouse"); } } else if (parent.LayoutStyle == MpeLayoutStyle.VerticalFlow) { mask.SelectedControl.SendBack(); } break; case Keys.Down | Keys.Shift: if (parent.LayoutStyle == MpeLayoutStyle.Grid) { if (mask.LocationLocked == false) { mask.Hide(); mask.SelectedControl.Top++; } else { mpe.StatusBar.Warn( "The selected control is LocationLocked and cannot be moved using the keyboard or mouse"); } } break; case Keys.Down | Keys.Control: if (parent.Spring == false) { if (mask.SizeLocked == false) { mask.Hide(); mask.SelectedControl.Height += (mask.GridSize.Height - (mask.SelectedControl.Height % mask.GridSize.Height)); } else { mpe.StatusBar.Warn( "The selected control is SizeLocked and cannot be resized using the keyboard or mouse"); } } break; case Keys.Down | Keys.Control | Keys.Shift: if (parent.Spring == false) { if (mask.SizeLocked == false) { mask.Hide(); mask.SelectedControl.Height++; } else { mpe.StatusBar.Warn( "The selected control is SizeLocked and cannot be resized using the keyboard or mouse"); } } break; } } return(true); }
public void OnMenuSelection(MenuCommand command) { if (command == null || command.Enabled == false || mask.SelectedControl == null) { return; } switch (command.Text) { case "Parent": mask.SelectedControl = mask.SelectedControl.MpeParent; UpdatePropertyManager(); break; case "Send To Back": mask.SelectedControl.SendToBack(); break; case "Bring To Front": mask.SelectedControl.BringToFront(); break; case "Cut": CutControl(); break; case "Copy": CopyControl(); break; case "Paste": PasteControl(); break; case "Delete": if (AllowDeletions) { if (mask.SelectedControl.MpeParent != null) { try { MpeControl control = mask.SelectedControl; MpeContainer parent = control.MpeParent; parent.Controls.Remove(control); mask.SelectedControl = null; UpdatePropertyManager(); } catch (Exception ee) { MpeLog.Debug(ee); MpeLog.Error(ee); } } } break; case "Properties": mpe.FocusPropertyManager(); break; case "Test": //mask2.SelectedControl = mask.SelectedControl; break; } }