Exemple #1
0
        public static void IncreaseIndent(OutlinerNote row, TreeListView outlinerTree, bool applyStyle)
        {
            if (!CanIncreaseIndent(row))
            {
                return;
            }

            int  activeColumn        = DocumentHelpers.GetFocusedColumnIdx(outlinerTree, row);
            bool isInlineNoteFocused = DocumentHelpers.IsInlineNoteFocused(outlinerTree);

            ObservableCollection <OutlinerNote> parentCollection = row.Document.GetParentCollection(row);
            int idx = GetNoteIndexAtParent(row);

            parentCollection.Remove(row);

            OutlinerNote newNote = new OutlinerNote(parentCollection[idx - 1]);

            newNote.Clone(row);

            DocumentHelpers.CopyNodesRecursively(newNote, row);

            parentCollection[idx - 1].SubNotes.Add(newNote);
            parentCollection[idx - 1].IsExpanded = true;

            row.Parent.UpdateParentCheckboxes();
            newNote.UpdateParentCheckboxes();
            if (applyStyle)
            {
                outlinerTree.MakeActive(newNote, activeColumn, isInlineNoteFocused, new EventHandler(ApplyStyleAfterMakeActive));
            }
            else
            {
                outlinerTree.MakeActive(newNote, activeColumn, isInlineNoteFocused);
            }
        }
Exemple #2
0
        public static void ApplyNewLevelStyle(OutlinerNote note, int newLevel)
        {
            // нолевой уровень - корень
            if (newLevel <= 0)
            {
                return;
            }

            UndoLevelStyle undoLevelStyle = new UndoLevelStyle(note);

            if (note.LastStyleApplied != null)
            {
                note.LastStyleApplied.UnapplyStyle(note);
            }

            LevelStyle levelStyle         = note.Document.Styles.GetStyleForLevel(newLevel);
            LevelStyle wholeDocumentStyle = note.Document.Styles.WholeDocumentStyle;

            wholeDocumentStyle.ApplyToNote(note);
            levelStyle.ApplyToNote(note);
            note.LastStyleApplied = levelStyle;

            undoLevelStyle.StyleApplied(note);

            note.Document.UndoManager.PushUndoAction(undoLevelStyle);
        }
Exemple #3
0
 private void MakeActiveDone(OutlinerNote note, MyEdit editor)
 {
     if (__OnMadeActive != null)
     {
         __OnMadeActive(this, new MakeActiveArgs(note, editor));
         __OnMadeActive = null;
     }
 }
Exemple #4
0
        internal OutlinerNote GetRoot()
        {
            OutlinerNote tmpParent = __Parent;

            while (!tmpParent.IsRoot)
            {
                tmpParent = tmpParent.Parent;
            }

            return(tmpParent);
        }
Exemple #5
0
 public static void GetLinearNotesList(OutlinerNote outlinerNote, List <OutlinerNote> notes, bool expandCollapsed)
 {
     for (int i = 0; i < outlinerNote.SubNotes.Count; i++)
     {
         notes.Add(outlinerNote.SubNotes[i]);
         if (expandCollapsed || outlinerNote.SubNotes[i].IsExpanded == true)
         {
             GetLinearNotesList(outlinerNote.SubNotes[i], notes, expandCollapsed);
         }
     }
 }
Exemple #6
0
 public OutlinerNote(OutlinerDocument document, OutlinerNoteCollection Subnotes)
 {
     this.__Document  = document;
     this.__Parent    = null;
     __IsDocumentRoot = true;
     this.__Subnotes  = Subnotes;
     this.__Subnotes.Collection.CollectionChanged += new NotifyCollectionChangedEventHandler(Collection_CollectionChanged);
     Id    = s_id;
     s_id += 1;
     CreateColumnData();
 }
Exemple #7
0
        public static int GetFocusedColumnIdx(TreeListView outlinerTree, OutlinerNote note)
        {
            MainWindow mainWindow = DragDropHelper.GetMainWindow(outlinerTree);

            if (mainWindow.IsEditorSelected == true)
            {
                return(mainWindow.LastColumn);
            }

            return(-1);
        }
