public override void Undo(OutlinerDocument document, TreeListView treeListView) { OutlinerNote row = document.FindOutlinerNoteById(__NodeId); MainWindow window = DragDropHelper.GetMainWindow(treeListView); window.DoHoist(row); }
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"); }
internal static void ExportAsTXT(OutlinerDocument Document, string fileName) { StreamWriter writer = new StreamWriter(fileName); DumpTextRecursively(writer, Document.RootNode, 0); writer.Close(); }
private static void ReadDocumentStyleAttributes(OutlinerDocument rnl, XmlReader reader) { if (reader.GetAttribute("OddBackgroundColor") != null) { rnl.OddBackgroundColor = new SolidColorBrush((Color)ColorConverter.ConvertFromString( reader.GetAttribute("OddBackgroundColor"))); } if (reader.GetAttribute("EvenBackgroundColor") != null) { rnl.EvenBackgroundColor = new SolidColorBrush((Color)ColorConverter.ConvertFromString( reader.GetAttribute("EvenBackgroundColor"))); } if (reader.GetAttribute("RowSeparatorColor") != null) { rnl.LinesBetweenRowsBrush = new SolidColorBrush((Color)ColorConverter.ConvertFromString( reader.GetAttribute("RowSeparatorColor"))); } string useRowSeparator = reader.GetAttribute("UseRowSeparator"); if (useRowSeparator != null) { rnl.LinesBetweenRows = bool.Parse(useRowSeparator); } }
/// <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); }); }
public override void Redo(OutlinerDocument document, TreeListView treeListView) { OutlinerNote note = document.FindOutlinerNoteById(__NoteId); SaveNote(note); DocumentHelpers.DeleteRow(note, treeListView); }
public static string ExportToXaml(OutlinerDocument Document, MainWindow wnd) { if (wnd.OutlinerTreeColumns.Count > 1) return ExportToXaml_MultiColumn(Document, wnd); else return ExportToXaml_MultiColumn(Document, wnd); }
public override void Redo(OutlinerDocument document, TreeListView treeListView) { OutlinerNote row = document.FindOutlinerNoteById(__NodeId); MainWindow window = DragDropHelper.GetMainWindow(treeListView); if (window != null && row != null) window.DoHoist(row); }
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); }
public override void Redo(OutlinerDocument document, TreeListView treeListView) { var note = document.FindOutlinerNoteById(__NoteId); if (note == null) return; note.Document.FocusEditAfterTemplateChange = true; note.RemoveInlineNoteIfEmpty(); }
public static void ExportAsRtf_List(OutlinerDocument document, string fileName) { FlowDocument flowDoc = ExportAsFlowDocument_List(document); TextRange range = new TextRange(flowDoc.ContentStart, flowDoc.ContentEnd); FileStream stream = new FileStream(fileName, FileMode.Create); range.Save(stream, DataFormats.Rtf); stream.Close(); }
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); }
public override void Redo(OutlinerDocument document, TreeListView treeListView) { BaseStyle style = document.Styles.GetStyleByTag(__StyleTag); style.Properties.Clear(); for (int i = 0; i < __AfterChange.Count; i++) style.AddProperty(__AfterChange[i].PropertyType, __AfterChange[i].Value); style.UpdateInspectorStyles(); }
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); } }
public override void Undo(OutlinerDocument document, TreeListView treeListView) { var note = document.FindOutlinerNoteById(__NoteId); if (note == null) return; treeListView.MakeActive(note, -1, false); note.CreateInlineNote(DocumentHelpers.RestoreDocumentFromStream(__Document)); note.InlineNoteDocument.Tag = __DocumentTag; }
public override void Undo(OutlinerDocument document, TreeListView treeListView) { OutlinerNote row = document.FindOutlinerNoteById(__NodeId); if (document.HostNode != row) return; MainWindow window = DragDropHelper.GetMainWindow(treeListView); if (window != null) window.DoUnhoist(row); }
public override void Redo(OutlinerDocument document, TreeListView treeListView) { MyEdit edit = GetEdit(document, treeListView); Debug.Assert(edit != null, "Bad news: UndoMyAction's Undo has edit == null"); __UndoAction.Redo(edit); edit.Links_Update(); Keyboard.Focus(edit); }
public override void Redo(OutlinerDocument document, TreeListView treeListView) { OutlinerNote note = document.FindOutlinerNoteById(__NoteId); if (note == null) return; if (__Direction == IndentDirection.IncreaseIndent) DocumentHelpers.IncreaseIndent(note, treeListView, false); else DocumentHelpers.DecreaseIndent(note, treeListView, false); }
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); } }
public static bool SaveFile(MainWindow wnd, OutlinerDocument rnl, string fileName) { rnl.FileName = fileName; XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; XmlWriter wr = XmlWriter.Create(fileName, settings); // TODO: Write header wr.WriteStartElement("Body"); wr.WriteAttributeString("CheckboxesVisible", rnl.CheckboxesVisble.ToString()); wr.WriteAttributeString("OddBackgroundColor", rnl.OddBackgroundColor.Color.ToString()); wr.WriteAttributeString("EvenBackgroundColor", rnl.EvenBackgroundColor.Color.ToString()); wr.WriteAttributeString("UseRowSeparator", rnl.LinesBetweenRows ? "true" :"false"); wr.WriteAttributeString("RowSeparatorColor", rnl.LinesBetweenRowsBrush.Color.ToString()); if (rnl.ShowInspectors == false) { wr.WriteAttributeString("ShowInspectors", rnl.ShowInspectors.ToString()); } wr.WriteStartElement("Styles"); for (int i = 0; i < rnl.Styles.Count; i++) { SaveStyle(wr, rnl.Styles[i]); } wr.WriteEndElement(); string[] id = new string[rnl.ColumnDefinitions.Count]; for (int i = 0; i < rnl.ColumnDefinitions.Count; i++) { id[i] = wnd.GetViewColumnId(i).ToString(); } wr.WriteStartElement("ColumnDefinitions"); wr.WriteAttributeString("Order", String.Join(";", id)); for (int i = 0; i < rnl.ColumnDefinitions.Count; i++) { SaveColumnDefinition(wr, rnl.ColumnDefinitions[i]); } wr.WriteEndElement(); for (int i = 0; i < rnl.Count; i++) { SaveRecursive(wr, rnl[i]); } wr.WriteEndElement(); wr.Close(); rnl.DocumentSaved(); return(true); }
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); }
public override void Redo(OutlinerDocument document, TreeListView treeListView) { BaseStyle style = document.Styles.GetStyleByTag(__StyleTag); style.Properties.Clear(); for (int i = 0; i < __AfterChange.Count; i++) { style.AddProperty(__AfterChange[i].PropertyType, __AfterChange[i].Value); } style.UpdateInspectorStyles(); }
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; }
internal static string ExportAsHtml(OutlinerDocument Document, MainWindow mainWindow) { MemoryStream stream = new MemoryStream(); StreamWriter writer = new StreamWriter(stream); writer.Write(ExportToHtml.Export(Document, mainWindow)); writer.Flush(); stream.Seek(0, SeekOrigin.Begin); StreamReader reader = new StreamReader(stream); return(reader.ReadToEnd()); }
public override void Undo(OutlinerDocument document, TreeListView treeListView) { var note = document.FindOutlinerNoteById(__NoteId); if (note == null) return; __Document = DocumentHelpers.SaveDocumentToStream(note.InlineNoteDocument); __DocumentTag = note.InlineNoteDocument.Tag; note.Document.FocusEditAfterTemplateChange = true; note.RemoveInlineNote(); }
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); }
internal static string ExportAsHtml_List(OutlinerDocument Document) { MemoryStream stream = new MemoryStream(); StreamWriter writer = new StreamWriter(stream); ExportAsHtml_List(Document, writer); writer.Flush(); stream.Seek(0, SeekOrigin.Begin); StreamReader reader = new StreamReader(stream); return(reader.ReadToEnd()); }
public override void Redo(OutlinerDocument document, TreeListView treeListView) { var note = document.FindOutlinerNoteById(__NoteId); if (note == null) { return; } treeListView.MakeActive(note, -1, false); note.CreateInlineNote(DocumentHelpers.RestoreDocumentFromStream(__Document)); note.InlineNoteDocument.Tag = __DocumentTag; }
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); }
public override void Undo(OutlinerDocument document, TreeListView treeListView) { OutlinerNote note = document.FindOutlinerNoteById(__NoteId); if (note == null) return; if (__Direction == IndentDirection.IncreaseIndent) DocumentHelpers.DecreaseIndent(note, treeListView, false); else { OutlinerNote limitNote = document.FindOutlinerNoteById(__LimitNoteId); DocumentHelpers.IncreaseIndentWithLimit(note, limitNote, __IsInlineEditFocused, treeListView, false); } }
public override void Undo(OutlinerDocument document, TreeListView treeListView) { var note = document.FindOutlinerNoteById(__NoteId); if (note == null) { return; } __Document = DocumentHelpers.SaveDocumentToStream(note.InlineNoteDocument); __DocumentTag = note.InlineNoteDocument.Tag; note.Document.FocusEditAfterTemplateChange = true; note.RemoveInlineNote(); }
private static void ExportAsHtml_List(OutlinerDocument Document, StreamWriter writer) { writer.WriteLine("<html>"); writer.WriteLine("<head>"); writer.WriteLine("<meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\" />"); writer.WriteLine("<title>{0}</title>", System.IO.Path.GetFileName(Document.FileName)); writer.WriteLine("<style>p {{margin:0px;}}</style>", System.IO.Path.GetFileName(Document.FileName)); writer.WriteLine("</head>"); writer.WriteLine("<body topmargin=0>\n"); DumpHTMLRecursive(writer, Document.RootNode); writer.WriteLine("\n</body>"); writer.WriteLine("</html>"); }
public static void ExportAsRtf(OutlinerDocument document, MainWindow mainWindow, string fileName) { string documentAsXaml = ExportToXaml_WordFriendly.ExportToXaml(document, mainWindow); MemoryStream stream = new MemoryStream(); StreamWriter writer = new StreamWriter(stream); writer.Write(documentAsXaml); writer.Flush(); stream.Seek(0, SeekOrigin.Begin); FlowDocument flowDoc = XamlReader.Load(stream) as FlowDocument; TextRange range = new TextRange(flowDoc.ContentStart, flowDoc.ContentEnd); FileStream fStream = new FileStream(fileName, FileMode.Create); range.Save(fStream, DataFormats.Rtf); fStream.Close(); }
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"); }
public override void Redo(OutlinerDocument document, TreeListView treeListView) { OutlinerNote note = document.FindOutlinerNoteById(__NoteId); if (note == null) return; __After.Seek(0, SeekOrigin.Begin); FlowDocument flowDocument = (FlowDocument)note.Columns[__ColumnId].ColumnData; TextRange range = new TextRange(flowDocument.ContentStart, flowDocument.ContentEnd); range.Load(__After, DataFormats.Xaml); __FontPropertiesAfter.ApplyToFlowDocument(flowDocument); if (__WasSelected) treeListView.MakeActive(note, -1, false); }
public override void Undo(OutlinerDocument document, TreeListView treeListView) { BaseStyle style = document.Styles.GetStyleByTag(__StyleTag); if (__AfterChange == null) { __AfterChange = new List<LevelStyleProperty>(); for (int i = 0; i < style.Count; i++) __AfterChange.Add(new LevelStyleProperty(style.Properties[i].PropertyType, style.Properties[i].Value)); } style.Properties.Clear(); for (int i = 0; i < __BeforeChange.Count; i++) style.AddProperty(__BeforeChange[i].PropertyType, __BeforeChange[i].Value); style.UpdateInspectorStyles(); }
public static string Export(OutlinerDocument Document, MainWindow wnd) { StringBuilder writer = new StringBuilder(); writer.AppendLine("<html>"); writer.AppendLine("<head>"); writer.AppendLine("<meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\" />"); writer.AppendLine(String.Format("<title>{0}</title>", System.IO.Path.GetFileName(Document.FileName))); writer.AppendLine("<style>p {{margin:0px;}}"); writer.AppendLine(" td {padding:0px;}"); writer.AppendLine(" th {font-size:12px; align:right; font-family: Helvetica,Arial,sans-serif;}" ); writer.AppendLine(" td#column{padding-left:4px;}"); writer.AppendLine(" td#note{padding-left:4px;}"); writer.AppendLine(" img#exp {padding-right:1px;}"); writer.AppendLine(" img#checkbox {padding-right:1px;}"); writer.AppendLine(" img#bul {padding-right:1px;}"); writer.AppendLine("</style>"); writer.AppendLine("</head>"); writer.AppendLine("<body topmargin=0>\n"); FlowDocument wholeDocument = new FlowDocument(); wholeDocument.FontFamily = UVOutliner.Settings.DefaultFontFamily; wholeDocument.FontSize = UVOutliner.Settings.DefaultFontSize; List<OutlinerNote> linearList = new List<OutlinerNote>(); DocumentHelpers.GetLinearNotesList(Document.RootNode, linearList, false); double totalWidth = 0; for (int i = 0; i < Document.ColumnDefinitions.Count; i++) totalWidth += Document.ColumnDefinitions[i].Width; writer.AppendLine("<table width='100%'>"); int[] columnWidths = new int[wnd.OutlinerTreeColumns.Count]; for (int i = 0; i < wnd.OutlinerTreeColumns.Count; i++) columnWidths[i] = (int)((Document.ColumnDefinitions[wnd.GetColumnIdByView(i)].Width / totalWidth) * 100); // add column headers if (Document.ColumnDefinitions.Count > 1) { writer.AppendLine("<tr>"); for (int i = 0; i < wnd.OutlinerTreeColumns.Count; i++) { int columnId = wnd.GetColumnIdByView(i); writer.Append( String.Format("<th width='{0}%'>", columnWidths[i])); writer.Append(Document.ColumnDefinitions[columnId].ColumnName); writer.AppendLine("</th>"); } writer.AppendLine("</tr>"); } // add all other columns for (int i = 0; i < linearList.Count; i++) { OutlinerNote note = linearList[i]; double indent = (Math.Max(0, note.Level - 1)) * 20; string indent_str = ""; for (int t = 0; t < indent / 10; t++) indent_str += " "; if (note.IsEmpty) { writer.AppendLine(indent_str + "<tr><td> </td></tr>"); continue; } writer.AppendLine(indent_str + "<tr>"); for (int c = 0; c < wnd.OutlinerTreeColumns.Count; c++) { int columnId = wnd.GetColumnIdByView(c); FlowDocument flowDocument = linearList[i].Columns[columnId].ColumnData as FlowDocument; if (flowDocument == null) { writer.AppendLine(indent_str + "<td></td>"); continue; } if (columnId != 0) { string style; var html = OpenSave.HtmlFromReport(flowDocument, out style); writer.AppendLine(String.Format(indent_str + "<td id=column style='{0}'>{1}</td>", style, html)); } else { writer.AppendLine(indent_str + "<td>"); writer.AppendLine(indent_str + " <table width='100%'>"); writer.AppendLine(indent_str + " <tr><td>"); writer.Append(String.Format(indent_str + " <nobr><div style='margin-left: {0}px;'>", indent)); if (note.SubNotes.Count == 0) writer.Append("<img src='uvbul.png' id=bul width=14 height=14 alt='•'>"); else { if (note.IsExpanded) writer.Append("<img src='uvndexpa.png' id=exp width=14 height=14>"); else writer.Append("<img src='uvndcol.png' id=exp width=14 height=14>"); } if (Document.CheckboxesVisble) { if (note.IsChecked == true) writer.Append("<img src='uvchboxch.png' id=checkbox width=14 height=14>"); else writer.Append("<img src='uvchboxunch.png' id=checkbox width=14 height=14>"); } writer.AppendLine("</div></nobr>"); string style; var html = OpenSave.HtmlFromReport(flowDocument, out style); writer.AppendLine(indent_str + String.Format(" </td><td width='100%' id=column style='{0}'>", style)); writer.AppendLine(indent_str + String.Format(" {0}", html)); writer.AppendLine(indent_str + " </td></tr>"); if (note.HasInlineNote) { html = OpenSave.HtmlFromReport(note.InlineNoteDocument, out style); writer.AppendLine(indent_str + " <tr><td></td>"); writer.AppendLine(indent_str + string.Format(" <td id=note style='{0}'>", style)); writer.AppendLine(indent_str + String.Format(" {0}", html)); writer.AppendLine(indent_str + " </td></tr>"); } writer.AppendLine(indent_str + " </table>"); writer.AppendLine(indent_str + "</td>"); } } writer.AppendLine(indent_str + "</tr>"); } writer.AppendLine("</table></body></html>"); return writer.ToString(); }
private static void UpdateOutlinerTreeItemsSource(OutlinerDocument document, TreeListView treeListView) { if (!document.IsHoisted) treeListView.ItemsSource = document; else treeListView.ItemsSource = document.HostNode.SubNotes; }
public override void Redo(OutlinerDocument document, TreeListView treeListView) { OutlinerNote note = document.FindOutlinerNoteById(__NoteId); SaveNote(note); DocumentHelpers.DeleteRow(note, treeListView); }
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(); }
public abstract void Undo(OutlinerDocument document, TreeListView treeListView);
public void Undo(OutlinerDocument document, TreeListView treeListView) { while (__UndoActions.Count > 0) { DocumentUndoAction action = __UndoActions.Pop(); action.Undo(document, treeListView); __RedoActions.Push(action); DoUndoCountChanged(); if (!action.UndoNext) break; } GC.Collect(); }
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"); }
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"); }
private MyEdit GetEdit(OutlinerDocument document, TreeListView treeListView) { OutlinerNote note = document.FindOutlinerNoteByDocument(__DocumentGuid); Debug.Assert(note != null, "GetEdit's note == null"); TreeListViewItem item = ViewHelpers.GetContainerForItem(treeListView, note); Debug.Assert(item != null, "Bad news: UndoMyAction's Undo has item == null"); MainWindow mw = DragDropHelper.GetMainWindow(treeListView); MyEdit edit = item.GetEditor(mw.GetViewColumnId(__ColumnId), __ColumnId, __IsInlineNote); return edit; }
public override void Undo(OutlinerDocument document, TreeListView treeListView) { OutlinerNote note = document.FindOutlinerNoteById(__NodeId); DocumentHelpers.MoveNodeDown(note, treeListView, __ActiveColumn, __IsInlineNoteFocused); }
public static string ExportToXaml(OutlinerDocument Document, MainWindow wnd) { FlowDocument wholeDocument = new FlowDocument(); wholeDocument.FontFamily = UVOutliner.Settings.DefaultFontFamily; wholeDocument.FontSize = UVOutliner.Settings.DefaultFontSize; List<OutlinerNote> linearList = new List<OutlinerNote>(); DocumentHelpers.GetLinearNotesList(Document.RootNode, linearList, false); double totalWidth = 0; for (int i = 0; i < Document.ColumnDefinitions.Count; i++) totalWidth += Document.ColumnDefinitions[i].Width; // just random if (totalWidth == 0) totalWidth = 300; Table table = new Table(); table.LineHeight = 1; table.Margin = new Thickness(0); table.Padding = new Thickness(0); wholeDocument.Blocks.Add(table); for (int i = 0; i < wnd.OutlinerTreeColumns.Count; i++) { int columnId = wnd.GetColumnIdByView(i); TableColumn column = new TableColumn(); column.Width = new GridLength(Document.ColumnDefinitions[columnId].Width / totalWidth, GridUnitType.Star); table.Columns.Add(column); } // add column headers if (Document.ColumnDefinitions.Count > 1) { TableRowGroup rowGroup = new TableRowGroup(); table.RowGroups.Add(rowGroup); TableRow row = new TableRow(); rowGroup.Rows.Add(row); for (int i = 0; i < wnd.OutlinerTreeColumns.Count; i++) { int columnId = wnd.GetColumnIdByView(i); row.Cells.Add(new TableCell(new Paragraph(new Run(Document.ColumnDefinitions[columnId].ColumnName)))); } } TableRowGroup mainRowGroup = new TableRowGroup(); table.RowGroups.Add(mainRowGroup); // add all other columns for (int i = 0; i < linearList.Count; i++) { TableRow tableRow = new TableRow(); OutlinerNote note = linearList[i]; if (note.IsEmpty) { tableRow.Cells.Add(new TableCell(new Paragraph())); mainRowGroup.Rows.Add(tableRow); continue; } for (int c = 0; c < wnd.OutlinerTreeColumns.Count; c++) { int columnId = wnd.GetColumnIdByView(c); FlowDocument flowDocument = linearList[i].Columns[columnId].ColumnData as FlowDocument; if (flowDocument == null) { tableRow.Cells.Add(new TableCell()); continue; } double indent = note.Level * 20; TableCell cell = new TableCell(); tableRow.Cells.Add(cell); Section section = XamlReader.Load(TransformFlowDocumentToSection(flowDocument)) as Section; if (section == null) continue; if (columnId != 0) cell.Blocks.Add(section); else { Table tbl = new Table(); tbl.LineHeight = 1; tbl.Margin = new Thickness(0); tbl.Padding = new Thickness(0); TableColumn c1 = new TableColumn(); c1.Width = new GridLength(indent + 20 + (Document.CheckboxesVisble ? 20 : 0), GridUnitType.Pixel); TableColumn c2 = new TableColumn(); c2.Width = new GridLength(1, GridUnitType.Auto); tbl.Columns.Add(c1); tbl.Columns.Add(c2); var tmpRowGroup = new TableRowGroup(); var tmpRow = new TableRow(); tmpRowGroup.Rows.Add(tmpRow); tbl.RowGroups.Add(tmpRowGroup); Paragraph para = new Paragraph(); para.Margin = new Thickness(indent, 0, 0, 0); AddImages(Document, note, para); tmpRow.Cells.Add(new TableCell(para)); tmpRow.Cells.Add(new TableCell(section)); cell.Blocks.Add(tbl); } } mainRowGroup.Rows.Add(tableRow); if (note.HasInlineNote) AddInlineNote(mainRowGroup.Rows, note); } MemoryStream outStream = new MemoryStream(); XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; XmlWriter writer = XmlWriter.Create(outStream, settings); XamlDesignerSerializationManager manager = new XamlDesignerSerializationManager(writer); XamlWriter.Save(wholeDocument, manager); outStream.Seek(0, SeekOrigin.Begin); StreamReader reader = new StreamReader(outStream); return reader.ReadToEnd(); }
public override void Redo(OutlinerDocument document, TreeListView treeListView) { MyEdit edit = GetEdit(document, treeListView); Debug.Assert(edit != null, "Bad news: UndoMyAction's Undo has edit == null"); __UndoAction.Redo(edit); edit.Links_Update(); Keyboard.Focus(edit); }
public override void Redo(OutlinerDocument document, TreeListView treeListView) { OutlinerNote note = document.FindOutlinerNoteById(__NoteId); if (note == null) return; for (int i = 0; i < note.Columns.Count; i++) { FlowDocument flowDocument = note.Columns[i].ColumnData as FlowDocument; if (flowDocument == null) continue; __After[i].Seek(0, SeekOrigin.Begin); TextRange range = new TextRange(flowDocument.ContentStart, flowDocument.ContentEnd); range.Load(__After[i], DataFormats.Xaml); } }