예제 #1
0
 public UndoInsertRow(OutlinerNote note, int columnIndex)
 {
     __NoteId = note.Id;
     __ParentNoteId = note.Parent.Id;
     __Index = note.Parent.SubNotes.IndexOf(note);
     __ColumnIndexAfterInsert = columnIndex;
 }
예제 #2
0
        public UndoLevelStyle(OutlinerNote note)
        {
            __NoteId = note.Id;

            __Before = new MemoryStream[note.Columns.Count];
            __After = new MemoryStream[note.Columns.Count];

            __IsEmpty = true;

            for (int i = 0; i < note.Columns.Count; i++)
            {
                FlowDocument document = note.Columns[i].ColumnData as FlowDocument;
                if (document == null)
                    continue;

                __Before[i] = new MemoryStream();
                __After[i] = new MemoryStream();

                TextRange range = new TextRange(document.ContentStart, document.ContentEnd);
                range.Save(__Before[i], DataFormats.Xaml);

                if (!range.IsEmpty)
                    __IsEmpty = false;

            }
        }
예제 #3
0
        public UndoLevelStyle(OutlinerNote note)
        {
            __NoteId = note.Id;


            __Before = new MemoryStream[note.Columns.Count];
            __After  = new MemoryStream[note.Columns.Count];

            __IsEmpty = true;

            for (int i = 0; i < note.Columns.Count; i++)
            {
                FlowDocument document = note.Columns[i].ColumnData as FlowDocument;
                if (document == null)
                {
                    continue;
                }

                __Before[i] = new MemoryStream();
                __After[i]  = new MemoryStream();

                TextRange range = new TextRange(document.ContentStart, document.ContentEnd);
                range.Save(__Before[i], DataFormats.Xaml);

                if (!range.IsEmpty)
                {
                    __IsEmpty = false;
                }
            }
        }
예제 #4
0
        private static void DumpHTMLRecursive(StreamWriter writer, OutlinerNote outlinerNote)
        {
            if (!outlinerNote.IsRoot)
            {
                string style;
                string html       = HtmlFromReport((FlowDocument)outlinerNote.Columns[0].ColumnData, out style);
                string inlineNote = "";
                if (outlinerNote.HasInlineNote)
                {
                    string inlineStyle;
                    inlineNote = HtmlFromReport((FlowDocument)outlinerNote.InlineNoteDocument, out inlineStyle);
                    inlineNote = string.Format("<div id=note style='{0}'>{1}</div>", inlineStyle, inlineNote);
                }
                writer.WriteLine("<li style='{0}'>{1}{2}</li>", style, html, inlineNote);
            }

            if (outlinerNote.SubNotes.Count > 0)
            {
                writer.WriteLine("<ul>");
                for (int i = 0; i < outlinerNote.SubNotes.Count; i++)
                {
                    DumpHTMLRecursive(writer, outlinerNote.SubNotes[i]);
                }
                writer.WriteLine("</ul>");
            }
        }
예제 #5
0
 private void SaveNote(OutlinerNote note)
 {
     __NoteId       = note.Id;
     __SavedNote    = note;
     __ParentNodeId = note.Parent.Id;
     __NodeIndex    = note.Parent.SubNotes.IndexOf(note);
 }
예제 #6
0
        private static void SaveRecursive(XmlWriter wr, OutlinerNote outlinerNote)
        {
            wr.WriteStartElement("Outline");
            wr.WriteAttributeString("IsExpanded", outlinerNote.IsExpanded.ToString());
            wr.WriteAttributeString("IsChecked", outlinerNote.IsChecked.ToString());
            wr.WriteStartElement("Columns");

            // Save all columns
            for (int i = 0; i < outlinerNote.Columns.Count; i++)
            {
                outlinerNote.Columns[i].Save(wr);
            }
            wr.WriteEndElement();

            if (outlinerNote.HasInlineNote)
            {
                SaveInlineNote(wr, outlinerNote);
            }

            for (int i = 0; i < outlinerNote.SubNotes.Count; i++)
            {
                SaveRecursive(wr, outlinerNote.SubNotes[i]);
            }
            wr.WriteEndElement();
        }
예제 #7
0
        public override void Undo(OutlinerDocument document, TreeListView treeListView)
        {
            OutlinerNote row    = document.FindOutlinerNoteById(__NodeId);
            MainWindow   window = DragDropHelper.GetMainWindow(treeListView);

            window.DoHoist(row);
        }