Exemple #8
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 #10
0
        public static bool CanMoveNodeDown(OutlinerNote note, TreeListView outlinerTree)
        {
            int selectedIndex = note.Parent.SubNotes.IndexOf(note);

            if (selectedIndex >= note.Parent.SubNotes.Count - 1)
            {
                return(false);
            }

            return(true);
        }
Exemple #11
0
        public static void CopyNodesRecursively(OutlinerNote destination, OutlinerNote source)
        {
            foreach (OutlinerNote subnote in source.SubNotes)
            {
                OutlinerNote newNote = new OutlinerNote(destination);
                newNote.Clone(subnote);
                destination.SubNotes.Add(newNote);

                CopyNodesRecursively(newNote, subnote);
            }
        }
Exemple #12
0
        public OutlinerNote(OutlinerNote parent)
        {
            this.__Document = parent.Document;
            this.__Parent   = parent;

            this.__Subnotes = new OutlinerNoteCollection();
            this.__Subnotes.Collection.CollectionChanged += new NotifyCollectionChangedEventHandler(Collection_CollectionChanged);
            CreateColumnData();

            Id    = s_id;
            s_id += 1;
        }
Exemple #13
0
        public static bool CanIncreaseIndent(OutlinerNote row)
        {
            ObservableCollection <OutlinerNote> parentCollection = row.Document.GetParentCollection(row);
            int idx = GetNoteIndexAtParent(row);

            if (idx == -1 || idx == 0)
            {
                return(false);
            }

            return(true);
        }
Exemple #14
0
        public OutlinerNote(OutlinerNote parent)
        {
            this.__Document = parent.Document;
            this.__Parent = parent;

            this.__Subnotes = new OutlinerNoteCollection();
            this.__Subnotes.Collection.CollectionChanged += new NotifyCollectionChangedEventHandler(Collection_CollectionChanged);
            CreateColumnData();

            Id = s_id;
            s_id += 1;
        }
Exemple #15
0
        public static TreeListViewItem GetContainerForItem(TreeListView view, OutlinerNote note)
        {
            ItemContainerGenerator generator = view.ItemContainerGeneratorFor(note);
            if (generator == null)
                return null;

            TreeListViewItem container = generator.ContainerFromItem(note) as TreeListViewItem;
            if (container == null)
                return null;

            return container;
        }
Exemple #16
0
        private void CopyInlineNote(OutlinerNote throwawayNote)
        {
            if (throwawayNote.InlineNoteDocument == null)
            {
                return;
            }

            FlowDocument inlineDoc = throwawayNote.InlineNoteDocument;

            __InlineNoteDocument = FlowDocumentUtils.CopyFlowDocument(inlineDoc);
            OnPropertyChanged("HasInlineNote");
            OnPropertyChanged("InlineNoteDocument");
        }
Exemple #17
0
        public void UpdateParentCheckboxes()
        {
            OutlinerNote parent = Parent;

            while (parent != null)
            {
                parent.OnPropertyChanged("IsChecked");
                parent.OnPropertyChanged("IsCheckedDirect");
                parent = parent.Parent;
            }

            OnPropertyChanged("IsChecked");
            OnPropertyChanged("IsCheckedDirect");
        }
Exemple #18
0
        public static bool CanDecreaseIndent(OutlinerNote selectedRow)
        {
            if (selectedRow == null)
            {
                return(false);
            }

            if (selectedRow.Parent.IsRoot)
            {
                return(false);
            }

            return(true);
        }
Exemple #19
0
        private static int GetNoteIndexAtParent(OutlinerNote note)
        {
            ObservableCollection <OutlinerNote> parentCollection = note.Document.GetParentCollection(note);

            for (int i = 0; i < parentCollection.Count; i++)
            {
                if (parentCollection[i] == note)
                {
                    return(i);
                }
            }

            return(-1);
        }
