private void NewVertexAndEdgeBySchema_FillForMeta(IVertex baseVertex, IVertex meta, IVertex metaEdges) { //if (meta.Value != null && !GeneralUtil.CompareStrings(meta.Value, "$Empty")) //{ MenuItem i = createMenuItem(meta.Value.ToString()); NewVertexBySchema.Items.Add(i); MenuItem ie = createMenuItem(meta.Value.ToString()); NewEdgeBySchema.Items.Add(ie); foreach (IEdge ee in metaEdges) { if (ee.To.Value != null && !GeneralUtil.CompareStrings(ee.To.Value, "$Empty")) { MenuItem ii = createMenuItem(ee.To.Value.ToString()); ii.Tag = ee.To; i.Items.Add(ii); MenuItem iie = createMenuItem(ee.To.Value.ToString()); iie.Tag = ee.To; ie.Items.Add(iie); if (VertexOperations.TestIfNewEdgeValid(baseVertex, ee.To, null) != null) { ii.IsEnabled = false; iie.IsEnabled = false; } ii.Click += OnNewVertexBySchema; iie.Click += OnNewEdgeBySchema; } } //} }
public virtual void DoCreateDiagramLine(DiagramItemBase toItem) { IVertex toEdge = toItem.Vertex.Get("BaseEdge:"); IVertex r = m0.MinusZero.Instance.Root; IVertex v = m0.MinusZero.Instance.CreateTempVertex(); foreach (IEdge def in Vertex.GetAll(@"Definition:\DiagramLineDefinition:")) { bool CreateEdgeOnly = false; if (GraphUtil.GetValueAndCompareStrings(def.To.Get("CreateEdgeOnly:"), "True")) { CreateEdgeOnly = true; } foreach (IEdge e in Vertex.GetAll(@"BaseEdge:\To:\" + def.To.Get("EdgeTestQuery:"))) { bool canAdd = true; if (def.To.Get("ToDiagramItemTestQuery:") != null && toItem.Vertex.Get((string)def.To.Get("ToDiagramItemTestQuery:").Value) == null) { canAdd = false; } if (e.To.Get(@"$EdgeTarget:") != null && !GeneralUtil.CompareStrings(e.To.Get(@"$EdgeTarget:").Value, "Vertex") && // Vertexes do not have $Is:Vertex toEdge.Get(@"To:\$Is:" + (string)e.To.Get(@"$EdgeTarget:").Value) == null) { canAdd = false; } if (CreateEdgeOnly == false && e.To.Get(@"$VertexTarget:") != null && toEdge.Get(@"To:\$Is:" + (string)e.To.Get(@"$VertexTarget:").Value) == null) { canAdd = false; } if (canAdd) { AddNewLineOption(v, def, e); } } if (GeneralUtil.CompareStrings(def.To.Value, "Edge"))// Vertex\Edge { foreach (IEdge e in r.Get(@"System\Meta\Base\Vertex")) { AddNewLineOption(v, def, e); } } if (GeneralUtil.CompareStrings(def.To.Get("EdgeTestQuery:"), "$EdgeTarget")) // $EdgeTarget is not present as there is no inheritance from Vertex { AddNewLineOption(v, def, GraphUtil.FindEdgeByToVertex(r.Get(@"System\Meta\Base\Vertex"), "$EdgeTarget")); } } if (v.Count() == 0) { MinusZero.Instance.DefaultShow.ShowInfo("There is no diagram line definition matching selected source and target items."); } IVertex info = m0.MinusZero.Instance.CreateTempVertex(); info.Value = "choose diagram line:"; Point mousePosition = UIWpf.GetMousePosition(); IVertex a = MinusZero.Instance.DefaultShow.SelectDialog(info, v, mousePosition); if (a != null) { IVertex test = VertexOperations.TestIfNewEdgeValid(Vertex.Get(@"BaseEdge:\To:"), a.Get("OptionEdge:"), toEdge.Get("To:")); if (test == null) { bool?ForceShowEditForm = null; // ForceShowEditForm if (a.Get(@"OptionDiagramLineDefinition:\ForceShowEditForm:") != null) { if (GeneralUtil.CompareStrings(a.Get(@"OptionDiagramLineDefinition:\ForceShowEditForm:"), "True")) { ForceShowEditForm = true; } if (GeneralUtil.CompareStrings(a.Get(@"OptionDiagramLineDefinition:\ForceShowEditForm:"), "False")) { ForceShowEditForm = false; } } bool CreateEdgeOnly = false; // CreateEdgeOnly if (GraphUtil.GetValueAndCompareStrings(a.Get(@"OptionDiagramLineDefinition:\CreateEdgeOnly:"), "True")) { CreateEdgeOnly = true; } CanAutomaticallyAddEdges = false; // for VertexChange IEdge edge = VertexOperations.AddEdgeOrVertexByMeta(Vertex.Get(@"BaseEdge:\To:"), a.Get("OptionEdge:"), toEdge.Get("To:"), mousePosition, CreateEdgeOnly, ForceShowEditForm); CanAutomaticallyAddEdges = true; AddDiagramLineVertex(edge, a.Get(@"OptionDiagramLineDefinition:"), toItem); } else { MinusZero.Instance.DefaultShow.ShowInfo("Adding new diagram line \"" + a.Value + "\" is not possible.\n\n" + test.Value); } } }