예제 #8
0
 public UndoInsertRow(OutlinerNote note, int columnIndex)
 {
     __NoteId                 = note.Id;
     __ParentNoteId           = note.Parent.Id;
     __Index                  = note.Parent.SubNotes.IndexOf(note);
     __ColumnIndexAfterInsert = columnIndex;
 }
예제 #9
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);
            }
        }
예제 #10
0
        public override void Redo(OutlinerDocument document, TreeListView treeListView)
        {
            OutlinerNote note = document.FindOutlinerNoteById(__NoteId);

            SaveNote(note);
            DocumentHelpers.DeleteRow(note, treeListView);
        }
예제 #11
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="note"></param>
        /// <param name="wasChecked">Была ли заметка выбрана до переключения</param>
        public UndoCheck(OutlinerNote currentNote, bool wasChecked, bool selectNote)
        {
            __WasChecked = wasChecked;
            __NodeId     = currentNote.Id;

            __SelectNote = selectNote;

            __SavedCheckboxes = new List <SavedCheckState>();
            SavedCheckState state = new SavedCheckState();

            state.NodeId    = currentNote.Id;
            state.IsChecked = currentNote.IsChecked == true;
            __SavedCheckboxes.Add(state);


            OutlinerDocument.WalkRecursively(currentNote,
                                             (RecursiveWalkDelegate) delegate(OutlinerNote note, out bool shouldWalkSubItems, out bool shouldContinue)
            {
                shouldContinue     = true;
                shouldWalkSubItems = true;
                state           = new SavedCheckState();
                state.NodeId    = note.Id;
                state.IsChecked = note.IsChecked == true;
                __SavedCheckboxes.Add(state);
            });
        }
예제 #12
0
        private static void DumpRtfRecursively_List(List list, OutlinerNote outlinerNote)
        {
            foreach (var note in outlinerNote.SubNotes)
            {
                MemoryStream sectionStream = ExportToXaml_Printing.TransformFlowDocumentToSection(note.DefaultRichTextDocument);
                ListItem     newItem       = new ListItem();

                Section section = XamlReader.Load(sectionStream) as Section;
                if (section == null)
                {
                    section = new Section();
                }

                newItem.Blocks.Add(section);
                list.ListItems.Add(newItem);

                if (outlinerNote.SubNotes.Count > 0)
                {
                    List newList = new List();
                    list.FontFamily = UVOutliner.Settings.DefaultFontFamily;
                    list.FontSize   = UVOutliner.Settings.DefaultFontSize;

                    newItem.Blocks.Add(newList);
                    DumpRtfRecursively_List(newList, note);
                }
            }
        }
예제 #13
0
        private static void DumpTextRecursively(StreamWriter writer, OutlinerNote outlinerNote, int padding)
        {
            int newPadding = padding;

            if (!outlinerNote.IsRoot)
            {
                string paddingStr = "";
                for (int i = 0; i < padding; i++)
                {
                    paddingStr += " ";
                }

                writer.Write(paddingStr);

                TextRange selection = new TextRange(outlinerNote.DefaultRichTextDocument.ContentStart, outlinerNote.DefaultRichTextDocument.ContentEnd);
                using (MemoryStream stream = new MemoryStream())
                {
                    selection.Save(stream, System.Windows.DataFormats.Text);
                    stream.Seek(0, SeekOrigin.Begin);

                    StreamReader sr   = new StreamReader(stream);
                    string       text = sr.ReadToEnd();
                    text = text.Replace("\r\n", "\r\n  " + paddingStr);
                    text = text.Trim();
                    writer.WriteLine("* {0}", text);
                }

                newPadding += 4;
            }

            for (int i = 0; i < outlinerNote.SubNotes.Count; i++)
            {
                DumpTextRecursively(writer, outlinerNote.SubNotes[i], newPadding);
            }
        }
예제 #14
0
 private void SaveNote(OutlinerNote note)
 {
     __NoteId = note.Id;
     __SavedNote = note;
     __ParentNodeId = note.Parent.Id;
     __NodeIndex = note.Parent.SubNotes.IndexOf(note);
 }