Exemple #20
0
        internal void SelectRow(OutlinerNote row)
        {
            ItemContainerGenerator t = ItemContainerGeneratorFor(row);

            if (t.Status != System.Windows.Controls.Primitives.GeneratorStatus.ContainersGenerated)
            {
                t.StatusChanged  += new EventHandler(SelectRow_ContainerGeneratorStatusChanged);
                rowToMakeSelected = row;
            }
            else
            {
                TreeListViewItem tvi = (t.ContainerFromItem(row) as TreeListViewItem);
                tvi.IsSelected = true;
            }
        }
Exemple #21
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 #22
0
        internal void Clone(OutlinerNote throwawayNote)
        {
            for (int i = 0; i < __Columns.Count; i++)
            {
                __Columns[i].CopyColumn(throwawayNote.Columns[i]);
            }

            CopyInlineNote(throwawayNote);

            IsExpanded       = throwawayNote.IsExpanded;
            IsChecked        = throwawayNote.IsChecked;
            WasAltered       = throwawayNote.WasAltered;
            LastStyleApplied = throwawayNote.LastStyleApplied;
            IsEmpty          = throwawayNote.IsEmpty;
            Id = throwawayNote.Id;
        }
Exemple #23
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 #24
0
        private static void CopyNodesRecursively(OutlinerNote destination1, OutlinerNote destination2, OutlinerNote source, OutlinerNote limit)
        {
            foreach (OutlinerNote subnote in source.SubNotes)
            {
                OutlinerNote newNote = new OutlinerNote(destination1);
                newNote.Clone(subnote);
                destination1.SubNotes.Add(newNote);

                CopyNodesRecursively(newNote, subnote);

                if (subnote == limit)
                {
                    destination1 = destination2;
                }
            }
        }
Exemple #25
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);
                    }
                }
            }
        }
Exemple #26
0
        public static void DecreaseIndent(OutlinerNote selectedRow, TreeListView outlinerTree, bool applyStyle)
        {
            int          activeColumn      = DocumentHelpers.GetFocusedColumnIdx(outlinerTree, selectedRow);
            bool         inlineNoteFocused = IsInlineNoteFocused(outlinerTree);
            OutlinerNote newRow            = new OutlinerNote(selectedRow.Parent.Parent);

            newRow.Clone(selectedRow);
            newRow.Parent.IsExpanded = true;
            newRow.IsExpanded        = true;
            DocumentHelpers.CopyNodesRecursively(newRow, selectedRow);

            int currentRowIndex = selectedRow.Parent.SubNotes.IndexOf(selectedRow);

            for (int i = currentRowIndex + 1; i < selectedRow.Parent.SubNotes.Count; i++)
            {
                OutlinerNote note    = selectedRow.Parent.SubNotes[i];
                OutlinerNote newNote = new OutlinerNote(newRow);
                newNote.Clone(note);

                DocumentHelpers.CopyNodesRecursively(newNote, note);
                newRow.SubNotes.Add(newNote);
            }

            for (int i = selectedRow.Parent.SubNotes.Count - 1; i > currentRowIndex; i--)
            {
                selectedRow.Parent.SubNotes.RemoveAt(i);
            }

            int parentIdx = selectedRow.Parent.Parent.SubNotes.IndexOf(selectedRow.Parent);

            selectedRow.Parent.Parent.SubNotes.Insert(parentIdx + 1, newRow);

            selectedRow.Parent.SubNotes.Remove(selectedRow);

            selectedRow.Parent.UpdateParentCheckboxes();
            newRow.UpdateParentCheckboxes();
            if (applyStyle)
            {
                outlinerTree.MakeActive(newRow, activeColumn, inlineNoteFocused, new EventHandler(ApplyStyleAfterMakeActive));
            }
            else
            {
                outlinerTree.MakeActive(newRow, activeColumn, inlineNoteFocused);
            }
        }
Exemple #27
0
        public static TreeListViewItem GetContainerForItem(TreeListView view, OutlinerNote note)
        {
            ItemContainerGenerator generator = view.ItemContainerGeneratorFor(note);

            if (generator == null)
            {
                return(null);
            }

            TreeListViewItem container = generator.ContainerFromItem(note) as TreeListViewItem;

            if (container == null)
            {
                return(null);
            }

            return(container);
        }
