Example #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);
            }
        }
Example #2
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);
            }
        }
Example #3
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;
                }
            }
        }
Example #4
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);
            }
        }
Example #5
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);
        }
Example #6
0
        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);
        }
Example #7
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;
            }
        }
Example #8
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);
        }
Example #9
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);
        }
Example #10
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);
        }
Example #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);
            }
        }