Exemple #1
0
 private void MakeActiveDone(OutlinerNote note, MyEdit editor)
 {
     if (__OnMadeActive != null)
     {
         __OnMadeActive(this, new MakeActiveArgs(note, editor));
         __OnMadeActive = null;
     }
 }
Exemple #2
0
        public static void ApplyNewInlineNoteStyle(MyEdit edit, OutlinerNote note)
        {
            BaseStyle inlineStyle = note.Document.Styles.InlineNoteStyle;

            TextRange range = new TextRange(
                note.InlineNoteDocument.ContentStart,
                note.InlineNoteDocument.ContentEnd);

            inlineStyle.ApplyToRange(range);
            inlineStyle.ApplyToDocument(note.InlineNoteDocument);
        }
        public static void ApplyNewInlineNoteStyle(MyEdit edit, OutlinerNote note)
        {
            BaseStyle inlineStyle = note.Document.Styles.InlineNoteStyle;

            TextRange range = new TextRange(
                            note.InlineNoteDocument.ContentStart,
                            note.InlineNoteDocument.ContentEnd);

            inlineStyle.ApplyToRange(range);
            inlineStyle.ApplyToDocument(note.InlineNoteDocument);
        }
Exemple #4
0
        internal void MakeFirstEditorFocused()
        {
            TreeListViewItem ti = (ItemContainerGenerator.ContainerFromIndex(0) as TreeListViewItem);

            if (ti != null)
            {
                MyEdit editor = ti.GetEditor(GetViewLastEditorColumnId(), GetLastEditorColumnId(), false) as MyEdit;
                if (editor != null)
                {
                    Keyboard.Focus(editor);
                }
            }
        }
Exemple #5
0
        internal void MakeActive(OutlinerNote newNote, int focusColumnIdx, bool isActiveInlineEdit, EventHandler madeActive)
        {
            __OnMadeActive          = madeActive;
            __ColumnIdxToFocus      = focusColumnIdx;
            __ColumnToFocusIsInline = isActiveInlineEdit;

            ItemContainerGenerator itemContainerGenerator = ItemContainerGeneratorFor(newNote, true);

            if (itemContainerGenerator == null)
            {
                return;
            }

            if (itemContainerGenerator.Status != System.Windows.Controls.Primitives.GeneratorStatus.ContainersGenerated)
            {
                __NoteToMakeActive = newNote;
                itemContainerGenerator.StatusChanged += new EventHandler(itemContainerGenerator_StatusChanged);
                return;
            }

            TreeListViewItem ti = (itemContainerGenerator.ContainerFromItem(newNote) as TreeListViewItem);

            if (ti != null)
            {
                ti.Focus();

                if (__ColumnIdxToFocus == -1)
                {
                    MakeActiveDone(newNote, null);
                }
                else
                {
                    CheckMainWindow();
                    MyEdit editor = ti.GetEditor(__MainWindow.GetViewColumnId(focusColumnIdx), focusColumnIdx, isActiveInlineEdit) as MyEdit;
                    if (editor != null)
                    {
                        Keyboard.Focus(editor);
                        MakeActiveDone(newNote, editor);
                    }
                    else
                    {
                        __NoteToMakeActive = newNote;
                        __TviToMakeActive  = ti;
                        ti.LayoutUpdated  += new EventHandler(ti_LayoutUpdated);
                    }
                }
            }
        }
Exemple #6
0
        void ti_LayoutUpdated(object sender, EventArgs e)
        {
            if (__TviToMakeActive != null)
            {
                MyEdit editor = __TviToMakeActive.GetEditor(GetViewLastEditorColumnId(), GetLastEditorColumnId(), __ColumnToFocusIsInline) as MyEdit;
                if (editor != null)
                {
                    Keyboard.Focus(editor);
                    __TviToMakeActive.LayoutUpdated -= ti_LayoutUpdated;
                    __TviToMakeActive = null;
                    MakeActiveDone(__NoteToMakeActive, editor);
                }
            }

            __NoteToMakeActive = null;
        }
Exemple #7
0
        void itemContainerGenerator_StatusChanged(object sender, EventArgs e)
        {
            ItemContainerGenerator generator = sender as ItemContainerGenerator;

            if (generator == null)
            {
                return;
            }

            if (generator.Status != System.Windows.Controls.Primitives.GeneratorStatus.ContainersGenerated)
            {
                return;
            }

            generator.StatusChanged -= itemContainerGenerator_StatusChanged;
            TreeListViewItem ti = (generator.ContainerFromItem(__NoteToMakeActive) as TreeListViewItem);

            if (ti == null)
            {
                __NoteToMakeActive = null;
            }
            else
            {
                ti.Focus();

                if (__ColumnIdxToFocus == -1)
                {
                    MakeActiveDone(__NoteToMakeActive, null);
                    __NoteToMakeActive = null;
                }
                else
                {
                    MyEdit editor = ti.GetEditor(GetViewLastEditorColumnId(), GetLastEditorColumnId(), __ColumnToFocusIsInline) as MyEdit;
                    if (editor != null)
                    {
                        Keyboard.Focus(editor);
                        MakeActiveDone(__NoteToMakeActive, editor);
                        __NoteToMakeActive = null;
                    }
                    else
                    {
                        __TviToMakeActive = ti;
                        ti.LayoutUpdated += new EventHandler(ti_LayoutUpdated);
                    }
                }
            }
        }
        public static void ApplyLevelStyleForEdit(OutlinerNote note, MyEdit myEdit)
        {
            // нолевой уровень - корень
            if (note.Level == -1)
                return;

            int level = note.Level;
            LevelStyle levelStyle = note.Document.Styles.GetStyleForLevel(level);
            LevelStyle wholeDocumentStyle = note.Document.Styles.WholeDocumentStyle;

            if (myEdit != null)
            {
                wholeDocumentStyle.ApplyToMyEdit(myEdit);
                wholeDocumentStyle.ApplyToRange(myEdit.Selection);
                levelStyle.ApplyToMyEdit(myEdit);
                levelStyle.ApplyToRange(myEdit.Selection);
                //UpdateFontSettings(myEdit.Selection);
            }
        }