예제 #15
0
        public static void AddInlineNote(TableRowCollection tableRowCollection, OutlinerNote note, bool fromWordFriendly = false)
        {
            TableRow tableRow = new TableRow();

            Section section = XamlReader.Load(TransformFlowDocumentToSection(note.InlineNoteDocument)) as Section;

            if (section == null)
            {
                return;
            }

            TableCell cell = new TableCell();

            if (fromWordFriendly)
            {
                section.Margin = new Thickness(note.Level * 20 + (note.Document.CheckboxesVisble ? 10 : 0), 0, 0, 2);
            }
            else
            {
                section.Margin = new Thickness(note.Level * 20 + 20 + (note.Document.CheckboxesVisble ? 20 : 0), 0, 0, 2);
            }

            cell.Blocks.Add(section);

            tableRow.Cells.Add(cell);

            for (int c = 0; c < note.Columns.Count - 1; c++)
            {
                tableRow.Cells.Add(new TableCell());
            }

            tableRowCollection.Add(tableRow);
        }
예제 #16
0
        public override void Undo(OutlinerDocument document, TreeListView treeListView)
        {
            OutlinerNote rootNote = null;

            for (int i = 0; i < __SavedCheckboxes.Count; i++)
            {
                OutlinerNote note = document.FindOutlinerNoteById(__SavedCheckboxes[i].NodeId);
                note.SetCheckedForCurrentNote(__SavedCheckboxes[i].IsChecked);

                if (rootNote == null)
                {
                    rootNote = note;
                }
            }

            for (int i = 0; i < __SavedCheckboxes.Count; i++)
            {
                OutlinerNote note = document.FindOutlinerNoteById(__SavedCheckboxes[i].NodeId);
                note.UpdateParentCheckboxes();
            }

            if (__SelectNote && rootNote != null)
            {
                treeListView.MakeActive(rootNote, -1, false);
            }

            rootNote.UpdateParentCheckboxes();
            rootNote.OnPropertyChanged("IsChecked");
            rootNote.OnPropertyChanged("IsCheckedDirect");
        }
예제 #17
0
        private void DropTarget_PreviewDrop(object sender, DragEventArgs e)
        {
            object draggedItem  = e.Data.GetData(this.format.Name);
            int    indexRemoved = -1;

            if (draggedItem != null)
            {
                OutlinerNote note = draggedItem as OutlinerNote;
                if (note == null)
                {
                    RemoveInsertionAdorner();
                    RemoveDragOverMargin();
                    return;
                }

                UndoDragDrop undo = new UndoDragDrop(note);

                indexRemoved = note.Parent.SubNotes.IndexOf(note);
                note.Parent.SubNotes.Remove(note);

                // This happens when we drag an item to a later position within the same ItemsControl.
                if (indexRemoved != -1 &&
                    this.sourceItemContainer.ParentItemsControl == this.targetItemContainer && indexRemoved < this.insertionIndex)
                {
                    this.insertionIndex--;
                }
                DranDropUtilities.InsertItemInItemsControl(this.targetItemContainer, draggedItem as OutlinerNote, this.insertionIndex);
                note.Document.UndoManager.PushUndoAction(undo);

                RemoveInsertionAdorner();
                RemoveDragOverMargin();
            }
            e.Handled = true;
        }
예제 #18
0
 private static void ReadColumns(XmlReader reader, OutlinerNote note)
 {
     for (int i = 0; i < note.Columns.Count; i++)
     {
         note.Columns[i].Load(reader);
     }
 }
예제 #19
0
 private void RemoveDragOverMargin()
 {
     if (__DragOverNote != null)
     {
         __DragOverNote.DragOverNote = false;
         __DragOverNote = null;
     }
 }
예제 #20
0
        public override void Undo(OutlinerDocument document, TreeListView treeListView)
        {
            OutlinerNote note = document.FindOutlinerNoteById(__NoteId);
            __SavedNote = note;
            __ColumnIndexBeforeUndo = DocumentHelpers.GetFocusedColumnIdx(treeListView, note);

            DocumentHelpers.DeleteRow(note, treeListView, __ColumnIndexAfterInsert);
        }
예제 #21
0
        public override void Undo(OutlinerDocument document, TreeListView treeListView)
        {
            OutlinerNote note = document.FindOutlinerNoteById(__NoteId);

            __SavedNote             = note;
            __ColumnIndexBeforeUndo = DocumentHelpers.GetFocusedColumnIdx(treeListView, note);

            DocumentHelpers.DeleteRow(note, treeListView, __ColumnIndexAfterInsert);
        }
예제 #22
0
        private static void ReadInlineNote(XmlReader reader, OutlinerNote note)
        {
            reader.ReadToFollowing("FlowDocument");
            XmlReader    xmlReader = reader.ReadSubtree();
            FlowDocument inlineDoc = (FlowDocument)XamlReader.Load(xmlReader);

            note.CreateInlineNote(inlineDoc);
            xmlReader.Close();
        }