Exemple #28
0
        public static void DeleteRow(OutlinerNote row, TreeListView outlinerTree, int columnIndex)
        {
            int idx = row.Parent.SubNotes.IndexOf(row);

            row.Parent.SubNotes.Remove(row);

            row.UpdateParentCheckboxes();
            if (row.Parent.SubNotes.Count > 0)
            {
                if (row.Parent.SubNotes.Count > idx)
                {
                    outlinerTree.MakeActive(row.Parent.SubNotes[idx], columnIndex, false);
                }
                else
                {
                    outlinerTree.MakeActive(row.Parent.SubNotes[row.Parent.SubNotes.Count - 1], columnIndex, false);
                }
            }
        }
Exemple #29
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 #30
0
        public static void MoveNodeUp(OutlinerNote selectedItem, TreeListView outlinerTree, int activeColumn, bool isInlineNoteActive)
        {
            int selectedIndex = selectedItem.Parent.SubNotes.IndexOf(selectedItem);

            if (selectedIndex == 0)
            {
                return;
            }

            OutlinerNote newNote = new OutlinerNote(selectedItem.Parent);

            newNote.Clone(selectedItem);
            CopyNodesRecursively(newNote, selectedItem);

            selectedItem.Parent.SubNotes.Remove(selectedItem);
            selectedItem.Parent.SubNotes.Insert(selectedIndex - 1, newNote);

            outlinerTree.MakeActive(newNote, activeColumn, isInlineNoteActive);
        }
Exemple #31
0
        public ItemContainerGenerator ItemContainerGeneratorFor(object SelectedItem, bool doWait)
        {
            if (SelectedItem == null)
            {
                return(null);
            }

            OutlinerNote Note = (SelectedItem as OutlinerNote);

            if (Note.Parent.IsRoot)
            {
                return(ItemContainerGenerator);
            }
            else
            {
                ItemContainerGenerator ig = ItemContainerGeneratorFor(Note.Parent);

                if (ig != null)
                {
                    if (ig.Status != GeneratorStatus.ContainersGenerated && doWait)
                    {
                        for (int limit = 0; limit < 100; limit++)
                        {
                            if (ig.Status == GeneratorStatus.ContainersGenerated)
                            {
                                break;
                            }

                            app.DoEvents();
                            Thread.Sleep(10);
                        }
                    }

                    TreeListViewItem tvi = (ig.ContainerFromItem(Note.Parent) as TreeListViewItem);
                    if (tvi != null)
                    {
                        return(tvi.ItemContainerGenerator);
                    }
                }
                return(null);
            }
        }
        public static void InsertItemInItemsControl(ItemsControl itemsControl, OutlinerNote itemToInsert, int insertionIndex)
        {
            OutlinerNote parent = itemsControl.DataContext as OutlinerNote;
            if (parent == null)
                parent = (itemToInsert as OutlinerNote).GetRoot();

            OutlinerNote newNote = new OutlinerNote(parent);
            newNote.Clone(itemToInsert);

            Window ownerWindow = TreeListView.FindParentWindow(itemsControl);
            if (ownerWindow == null)
                throw new Exception("Window cannot be null");

            DocumentHelpers.CopyNodesRecursively(newNote, itemToInsert);

            parent.SubNotes.Insert(insertionIndex, newNote);

            if (itemsControl is TreeListView)
                ((TreeListView)itemsControl).MakeActive(newNote, -1, false);
        }
Exemple #33
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 #34
0
        public static void ApplyNewLevelStyle(OutlinerNote note, int newLevel)
        {
            // нолевой уровень - корень
            if (newLevel <= 0)
                return;

            UndoLevelStyle undoLevelStyle = new UndoLevelStyle(note);

            if (note.LastStyleApplied != null)
                note.LastStyleApplied.UnapplyStyle(note);

            LevelStyle levelStyle = note.Document.Styles.GetStyleForLevel(newLevel);
            LevelStyle wholeDocumentStyle = note.Document.Styles.WholeDocumentStyle;

            wholeDocumentStyle.ApplyToNote(note);
            levelStyle.ApplyToNote(note);
            note.LastStyleApplied = levelStyle;

            undoLevelStyle.StyleApplied(note);

            note.Document.UndoManager.PushUndoAction(undoLevelStyle);
        }
