/// <summary> /// Parse and display the new input stream /// </summary> private void CreatePaths(string stream) { GraphicPath path; try { var streamGeometryParser = new StreamGeometryParser(); var graphicPathGeometry = streamGeometryParser.ParseGeometry(stream); path = new GraphicPath(); path.Geometry = graphicPathGeometry; path.FillBrush = new GraphicSolidColorBrush { Color = Color.FromRgb(128, 128, 128) }; ShowError = false; } catch { path = null; ShowError = true; } PreviewViewModel.SetNewGraphicPath(path); ResourceViewModel.SetNewGraphicVisual(path); XamlViewModel.SetNewGraphicVisual(path); CSharpViewModel.SetNewGraphicVisual(path); ExportViewModel.SetNewGraphicVisual(path); }
/// <summary> /// Prepare all data for the graphic path selection listbox /// </summary> void PrepSelectionList() { if (graphicVisual != null) { var previewIcons = new List <PreviewShapeViewModel>(); int index = 0; CreateShapeSelectionList(graphicVisual, previewIcons, ref index); PreviewShapes = previewIcons; if (previewIcons.Count > 0) { TriggerResetView.Fire(); ResourceViewModel.Reset(); XamlViewModel.Reset(); CSharpViewModel.Reset(); } SelectAllPreviewIcons(true); } else { PreviewShapes = null; PreviewViewModel.SetNewGraphicVisual(null); ResourceViewModel.SetNewGraphicVisual(null); XamlViewModel.SetNewGraphicVisual(null); CSharpViewModel.SetNewGraphicVisual(null); ExportViewModel.SetNewGraphicVisual(null); } }
/// <summary> /// Constructor /// </summary> public StreamConverterViewModel() { PreviewViewModel = new PreviewViewModel(); ResourceViewModel = new ResourceViewModel(); XamlViewModel = new XamlViewModel(); CSharpViewModel = new CSharpViewModel(); ExportViewModel = new ExportViewModel(); }
/// <summary> /// Constructor /// </summary> public FileConverterViewModel() { PreviewViewModel = new PreviewViewModel(); ResourceViewModel = new ResourceViewModel(); XamlViewModel = new XamlViewModel(); CSharpViewModel = new CSharpViewModel(); ExportViewModel = new ExportViewModel(); SelectFile = new DelegateCommand(OnSelectFile); SelectAll = new DelegateCommand(OnSelectAll); TriggerResetView = new FireTrigger(); fileParser = new FileParser(); fileParser.Init(); }
/// <summary> /// Update all views with the new selection /// </summary> private void UpdateAll() { GraphicColorPrecision?colorPrecision = null; // get the selected paths selectedVisual = BuildSelectedDrawing(graphicVisual); if (selectedVisual != null) { colorPrecision = GetColorPrecision(selectedVisual); } PreviewViewModel.SetNewGraphicVisual(selectedVisual, colorPrecision); ResourceViewModel.SetNewGraphicVisual(selectedVisual, colorPrecision); XamlViewModel.SetNewGraphicVisual(selectedVisual, colorPrecision); CSharpViewModel.SetNewGraphicVisual(selectedVisual); ExportViewModel.SetNewGraphicVisual(selectedVisual); }
/// <summary> /// Add graphic paths to the graphic path selection listbox /// </summary> void ShowPaths(string filename) { this.filename = filename; graphicVisual = fileParser.Parse(filename); if (graphicVisual != null) { ShowError = false; CSharpViewModel.SetFilename(filename); } else { ShowError = true; } PrepSelectionList(); }