/// <summary> /// Update all code generators /// </summary> private void UpdateAll() { if (StreamCode == null || DrawingBrushCode == null || Preview == null) { return; } var path = selectedPath; if (path == null) { Preview.Data = null; StreamCode.Text = string.Empty; DrawingBrushCode.Text = string.Empty; GeometryCode.Text = string.Empty; return; } if (NormalizeCheckBox.IsChecked == true) { var normalizer = new NormalizeVisual(); path = (GraphicPath)normalizer.Normalize(selectedPath, NormalizeAspect.Both, 100); } var xamlStream = StreamSourceGenerator.GeneratePath(path); StreamCode.Text = xamlStream; var drawingBrushSource = DrawingBrushSourceGenerator.Generate(path); DrawingBrushCode.Text = drawingBrushSource; var geometry = GeometryBinaryGenerator.GenerateGeometry(path.Geometry); Preview.Data = geometry; UpdatePreviewAll(); UpdateGeometrySourceCode(); }
/// <summary> /// Update the Stream /// </summary> private void UpdateStreamSourceCode() { if (TypeComboBox == null || StreamCode == null) { return; } GraphicVisual visual = selectedVisual; if (NormalizeCheckBox.IsChecked == true) { var normalizer = new NormalizeVisual(); visual = normalizer.Normalize(selectedVisual, NormalizeAspect.Both, 100); } string xamlStream; GraphicPath graphicPath = visual as GraphicPath; if (graphicPath != null) { enableAllItems = true; SetTypeItemStatus(); StreamCode.TextWrapping = TextWrapping.NoWrap; } else { enableAllItems = false; SetTypeItemStatus(); if (TypeComboBox.SelectedIndex >= 2) { TypeComboBox.SelectedIndex = 1; } StreamCode.TextWrapping = TextWrapping.NoWrap; } if (graphicPath != null) { if (TypeComboBox.SelectedIndex == 0) { var streams = StreamSourceGenerator.GenerateStreamGeometries(visual); xamlStream = string.Join("\n", streams); } else if (TypeComboBox.SelectedIndex == 2) { xamlStream = StreamSourceGenerator.GeneratePathGeometry(graphicPath); } else if (TypeComboBox.SelectedIndex == 3) { xamlStream = StreamSourceGenerator.GenerateGeometry(graphicPath); } else { xamlStream = StreamSourceGenerator.GeneratePath(visual); } } else if (TypeComboBox.SelectedIndex == 0) { var streams = StreamSourceGenerator.GenerateStreamGeometries(visual); xamlStream = string.Join("\n", streams); } else { xamlStream = StreamSourceGenerator.GeneratePath(visual); } StreamCode.Text = xamlStream; }