예제 #23
0
        public override void Redo(OutlinerDocument document, TreeListView treeListView)
        {
            OutlinerNote row    = document.FindOutlinerNoteById(__NodeId);
            MainWindow   window = DragDropHelper.GetMainWindow(treeListView);

            if (document.HostNode == row && row != null)
            {
                window.DoUnhoist(row);
            }
        }
예제 #24
0
        public static OutlinerNote PasteFromClipboard(OutlinerNote insertAfterThisNote)
        {
            OutlinerNote note           = null;
            OutlinerNote parentNode     = insertAfterThisNote.Parent;
            int          insertionIndex = insertAfterThisNote.Parent.SubNotes.IndexOf(insertAfterThisNote) + 1;

            if (Clipboard.ContainsData("uvoutlinerdata"))
            {
                try
                {
                    string data = (string)Clipboard.GetData("uvoutlinerdata");
                    if (data == null || data == "")
                    {
                        return(null);
                    }

                    byte[] clipboard = Encoding.UTF8.GetBytes(data);

                    MemoryStream stream = new MemoryStream();
                    stream.Write(clipboard, 0, clipboard.Length);
                    stream.Seek(0, SeekOrigin.Begin);

                    XmlReaderSettings settings = new XmlReaderSettings();
                    settings.CheckCharacters = false;
                    XmlReader reader = XmlReader.Create(stream, settings);

                    reader.ReadStartElement("UVOutlinerClipboard");
                    //reader.Read();
                    XmlReader subtree = reader.ReadSubtree();
                    note = ReadRecustive(subtree, parentNode);
                    subtree.Close();

                    if (note != null)
                    {
                        parentNode.SubNotes.Insert(insertionIndex, note);
                    }

                    reader.Close();
                }
                catch
                {
                    // do nothing
                }
            }
            else if (Clipboard.ContainsData(DataFormats.Text))
            {
                note = new OutlinerNote(parentNode);
                FlowDocument firstColumnDocument = (FlowDocument)(note.Columns[0].ColumnData);
                TextRange    range = new TextRange(firstColumnDocument.ContentStart, firstColumnDocument.ContentEnd);
                range.Text = Clipboard.GetText();
                parentNode.SubNotes.Insert(insertionIndex, note);
            }

            return(note);
        }
예제 #25
0
        private static void AddImages(OutlinerDocument Document, OutlinerNote note, Paragraph para)
        {
            Image expImage = new Image();

            expImage.Margin = new Thickness(0, 2, 0, 0);
            expImage.Width  = 14;
            expImage.Height = 14;
            expImage.SetValue(RenderOptions.BitmapScalingModeProperty, BitmapScalingMode.NearestNeighbor);

            BitmapImage bImage = new BitmapImage();

            if (note.SubNotes.Count == 0)
            {
                bImage.UriSource = new Uri("pack://application:,,,/uv;component/res/bullet.png");
            }
            else
            {
                if (note.IsExpanded)
                {
                    bImage.UriSource = new Uri("pack://application:,,,/uv;component/res/node_expanded.png");
                }
                else
                {
                    bImage.UriSource = new Uri("pack://application:,,,/uv;component/res/node_collapsed.png");
                }
            }

            expImage.Source  = bImage;
            expImage.Stretch = Stretch.None;
            para.Inlines.Add(expImage);

            if (Document.CheckboxesVisble)
            {
                Image checkBox = new Image();
                checkBox.Margin = new Thickness(0, 2, 0, 0);
                checkBox.Width  = 14;
                checkBox.Height = 14;
                checkBox.SetValue(RenderOptions.BitmapScalingModeProperty, BitmapScalingMode.NearestNeighbor);

                var checkSource = new BitmapImage();
                if (note.IsChecked == true)
                {
                    checkSource.UriSource = new Uri("pack://application:,,,/uv;component/res/checkbox_checked.png");
                }
                else
                {
                    checkSource.UriSource = new Uri("pack://application:,,,/uv;component/res/checkbox_unchecked.png");
                }

                checkBox.Source  = checkSource;
                checkBox.Stretch = Stretch.None;
                para.Inlines.Add(checkBox);
            }
        }
예제 #26
0
        public static OutlinerColumn CreateColumnClass(OutlinerNote note, OutlinerColumnDefinition definition)
        {
            switch (definition.DataType)
            {
                case ColumnDataType.RichText:
                    return new RichTextColumn(note);

                default:
                    return null;
            }
        }
