public DiagramArguments(string source, DiagramType type, DiagramStyle style, bool debug = false) { Source = source; Type = type; Style = style; Debug = debug; }
public DiagramMarkEditorViewModel(DiagramMark diagramMark, bool isNew) { DiagramMark = diagramMark ?? throw new ArgumentNullException(nameof(diagramMark)); // Save properties _text = diagramMark.Text; // Save original _originalStyle = new ObservableDiagramStyle(diagramMark.Style, diagramMark.MarkStyle); // Create editable clone DiagramStyle clone = _originalStyle.Style.Clone(); if (_originalStyle.Style.ReadOnly) { clone.MarkAsReadOnly(); } Style = new ObservableDiagramStyle(clone); Style.MarkStyle.MarkType = DiagramMark.Type; Style.PropertyChanged += ObservableDiagramStyle_PropertyChanged; if (isNew) { _dirty = true; } }
public void GenerateVerificationDiagrams(DiagramStyle diagramStyle) { string directory = diagramStyle.ToString(); string htmlFileName = string.Format("{0}\\VisualVerificationDiagrams.html", directory); Directory.CreateDirectory(directory); using (var reader = File.OpenText(@"SequenceDiagrams\EndToEnd\TestCaseSources.txt")) { using (TextWriter textWriter = new StreamWriter(htmlFileName)) using (var writer = new HtmlTextWriter(textWriter)) { writer.RenderBeginTag(HtmlTextWriterTag.Html); writer.RenderBeginTag(HtmlTextWriterTag.Head); writer.RenderBeginTag(HtmlTextWriterTag.Title); writer.Write("KangaModeling.SequenceDiagram Visual Tests"); writer.RenderEndTag(); writer.RenderEndTag(); writer.RenderBeginTag(HtmlTextWriterTag.Body); writer.AddAttribute("border", "1"); writer.AddAttribute(HtmlTextWriterAttribute.Width, "250px"); writer.RenderBeginTag(HtmlTextWriterTag.Table); foreach (var testCase in GetTestCases(reader)) { Write(testCase.Item1, testCase.Item2, writer, diagramStyle); } writer.RenderEndTag(); writer.RenderEndTag(); writer.RenderEndTag(); } } System.Diagnostics.Process.Start(htmlFileName); }
public DiagramBarreEditorViewModel(DiagramBarre diagramBarre, bool isNew) { if (null == diagramBarre) { throw new ArgumentNullException("diagramBarre"); } DiagramBarre = diagramBarre; // Save original _originalStyle = new ObservableDiagramStyle(diagramBarre.Style); // Create editable clone DiagramStyle clone = _originalStyle.Style.Clone(); if (_originalStyle.Style.ReadOnly) { clone.MarkAsReadOnly(); } Style = new ObservableDiagramStyle(clone); Style.PropertyChanged += ObservableDiagramStyle_PropertyChanged; if (isNew) { _dirty = true; } }
/// <summary> /// Set Diagram styles in PDATA and StyleEx. /// /// HideQuals=1 HideQualifiers: /// OpParams=2 Show full Operation Parameter /// ScalePI=1 Scale to fit page /// Theme=:119 Set the diagram theme and the used features of the theme (here 119, see StyleEx of t_diagram) /// /// par[0] contains the values as a semicolon/comma separated Style /// par[1] contains the values as a semicolon/comma separated PDATA /// par[2] contains the values as a semicolon/comma separated properties /// par[3] contains the possible diagram types /// </summary> /// <param name="rep"></param> /// <param name="dia"></param> /// <param name="par">par[] </param> private static void SetDiagramStyle(Repository rep, EA.Diagram dia, string[] par) { EaDiagram eaDia = new EaDiagram(rep, getAllDiagramObject: false); if (eaDia.Dia == null) { return; } rep.SaveDiagram(eaDia.Dia.DiagramID); string styles = par[0].Replace(",", ";"); string pdatas = par[1].Replace(",", ";"); string properties = par[2].Replace(",", ";"); string types = par[3]; var diagramStyle = new DiagramStyle(rep, dia, types, styles, pdatas, properties); if (diagramStyle.IsToProcess()) { diagramStyle.UpdateStyles(); diagramStyle.SetProperties(withSql: false); diagramStyle.SetProperties(withSql: true); } eaDia.ReloadSelectedObjectsAndConnector(saveDiagram: false); }
public DiagramFretLabelEditorViewModel(DiagramFretLabel diagramFretLabel, bool isNew) { if (null == diagramFretLabel) { throw new ArgumentNullException("diagramFretLabel"); } DiagramFretLabel = diagramFretLabel; // Save properties _text = diagramFretLabel.Text; // Save original _originalStyle = new ObservableDiagramStyle(diagramFretLabel.Style); // Create editable clone DiagramStyle clone = _originalStyle.Style.Clone(); if (_originalStyle.Style.ReadOnly) { clone.MarkAsReadOnly(); } Style = new ObservableDiagramStyle(clone); Style.PropertyChanged += ObservableDiagramStyle_PropertyChanged; if (isNew) { _dirty = true; } }
public OptionsViewModel() { SettingsBuffer = new ChordiousSettings(AppVM.UserConfig.ChordiousSettings, "Options"); StyleBuffer = new DiagramStyle(AppVM.UserConfig.DiagramStyle, "Options"); _advancedSettingsClean = true; _advancedStyleClean = true; }
public Diagram(DiagramStyle parentStyle, XmlReader xmlReader) : this(parentStyle) { if (null == xmlReader) { throw new ArgumentNullException(nameof(xmlReader)); } Read(xmlReader); }
public void MarkAsReadOnly() { ReadOnly = true; ChordiousSettings.MarkAsReadOnly(); DiagramStyle.MarkAsReadOnly(); Instruments.MarkAsReadOnly(); ChordQualities.MarkAsReadOnly(); Scales.MarkAsReadOnly(); }
public DiagramMarkStyleWrapper(DiagramStyle style, DiagramMarkType markType = DiagramMarkType.Normal) { if (null == style) { throw new ArgumentNullException("style"); } Style = style; MarkType = markType; }
public DiagramElement(Diagram parent) { if (null == parent) { throw new ArgumentNullException("parent"); } Parent = parent; Style = new DiagramStyle(parent.Style, "Element"); }
public ConfigFile(string level) { Level = level; ChordiousSettings = new ChordiousSettings(level); DiagramStyle = new DiagramStyle(level); Instruments = new InstrumentSet(level); ChordQualities = new ChordQualitySet(level); Scales = new ScaleSet(level); DiagramLibrary = new DiagramLibrary(DiagramStyle); }
public DiagramCollection(DiagramStyle parentStyle) { if (null == parentStyle) { throw new ArgumentNullException(nameof(parentStyle)); } Style = new DiagramStyle(parentStyle, LevelKey); _diagrams = new List <Diagram>(); }
private string GenetareImage(string source, string testCaseName, DiagramStyle diagramStyle) { var arguments = new DiagramArguments(source, DiagramType.Sequence, diagramStyle); var result = DiagramFactory.Create(arguments); using (result) { string filename = testCaseName + ".png"; result.Image.Save(diagramStyle + "\\" + filename, ImageFormat.Png); return(filename); } }
public Diagram(DiagramStyle parentStyle) { if (null == parentStyle) { throw new ArgumentNullException(nameof(parentStyle)); } _marks = new List <DiagramMark>(); _fretLabels = new List <DiagramFretLabel>(); _barres = new List <DiagramBarre>(); Style = new DiagramStyle(parentStyle, LevelKey); _numFrets = Style.NewDiagramNumFrets; _numStrings = Style.NewDiagramNumStrings; }
public static DiagramCollection Load(DiagramStyle parentStyle, Stream inputStream) { if (null == parentStyle) { throw new ArgumentNullException(nameof(parentStyle)); } if (null == inputStream) { throw new ArgumentNullException(nameof(inputStream)); } DiagramCollection collection = new DiagramCollection(parentStyle); using (StreamReader sr = new StreamReader(inputStream)) { ChordOptions currentChordOptions = new ChordOptions(); string line; while (null != (line = sr.ReadLine())) { line = line.Trim(); try { if (line.StartsWith(CommentPrefix)) // line is a comment { // ignore } else if (line.StartsWith(OptionsPrefix)) // line modifies the options { currentChordOptions = new ChordOptions(line); } else if (!string.IsNullOrEmpty(line)) // treat line as a chord { Chord chord = new Chord(line); Diagram diagram = GetDiagram(chord, currentChordOptions, collection.Style); collection.Add(diagram); } } catch (Exception) { } } } return(collection); }
internal AdvancedDataViewModel(InheritableDictionary inheritableDictionary, string filter) { if (null == inheritableDictionary) { throw new ArgumentNullException(nameof(inheritableDictionary)); } _clearedKeys = new List <string>(); Filter = string.IsNullOrEmpty(filter) ? "" : filter; if (null != (inheritableDictionary as ChordiousSettings)) { LocalBuffer = new ChordiousSettings(inheritableDictionary as ChordiousSettings, "Changed"); } else if (null != (inheritableDictionary as DiagramStyle)) { LocalBuffer = new DiagramStyle(inheritableDictionary as DiagramStyle, "Changed"); } }
public void LoadFile(Stream inputStream, ConfigParts configParts) { if (null == inputStream) { throw new ArgumentNullException(nameof(inputStream)); } using (XmlReader reader = XmlReader.Create(inputStream)) { while (reader.Read()) { if (reader.IsStartElement()) { if (reader.Name == "settings" && ((configParts & ConfigParts.Settings) == ConfigParts.Settings)) { ChordiousSettings.Read(reader.ReadSubtree()); } else if (reader.Name == "styles" && ((configParts & ConfigParts.Styles) == ConfigParts.Styles)) { DiagramStyle.Read(reader.ReadSubtree()); } else if (reader.Name == "instruments" && ((configParts & ConfigParts.Instruments) == ConfigParts.Instruments)) { Instruments.Read(reader.ReadSubtree()); } else if (reader.Name == "qualities" && ((configParts & ConfigParts.Qualities) == ConfigParts.Qualities)) { ChordQualities.Read(reader.ReadSubtree()); } else if (reader.Name == "scales" && ((configParts & ConfigParts.Scales) == ConfigParts.Scales)) { Scales.Read(reader.ReadSubtree()); } else if (reader.Name == "library" && ((configParts & ConfigParts.Library) == ConfigParts.Library)) { DiagramLibrary.Read(reader.ReadSubtree()); } } } } }
public DiagramStyleEditorViewModel(ObservableDiagramStyle diagramStyle) { if (null == diagramStyle) { throw new ArgumentNullException(nameof(diagramStyle)); } // Add original _originalStyles = new ObservableCollection <ObservableDiagramStyle> { diagramStyle }; // Recursively parents up the tree DiagramStyle style = diagramStyle.Style.Parent; while (null != style) { ObservableDiagramStyle parentStyle = new ObservableDiagramStyle(style); _originalStyles.Insert(0, parentStyle); style = style.Parent; } // Add editable clones Styles = new ObservableCollection <ObservableDiagramStyle>(); foreach (ObservableDiagramStyle originalStyle in _originalStyles) { DiagramStyle clone = originalStyle.Style.Clone(); if (originalStyle.Style.ReadOnly) { clone.MarkAsReadOnly(); } ObservableDiagramStyle editableStyle = new ObservableDiagramStyle(clone); editableStyle.PropertyChanged += ObservableDiagramStyle_PropertyChanged; Styles.Add(editableStyle); } _selectedStyleIndex = Styles.Count - 1; }
public override void Write(XmlWriter xmlWriter) { if (null == xmlWriter) { throw new ArgumentNullException(nameof(xmlWriter)); } xmlWriter.WriteStartElement("mark"); xmlWriter.WriteAttributeString("text", Text); xmlWriter.WriteAttributeString("type", Type.ToString()); xmlWriter.WriteAttributeString("string", Position.String.ToString()); xmlWriter.WriteAttributeString("fret", Position.Fret.ToString()); string prefix = DiagramStyle.GetMarkStylePrefix(Type); // Only write the styles that apply to the type of this mark Style.Write(xmlWriter, prefix + "mark"); xmlWriter.WriteEndElement(); }
public ChordFinderStyle(ConfigFile configFile, ChordiousSettings chordiousSettings = null, DiagramStyle diagramStyle = null) : base(configFile, "chord") { string level = "ChordFinderStyle"; if (null != chordiousSettings) { Settings = chordiousSettings; } else { Settings = new ChordiousSettings(_configFile.ChordiousSettings, level); } if (null != diagramStyle) { Style = diagramStyle; } else { Style = new DiagramStyle(_configFile.DiagramStyle, level); } }
public void ImportConfig(ConfigFile configFile, ConfigParts configParts) { if (null == configFile) { throw new ArgumentNullException(nameof(configFile)); } if ((configParts & ConfigParts.Settings) == ConfigParts.Settings) { ChordiousSettings.CopyFrom(configFile.ChordiousSettings); } if ((configParts & ConfigParts.Styles) == ConfigParts.Styles) { DiagramStyle.CopyFrom(configFile.DiagramStyle); } if ((configParts & ConfigParts.Instruments) == ConfigParts.Instruments) { Instruments.CopyFrom(configFile.Instruments); } if ((configParts & ConfigParts.Qualities) == ConfigParts.Qualities) { ChordQualities.CopyFrom(configFile.ChordQualities); } if ((configParts & ConfigParts.Scales) == ConfigParts.Scales) { Scales.CopyFrom(configFile.Scales); } if ((configParts & ConfigParts.Library) == ConfigParts.Library) { DiagramLibrary.CopyFrom(configFile.DiagramLibrary); } }
public DiagramElement(Diagram parent) { Parent = parent ?? throw new ArgumentNullException(nameof(parent)); Style = new DiagramStyle(parent.Style, "Element"); }
public override string ToSvg() { string svg = ""; if (IsVisible()) { string prefix = DiagramStyle.GetMarkStylePrefix(Type); DiagramMarkShape shape = MarkStyle.MarkShape; double radius = MarkStyle.MarkRadiusRatio * 0.5 * Math.Min(Parent.Style.GridStringSpacing, Parent.Style.GridFretSpacing); double centerX = Parent.GridLeftEdge() + (Parent.Style.GridStringSpacing * (Position.String - 1)); double centerY = Parent.GridTopEdge() + (Parent.Style.GridFretSpacing / 2.0) + (Parent.Style.GridFretSpacing * (Position.Fret - 1)); // Draw shape string shapeStyle = Style.GetSvgStyle(DiagramMark._shapeStyleMap, prefix); if (MarkStyle.MarkBorderThickness > 0) { shapeStyle += Style.GetSvgStyle(DiagramMark._shapeStyleMapBorder, prefix); } switch (shape) { case DiagramMarkShape.Circle: svg += string.Format(CultureInfo.InvariantCulture, SvgConstants.CIRCLE, shapeStyle, radius, centerX, centerY); break; case DiagramMarkShape.Square: svg += string.Format(CultureInfo.InvariantCulture, SvgConstants.RECTANGLE, shapeStyle, radius * 2.0, radius * 2.0, centerX - radius, centerY - radius); break; case DiagramMarkShape.Diamond: string diamondPoints = ""; for (int i = 0; i < 4; i++) { double angle = (i * 90.0) * (Math.PI / 180.0); diamondPoints += string.Format(CultureInfo.InvariantCulture, "{0},{1} ", centerX + (radius * Math.Cos(angle)), centerY + (radius * Math.Sin(angle))); } svg += string.Format(CultureInfo.InvariantCulture, SvgConstants.POLYGON, shapeStyle, diamondPoints); break; case DiagramMarkShape.X: string xPoints = ""; for (int i = 0; i < 4; i++) { double angle = (45.0 + (i * 90.0)); double rad0 = (angle - 45.0) * (Math.PI / 180.0); // Starting close point double len0 = Math.Sqrt(2 * Math.Pow(radius * Math.Sin(XThicknessAngle), 2)); xPoints += string.Format(CultureInfo.InvariantCulture, "{0},{1} ", centerX + (len0 * Math.Cos(rad0)), centerY + (len0 * Math.Sin(rad0))); double rad1 = (angle * (Math.PI / 180.0)) - XThicknessAngle; // First far corner xPoints += string.Format(CultureInfo.InvariantCulture, "{0},{1} ", centerX + (radius * Math.Cos(rad1)), centerY + (radius * Math.Sin(rad1))); double rad2 = (angle * (Math.PI / 180.0)) + XThicknessAngle; // Second far corner xPoints += string.Format(CultureInfo.InvariantCulture, "{0},{1} ", centerX + (radius * Math.Cos(rad2)), centerY + (radius * Math.Sin(rad2))); } svg += string.Format(CultureInfo.InvariantCulture, SvgConstants.POLYGON, shapeStyle, xPoints.Trim()); break; case DiagramMarkShape.None: default: break; } // Draw text if (!StringUtils.IsNullOrWhiteSpace(Text) && MarkStyle.MarkTextVisible) { double textSize = radius * 2.0 * MarkStyle.MarkTextSizeRatio; double textX = centerX; double textY = centerY; switch (MarkStyle.MarkTextAlignment) { case DiagramHorizontalAlignment.Left: textX += (Parent.Style.Orientation == DiagramOrientation.LeftRight) ? -1.0 * textSize * 0.5 : -1.0 * radius; // D <-> U : L <-> R textY += (Parent.Style.Orientation == DiagramOrientation.LeftRight) ? -1.0 * radius : textSize * 0.5; // L <-> R : U <-> D break; case DiagramHorizontalAlignment.Center: textX += (Parent.Style.Orientation == DiagramOrientation.LeftRight) ? -1.0 * textSize * 0.5 : 0; // D <-> U : L <-> R textY += (Parent.Style.Orientation == DiagramOrientation.LeftRight) ? 0 : textSize * 0.5; // L <-> R : U <-> D break; case DiagramHorizontalAlignment.Right: textX += (Parent.Style.Orientation == DiagramOrientation.LeftRight) ? -1.0 * textSize * 0.5 : radius; // D <-> U : L <-> R textY += (Parent.Style.Orientation == DiagramOrientation.LeftRight) ? radius : textSize * 0.5; // L <-> R : U <-> D break; } string textStyle = Style.GetSvgStyle(DiagramMark._textStyleMap, prefix); textStyle += string.Format(CultureInfo.InvariantCulture, "font-size:{0}pt;", textSize); string textFormat = (Parent.Style.Orientation == DiagramOrientation.LeftRight) ? SvgConstants.ROTATED_TEXT : SvgConstants.TEXT; svg += string.Format(CultureInfo.InvariantCulture, textFormat, textStyle, textX, textY, Text); } } return(svg); }
public DiagramLibraryNode(DiagramStyle parentStyle, XmlReader xmlReader) : this(parentStyle) { Read(xmlReader); }
private void Write(string source, string testCaseName, HtmlTextWriter writer, DiagramStyle diagramStyle) { writer.RenderBeginTag(HtmlTextWriterTag.Tr); writer.AddAttribute(HtmlTextWriterAttribute.Colspan, "2"); writer.RenderBeginTag(HtmlTextWriterTag.Td); writer.Write(testCaseName); writer.RenderEndTag(); writer.RenderEndTag(); writer.RenderBeginTag(HtmlTextWriterTag.Tr); writer.RenderBeginTag(HtmlTextWriterTag.Td); writer.RenderBeginTag(HtmlTextWriterTag.Pre); writer.WriteLineNoTabs(source); writer.RenderEndTag(); writer.RenderEndTag(); writer.RenderBeginTag(HtmlTextWriterTag.Td); string fileName = GenetareImage(source, testCaseName, diagramStyle); writer.AddAttribute(HtmlTextWriterAttribute.Src, fileName); writer.AddAttribute(HtmlTextWriterAttribute.Alt, testCaseName); writer.RenderBeginTag(HtmlTextWriterTag.Img); writer.RenderEndTag(); writer.RenderEndTag(); writer.RenderEndTag(); }
public void SaveFile(Stream outputStream, ConfigParts configParts) { if (null == outputStream) { throw new ArgumentNullException(nameof(outputStream)); } XmlWriterSettings settings = new XmlWriterSettings { Indent = true }; using (XmlWriter writer = XmlWriter.Create(outputStream, settings)) { writer.WriteStartElement("chordious"); writer.WriteAttributeString("version", AppInfo.ProgramTitle); writer.WriteAttributeString("date", DateTime.UtcNow.ToString()); if ((configParts & ConfigParts.Settings) == ConfigParts.Settings) { writer.WriteStartElement("settings"); ChordiousSettings.Write(writer); writer.WriteEndElement(); } if ((configParts & ConfigParts.Styles) == ConfigParts.Styles) { writer.WriteStartElement("styles"); DiagramStyle.Write(writer); writer.WriteEndElement(); } if ((configParts & ConfigParts.Instruments) == ConfigParts.Instruments) { writer.WriteStartElement("instruments"); Instruments.Write(writer); writer.WriteEndElement(); } if ((configParts & ConfigParts.Qualities) == ConfigParts.Qualities) { writer.WriteStartElement("qualities"); ChordQualities.Write(writer); writer.WriteEndElement(); } if ((configParts & ConfigParts.Scales) == ConfigParts.Scales) { writer.WriteStartElement("scales"); Scales.Write(writer); writer.WriteEndElement(); } if ((configParts & ConfigParts.Library) == ConfigParts.Library) { writer.WriteStartElement("library"); DiagramLibrary.Write(writer); writer.WriteEndElement(); } writer.WriteEndElement(); } }
private DiagramLibraryNode(DiagramStyle parentStyle) { DiagramCollection = new DiagramCollection(parentStyle); }
public DiagramCollection(DiagramStyle parentStyle, XmlReader xmlReader) : this(parentStyle) { Read(xmlReader); }
public DiagramLibraryNode(DiagramStyle parentStyle, string path, string name) : this(parentStyle) { Path = path; Name = name; }