Example #1
0
        public EdgeControl(VertexControl source, VertexControl target, object edge, bool showLabels = false, bool showArrows = true)
        {
            DataContext          = edge;
            Source               = source; Target = target;
            Edge                 = edge; DataContext = edge;
            ShowArrows           = showArrows;
            ShowLabel            = showLabels;
            _updateLabelPosition = true;
            IsHiddenEdgesUpdated = true;

            EventOptions = new EdgeEventOptions(this);
            foreach (var item in Enum.GetValues(typeof(EventType)).Cast <EventType>())
            {
                UpdateEventhandling(item);
            }

            if (source != null)
            {
                _sourceTrace = source.EventOptions.PositionChangeNotification;
                source.EventOptions.PositionChangeNotification = true;
                source.PositionChanged += source_PositionChanged;
            }
            if (target != null)
            {
                _targetTrace = target.EventOptions.PositionChangeNotification;
                target.EventOptions.PositionChangeNotification = true;
                target.PositionChanged += source_PositionChanged;
            }

            var dpd = DependencyPropertyDescriptor.FromProperty(SourceProperty, typeof(EdgeControl));

            if (dpd != null)
            {
                dpd.AddValueChanged(this, SourceChanged);
            }
            dpd = DependencyPropertyDescriptor.FromProperty(TargetProperty, typeof(EdgeControl));
            if (dpd != null)
            {
                dpd.AddValueChanged(this, TargetChanged);
            }

            IsSelfLooped = _isSelfLooped;
        }
Example #2
0
        public EdgeControl(VertexControl source, VertexControl target, object edge, bool showLabels = false, bool showArrows = true)
        {
            DataContext = edge;
            Source = source; Target = target;
            Edge = edge; DataContext = edge;
            ShowArrows = showArrows;
            ShowLabel = showLabels;

            EventOptions = new EdgeEventOptions(this);
            foreach (var item in Enum.GetValues(typeof(EventType)).Cast<EventType>())
                UpdateEventhandling(item);

            if (source != null)
            {
                _sourceTrace = source.EventOptions.PositionChangeNotification;
                source.EventOptions.PositionChangeNotification = true;
                source.PositionChanged += source_PositionChanged;
            }
            if (target != null)
            {
                _targetTrace = target.EventOptions.PositionChangeNotification;
                target.EventOptions.PositionChangeNotification = true;
                target.PositionChanged += source_PositionChanged;
            }

            var dpd = DependencyPropertyDescriptor.FromProperty(SourceProperty, typeof(EdgeControl));
            if (dpd != null) dpd.AddValueChanged(this, SourceChanged);
            dpd = DependencyPropertyDescriptor.FromProperty(TargetProperty, typeof(EdgeControl));
            if (dpd != null) dpd.AddValueChanged(this, TargetChanged);
        }