protected virtual bool FocusLastProtected() { MathBox box = AvailableBoxes.LastOrDefault(); if (box == null) { return(false); } FocusBox(box, BoxCaretPosition.End); return(true); }
private bool FocusPreviousPrivate() { int?focusedIndex = GetFocusedIndex(); if (focusedIndex == null) { return(false); } if (focusedIndex == 0) { return(false); } MathBox box = AvailableBoxes[focusedIndex.Value - 1]; FocusBox(box, BoxCaretPosition.End); return(true); }
private bool FocusNextPrivate() { MathBox[] visibleBoxes = AvailableBoxes; int? focusedIndex = GetFocusedIndex(); if (focusedIndex == null) { return(false); } if (focusedIndex == visibleBoxes.Length - 1) { return(false); } MathBox box = visibleBoxes[focusedIndex.Value + 1]; FocusBox(box, BoxCaretPosition.Start); return(true); }
void AddColumn() { contentGrid.ColumnDefinitions.Add( new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Auto) } ); for (int i = 0; i < rowCount; i++) { var box = new MathBox(); AttachEvents(box); box.SetValue(Grid.RowProperty, i); box.SetValue(Grid.ColumnProperty, columnCount); boxRows[i].Add(box); contentGrid.Children.Add(box); } columnCount++; }
private MathBox GetElementBox(ElementBox elementBox) { MathBox box = null; switch (elementBox) { case ElementBox.Main: box = main; break; case ElementBox.Sub: box = sub; break; case ElementBox.Sup: box = sup; break; } return(box); }
void AddRow() { contentGrid.RowDefinitions.Add( new RowDefinition() { Height = new GridLength(1, GridUnitType.Auto) } ); var newRow = new List <MathBox>(); for (int i = 0; i < columnCount; i++) { var box = new MathBox(); AttachEvents(box); box.SetValue(Grid.RowProperty, rowCount); box.SetValue(Grid.ColumnProperty, i); newRow.Add(box); contentGrid.Children.Add(box); } boxRows.Add(newRow); rowCount++; }
private void AttachEvents(MathBox box) { box.NextMatrixRowRequested += HandleNextRowRequested; box.NextMatrixColumnRequested += HandleNextColumnRequested; }
public void FocusBox(ElementBox elementBox, BoxCaretPosition boxCaretPosition = BoxCaretPosition.Default) { MathBox mathBox = GetElementBox(elementBox); FocusBox(mathBox, boxCaretPosition); }
protected void SetCaretPosition(MathBox mathBox, BoxCaretPosition boxCaretPosition) => mathBox.SetCaretPosition(boxCaretPosition);
protected void FocusBox(MathBox mathBox, BoxCaretPosition boxCaretPosition = BoxCaretPosition.Start) { Dispatcher.InvokeAsync(mathBox.Focus, System.Windows.Threading.DispatcherPriority.Input); SetCaretPosition(mathBox, boxCaretPosition); }