예제 #27
0
        public static OutlinerColumn CreateColumnClass(OutlinerNote note, OutlinerColumnDefinition definition)
        {
            switch (definition.DataType)
            {
            case ColumnDataType.RichText:
                return(new RichTextColumn(note));

            default:
                return(null);
            }
        }
예제 #28
0
        private static void ReadOutlinerRow(OutlinerDocument rnl, XmlReader reader)
        {
            XmlReader    subtree = reader.ReadSubtree();
            OutlinerNote note    = ReadRecustive(subtree, rnl.RootNode);

            subtree.Close();
            if (note != null)
            {
                rnl.Add(note);
            }
        }
예제 #29
0
        public override void Redo(OutlinerDocument document, TreeListView treeListView)
        {
            OutlinerNote newParent = document.FindOutlinerNoteById(__ParentNoteId);

            OutlinerNote newNote = new OutlinerNote(newParent);
            newNote.Clone(__SavedNote);
            DocumentHelpers.CopyNodesRecursively(newNote, __SavedNote);

            newParent.SubNotes.Insert(__Index, newNote);

            treeListView.MakeActive(newNote, __ColumnIndexBeforeUndo, false);
        }
예제 #30
0
        public static void CopyToClipboard(OutlinerNote note)
        {
            MemoryStream clipboardStream = new MemoryStream();

            XmlWriter wr = XmlWriter.Create(clipboardStream);
            // TODO: Write header
            wr.WriteStartElement("UVOutlinerClipboard");
            SaveRecursive(wr, note);
            wr.WriteEndElement();
            wr.Close();

            Clipboard.SetData("uvoutlinerdata", Encoding.UTF8.GetString((clipboardStream as MemoryStream).ToArray()));
        }
예제 #31
0
        public override void Redo(OutlinerDocument document, TreeListView treeListView)
        {
            OutlinerNote newParent = document.FindOutlinerNoteById(__ParentNoteId);

            OutlinerNote newNote = new OutlinerNote(newParent);

            newNote.Clone(__SavedNote);
            DocumentHelpers.CopyNodesRecursively(newNote, __SavedNote);

            newParent.SubNotes.Insert(__Index, newNote);

            treeListView.MakeActive(newNote, __ColumnIndexBeforeUndo, false);
        }
예제 #32
0
        public UndoIndent(OutlinerNote note, bool isInlineNoteFocused, IndentDirection direction)
        {
            __Direction = direction;
            __NoteId = note.Id;
            __IsInlineEditFocused = isInlineNoteFocused;

            if (direction == IndentDirection.DecreaseIndent)
            {
                if (note.SubNotes.Count > 0)
                    __LimitNoteId = note.SubNotes[note.SubNotes.Count - 1].Id;
                else
                    __LimitNoteId = note.Id;
            }
        }
예제 #33
0
        public void StyleApplied(OutlinerNote note)
        {
            for (int i = 0; i < note.Columns.Count; i++)
            {
                FlowDocument document = note.Columns[i].ColumnData as FlowDocument;
                if (document == null)
                {
                    continue;
                }

                TextRange range = new TextRange(document.ContentStart, document.ContentEnd);
                range.Save(__After[i], DataFormats.Xaml);
            }
        }
예제 #34
0
        public static void CopyToClipboard(OutlinerNote note)
        {
            MemoryStream clipboardStream = new MemoryStream();

            XmlWriter wr = XmlWriter.Create(clipboardStream);

            // TODO: Write header
            wr.WriteStartElement("UVOutlinerClipboard");
            SaveRecursive(wr, note);
            wr.WriteEndElement();
            wr.Close();

            Clipboard.SetData("uvoutlinerdata", Encoding.UTF8.GetString((clipboardStream as MemoryStream).ToArray()));
        }
예제 #35
0
        public static int RemoveItemFromItemsControl(ItemsControl itemsControl, object itemToRemove)
        {
            OutlinerNote note = (OutlinerNote)itemToRemove;

            if (note == null)
            {
                return(-1);
            }

            int noteIndex = note.Parent.SubNotes.IndexOf(note);

            note.Parent.SubNotes.Remove(note);
            return(noteIndex);
        }
