Esempio n. 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="XCasePrimitiveJunction"/> class.
        /// </summary>
        /// <param name="xCaseCanvas">canvas where the control is placed</param>
        /// <param name="sourceElement">source element</param>
        /// <param name="targetElement">target element</param>
        public XCasePrimitiveJunction(XCaseCanvas xCaseCanvas, IHasBounds sourceElement, IPrimitiveJunctionTarget targetElement)
        {
            SourceElement = sourceElement;
            TargetElement = targetElement;
            XCaseCanvas   = xCaseCanvas;

            ((FrameworkElement)sourceElement).SizeChanged += delegate { InvalidateVisual(); };
            ((Control)sourceElement).LayoutUpdated        += Source_LayoutUpdated;
            XCaseCanvas.Children.Add(this);
            Source_LayoutUpdated(null, null);
            Pen = MediaLibrary.SolidBlackPen;
        }
Esempio n. 2
0
        /// <summary>
        /// Invoked when an unhandled <see cref="System.Windows.Input.Mouse.PreviewMouseDownEvent"/>�attached event reaches
        /// an element in its route that is derived from this class.
        /// The event drops dragging and this method stops highlighting the association to which the association end belongs.
        /// </summary>
        /// <param name="e">The <see cref="T:System.Windows.Input.MouseButtonEventArgs"/> that contains the event data. The event data reports that one or more mouse buttons were pressed.</param>
        protected override void OnPreviewMouseDown(System.Windows.Input.MouseButtonEventArgs e)
        {
            IPrimitiveJunctionTarget targetJunction = null;

            if (Association != null)
            {
                Association.Highlight();
            }
            if (PSM_Association != null)
            {
                PSM_Association.Junction.Highlight();
            }
            if (highlightJunction == null)
            {
                if (Association != null && AssociationEnd != null)
                {
                    targetJunction = Association.GetJunctionConnectingEnd(AssociationEnd);
                }
                if (PSM_Association != null)
                {
                    targetJunction = PSM_Association;
                }
                if (targetJunction != null)
                {
                    highlightJunction = new XCasePrimitiveJunction(XCaseCanvas, this, targetJunction)
                    {
                        Pen = MediaLibrary.DashedBlackPen
                    };
                }
            }
            if (highlightJunction != null)
            {
                highlightJunction.Visibility = Visibility.Visible;
            }
            base.OnPreviewMouseDown(e);
        }