/// <summary> /// Метод, вызывающийся при добавлении вершины /// </summary> /// <param name="shape"></param> public void AddNode(Visio.Shape shape) { // Проверяем, что это соединительная линия if (shape.Master.NameU == "Dynamic connector") { // Do nothing } else { // Если новая фигура допустимой формы if (GetDotShapes().ContainsKey(shape.Master.NameU.ToUpper())) { if (shape.Text == "") { shape.Text = shape.GetHashCode().ToString(); } DotVertex <string> newNode = new DotVertex <string>(shape.GetHashCode().ToString()); newNode.Attributes.Add("shape", GetDotShapes()[shape.Master.NameU.ToUpper()]); newNode.Attributes.Add("label", shape.Text); graph.AddVertex(newNode); vertices.Add(newNode, shape); } else { throw new ArgumentException("Фигура не поддерживается языком DOT! Она не будет включена в список вершин графа!"); } } }
protected override DotVertex <string> CreateVertex(string idStr, IDictionary <string, string> attributes) { var result = new DotVertex <string>(idStr, attributes); this.vertices.Add(idStr, result); return(result); }
private static void CreateArrow( Point arrowCorner1, Point arrowCorner2, DotVertex <int> edgeDestination, FrameworkElement edgeArrow, Canvas canvas) { Point arrowStart, border; if (IsOnBoder(edgeDestination.Position.Value, edgeDestination.Width.Value, edgeDestination.Height.Value, arrowCorner2)) { arrowStart = arrowCorner1; border = arrowCorner2; } else { arrowStart = arrowCorner2; border = arrowCorner1; } double width = arrowStart.X - border.X; double height = border.Y - arrowStart.Y; double angle = (180 / Math.PI) * Math.Atan2(width, height); var arrowControl = edgeArrow; canvas.Children.Add(arrowControl); arrowControl.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)); double halfWidth = Math.Floor(arrowControl.DesiredSize.Width / 2); arrowControl.RenderTransform = new RotateTransform(angle, halfWidth, 0); Canvas.SetTop(arrowControl, arrowStart.Y); Canvas.SetLeft(arrowControl, arrowStart.X - halfWidth); }
/// <summary> /// Initializes a vertex /// </summary> /// <returns>The initialized vertex</returns> private DotVertex InitializeVertex(float x, float y, float z, float tu, float tv) { DotVertex vertex = new DotVertex(); Vector3 v = new Vector3(1, 1, 1); v.Normalize(); vertex.p = new Vector3(x, y, z); vertex.diffuse = VectorToRgba(v, 1.0f); vertex.specular = 0x40400000; vertex.tu1 = tu; vertex.tv1 = tv; return(vertex); }
protected override DotVertex <int> CreateVertex(string idStr, IDictionary <string, string> attributes) { int id; if (int.TryParse(idStr, out id) == false) { throw new ParserException(GetInvalidIdMessage(idStr)); } var vertex = new DotVertex <int>(id, attributes); this.vertices.InsertAt(id, vertex); return(vertex); }
/// <summary> /// Метод, вызывающийся при добавлении нового ребра между ребрами графа /// </summary> /// <param name="connects">Коннектор</param> public void AddEdge(Visio.Connects connects) { // Если соединение добавлено с использованием существующей соединительной линии, т.е. добавляем вторую вершину if (newEdges.ContainsKey(connects.FromSheet)) { // Добавляем вторую вершину в пару связанных вершин newEdges[connects.FromSheet].Add(connects.ToSheet); // Если обе соединенные фигуры - это вершины нашего графа if (vertices.ContainsValue(newEdges[connects.FromSheet][0]) && vertices.ContainsValue(newEdges[connects.FromSheet][1])) { DotVertex <string> from = new DotVertex <string>(""); DotVertex <string> to = new DotVertex <string>(""); // Ищем, каким вершинам они соответствуют foreach (var node in vertices) { if (node.Value == newEdges[connects.FromSheet][0]) { from = node.Key; } if (node.Value == newEdges[connects.FromSheet][1]) { to = node.Key; } } // Добавляем ребро с данными вершинами DotEdge <string> edge = new DotEdge <string>(from, to); graph.AddEdge(edge); // Добавляем новое ребро в список ребер edges.Add(edge, connects.FromSheet); } // Удаляем пару newEdges.Remove(connects.FromSheet); } else { // Применяем стили к коннектору connects.FromSheet.get_Cells("ConLineRouteExt").FormulaU = "2"; connects.FromSheet.get_Cells("EndArrow").Formula = "=5"; // Добавляем новый коннектор в словарь + вершину, от которой он стартовал, ожидая соединения ее со второй вершиной List <Visio.Shape> listOfConnectingNodes = new List <Visio.Shape>(); listOfConnectingNodes.Add(connects.ToSheet); newEdges.Add(connects.FromSheet, listOfConnectingNodes); } }
public override void BuildVertex(Point position, double width, double height, object originalVertex, DotVertex <int> dotVertex) { var element = this.verticesElements[originalVertex]; UpdatePosition(element, position.X, position.Y, width, height, canvas); #if !SILVERLIGHT Panel.SetZIndex(element, 1); // TODO: implement this functionality for Silverlight #endif }
public override void BuildVertex(Primitives.Point position, double width, double height, object originalVertex, DotVertex <int> dotVertex) { var element = this.verticesElements[originalVertex]; UpdatePosition(element, position.X, position.Y, width, height, canvas); Panel.SetZIndex(element, 1); }
public static string GetStateName(DotVertex <string> vertex) => vertex.Id;
public static string GetVertexClassName(string dotFileName, DotVertex <string> vertex) => $"{vertex.Id}{GetBaseName(dotFileName)}";
public abstract void BuildVertex(Point position, double width, double height, object originalVertex, DotVertex <TVertexId> dotVertex);