Exemplo n.º 1
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            if (Template == null)
            {
                return;
            }
            VertexLabelControl = Template.FindName("PART_vertexLabel", this) as IVertexLabelControl;

            if (VertexLabelControl != null)
            {
                if (ShowLabel)
                {
                    VertexLabelControl.Show();
                }
                else
                {
                    VertexLabelControl.Hide();
                }
                UpdateLayout();
                VertexLabelControl.UpdatePosition();
            }

            VertexConnectionPointsList = this.FindDescendantsOfType <IVertexConnectionPoint>().ToList();
            if (VertexConnectionPointsList.GroupBy(x => x.Id).Count(group => @group.Count() > 1) > 0)
            {
                throw new GX_InvalidDataException("Vertex connection points in VertexControl template must have unique Id!");
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Returns first connection point found with specified Id
        /// </summary>
        /// <param name="id">Connection point identifier</param>
        /// <param name="runUpdate">Update connection point if found</param>
        public IVertexConnectionPoint GetConnectionPointById(int id, bool runUpdate = false)
        {
            var result = VertexConnectionPointsList.FirstOrDefault(a => a.Id == id);

            result?.Update();
            return(result);
        }
Exemplo n.º 3
0
        public IVertexConnectionPoint GetConnectionPointAt(Point position)
        {
            Measure(new USize(double.PositiveInfinity, double.PositiveInfinity));

            return(VertexConnectionPointsList.FirstOrDefault(a =>
            {
                var rect = new Rect(a.RectangularSize.X, a.RectangularSize.Y, a.RectangularSize.Width, a.RectangularSize.Height);
                return rect.Contains(position.ToGraphX());
            }));
        }