示例#1
0
        /// <summary>
        /// Update the XAML source code
        /// </summary>
        private void UpdateSourceCode()
        {
            var path = selectedVisual;

            if (path == null)
            {
                return;
            }

            if (Normalize)
            {
                var normalizer = new NormalizeVisual();
                path = normalizer.Normalize(selectedVisual, NormalizeAspect.Both, 100);
            }

            var geometryGeneratorType = SelectedGeometryType.GeometryGeneratorType;

            switch (SelectedCodeTypeItem.CodeGeneratorType)
            {
            case XamlCodeGeneratorType.DrawingBrush:
                SourceCode = DrawingBrushSourceGenerator.Generate(path, geometryGeneratorType);
                break;

            case XamlCodeGeneratorType.Path:
                SourceCode = PathSourceGenerator.GeneratePath(path, geometryGeneratorType);
                break;
            }
        }
        /// <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();
        }
示例#3
0
        /// <summary>
        /// Update all views with the new selection
        /// </summary>
        private void UpdateAll()
        {
            if (selectionChangedFromCode || PathSelectionBox == null || StreamCode == null || DrawingBrushCode == null || Preview == null)
            {
                return;
            }

            // get the selected paths
            selectedVisual = BuildSelectedDrawing(graphicVisual);

            // handle the color warning indicator
            if (selectedVisual == null)
            {
                SetColorWarning("");

                Preview.Fill          = null;
                StreamCode.Text       = string.Empty;
                DrawingBrushCode.Text = string.Empty;
                GeometryCode.Text     = string.Empty;

                return;
            }

            GraphicColorPrecision colorPrecision = GetColorPrecision(selectedVisual);

            switch (colorPrecision)
            {
            case GraphicColorPrecision.Precise:
                SetColorWarning("");
                break;

            case GraphicColorPrecision.Estimated:
                SetColorWarning("Colors are estimated");
                break;

            case GraphicColorPrecision.Placeholder:
                SetColorWarning("Colors are placeholders");
                break;
            }

            // on request normalize the drawin
            GraphicVisual visual = selectedVisual;

            if (NormalizeCheckBox.IsChecked == true)
            {
                var normalizer = new NormalizeVisual();
                visual = normalizer.Normalize(selectedVisual, NormalizeAspect.Both, 100);
            }

            // update the preview
            var drawingBrush = DrawingBrushBinaryGenerator.Generate(visual);

            Preview.Fill = drawingBrush;

            // update the stream source code
            UpdateStreamSourceCode();

            // update the drawing brush source code
            var drawingBrushSource = DrawingBrushSourceGenerator.Generate(visual);

            DrawingBrushCode.Text = drawingBrushSource;

            // update the geometry source code
            UpdateGeometrySourceCode();

            ExportMessage.Visibility = Visibility.Collapsed;
        }