예제 #36
0
        public override void Redo(OutlinerDocument document, TreeListView treeListView)
        {
            OutlinerNote note = document.FindOutlinerNoteById(__NoteId);

            OutlinerNote newParent = document.FindOutlinerNoteById(__ParentNoteIdAfter);
            Debug.Assert(newParent != null);
            note.Parent.SubNotes.Remove(note);

            OutlinerNote newNote = new OutlinerNote(newParent);
            newNote.Clone(note);
            DocumentHelpers.CopyNodesRecursively(newNote, note);
            newParent.SubNotes.Insert(__IndexAfter, newNote);
            treeListView.MakeActive(newNote, -1, false);
        }
예제 #37
0
        public override void Redo(OutlinerDocument document, TreeListView treeListView)
        {
            OutlinerNote note = document.FindOutlinerNoteById(__NodeId);

            note.IsChecked = __WasChecked;

            if (__SelectNote)
            {
                treeListView.MakeActive(note, -1, false);
            }

            note.UpdateParentCheckboxes();
            note.OnPropertyChanged("IsChecked");
            note.OnPropertyChanged("IsCheckedDirect");
        }
예제 #38
0
        internal void ApplyToNote(OutlinerNote note)
        {
            for (int i = 0; i < note.Columns.Count; i++)
            {
                FlowDocument document = note.Columns[i].ColumnData as FlowDocument;
                if (document == null)
                {
                    continue;
                }

                TextRange range = new TextRange(document.ContentStart, document.ContentEnd);

                ApplyToRange(range);
                ApplyToDocument(document);
            }
        }
예제 #39
0
        internal void UnapplyStyle(OutlinerNote note)
        {
            for (int i = 0; i < note.Columns.Count; i++)
            {
                if (note.Columns[i].DataType != UVOutliner.Columns.ColumnDataType.RichText)
                {
                    continue;
                }

                FlowDocument document = (FlowDocument)note.Columns[i].ColumnData;

                TextRange range = new TextRange(document.ContentStart, document.ContentEnd);
                UnapplyToRange(range);
                UnapplyToDocument(document);
            }
        }
        public UndoFlowDocumentFormatting(OutlinerNote note, int columnId, bool isInlineNote, bool wasSelected)
        {
            __NoteId = note.Id;
            __ColumnId = columnId;
            __IsInlineNote = isInlineNote;

            __Before = new MemoryStream();

            FlowDocument flowDocument = (FlowDocument)note.Columns[columnId].ColumnData;

            __FontPropertiesBefore = new FontProperties(flowDocument);

            TextRange range = new TextRange(flowDocument.ContentStart, flowDocument.ContentEnd);
            range.Save(__Before, DataFormats.Xaml);

            __WasSelected = wasSelected;
        }
예제 #41
0
        public static void AddInlineNote(TableRowCollection tableRowCollection, OutlinerNote note, bool fromWordFriendly = false)
        {
            TableRow tableRow = new TableRow();

            Section section = XamlReader.Load(TransformFlowDocumentToSection(note.InlineNoteDocument)) as Section;
            if (section == null)
                return;

            TableCell cell = new TableCell();
            if (fromWordFriendly)
                section.Margin = new Thickness(note.Level * 20 + (note.Document.CheckboxesVisble ? 10 : 0), 0, 0, 2);
            else
                section.Margin = new Thickness(note.Level * 20 + 20 + (note.Document.CheckboxesVisble ? 20 : 0), 0, 0, 2);

            cell.Blocks.Add(section);

            tableRow.Cells.Add(cell);

            for (int c = 0; c < note.Columns.Count - 1; c++)
                tableRow.Cells.Add(new TableCell());

            tableRowCollection.Add(tableRow);
        }
예제 #42
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="note"></param>
        /// <param name="wasChecked">Была ли заметка выбрана до переключения</param>
        public UndoCheck(OutlinerNote currentNote, bool wasChecked, bool selectNote)
        {
            __WasChecked = wasChecked;
            __NodeId = currentNote.Id;

            __SelectNote = selectNote;

            __SavedCheckboxes = new List<SavedCheckState>();
            SavedCheckState state = new SavedCheckState();
            state.NodeId = currentNote.Id;
            state.IsChecked = currentNote.IsChecked == true;
            __SavedCheckboxes.Add(state);

            OutlinerDocument.WalkRecursively(currentNote,
                (RecursiveWalkDelegate)delegate(OutlinerNote note, out bool shouldWalkSubItems, out bool shouldContinue)
                {
                    shouldContinue = true;
                    shouldWalkSubItems = true;
                    state = new SavedCheckState();
                    state.NodeId = note.Id;
                    state.IsChecked = note.IsChecked == true;
                    __SavedCheckboxes.Add(state);
                });
        }