Exemple #35
0
        void SelectRow_ContainerGeneratorStatusChanged(object sender, EventArgs e)
        {
            ItemContainerGenerator icg = sender as ItemContainerGenerator;

            if (icg.Status == System.Windows.Controls.Primitives.GeneratorStatus.GeneratingContainers)
            {
                return;
            }

            icg.StatusChanged -= SelectRow_ContainerGeneratorStatusChanged;
            if (rowToMakeSelected == null)
            {
                return;
            }

            TreeListViewItem tvi = icg.ContainerFromItem(rowToMakeSelected) as TreeListViewItem;

            if (tvi != null)
            {
                tvi.IsSelected    = true;
                rowToMakeSelected = null;
            }
        }
Exemple #36
0
        public static void DeleteRow(OutlinerNote row, TreeListView outlinerTree, int columnIndex)
        {
            int idx = row.Parent.SubNotes.IndexOf(row);
            row.Parent.SubNotes.Remove(row);

            row.UpdateParentCheckboxes();
            if (row.Parent.SubNotes.Count > 0)
            {
                if (row.Parent.SubNotes.Count > idx)
                    outlinerTree.MakeActive(row.Parent.SubNotes[idx], columnIndex, false);
                else
                    outlinerTree.MakeActive(row.Parent.SubNotes[row.Parent.SubNotes.Count - 1], columnIndex, false);
            }
        }
Exemple #37
0
 public static void DeleteRow(OutlinerNote row, TreeListView outlinerTree)
 {
     DeleteRow(row, outlinerTree, -1);
 }
Exemple #38
0
        private void DecideDropTarget(DragEventArgs e)
        {
            int targetItemsControlCount = this.targetItemsControl.Items.Count;
            object draggedItem = e.Data.GetData(this.format.Name);

            Visual visual = e.OriginalSource as Visual;

            targetOverItem = DranDropUtilities.FindAncestor(typeof(TreeListViewItem), visual) as TreeListViewItem;
            if (targetOverItem == null)
            {
                this.targetItemContainer = null;
                this.insertionIndex = -1;
                e.Effects = DragDropEffects.None;
                return;
            }

            bool newDragOverNote = false;
            OutlinerNote dragOverNote = null;
            if (targetOverItem != null)
            {
                dragOverNote = targetOverItem.DataContext as OutlinerNote;
                if (dragOverNote != null)
                {
                    if (__DragOverNote != dragOverNote)
                    {
                        if (__DragOverNote != null)
                            __DragOverNote.DragOverNote = false;

                        newDragOverNote = true;
                    }
                }
            }

            ItemsControl parentItemsControl = targetOverItem.ParentItemsControl;
            if (parentItemsControl == null)
            {
                this.targetItemContainer = null;
                this.insertionIndex = -1;
                e.Effects = DragDropEffects.None;
                return;
            }

            if (targetItemsControlCount > 0)
            {
                this.hasVerticalOrientation = DranDropUtilities.HasVerticalOrientation(this.targetItemsControl.ItemContainerGenerator.ContainerFromIndex(0) as FrameworkElement);
                this.targetItemContainer = parentItemsControl;
                this.insertionIndex = parentItemsControl.ItemContainerGenerator.IndexFromContainer(targetOverItem);
                if (this.insertionIndex == -1)
                {
                    this.targetItemContainer = null;
                    this.insertionIndex = -1;
                    e.Effects = DragDropEffects.None;
                    return;
                }

                if (IsParent(this.targetItemContainer as TreeListViewItem, this.sourceItemContainer))
                {
                    this.targetItemContainer = null;
                    this.insertionIndex = -1;
                    e.Effects = DragDropEffects.None;
                    return;
                }

                if (newDragOverNote && dragOverNote != null)
                {
                    dragOverNote.DragOverNote = true;
                    __DragOverNote = dragOverNote;
                }
            }
            else
            {
                this.targetItemContainer = null;
                this.insertionIndex = 0;
            }
        }
