private void RestoreControlState(UndoControlState state) { var elem = state.Element; var ctl = elem as Control; if (ctl != null && (state.Operation & UndoOperation.Position) != 0) { ctl.SuspendLayout(); ctl.SetBounds(state.Bounds.X, state.Bounds.Y, state.Bounds.Width, state.Bounds.Height); ctl.ResumeLayout(); } if ((state.Operation & UndoOperation.Text) != 0) { TranslationToolHelperWinClient.SetComponentText(elem, state.Caption); } if (ctl != null && (state.Operation & UndoOperation.Visibility) != 0) { ctl.Visible = state.Visible; } if (state.RelatedChanges != null && state.RelatedChanges.Length > 0) { foreach (var change in state.RelatedChanges) { RestoreControlState(change); } } }
private void Size_MouseDown(object sender, MouseEventArgs e) { if (e.Button != MouseButtons.Left) { return; } ControlEdge edge; if (!IsCursorInsideResizeArea(sender, e, out edge)) { return; } m_Resizing = true; var ctl = sender as Control; if (ctl != null) { ctl.Capture = true; if (StoredUndoState == null) { StoredUndoState = new UndoControlState { Element = RealControl, Bounds = ctl.Bounds, Operation = UndoOperation.Position }; RaiseCreateUndoStateEvent(new ControlDesignerEventArgs { UndoState = StoredUndoState }); } } }
public UndoControlState Push(Component ctl, bool visibility) { var state = new UndoControlState() { Element = ctl, Operation = UndoOperation.Visibility, Visible = visibility }; m_UndoStack.Push(state); return(state); }
public UndoControlState Push(Component ctl, string caption) { var state = new UndoControlState() { Element = ctl, Operation = UndoOperation.Text, Caption = caption }; m_UndoStack.Push(state); return(state); }
public UndoControlState Push(Component ctl, Rectangle bounds) { var state = new UndoControlState() { Element = ctl, Operation = UndoOperation.Position, Bounds = bounds }; m_UndoStack.Push(state); return(state); }
public UndoControlState Push(Component ctl, UndoOperation operation, Rectangle bounds, string caption, bool visibility) { var state = new UndoControlState() { Element = ctl, Operation = operation, Bounds = bounds, Caption = caption, Visible = visibility }; m_UndoStack.Push(state); return(state); }
private void GetChangeFromUndoState(UndoControlState undoState, Dictionary <object, DesignElement> changes) { DesignElement de = DesignElement.None; if ((undoState.Operation & UndoOperation.Text) != 0) { de |= DesignElement.Caption; } var ctl = undoState.Element as Control; if (ctl != null) { if ((undoState.Operation & UndoOperation.Position) != 0) { if (ctl.Location != undoState.Bounds.Location) { de |= DesignElement.Moving; } if (ctl.Size != undoState.Bounds.Size) { de |= DesignElement.Sizing; } } if ((undoState.Operation & UndoOperation.Visibility) != 0) { de |= DesignElement.Visibility; } } if (de == DesignElement.None) { return; } object element = undoState.Element is ControlDesignerProxy ? (undoState.Element as ControlDesignerProxy).HostControl : undoState.Element; if (!changes.ContainsKey(element)) { changes.Add(element, de); } else { changes[element] |= de; } }
public List <ControlDesignerEventArgs> GetChanges() { var changes = new List <ControlDesignerEventArgs>(); foreach (CategoryRow cRow in menuEditoGrid.Rows) { foreach (EditorRow eRow in cRow.ChildRows) { var link = eRow.Tag as BarItemLink; if (link != null && !Utils.IsEmpty(eRow.Properties.Value) && !link.Item.Caption.Equals(eRow.Properties.Value)) { var state = new UndoControlState { Element = link.Item, Caption = link.Item.Caption, Operation = UndoOperation.Text }; link.Item.Caption = eRow.Properties.Value.ToString(); changes.Add(new ControlDesignerEventArgs { UndoState = state }); } } } return(changes); }
public UndoControlState Push(UndoControlState state) { m_UndoStack.Push(state); return(state); }