Пример #1
0
        protected virtual bool FocusLastProtected()
        {
            MathBox box = AvailableBoxes.LastOrDefault();

            if (box == null)
            {
                return(false);
            }
            FocusBox(box, BoxCaretPosition.End);
            return(true);
        }
Пример #2
0
        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);
        }
Пример #3
0
        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);
        }
Пример #4
0
        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);
        }
Пример #6
0
        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++;
        }
Пример #7
0
 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);
        }
Пример #9
0
 protected void SetCaretPosition(MathBox mathBox, BoxCaretPosition boxCaretPosition) =>
 mathBox.SetCaretPosition(boxCaretPosition);
Пример #10
0
 protected void FocusBox(MathBox mathBox, BoxCaretPosition boxCaretPosition = BoxCaretPosition.Start)
 {
     Dispatcher.InvokeAsync(mathBox.Focus,
                            System.Windows.Threading.DispatcherPriority.Input);
     SetCaretPosition(mathBox, boxCaretPosition);
 }