public override bool ConsumeKey(Key key) { if ((Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift)) && (new[] { Key.Right, Key.Left, Key.Up, Key.Down, Key.Home, Key.End }).Contains(key)) { if (!IsSelecting) { IsSelecting = true; ((RowContainer)ActiveChild).StartSelection(); } ActiveChild.Select(key); AdjustCarets(); return(true); } Key[] handledKeys = { Key.Left, Key.Right, Key.Delete, Key.Up, Key.Down, Key.Enter, Key.Escape, Key.Back, Key.Home, Key.End }; bool result = false; if (handledKeys.Contains(key)) { result = true; if (IsSelecting && (new[] { Key.Delete, Key.Enter, Key.Back }).Contains(key)) { ActiveChild.RemoveSelection(true); } else { ActiveChild.ConsumeKey(key); } CalculateSize(); AdjustCarets(); DeSelect(); } return(result); }
public override void RemoveSelection(bool registerUndo) { if (IsSelecting) { ActiveChild.RemoveSelection(registerUndo); CalculateSize(); AdjustCarets(); DeSelect(); } }
public override void ConsumeText(string text) { int undoCount = UndoManager.UndoCount + 1; if (IsSelecting) { ActiveChild.RemoveSelection(true); } ActiveChild.ConsumeText(text); if (IsSelecting && undoCount < UndoManager.UndoCount) { UndoManager.ChangeUndoCountOfLastAction(1); } CalculateSize(); AdjustCarets(); DeSelect(); }
public override void Paste(XElement xe) { string id = xe.Element("SessionId").Value; if (id != sessionString) { textManager.ProcessPastedXML(xe); } int undoCount = UndoManager.UndoCount + 1; if (IsSelecting) { ActiveChild.RemoveSelection(true); } ActiveChild.Paste(xe.Element("payload").Elements().First()); if (IsSelecting && undoCount < UndoManager.UndoCount) { UndoManager.ChangeUndoCountOfLastAction(1); } CalculateSize(); AdjustCarets(); DeSelect(); }
public void HandleUserCommand(CommandDetails commandDetails) { if (commandDetails.CommandType == CommandType.Text) { ConsumeText(commandDetails.UnicodeString); //ConsumeText() will call DeSelect() itself. No worries here } else { int undoCount = UndoManager.UndoCount + 1; if (IsSelecting) { ActiveChild.RemoveSelection(true); } ((EquationContainer)ActiveChild).ExecuteCommand(commandDetails.CommandType, commandDetails.CommandParam); if (IsSelecting && undoCount < UndoManager.UndoCount) { UndoManager.ChangeUndoCountOfLastAction(1); } CalculateSize(); AdjustCarets(); DeSelect(); } }