예제 #43
0
 public RichTextColumn(OutlinerNote note)
 {
     __Document = null;
     __Note = note;
 }
예제 #44
0
 public override void RemoveColumnData()
 {
     __Document = null;
     __LazyDocument = null;
     __Note = null;
 }
예제 #45
0
 public UndoDeleteRow(OutlinerNote note)
 {
     __NoteId = note.Id;
     SaveNote(note);
 }
예제 #46
0
        private static void DumpTextRecursively(StreamWriter writer, OutlinerNote outlinerNote, int padding)
        {
            int newPadding = padding;
            if (!outlinerNote.IsRoot)
            {
                string paddingStr = "";
                for (int i = 0; i < padding; i++)
                    paddingStr += " ";

                writer.Write(paddingStr);

                 TextRange selection = new TextRange(outlinerNote.DefaultRichTextDocument.ContentStart, outlinerNote.DefaultRichTextDocument.ContentEnd);
                using (MemoryStream stream = new MemoryStream())
                {
                    selection.Save(stream, System.Windows.DataFormats.Text);
                    stream.Seek(0, SeekOrigin.Begin);

                    StreamReader sr = new StreamReader(stream);
                    string text = sr.ReadToEnd();
                    text = text.Replace("\r\n", "\r\n  " + paddingStr);
                    text = text.Trim();
                    writer.WriteLine("* {0}", text);
                }

                newPadding += 4;
            }

            for (int i = 0; i < outlinerNote.SubNotes.Count; i++)
                DumpTextRecursively(writer, outlinerNote.SubNotes[i], newPadding);
        }
예제 #47
0
 private static void ReadColumns(XmlReader reader, OutlinerNote note)
 {
     for (int i = 0; i < note.Columns.Count; i++)
         note.Columns[i].Load(reader);
 }
예제 #48
0
 private static void ReadInlineNote(XmlReader reader, OutlinerNote note)
 {
     reader.ReadToFollowing("FlowDocument");
     XmlReader xmlReader = reader.ReadSubtree();
     FlowDocument inlineDoc = (FlowDocument)XamlReader.Load(xmlReader);
     note.CreateInlineNote(inlineDoc);
     xmlReader.Close();
 }
예제 #49
0
        private static OutlinerNote ReadRecustive(XmlReader reader, OutlinerNote parent)
        {
            OutlinerNote note = new OutlinerNote(parent);
            note.LastStyleApplied = note.Document.Styles.GetStyleForLevel(note.Level);
            reader.Read();
            string res = reader.GetAttribute("IsExpanded");
            note.IsExpanded = bool.Parse(res);

            string isChecked = reader.GetAttribute("IsChecked");
            if (isChecked != null && isChecked != "")
                note.IsChecked = bool.Parse(isChecked);

            reader.MoveToElement();
            if (reader.ReadToFollowing("Columns") == false)
                throw new OpenFileException("No column tag found");

            XmlReader subtree = reader.ReadSubtree();
            ReadColumns(subtree, note);
            subtree.Close();

            while (reader.Read())
            {
                if (reader.Name == "InlineNote" && reader.IsStartElement())
                    ReadInlineNote(reader, note);

                if (reader.Name == "Outline" && reader.IsStartElement())
                {
                    subtree = reader.ReadSubtree();
                    OutlinerNote subNote = ReadRecustive(subtree, note);
                    subtree.Close();

                    note.SubNotes.Add(subNote);
                }
            }

            return note;
        }
예제 #50
0
 private static void SaveInlineNote(XmlWriter wr, OutlinerNote outlinerNote)
 {
     wr.WriteStartElement("InlineNote");
     wr.WriteRaw(XamlWriter.Save(outlinerNote.InlineNoteDocument));
     wr.WriteEndElement();
 }
예제 #51
0
        private static void SaveRecursive(XmlWriter wr, OutlinerNote outlinerNote)
        {
            wr.WriteStartElement("Outline");
            wr.WriteAttributeString("IsExpanded", outlinerNote.IsExpanded.ToString());
            wr.WriteAttributeString("IsChecked", outlinerNote.IsChecked.ToString());
            wr.WriteStartElement("Columns");

            // Save all columns
            for (int i = 0; i < outlinerNote.Columns.Count; i++)
                outlinerNote.Columns[i].Save(wr);
            wr.WriteEndElement();

            if (outlinerNote.HasInlineNote)
                SaveInlineNote(wr, outlinerNote);

            for (int i = 0; i < outlinerNote.SubNotes.Count; i++)
                SaveRecursive(wr, outlinerNote.SubNotes[i]);
            wr.WriteEndElement();
        }