Exemple #39
0
 public static void ApplyLevelStyle(OutlinerNote note, MyEdit myEdit)
 {
     ApplyNewLevelStyle(note, note.Level);
 }
Exemple #40
0
        public static void IncreaseIndentWithLimit(OutlinerNote row, OutlinerNote limit, bool isInlineNoteFocused, TreeListView outlinerTree, bool applyStyle)
        {
            if (!CanIncreaseIndent(row))
                return;

            int activeColumn = DocumentHelpers.GetFocusedColumnIdx(outlinerTree, row);

            ObservableCollection<OutlinerNote> parentCollection = row.Document.GetParentCollection(row);
            int idx = GetNoteIndexAtParent(row);
            parentCollection.Remove(row);

            OutlinerNote newNote = new OutlinerNote(parentCollection[idx - 1]);
            newNote.Clone(row);

            int insertIntoIdx = parentCollection[idx - 1].SubNotes.Count;
            if (limit == row)
                DocumentHelpers.CopyNodesRecursively(parentCollection[idx - 1], row);
            else
                DocumentHelpers.CopyNodesRecursively(newNote, parentCollection[idx - 1], row, limit);

            parentCollection[idx - 1].SubNotes.Insert(insertIntoIdx, newNote);
            parentCollection[idx - 1].IsExpanded = true;

            row.Parent.UpdateParentCheckboxes();
            newNote.UpdateParentCheckboxes();
            if (applyStyle)
                outlinerTree.MakeActive(newNote, activeColumn, isInlineNoteFocused, new EventHandler(ApplyStyleAfterMakeActive));
            else
                outlinerTree.MakeActive(newNote, activeColumn, isInlineNoteFocused);
        }
Exemple #41
0
        private static void CopyNodesRecursively(OutlinerNote destination1, OutlinerNote destination2, OutlinerNote source, OutlinerNote limit)
        {
            foreach (OutlinerNote subnote in source.SubNotes)
            {

                OutlinerNote newNote = new OutlinerNote(destination1);
                newNote.Clone(subnote);
                destination1.SubNotes.Add(newNote);

                CopyNodesRecursively(newNote, subnote);

                if (subnote == limit)
                    destination1 = destination2;
            }
        }
Exemple #42
0
 public OutlinerNote(OutlinerDocument document, OutlinerNoteCollection Subnotes)
 {
     this.__Document = document;
     this.__Parent = null;
     __IsDocumentRoot = true;
     this.__Subnotes = Subnotes;
     this.__Subnotes.Collection.CollectionChanged += new NotifyCollectionChangedEventHandler(Collection_CollectionChanged);
     Id = s_id;
     s_id += 1;
     CreateColumnData();
 }
Exemple #43
0
 public MakeActiveArgs(OutlinerNote note, MyEdit edit)
 {
     Note = note;
     Edit = edit;
 }
Exemple #44
0
        private void CopyInlineNote(OutlinerNote throwawayNote)
        {
            if (throwawayNote.InlineNoteDocument == null)
                return;

            FlowDocument inlineDoc = throwawayNote.InlineNoteDocument;
            __InlineNoteDocument = FlowDocumentUtils.CopyFlowDocument(inlineDoc);
            OnPropertyChanged("HasInlineNote");
            OnPropertyChanged("InlineNoteDocument");
        }
Exemple #45
0
        private void ApplyUndoEnabledPropertyValue(OutlinerNote note, DependencyProperty property, object value)
        {
            for (int i = 0; i < note.Document.ColumnDefinitions.Count; i++)
            {
                if (note.Columns[i].DataType == ColumnDataType.RichText)
                {
                    FlowDocument document = (FlowDocument)note.Columns[i].ColumnData;
                    StoreRowFormatting(note, i);

                    TextRange range = new TextRange(document.ContentStart, document.ContentEnd);
                    range.ApplyPropertyValue(property, value);
                }
            }
        }
