public XmlElement Serialize(Block block, XmlDocument xmlDocument) { var paragraph = (Paragraph)block; var paragraphElement = xmlDocument.CreateElement("Paragraph"); foreach (var inline in paragraph.Inlines) { var properties = inline.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.SetProperty) .Where(p => ParagraphSerializationHelper.PropertyConverters.Keys.Contains(p.Name)) .Select(p => Tuple.Create(p.Name, p.GetValue(inline))); var inlineElement = xmlDocument.CreateElement("Inline"); foreach (var prop in properties) { var xmlAttribute = xmlDocument.CreateAttribute(prop.Item1); if (prop.Item2 != null) { xmlAttribute.InnerText = prop.Item2.ToString(); //TODO сложные объекты? } inlineElement.Attributes.Append(xmlAttribute); } inlineElement.SetAttribute("StyleName", FlowDocumentHelper.GetStyleName(inline)); paragraphElement.AppendChild(inlineElement); } return(paragraphElement); }
public override FlowDocument Build() { FlowDocument flowDocument = new FlowDocument(); flowDocument.Blocks.Add(FlowDocumentHelper.BuildTitle(Title)); Dictionary <string, Tuple <string, string> > columnDefinitions = new Dictionary <string, Tuple <string, string> >() { { "Title", new Tuple <string, string>("Title", null) }, { "StatusDescription", new Tuple <string, string>("Status", null) }, { "PriorityDescription", new Tuple <string, string>("Priority", null) }, { "CreatedDate", new Tuple <string, string>("Date Created", null) }, { "CompletedDate", new Tuple <string, string>("Date Completed", null) } }; using (TaskData tData = new TaskData()) { List <Task> activeTasks = tData.GetActiveTasks(); List <TaskViewModel> rowData = new List <TaskViewModel>(); foreach (Task task in activeTasks) { rowData.Add(new TaskViewModel(task, tData)); } flowDocument.Blocks.Add(FlowDocumentHelper.BuildTable <TaskViewModel>(columnDefinitions, rowData)); foreach (TaskViewModel taskVm in rowData) { taskVm.Dispose(); } } return(flowDocument); }
public override FlowDocument Build() { FlowDocument flowDocument = new FlowDocument(); flowDocument.Blocks.Add(FlowDocumentHelper.BuildTitle(Title)); Paragraph criteriaPara = new Paragraph(); Span startTitleSpan = new Span(); startTitleSpan.Inlines.Add("Start Date: "); startTitleSpan.FontWeight = FontWeights.Bold; Span startValueSpan = new Span(); startValueSpan.Inlines.Add(StartDate.ToShortDateString()); Span endTitleSpan = new Span(); endTitleSpan.Inlines.Add(" End Date: "); endTitleSpan.FontWeight = FontWeights.Bold; Span endValueSpan = new Span(); endValueSpan.Inlines.Add(EndDate.ToShortDateString()); criteriaPara.Inlines.Add(startTitleSpan); criteriaPara.Inlines.Add(startValueSpan); criteriaPara.Inlines.Add(endTitleSpan); criteriaPara.Inlines.Add(endValueSpan); flowDocument.Blocks.Add(criteriaPara); return(flowDocument); }
public void Upadate() { foreach (var style in TextStyles) { style.IsActive = false; } var inline = _documentState.CurrentSelection.Start.Parent as Inline; if (inline == null) { return; } var styleName = FlowDocumentHelper.GetStyleName(inline); if (String.IsNullOrEmpty(styleName)) { return; } var textStyle = TextStyles.SingleOrDefault(s => s.TextStyle.Name == styleName); if (textStyle == null) { return; } textStyle.IsActive = true; }
public override FlowDocument Build() { FlowDocument flowDocument = new FlowDocument(); flowDocument.Blocks.Add(FlowDocumentHelper.BuildTitle(Title)); Paragraph criteriaPara = new Paragraph(); Span titleSpan = new Span(); titleSpan.Inlines.Add("Title: "); titleSpan.FontWeight = FontWeights.Bold; Span titleValueSpan = new Span(); titleValueSpan.Inlines.Add(SelectedProject.Title); Span dateTitleSpan = new Span(); dateTitleSpan.Inlines.Add(" Date Created: "); dateTitleSpan.FontWeight = FontWeights.Bold; Span dateValueSpan = new Span(); dateValueSpan.Inlines.Add(SelectedProject.CreatedDate.ToShortDateString()); criteriaPara.Inlines.Add(titleSpan); criteriaPara.Inlines.Add(titleValueSpan); criteriaPara.Inlines.Add(dateTitleSpan); criteriaPara.Inlines.Add(dateValueSpan); flowDocument.Blocks.Add(criteriaPara); Dictionary <string, Tuple <string, string> > columnDefinitions = new Dictionary <string, Tuple <string, string> >() { { "Title", new Tuple <string, string>("Task Title", null) }, { "StatusDescription", new Tuple <string, string>("Status", null) }, { "PriorityDescription", new Tuple <string, string>("Priority", null) }, { "CreatedDate", new Tuple <string, string>("Date Created", null) }, { "CompletedDate", new Tuple <string, string>("Date Completed", null) } }; using (TaskData tData = new TaskData()) { using (ProjectData pData = new ProjectData()) { List <Task> childTasks = pData.GetChildTasks(SelectedProject.ProjectId); List <TaskViewModel> rowData = new List <TaskViewModel>(); foreach (Task task in childTasks) { rowData.Add(new TaskViewModel(task, tData)); } flowDocument.Blocks.Add(FlowDocumentHelper.BuildTable <TaskViewModel>(columnDefinitions, rowData)); foreach (TaskViewModel taskVm in rowData) { taskVm.Dispose(); } } } return(flowDocument); }
public static void ApplyTextStyle(this TextSelection selection, ITextStyle style) { if (selection == null || selection.Start == selection.End) { return; } selection.ApplyPropertyValue(TextElement.FontFamilyProperty, style.FontFamily); selection.ApplyPropertyValue(TextElement.FontSizeProperty, style.FontSize * 96d / 72d); selection.ApplyPropertyValue(TextElement.FontStyleProperty, style.FontStyle); selection.ApplyPropertyValue(TextElement.FontWeightProperty, style.FontWeight); selection.ApplyPropertyValue(TextElement.ForegroundProperty, new SolidColorBrush(style.FontColor)); FlowDocumentHelper.SetStyleName(selection.Start.Parent, style.Name); }
private void ChangeStyle(ITextStyle style) { foreach (var block in _flowDocument.Blocks) { var paragraph = block as Paragraph; if (paragraph == null) { continue; } foreach (var inline in paragraph.Inlines) { if (FlowDocumentHelper.GetStyleName(inline) == style.Name) { inline.ApplyTextStyle(style); } } } }
public void Deserialize(XmlNode xmlNode, FlowDocument flowDocument) { var paragraph = new Paragraph(); foreach (XmlNode inline in xmlNode.ChildNodes) { var run = new Run(); //TODO: other inlines ? foreach (XmlAttribute attribute in inline.Attributes) { if (attribute.Name != "StyleName") { run.GetType().GetProperty(attribute.Name).SetValue(run, ParagraphSerializationHelper.PropertyConverters[attribute.Name].ConvertFromString(attribute.InnerText)); } } if (xmlNode.Attributes["StyleName"] != null) { FlowDocumentHelper.SetStyleName(run, xmlNode.Attributes["StyleName"].InnerText); } paragraph.Inlines.Add(run); } flowDocument.Blocks.Add(paragraph); }
public override FlowDocument Build() { FlowDocument flowDocument = base.Build(); Dictionary <string, Tuple <string, string> > columnDefinitions = new Dictionary <string, Tuple <string, string> >() { { "Title", new Tuple <string, string>("Title", null) }, { "StatusDescription", new Tuple <string, string>("Status", null) }, { "CategoryDescription", new Tuple <string, string>("Category", null) }, { "CreatedDate", new Tuple <string, string>("Date Created", null) }, { "CompletedDate", new Tuple <string, string>("Date Completed", null) } }; using (GoalData gData = new GoalData()) { using (ProjectData pData = new ProjectData()) { using (TaskData tData = new TaskData()) { List <Goal> completedGoals = gData.GetCompletedGoalsByDate(StartDate, EndDate); List <GoalViewModel> rowData = new List <GoalViewModel>(); foreach (Goal goal in completedGoals) { rowData.Add(new GoalViewModel(goal, gData, pData, tData)); } flowDocument.Blocks.Add(FlowDocumentHelper.BuildTable <GoalViewModel>(columnDefinitions, rowData)); foreach (GoalViewModel goalVm in rowData) { goalVm.Dispose(); } } } } return(flowDocument); }
public void Deserialize(XmlNode xmlNode, FlowDocument flowDocument) { var list = new List { MarkerStyle = _markerStyle }; foreach (XmlNode listItemNode in xmlNode.ChildNodes) { var listItem = new ListItem(); foreach (XmlNode listItemBlockNode in listItemNode.ChildNodes) { var paragraph = new Paragraph(); foreach (XmlNode listItemInlineNode in listItemBlockNode.ChildNodes) { var run = new Run(); foreach (XmlAttribute attribute in listItemInlineNode.Attributes) { if (attribute.Name != "StyleName") { run.GetType().GetProperty(attribute.Name).SetValue(run, ParagraphSerializationHelper.PropertyConverters[attribute.Name].ConvertFromString( attribute.InnerText)); } } if (xmlNode.Attributes["StyleName"] != null) { FlowDocumentHelper.SetStyleName(run, xmlNode.Attributes["StyleName"].InnerText); } paragraph.Inlines.Add(run); } listItem.Blocks.Add(paragraph); } list.ListItems.Add(listItem); } flowDocument.Blocks.Add(list); }
public override FlowDocument Build() { FlowDocument flowDocument = base.Build(); Dictionary <string, Tuple <string, string> > columnDefinitions = new Dictionary <string, Tuple <string, string> >() { { "Title", new Tuple <string, string>("Title", null) }, { "StatusDescription", new Tuple <string, string>("Status", null) }, { "GoalTitle", new Tuple <string, string>("Goal", null) }, { "EstimatedCost", new Tuple <string, string>("Est. Cost", "{0:C}") }, { "CreatedDate", new Tuple <string, string>("Date Created", null) }, { "CompletedDate", new Tuple <string, string>("Date Completed", null) } }; using (ProjectData pData = new ProjectData()) { using (TaskData tData = new TaskData()) { List <Project> completedProjects = pData.GetCompletedProjectsByDate(StartDate, EndDate); List <ProjectViewModel> rowData = new List <ProjectViewModel>(); foreach (Project project in completedProjects) { rowData.Add(new ProjectViewModel(project, pData, tData)); } flowDocument.Blocks.Add(FlowDocumentHelper.BuildTable <ProjectViewModel>(columnDefinitions, rowData)); foreach (ProjectViewModel projectVm in rowData) { projectVm.Dispose(); } } } return(flowDocument); }
public override FlowDocument Build() { FlowDocument flowDocument = new FlowDocument(); flowDocument.Blocks.Add(FlowDocumentHelper.BuildTitle(Title)); Paragraph criteriaPara = new Paragraph(); Span titleSpan = new Span(); titleSpan.Inlines.Add("Title: "); titleSpan.FontWeight = FontWeights.Bold; Span titleValueSpan = new Span(); titleValueSpan.Inlines.Add(SelectedGoal.Title); Span dateTitleSpan = new Span(); dateTitleSpan.Inlines.Add(" Date Created: "); dateTitleSpan.FontWeight = FontWeights.Bold; Span dateValueSpan = new Span(); dateValueSpan.Inlines.Add(SelectedGoal.CreatedDate.ToShortDateString()); criteriaPara.Inlines.Add(titleSpan); criteriaPara.Inlines.Add(titleValueSpan); criteriaPara.Inlines.Add(dateTitleSpan); criteriaPara.Inlines.Add(dateValueSpan); flowDocument.Blocks.Add(criteriaPara); Dictionary <string, Tuple <string, string> > columnDefinitions = new Dictionary <string, Tuple <string, string> >() { { "Title", new Tuple <string, string>("Project Title", null) }, { "StatusDescription", new Tuple <string, string>("Status", null) }, { "EstimatedCost", new Tuple <string, string>("Estimated Cost", "0:C") }, { "CreatedDate", new Tuple <string, string>("Date Created", null) }, { "CompletedDate", new Tuple <string, string>("Date Completed", null) } }; using (ProjectData pData = new ProjectData()) { using (TaskData tData = new TaskData()) { using (GoalData gData = new GoalData()) { List <Project> childProjects = gData.GetChildProjects(SelectedGoal.GoalId); List <ProjectViewModel> rowData = new List <ProjectViewModel>(); foreach (Project project in childProjects) { rowData.Add(new ProjectViewModel(project, pData, tData)); } flowDocument.Blocks.Add(FlowDocumentHelper.BuildTable <ProjectViewModel>(columnDefinitions, rowData)); foreach (ProjectViewModel projectVm in rowData) { projectVm.Dispose(); } } } } return(flowDocument); }