Exemple #9
0
        public static void ApplyLevelStyleForEdit(OutlinerNote note, MyEdit myEdit)
        {
            // нолевой уровень - корень
            if (note.Level == -1)
            {
                return;
            }

            int        level              = note.Level;
            LevelStyle levelStyle         = note.Document.Styles.GetStyleForLevel(level);
            LevelStyle wholeDocumentStyle = note.Document.Styles.WholeDocumentStyle;

            if (myEdit != null)
            {
                wholeDocumentStyle.ApplyToMyEdit(myEdit);
                wholeDocumentStyle.ApplyToRange(myEdit.Selection);
                levelStyle.ApplyToMyEdit(myEdit);
                levelStyle.ApplyToRange(myEdit.Selection);
                //UpdateFontSettings(myEdit.Selection);
            }
        }
Exemple #10
0
        private void FocusEditorForSelectedRow()
        {
            if (SelectedItem != null)
            {
                ItemContainerGenerator itemGenerator = ItemContainerGeneratorFor(SelectedItem);

                //BUG: Почему здесь иногда бывает null - не ясно
                if (itemGenerator != null)
                {
                    TreeListViewItem li = itemGenerator.ContainerFromItem(SelectedItem) as TreeListViewItem;
                    if (li != null)
                    {
                        MyEdit edit = li.GetEditor(GetViewLastEditorColumnId(), GetLastEditorColumnId(), false) as MyEdit;
                        if (edit != null)
                        {
                            Keyboard.Focus(edit);
                        }
                    }
                }
            }
        }
Exemple #11
0
 public static void ApplyLevelStyle(OutlinerNote note, MyEdit myEdit)
 {
     ApplyNewLevelStyle(note, note.Level);
 }
Exemple #12
0
 public MakeActiveArgs(OutlinerNote note, MyEdit edit)
 {
     Note = note;
     Edit = edit;
 }
Exemple #13
0
 public static void ApplyLevelStyle(OutlinerNote note, MyEdit myEdit)
 {
     ApplyNewLevelStyle(note, note.Level);
 }
Exemple #14
0
        public void OnEditGotFocus(object sender, RoutedEventArgs e)
        {
            UnsetEditorHandlers();

            __SelectedEdit = e.OriginalSource as MyEdit;

            if (__SelectedEdit == null)
                return;

            __SelectedEditColumn = GetSelectedEditColumn();
            if (__SelectedEditColumn != -1)
                __LastColumn = __SelectedEditColumn;

            SetEditorHandlers();
            Editor_SelectionChanged(sender, e);
            e.Handled = true;
        }
Exemple #15
0
 public void ApplyUndoAwarePropertyValue(MyEdit edit, TextRange range,
     DependencyProperty property, object value)
 {
     edit.ApplyUndoAwarePropertyValue(range, property, value);
 }
Exemple #16
0
        private SolidColorBrush SelectColor(MyEdit edit, TextRange range)
        {
            SolidColorBrush currentBrush = Brushes.Black;
            SolidColorBrush newBrush = null;
            if (range.GetPropertyValue(ForegroundProperty) != DependencyProperty.UnsetValue)
            {
                currentBrush = (SolidColorBrush)range.GetPropertyValue(ForegroundProperty);
            }

            ColorPickerDialog colorPicker = new ColorPickerDialog();
            colorPicker.Owner = this;

            colorPicker.cPicker.SelectedColor = currentBrush.Color;
            if (colorPicker.ShowDialog() == true)
            {
                newBrush = new SolidColorBrush(colorPicker.cPicker.SelectedColor);
                if (edit != null)
                {
                    edit.ApplyUndoAwarePropertyValue(range, ForegroundProperty, newBrush);
                }
                else
                {

                    ApplyUndoEnabledPropertyValue(OutlinerTree.SelectedItem, ForegroundProperty, newBrush);
                }
            }

            UpdateFontSettings(range);
            return newBrush;
        }
Exemple #17
0
        private void UnsetEditorHandlers()
        {
            if (__SelectedEdit != null)
            {
                __SelectedEdit.SelectionChanged -= Editor_SelectionChanged;
                __SelectedEdit.TextChanged -= Editor_TextChanged;
                __SelectedEdit.EditorCommandIssued -= Editor_CommandIssued;

                __SelectedEdit = null;
            }
        }
 public MakeActiveArgs(OutlinerNote note, MyEdit edit)
 {
     Note = note;
     Edit = edit;
 }