Exemple #46
0
        internal void Clone(OutlinerNote throwawayNote)
        {
            for (int i = 0; i < __Columns.Count; i++)
                __Columns[i].CopyColumn(throwawayNote.Columns[i]);

            CopyInlineNote(throwawayNote);

            IsExpanded = throwawayNote.IsExpanded;
            IsChecked = throwawayNote.IsChecked;
            WasAltered = throwawayNote.WasAltered;
            LastStyleApplied = throwawayNote.LastStyleApplied;
            IsEmpty = throwawayNote.IsEmpty;
            Id = throwawayNote.Id;
        }
Exemple #47
0
        private void CheckAndFuckEdit(OutlinerNote note)
        {
            ItemContainerGenerator ig = OutlinerTree.ItemContainerGeneratorFor(note);
            if (ig == null)
                ig = OutlinerTree.ItemContainerGeneratorFor(note.Parent);

            if (ig != null)
            {
                TreeListViewItem container = ig.ContainerFromItem(note) as TreeListViewItem;
                if (container != null)
                {
                    for (int i = 0; i < Document.ColumnDefinitions.Count; i++)
                    {
                        MyEdit editor = container.GetEditor(i, GetViewColumnId(i), false);
                        if (editor != null)
                            editor.Document = new FlowDocument();

                        editor = container.GetEditor(i, GetViewColumnId(i), true);
                        if (editor != null)
                            editor.Document = new FlowDocument();
                    }
                }
            }
        }
Exemple #48
0
 private void RemoveDragOverMargin()
 {
     if (__DragOverNote != null)
     {
         __DragOverNote.DragOverNote = false;
         __DragOverNote = null;
     }
 }
Exemple #49
0
        public static int GetFocusedColumnIdx(TreeListView outlinerTree, OutlinerNote note)
        {
            MainWindow mainWindow = DragDropHelper.GetMainWindow(outlinerTree);
            if (mainWindow.IsEditorSelected == true)
                return mainWindow.LastColumn;

            return -1;
        }
Exemple #50
0
        public static bool CanDecreaseIndent(OutlinerNote selectedRow)
        {
            if (selectedRow == null)
                return false;

            if (selectedRow.Parent.IsRoot)
                return false;

            return true;
        }
Exemple #51
0
 public static void GetLinearNotesList(OutlinerNote outlinerNote, List<OutlinerNote> notes, bool expandCollapsed)
 {
     for (int i = 0; i < outlinerNote.SubNotes.Count; i++)
     {
         notes.Add(outlinerNote.SubNotes[i]);
         if (expandCollapsed || outlinerNote.SubNotes[i].IsExpanded == true)
             GetLinearNotesList(outlinerNote.SubNotes[i], notes, expandCollapsed);
     }
 }
Exemple #52
0
        public static bool CanIncreaseIndent(OutlinerNote row)
        {
            ObservableCollection<OutlinerNote> parentCollection = row.Document.GetParentCollection(row);
            int idx = GetNoteIndexAtParent(row);
            if (idx == -1 || idx == 0)
                return false;

            return true;
        }
Exemple #53
0
        public static void MoveNodeUp(OutlinerNote selectedItem, TreeListView outlinerTree, int activeColumn, bool isInlineNoteActive)
        {
            int selectedIndex = selectedItem.Parent.SubNotes.IndexOf(selectedItem);
            if (selectedIndex == 0)
                return;

            OutlinerNote newNote = new OutlinerNote(selectedItem.Parent);
            newNote.Clone(selectedItem);
            CopyNodesRecursively(newNote, selectedItem);

            selectedItem.Parent.SubNotes.Remove(selectedItem);
            selectedItem.Parent.SubNotes.Insert(selectedIndex - 1, newNote);

            outlinerTree.MakeActive(newNote, activeColumn, isInlineNoteActive);
        }
Exemple #54
0
        public static bool CanMoveNodeUp(OutlinerNote note, TreeListView outlinerTree)
        {
            int selectedIndex = note.Parent.SubNotes.IndexOf(note);
            if (selectedIndex == 0)
                return false;

            return true;
        }
