Ejemplo n.º 1
0
        protected virtual bool FocusLastProtected()
        {
            MathBox box = AvailableBoxes.LastOrDefault();

            if (box == null)
            {
                return(false);
            }
            FocusBox(box, BoxCaretPosition.End);
            return(true);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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++;
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 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++;
        }
Ejemplo n.º 7
0
 private void AttachEvents(MathBox box)
 {
     box.NextMatrixRowRequested    += HandleNextRowRequested;
     box.NextMatrixColumnRequested += HandleNextColumnRequested;
 }
Ejemplo n.º 8
0
        public void FocusBox(ElementBox elementBox, BoxCaretPosition boxCaretPosition = BoxCaretPosition.Default)
        {
            MathBox mathBox = GetElementBox(elementBox);

            FocusBox(mathBox, boxCaretPosition);
        }
Ejemplo n.º 9
0
 protected void SetCaretPosition(MathBox mathBox, BoxCaretPosition boxCaretPosition) =>
 mathBox.SetCaretPosition(boxCaretPosition);
Ejemplo n.º 10
0
 protected void FocusBox(MathBox mathBox, BoxCaretPosition boxCaretPosition = BoxCaretPosition.Start)
 {
     Dispatcher.InvokeAsync(mathBox.Focus,
                            System.Windows.Threading.DispatcherPriority.Input);
     SetCaretPosition(mathBox, boxCaretPosition);
 }