public void LoadGraph(string data, string CWD, bool readOnly = false) { Release(); Graph = new ImageGraph("Untitled"); if (string.IsNullOrEmpty(data)) { return; } Original = Graph; Graph.CWD = CWD; Graph.FromJson(data); HdriManager.Selected = Graph.HdriIndex; Graph.OnGraphUpdated += Graph_OnGraphUpdated; Scale = Graph.Zoom; XShift = Graph.ShiftX; YShift = Graph.ShiftY; ZoomLevel.Text = String.Format("{0:0}", Scale * 100); LoadGraphUI(); ReadOnly = readOnly; Crumbs.Clear(); BreadCrumb cb = new BreadCrumb(Crumbs, "Root", this, null); }
public UIGraph() { InitializeComponent(); Id = Guid.NewGuid().ToString(); GraphStack = new Stack <GraphStackItem>(); SelectedNodes = new List <UINode>(); selectionRect = new Rectangle(); selectionRect.Stroke = new SolidColorBrush(Colors.DarkRed); selectionRect.StrokeDashArray.Add(2); selectionRect.StrokeDashArray.Add(2); selectionRect.StrokeDashCap = PenLineCap.Round; selectionRect.StrokeEndLineCap = PenLineCap.Round; selectionRect.StrokeThickness = 1; selectionRect.HorizontalAlignment = HorizontalAlignment.Left; selectionRect.VerticalAlignment = VerticalAlignment.Top; selectionRect.Fill = null; selectionRect.RenderTransformOrigin = new Point(0, 0); lookup = new Dictionary <string, UINode>(); Scale = 1; PrevScale = 1; moving = false; GraphNodes = new List <UINode>(); Original = Graph = new ImageGraph("Untitled"); UpdateGrid(); Crumbs.Clear(); ConnectionPointPreview.RadiusX = 8; ConnectionPointPreview.RadiusY = 8; ConnectionPointPreview.Width = 16; ConnectionPointPreview.Height = 16; ConnectionPointPreview.Fill = new SolidColorBrush(Colors.DarkRed); ConnectionPointPreview.HorizontalAlignment = HorizontalAlignment.Left; ConnectionPointPreview.VerticalAlignment = VerticalAlignment.Top; ConnectionPathPreview.HorizontalAlignment = HorizontalAlignment.Left; ConnectionPathPreview.VerticalAlignment = VerticalAlignment.Top; ConnectionPathPreview.Stroke = new SolidColorBrush(Colors.DarkRed); ConnectionPointPreview.IsHitTestVisible = false; ConnectionPathPreview.IsHitTestVisible = false; BreadCrumb cb = new BreadCrumb(Crumbs, "Root", this, null); }