예제 #52
0
 public UndoHoist(OutlinerNote note)
 {
     __NodeId = note.Id;
 }
예제 #53
0
        public void StyleApplied(OutlinerNote note)
        {
            for (int i = 0; i < note.Columns.Count; i++)
            {
                FlowDocument document = note.Columns[i].ColumnData as FlowDocument;
                if (document == null)
                    continue;

                TextRange range = new TextRange(document.ContentStart, document.ContentEnd);
                range.Save(__After[i], DataFormats.Xaml);
            }
        }
예제 #54
0
 public UndoDeleteInline(OutlinerNote note)
 {
     __NoteId = note.Id;
     __Document = DocumentHelpers.SaveDocumentToStream(note.InlineNoteDocument);
     __DocumentTag = note.InlineNoteDocument.Tag;
 }
예제 #55
0
 public UndoDragDrop(OutlinerNote note)
 {
     __NoteId = note.Id;
     __ParentNoteIdBefore = note.Parent.Id;
     __IndexBefore = note.Parent.SubNotes.IndexOf(note);
 }
예제 #56
0
 public UndoInsertInline(OutlinerNote note)
 {
     __NoteId = note.Id;
 }
예제 #57
0
        private static void AddImages(OutlinerDocument Document, OutlinerNote note, Paragraph para)
        {
            Image expImage = new Image();
            expImage.Margin = new Thickness(0, 2, 0, 0);
            expImage.Width = 14;
            expImage.Height = 14;
            expImage.SetValue(RenderOptions.BitmapScalingModeProperty, BitmapScalingMode.NearestNeighbor);

            BitmapImage bImage = new BitmapImage();

            if (note.SubNotes.Count == 0)
                bImage.UriSource = new Uri("pack://application:,,,/uv;component/res/bullet.png");
            else
            {
                if (note.IsExpanded)
                    bImage.UriSource = new Uri("pack://application:,,,/uv;component/res/node_expanded.png");
                else
                    bImage.UriSource = new Uri("pack://application:,,,/uv;component/res/node_collapsed.png");
            }

            expImage.Source = bImage;
            expImage.Stretch = Stretch.None;
            para.Inlines.Add(expImage);

            if (Document.CheckboxesVisble)
            {
                Image checkBox = new Image();
                checkBox.Margin = new Thickness(0, 2, 0, 0);
                checkBox.Width = 14;
                checkBox.Height = 14;
                checkBox.SetValue(RenderOptions.BitmapScalingModeProperty, BitmapScalingMode.NearestNeighbor);

                var checkSource = new BitmapImage();
                if (note.IsChecked == true)
                    checkSource.UriSource = new Uri("pack://application:,,,/uv;component/res/checkbox_checked.png");
                else
                    checkSource.UriSource = new Uri("pack://application:,,,/uv;component/res/checkbox_unchecked.png");

                checkBox.Source = checkSource;
                checkBox.Stretch = Stretch.None;
                para.Inlines.Add(checkBox);
            }
        }
예제 #58
0
        internal void UnapplyStyle(OutlinerNote note)
        {
            for (int i = 0; i < note.Columns.Count; i++)
            {
                if (note.Columns[i].DataType != UVOutliner.Columns.ColumnDataType.RichText)
                    continue;

                FlowDocument document = (FlowDocument)note.Columns[i].ColumnData;

                TextRange range = new TextRange(document.ContentStart, document.ContentEnd);
                UnapplyToRange(range);
                UnapplyToDocument(document);
            }
        }
예제 #59
0
 public UndoMoveUp(OutlinerNote note, int activeColumn, bool isInlineNoteFocused)
 {
     __NodeId = note.Id;
     __ActiveColumn = activeColumn;
     __IsInlineNoteFocused = isInlineNoteFocused;
 }
예제 #60
0
        internal void ApplyToNote(OutlinerNote note)
        {
            for (int i = 0; i < note.Columns.Count; i++)
            {
                FlowDocument document = note.Columns[i].ColumnData as FlowDocument;
                if (document == null)
                    continue;

                TextRange range = new TextRange(document.ContentStart, document.ContentEnd);

                ApplyToRange(range);
                ApplyToDocument(document);
            }
        }