Exemple #55
0
        private static int GetNoteIndexAtParent(OutlinerNote note)
        {
            ObservableCollection<OutlinerNote> parentCollection = note.Document.GetParentCollection(note);

            for (int i = 0; i < parentCollection.Count; i++)
                if (parentCollection[i] == note)
                    return i;

            return -1;
        }
Exemple #56
0
        public static void CopyNodesRecursively(OutlinerNote destination, OutlinerNote source)
        {
            foreach (OutlinerNote subnote in source.SubNotes)
            {
                OutlinerNote newNote = new OutlinerNote(destination);
                newNote.Clone(subnote);
                destination.SubNotes.Add(newNote);

                CopyNodesRecursively(newNote, subnote);
            }
        }
Exemple #57
0
 internal void MakeActiveAndApplyStyle(OutlinerNote newNote, int focusedColumn, bool isInlineNote)
 {
     OutlinerTree.MakeActive(newNote, focusedColumn, isInlineNote, new EventHandler(DocumentHelpers.ApplyStyleAfterMakeActive));
 }
Exemple #58
0
        public static void DecreaseIndent(OutlinerNote selectedRow, TreeListView outlinerTree, bool applyStyle)
        {
            int activeColumn = DocumentHelpers.GetFocusedColumnIdx(outlinerTree, selectedRow);
            bool inlineNoteFocused = IsInlineNoteFocused(outlinerTree);
            OutlinerNote newRow = new OutlinerNote(selectedRow.Parent.Parent);
            newRow.Clone(selectedRow);
            newRow.Parent.IsExpanded = true;
            newRow.IsExpanded = true;
            DocumentHelpers.CopyNodesRecursively(newRow, selectedRow);

            int currentRowIndex = selectedRow.Parent.SubNotes.IndexOf(selectedRow);
            for (int i = currentRowIndex + 1; i < selectedRow.Parent.SubNotes.Count; i++)
            {
                OutlinerNote note = selectedRow.Parent.SubNotes[i];
                OutlinerNote newNote = new OutlinerNote(newRow);
                newNote.Clone(note);

                DocumentHelpers.CopyNodesRecursively(newNote, note);
                newRow.SubNotes.Add(newNote);
            }

            for (int i = selectedRow.Parent.SubNotes.Count - 1; i > currentRowIndex; i--)
                selectedRow.Parent.SubNotes.RemoveAt(i);

            int parentIdx = selectedRow.Parent.Parent.SubNotes.IndexOf(selectedRow.Parent);
            selectedRow.Parent.Parent.SubNotes.Insert(parentIdx + 1, newRow);

            selectedRow.Parent.SubNotes.Remove(selectedRow);

            selectedRow.Parent.UpdateParentCheckboxes();
            newRow.UpdateParentCheckboxes();
            if (applyStyle)
                outlinerTree.MakeActive(newRow, activeColumn, inlineNoteFocused, new EventHandler(ApplyStyleAfterMakeActive));
            else
                outlinerTree.MakeActive(newRow, activeColumn, inlineNoteFocused);
        }
Exemple #59
0
 public static void DeleteRow(OutlinerNote row, TreeListView outlinerTree)
 {
     DeleteRow(row, outlinerTree, -1);
 }
Exemple #60
0
        private void DeleteOutlinerNote(OutlinerNote row)
        {
            throw new Exception("test");

            // When deleting an element in the subtree, the focus doesn't moves automatically to where we want
            // so we have to move it manually
            OutlinerNote parentToFocus = null;
            if (row.Parent.SubNotes.Count == 1)
                parentToFocus = row.Parent;

            UndoDeleteRow undoDeleteRow = new UndoDeleteRow(row);
            DocumentHelpers.DeleteRow(row, OutlinerTree);
            Document.UndoManager.PushUndoAction(undoDeleteRow);
            if (Document.RootNode.SubNotes.Count == 0)
            {
                OutlinerNote newNote = new OutlinerNote(Document.RootNode);
                Document.RootNode.SubNotes.Add(newNote);
                OutlinerTree.MakeActive(newNote, 0, false);
            }
            else
            {
                if (parentToFocus != null)
                {
                    OutlinerTree.MakeActive(parentToFocus, -1, false);
                }
            }
        }