private BitmapSource GetIcon(DeclarativeValueConstructorViewModel item) { BitmapImage image = new BitmapImage(new Uri("pack://application:,,,/Lithnet.Acma.Presentation;component/Resources/DeclarativeValueConstructor.png", UriKind.Absolute)); if (item.Disabled) { BitmapImage disabled = new BitmapImage(new Uri("pack://application:,,,/Lithnet.Acma.Presentation;component/Resources/DisabledOverlay.png", UriKind.Absolute)); return(this.MergeImages(image, disabled)); } else { return(image); } }
private static void WriteConstructorObject(IEnumerable <ExecutableConstructorObjectViewModel> constructors, DocX doc) { Paragraph p; //http://python-docx.readthedocs.org/en/latest/user/styles.html foreach (ExecutableConstructorObjectViewModel constructor in constructors) { p = doc.InsertParagraph(); p.StyleName = "Heading3"; p.InsertText(constructor.DisplayName); p = doc.InsertParagraph(); p.StyleName = "Normal"; p.InsertText(constructor.Description); if (constructor.RuleGroup != null && constructor.RuleGroup.Rules.Count > 0) { p = doc.InsertParagraph(); p.StyleName = "Heading5"; p.InsertText("Execution conditions"); p = doc.InsertParagraph(); p.StyleName = "Normal"; p.InsertText(DocXExporter.WriteRuleGroup(constructor.RuleGroup, 0)); // System.Diagnostics.Debug.WriteLine(p.Text); } if (constructor is AttributeConstructorGroupViewModel) { DocXExporter.WriteConstructorObject(((AttributeConstructorGroupViewModel)constructor).Constructors, doc); } else if (constructor is AttributeConstructorViewModel) { if (constructor is DeclarativeValueConstructorViewModel) { DeclarativeValueConstructorViewModel dvc = constructor as DeclarativeValueConstructorViewModel; if (dvc.ModificationType == AcmaAttributeModificationType.Conditional) { p = doc.InsertParagraph(); p.StyleName = "Heading5"; p.InsertText("Presence Conditions"); p = doc.InsertParagraph(); p.StyleName = "Normal"; p.InsertText(DocXExporter.WriteRuleGroup(dvc.PresenceConditions, 0)); } string action; switch (dvc.ModificationType) { case AcmaAttributeModificationType.Add: action = "The following values will be added"; break; case AcmaAttributeModificationType.Replace: action = "The following values will replace any existing values"; break; case AcmaAttributeModificationType.Delete: action = "The following values will be deleted"; break; case AcmaAttributeModificationType.Conditional: action = "The following values will be added or deleted based on the defined presence conditions"; break; default: throw new InvalidOperationException(); } p = doc.InsertParagraph(); p.StyleName = "Heading5"; p.InsertText("Value Modifications"); p = doc.InsertParagraph(); p.StyleName = "Normal"; p.InsertText(action); Table t = doc.InsertTable(dvc.ValueDeclarations.Count + 1, 2); t.Alignment = Alignment.left; t.Design = TableDesign.LightListAccent1; t.Rows[0].Cells[0].Paragraphs.First().Append("Declaration"); t.Rows[0].Cells[1].Paragraphs.First().Append("Transforms"); for (int i = 0; i < dvc.ValueDeclarations.Count; i++) { t.Rows[i + 1].Cells[0].Paragraphs.First().Append(dvc.ValueDeclarations[i].Declaration); t.Rows[i + 1].Cells[1].Paragraphs.First().Append(dvc.ValueDeclarations[i].TransformsString); } } } } }