Beispiel #1
0
        /// <summary>
        /// Create vertex visual control
        /// </summary>
        /// <param name="vertexData">Vertex data object</param>
        /// <param name="bindToDataObject">Bind DataContext to the Vertex data. True by default. </param>
        public VertexControl(object vertexData,  bool bindToDataObject = true)
        {
            DefaultStyleKey = typeof (VertexControl);
            if (bindToDataObject) DataContext = vertexData;
            Vertex = vertexData;

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

            IsEnabledChanged += VertexControl_IsEnabledChanged;

            var xBinding = new Binding
            {
                Path = new PropertyPath("(Canvas.Left)"),
                Source = this
            };
            SetBinding(TestXProperty, xBinding);
            var yBinding = new Binding
            {
                Path = new PropertyPath("(Canvas.Top)"),
                Source = this
            };
            SetBinding(TestYProperty, yBinding);
        }
Beispiel #2
0
        /// <summary>
        /// Create vertex visual control
        /// </summary>
        /// <param name="vertexData">Vertex data object</param>
        /// <param name="bindToDataObject">Bind DataContext to the Vertex data. True by default. </param>
        public VertexControl(object vertexData, bool bindToDataObject = true)
        {
            DefaultStyleKey = typeof(VertexControl);
            if (bindToDataObject)
            {
                DataContext = vertexData;
            }
            Vertex = vertexData;

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

            IsEnabledChanged += (sender, args) => VisualStateManager.GoToState(this, IsEnabled ? "Normal" : "Disabled", true);

            var xBinding = new Binding
            {
                Path   = new PropertyPath("(Canvas.Left)"),
                Source = this
            };

            SetBinding(TestXProperty, xBinding);
            var yBinding = new Binding
            {
                Path   = new PropertyPath("(Canvas.Top)"),
                Source = this
            };

            SetBinding(TestYProperty, yBinding);
        }
Beispiel #3
0
        /// <summary>
        /// Create vertex visual control
        /// </summary>
        /// <param name="vertexData">Vertex data object</param>
        /// <param name="tracePositionChange">Listen for the vertex position changed events and fire corresponding event</param>
        /// <param name="bindToDataObject">Bind DataContext to the Vertex data. True by default. </param>
        public VertexControl(object vertexData, bool tracePositionChange = true, bool bindToDataObject = true)
        {
            if (bindToDataObject) DataContext = vertexData;
            Vertex = vertexData;

            EventOptions = new VertexEventOptions(this) { PositionChangeNotification = tracePositionChange };
            foreach(var item in Enum.GetValues(typeof(EventType)).Cast<EventType>())
                UpdateEventhandling(item);
        }
Beispiel #4
0
        /// <summary>
        /// Create vertex visual control
        /// </summary>
        /// <param name="vertexData">Vertex data object</param>
        /// <param name="tracePositionChange">Listen for the vertex position changed events and fire corresponding event</param>
        /// <param name="bindToDataObject">Bind DataContext to the Vertex data. True by default. </param>
        public VertexControl(object vertexData, bool tracePositionChange = true, bool bindToDataObject = true)
        {
            if (bindToDataObject)
            {
                DataContext = vertexData;
            }
            Vertex = vertexData;

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