コード例 #1
0
        private void AdornedElement_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            if (dragging)
            {
                dragging = false;

                AdornedElement.ReleaseMouseCapture();
                e.Handled = true;

                OnDragEnd?.Invoke(this, new EventArgs());
            }
        }
コード例 #2
0
ファイル: StoryboardLayer.cs プロジェクト: sqler21c/DeXign
        private void Element_Loaded(object sender, RoutedEventArgs e)
        {
            ((FrameworkElement)sender).Loaded -= Element_Loaded;

            this.Storyboard = AdornedElement
                              .FindLogicalParents <Storyboard>()
                              .FirstOrDefault();

            OnLoaded((FrameworkElement)AdornedElement);

            RendererLoaded?.Invoke(this, e);
        }
コード例 #3
0
        /// <summary>
        /// handle the mouse down so that the Prompt is disabled
        /// </summary>
        /// <param name="e">Event args</param>
        protected override void OnMouseDown(MouseButtonEventArgs e)
        {
            AdornerLayer layer = AdornerLayer.GetAdornerLayer(AdornedElement);

            if (layer != null)
            {
                layer.Remove(this);
                EnableDisableElement(AdornedElement, false);
                AdornedElement.Focus();
            }
            base.OnMouseDown(e);
        }
コード例 #4
0
        /// <summary>
        /// Override to measure elements.
        /// </summary>
        protected override Size MeasureOverride(Size constraint)
        {
            _TextBox.IsEnabled = _IsVisible;

            // if in editing mode, measure the space the adorner element should cover.
            if (_IsVisible == true)
            {
                if (double.IsInfinity(_TextBoxMaxWidth) == true)
                {
                    Point position        = _TextBox.PointToScreen(new Point(0, 0)),
                          controlPosition = _EditBox.ParentScrollViewer.PointToScreen(new Point(0, 0));

                    position.X = Math.Abs(controlPosition.X - position.X);
                    position.Y = Math.Abs(controlPosition.Y - position.Y);

                    _TextBoxMaxWidth = _EditBox.ParentScrollViewer.ViewportWidth - position.X;
                }

                if (this.AdornedElement.Visibility == System.Windows.Visibility.Collapsed)
                {
                    return(new Size(_TextBoxMaxWidth, _TextBox.DesiredSize.Height));
                }

                //
                if (constraint.Width > _TextBoxMaxWidth)
                {
                    constraint.Width = _TextBoxMaxWidth;
                }

                AdornedElement.Measure(constraint);
                _TextBox.Measure(constraint);

                double desiredWidth = AdornedElement.DesiredSize.Width + ExtraWidth;

                // since the adorner is to cover the EditBox, it should return
                // the AdornedElement.Width, the extra 15 is to make it more clear.
                if (desiredWidth < _TextBoxMaxWidth)
                {
                    return(new Size(desiredWidth, _TextBox.DesiredSize.Height));
                }
                else
                {
                    this.AdornedElement.Visibility = System.Windows.Visibility.Collapsed;

                    return(new Size(_TextBoxMaxWidth, _TextBox.DesiredSize.Height));
                }
            }
            else  // no need to show anything if it is not in editable mode.
            {
                return(new Size(0, 0));
            }
        }
コード例 #5
0
ファイル: GridAdorner.cs プロジェクト: AndreiBer/MSOM2
        private void refreshRelativePositions()
        {
            Point relativeLocation = AdornedElement.TranslatePoint(new Point(0, 0), _parentElement);

            _yOffset = relativeLocation.Y < 0 ? -relativeLocation.Y : 0;
            _xOffset = relativeLocation.X < _parentDrawAreaMargin ? _parentDrawAreaMargin - relativeLocation.X : 0;

            _yLength = AdornedElement.RenderSize.Height;
            if (_yLength > _parentElement.ActualHeight - _parentDrawAreaMargin)
            {
                _yLength = _parentElement.ActualHeight - _parentDrawAreaMargin;
            }
        }
コード例 #6
0
        private void RemoveAdorner()
        {
            if (currentAdorner != null)
            {
                if (currentAdorner.ElementContainerControl != null && currentAdorner.ElementContainerControl.Element != null)
                {
                    currentAdorner.ElementContainerControl.Element.Deleted -= AdornedElementDeleted;
                }

                currentAdorner.Dispose();
                currentAdorner = null;
            }
        }
コード例 #7
0
        internal void AdornSelectedElement(ElementModelContainer elementContainer)
        {
            RemoveAdorner();

            if (elementContainer.Element == null)
            {
                return;
            }

            currentAdorner = new AdornedElement(elementContainer, RelationshipCanvas);
            currentAdorner.ElementContainerControl.Element.Deleted += AdornedElementDeleted;
            currentAdorner.DrawRelationships();
        }
コード例 #8
0
 /// <summary>
 /// Update the height to the newheight and the top location to newtop.
 /// </summary>
 /// <param name="newwidth"></param>
 /// <param name="newleft"></param>
 private void UpdateHeight(double newheight, double newtop)
 {
     // if within the min height and a location greater than or equal to zero then update the height and the top location
     if ((newheight >= mMinHeight) &&
         (newtop >= 0))
     {
         if (mWindow != null)
         {
             mWindow.Height = newheight;
             mWindow.Top    = newtop;
         }
         else
         {
             Canvas.SetTop(AdornedElement, newtop);
             AdornedElement.SetValue(AnalysisChild.HeightProperty, newheight);
         }
     }
     else // otherwise set the height the the min or max bound accordingly
     {
         if (mWindow != null)
         {
             double height = mWindow.Height;
             double top    = mWindow.Top;
             if (!(newtop >= 0))
             {
                 mWindow.Top    = 0;
                 mWindow.Height = top + height;
             }
             else
             {
                 mWindow.Top   += mWindow.Height - mMinHeight;
                 mWindow.Height = mMinHeight;
             }
         }
         else
         {
             double height = (double)AdornedElement.GetValue(HeightProperty);
             double top    = Canvas.GetTop(AdornedElement);
             if (!(newtop >= 0))
             {
                 Canvas.SetTop(AdornedElement, 0);
                 AdornedElement.SetValue(AnalysisChild.HeightProperty, top + height);
             }
             else
             {
                 Canvas.SetTop(AdornedElement, top + (height - mMinHeight));
                 AdornedElement.SetValue(AnalysisChild.HeightProperty, mMinHeight);
             }
         }
     }
 }
コード例 #9
0
 /// <summary>
 /// Update the width to the newwidth and the left location to newleft.
 /// </summary>
 /// <param name="newwidth"></param>
 /// <param name="newleft"></param>
 private void UpdateWidth(double newwidth, double newleft)
 {
     // if within the min width and a location greater than or equal to zero then update the width and the left location
     if ((newwidth >= mMinWidth) &&
         (newleft >= 0))
     {
         if (mWindow != null)
         {
             mWindow.SetValue(Window.WidthProperty, newwidth);
             mWindow.SetValue(Window.LeftProperty, newleft);
         }
         else
         {
             Canvas.SetLeft(AdornedElement, newleft);
             AdornedElement.SetValue(AnalysisChild.WidthProperty, newwidth);
         }
     }
     else // otherwise set the width the the min or max bound accordingly
     {
         if (mWindow != null)
         {
             double width = mWindow.Width;
             double left  = mWindow.Left;
             if (!(newleft >= 0))
             {
                 mWindow.Left  = 0;
                 mWindow.Width = left + width;
             }
             else
             {
                 mWindow.Left += (mWindow.Width - mMinWidth);
                 mWindow.Width = mMinWidth;
             }
         }
         else
         {
             double width = (double)AdornedElement.GetValue(WidthProperty);
             double left  = Canvas.GetLeft(AdornedElement);
             if (!(newleft >= 0))
             {
                 Canvas.SetLeft(AdornedElement, 0);
                 AdornedElement.SetValue(AnalysisChild.WidthProperty, left + width);
             }
             else
             {
                 Canvas.SetLeft(AdornedElement, left + (width - mMinWidth));
                 AdornedElement.SetValue(AnalysisChild.WidthProperty, mMinWidth);
             }
         }
     }
 }
コード例 #10
0
        public override void SetAdornedElement(DependencyObject adorner, FrameworkElement?adornedElement)
        {
            if (adorner is SettingsControl settingsControl)
            {
                if (adornedElement == null)
                {
                    disposable?.Dispose();
                    return;
                }
                else
                {
                    adornedElement.SetValue(Type.ShowDataContextProperty, true);
                    disposable = settingsControl
                                 .WhenAnyValue(a => a.SelectedDock)
                                 .Subscribe(dock =>
                    {
                        adornedElement.SetValue(Text.PositionProperty, dock);
                    });

                    settingsControl.Checked += SettingsControl_Checked;
                }
            }

            void SettingsControl_Checked(object sender, CheckedEventArgs e)
            {
                switch (e.CheckedType)
                {
                case CheckedType.DataContext:
                    AdornedElement.SetValue(Type.ShowDataContextProperty, e.IsChecked);
                    break;

                case CheckedType.Dimensions:
                    AdornedElement.SetValue(Type.ShowDimensionsProperty, e.IsChecked);
                    break;

                case CheckedType.HighlightArea:
                    controlColourer ??= new(adornedElement);
                    //AdornedElement.SetValue(Type.HighlightColourProperty, e.IsChecked);
                    if (e.IsChecked)
                    {
                        controlColourer.Apply();
                    }
                    else
                    {
                        controlColourer.Remove();
                    }
                    break;
                }
            }
        }
コード例 #11
0
        private AdornerLayer FindAdornerLayer()
        {
            //var window = Window.GetWindow(AdornedElement);
            //return window.FindChild<AdornerLayer>();

            ScrollViewer parent = AdornedElement.FindParent <ScrollViewer>();

            if (parent != null)
            {
                return(AdornerLayer.GetAdornerLayer(parent));
            }

            return(AdornerLayer.GetAdornerLayer(AdornedElement));
        }
コード例 #12
0
        protected override void OnInitialized(EventArgs e)
        {
            if (TemplatedParent == null)
            {
                throw new InvalidOperationException("Must be in a template");
            }

            base.OnInitialized(e);
            if (AdornedElement != null)
            {
                BindingOperations.SetBinding(this, WidthProperty, AdornedElement.CreateOneWayBinding(ActualWidthProperty));
                BindingOperations.SetBinding(this, HeightProperty, AdornedElement.CreateOneWayBinding(ActualHeightProperty));
            }
        }
コード例 #13
0
        protected override void OnDisposed()
        {
            // 스냅라인 등록 해제
            Storyboard?.GuideLayer.Remove(this);

            // GroupSelector
            this.RemoveSelectedHandler(OnSelected);
            this.RemoveUnselectedHandler(OnUnselected);

            // Design Mode
            DesignModeProperty.RemoveValueChanged(this, DesignMode_Changed);

            // Grip Layer
            AdornedElement.RemoveAdorner(GripLayer);
        }
コード例 #14
0
        private void OpenToolTip()
        {
            var toolTip = ToolTipService.GetToolTip(this) as ToolTip;

            if (toolTip == null)
            {
                return;
            }
            if (AdornedElement != null)
            {
                toolTip.PlacementTarget = AdornedElement;
                Debug.Print("Set placement target: {0}", AdornedElement?.GetType().Name ?? "null");
            }
            toolTip.IsOpen = true;
        }
コード例 #15
0
        /// <summary>
        /// When the left mouse button is down get the current point and capture the mouse.
        /// </summary>
        /// <param name="e"></param>
        protected override void OnPreviewMouseLeftButtonDown(MouseButtonEventArgs e)
        {
            base.OnPreviewMouseLeftButtonDown(e);

            if (!mIsDown && mCurrentHotSpot != HotSpot.None)
            {
                if (AdornedElement.GetType().Equals(typeof(AnalysisChild)))
                {
                    ((AnalysisChild)AdornedElement).IsSelected = true; // promote the child to the front since it has been selected.
                }
                mIsDown       = true;                                  // mouse button is down
                mCurrentPoint = e.GetPosition(this);
                mLastPoint    = mCurrentPoint;
                this.CaptureMouse();
            }
        }
コード例 #16
0
        private void HandleBottomRight(object sender, DragDeltaEventArgs eventArgs)
        {
            var thumb   = sender as Thumb;
            var element = AdornedElement as FrameworkElement;

            if (element == null || thumb == null)
            {
                return;
            }

            element.MaxWidth  = Math.Max(element.MaxWidth + eventArgs.HorizontalChange, thumb.DesiredSize.Width);
            element.MaxHeight = Math.Max(element.MaxHeight + eventArgs.VerticalChange, thumb.DesiredSize.Height);
            var size = new Size(element.MaxWidth, element.MaxHeight);

            AdornedElement.Measure(size);
        }
コード例 #17
0
        /// <summary>
        /// Update the height with the newheight based on the current mouse point.
        /// </summary>
        /// <param name="newheight"></param>
        /// <param name="p"></param>
        private void UpdateHeight(double newheight, Point p)
        {
            if (AdornedElement.GetType().Equals(typeof(AnalysisChild)))
            {
                mMaxHeight = ((AnalysisChild)AdornedElement).MwiParent.ActualHeight - 3 - Canvas.GetTop(AdornedElement);
            }

            // if within the min and max height then update the height to the new height
            if ((newheight >= mMinHeight && p.Y >= mMinHeight) &&
                (newheight <= mMaxHeight && p.Y <= mMaxHeight))
            {
                if (mWindow != null)
                {
                    mWindow.Height = newheight;
                }
                else
                {
                    AdornedElement.SetValue(AnalysisChild.HeightProperty, newheight);
                }
            }
            else // otherwise set the height to the min or max bound accordingly
            {
                if (mWindow != null)
                {
                    if (!(newheight <= mMaxHeight && p.Y <= mMaxHeight))
                    {
                        mWindow.Height = mMaxHeight;
                    }
                    else
                    {
                        mWindow.Height = mMinHeight;
                    }
                }
                else
                {
                    if (!(newheight <= mMaxHeight && p.Y <= mMaxHeight))
                    {
                        AdornedElement.SetValue(AnalysisChild.HeightProperty, mMaxHeight);
                    }
                    else
                    {
                        AdornedElement.SetValue(AnalysisChild.HeightProperty, mMinHeight);
                    }
                }
            }
        }
コード例 #18
0
        /// <summary>
        /// Updates the width to the newwidth provided based on the current mouse point.
        /// </summary>
        /// <param name="newwidth"></param>
        /// <param name="p"></param>
        private void UpdateWidth(double newwidth, Point p)
        {
            if (AdornedElement.GetType().Equals(typeof(AnalysisChild)))
            {
                mMaxWidth = ((AnalysisChild)AdornedElement).MwiParent.ActualWidth - 3 - Canvas.GetLeft(AdornedElement);
            }

            // if within the min and max width then update the width to the new width
            if ((newwidth >= mMinWidth && p.X >= mMinWidth) &&
                (newwidth <= mMaxWidth && p.X <= mMaxWidth))
            {
                if (mWindow != null)
                {
                    mWindow.Width = newwidth;
                }
                else
                {
                    AdornedElement.SetValue(AnalysisChild.WidthProperty, newwidth);
                }
            }
            else // otherwise set the width to the min or max bound accordingly
            {
                if (mWindow != null)
                {
                    if (!(newwidth <= mMaxWidth && p.X <= mMaxWidth))
                    {
                        mWindow.Width = mMaxWidth;
                    }
                    else
                    {
                        mWindow.Width = mMinWidth;
                    }
                }
                else
                {
                    if (!(newwidth <= mMaxWidth && p.X <= mMaxWidth))
                    {
                        AdornedElement.SetValue(AnalysisChild.WidthProperty, mMaxWidth);
                    }
                    else
                    {
                        AdornedElement.SetValue(AnalysisChild.WidthProperty, mMinWidth);
                    }
                }
            }
        }
コード例 #19
0
        /// <summary>
        ///     Override to measure elements.
        /// </summary>
        protected override Size MeasureOverride(Size constraint)
        {
            mTextBox.IsEnabled = mIsVisible;

            // if in editing mode, measure the space the adorner element should cover.
            if (mIsVisible)
            {
                if (double.IsInfinity(mTextBoxMaxWidth))
                {
                    Point position        = mTextBox.PointToScreen(new Point(0, 0)),
                          controlPosition = mEditBox.ParentScrollViewer.PointToScreen(new Point(0, 0));

                    position.X = Math.Abs(controlPosition.X - position.X);
                    position.Y = Math.Abs(controlPosition.Y - position.Y);

                    mTextBoxMaxWidth = mEditBox.ParentScrollViewer.ViewportWidth - position.X;
                }

                if (AdornedElement.Visibility == Visibility.Collapsed)
                {
                    return(new Size(mTextBoxMaxWidth, mTextBox.DesiredSize.Height));
                }

                //
                if (constraint.Width > mTextBoxMaxWidth)
                {
                    constraint.Width = mTextBoxMaxWidth;
                }

                AdornedElement.Measure(constraint);
                mTextBox.Measure(constraint);

                var desiredWidth = AdornedElement.DesiredSize.Width + ExtraWidth;

                // since the adorner is to cover the EditBox, it should return
                // the AdornedElement.Width, the extra 15 is to make it more clear.
                if (desiredWidth < mTextBoxMaxWidth)
                {
                    return(new Size(desiredWidth, mTextBox.DesiredSize.Height));
                }
                AdornedElement.Visibility = Visibility.Collapsed;

                return(new Size(mTextBoxMaxWidth, mTextBox.DesiredSize.Height));
            }
            return(new Size(0, 0));
        }
コード例 #20
0
        protected override void OnRender(DrawingContext drawingContext)
        {
            base.OnRender(drawingContext);

            if (AdornedElement != null)
            {
                var screenPos = new Win32.POINT();
                if (Win32.GetCursorPos(ref screenPos))
                {
                    var pos  = AdornedElement.PointFromScreen(new Point(screenPos.X, screenPos.Y));
                    var rect = new Rect(new Point(pos.X - _posRelative.X, pos.Y - _posRelative.Y), _adornerElementSize);

                    //System.Diagnostics.Trace.TraceInformation("Adorner Pos = {0},{1},{2},{3}", rect.X, rect.Y, rect.Width, rect.Height);

                    drawingContext.DrawRectangle(_imageBrush, null, rect);
                }
            }
        }
コード例 #21
0
        /// <summary>
        ///     Override to measure elements.
        /// </summary>
        protected override Size MeasureOverride(Size constraint)
        {
            _textBox.IsEnabled = _isVisible;
            //if in editing mode, measure the space the adorner element
            //should cover.
            if (_isVisible)
            {
                AdornedElement.Measure(constraint);
                _textBox.Measure(constraint);

                //since the adorner is to cover the EditBox, it should return
                //the AdornedElement.Width, the extra 15 is to make it more
                //clear.
                return(new Size(AdornedElement.DesiredSize.Width + ExtraWidth,
                                _textBox.DesiredSize.Height));
            }
            return(new Size(0, 0));
        }
コード例 #22
0
        /// <summary>
        /// Override to measure elements.
        /// </summary>
        protected override Size MeasureOverride(Size constraint)
        {
            _textBox.IsEnabled = _isVisible;
            //if in editable mode, measure the space the adorner element should cover.
            if (_isVisible)
            {
                AdornedElement.Measure(constraint);
                _textBox.Measure(constraint);

                //since the adorner is to cover the EditBox, it should return the AdornedElement.Width,
                //the extra 15 is to make it more clear.
                return(new Size(AdornedElement.DesiredSize.Width + _extraWidth, _textBox.DesiredSize.Height));
            }
            else  //if it is not in editable mode, no need to show anything.
            {
                return(new Size(0, 0));
            }
        }
コード例 #23
0
ファイル: DragAdorner.cs プロジェクト: ysx1993/netprints
        private void AdornedElement_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            dragging = true;

            if (!(AdornedElement.RenderTransform is TranslateTransform transform))
            {
                transform = new TranslateTransform();
                AdornedElement.RenderTransform = transform;
            }

            dragStartElementPosition = new Point(transform.X, transform.Y);
            dragStartMousePosition   = e.GetPosition(null);

            AdornedElement.CaptureMouse();
            e.Handled = true;

            OnDragStart?.Invoke(this, EventArgs.Empty);
        }
コード例 #24
0
        /// <summary>
        ///     Get cropping areas as BitmapFrame
        /// </summary>
        /// <returns></returns>
        public BitmapFrame GetCroppedBitmapFrame()
        {
            var parent = VisualTreeHelper.GetParent(AdornedElement) as UIElement;
            // 1) get current dpi
            var    pSource = PresentationSource.FromVisual(Application.Current.MainWindow);
            Matrix m       = pSource.CompositionTarget.TransformToDevice;
            double dpiX    = m.M11 * 96;
            double dpiY    = m.M22 * 96;

            // 2) create RenderTargetBitmap
            var elementBitmap = new RenderTargetBitmap(
                (int)AdornedElement.RenderSize.Width,
                (int)AdornedElement.RenderSize.Height,
                dpiX,
                dpiY,
                PixelFormats.Default
                );

            //Important
            AdornedElement.Measure(AdornedElement.RenderSize);
            AdornedElement.Arrange(new Rect(AdornedElement.RenderSize));

            // 3) draw element
            elementBitmap.Render(AdornedElement);

            if (parent != null)
            {
                //Important
                parent.Measure(AdornedElement.RenderSize);
                parent.Arrange(new Rect(AdornedElement.RenderSize));
            }

            var crop = new CroppedBitmap(
                elementBitmap,
                new Int32Rect(
                    (int)_rectangleManager.TopLeft.X,
                    (int)_rectangleManager.TopLeft.Y,
                    (int)_rectangleManager.RectangleWidth,
                    (int)_rectangleManager.RectangleHeight
                    )
                );

            return(BitmapFrame.Create(crop));
        }
コード例 #25
0
    // Arrange the Adorners.
    protected override Size ArrangeOverride(Size finalSize)
    {
        // desiredWidth and desiredHeight are the width and height of the element that's being adorned.
        // These will be used to place the ResizingAdorner at the corners of the adorned element.
        double desiredWidth  = AdornedElement.DesiredSize.Width;
        double desiredHeight = AdornedElement.DesiredSize.Height;

        // adornerWidth & adornerHeight are used for placement as well.
        double adornerWidth  = this.DesiredSize.Width;
        double adornerHeight = this.DesiredSize.Height;

        if (AdornedElement.GetType() == typeof(Line) && AdornedElement.Uid.Contains("DC"))
        {
            var    selectedLine = AdornedElement as Line;
            double left         = Math.Min(selectedLine.X1, selectedLine.X2);
            double top          = Math.Min(selectedLine.Y1, selectedLine.Y2);
            var    startRect    = new Rect(selectedLine.X1 - (Left.Width / 2), selectedLine.Y1 - (Left.Width / 2), Left.Width, Left.Height);
            Left.Arrange(startRect);
            var endRect = new Rect(selectedLine.X2 - (Right.Width / 2), selectedLine.Y2 - (Right.Height / 2), Right.Width, Right.Height);
            Right.Arrange(endRect);
        }
        else if (AdornedElement.GetType() == typeof(Ellipse) && AdornedElement.Uid.Contains("DC"))
        {
            FrameworkElement adornedElement = AdornedElement as FrameworkElement;
            List <Point>     elipsendPoints = ((List <Point>)(adornedElement.DataContext));
            if (elipsendPoints.Count == 0)
            {
                return(finalSize);
            }
            Line selectedLine = new Line()
            {
                X1 = elipsendPoints[0].X, Y1 = elipsendPoints[0].Y, X2 = elipsendPoints[1].X, Y2 = elipsendPoints[1].Y
            };
            double left      = Math.Min(selectedLine.X1, selectedLine.X2);
            double top       = Math.Min(selectedLine.Y1, selectedLine.Y2);
            var    startRect = new Rect(selectedLine.X1 - (Left.Width / 2), selectedLine.Y1 - (Left.Width / 2), Left.Width, Left.Height);
            var    endRect   = new Rect(selectedLine.X2 - (Right.Width / 2), selectedLine.Y2 - (Right.Height / 2), Right.Width, Right.Height);
            Left.Arrange(startRect);
            Right.Arrange(endRect);
        }
        // Return the final size.
        return(finalSize);
    }
コード例 #26
0
        protected override void OnRender(DrawingContext drawingContext)
        {
            base.OnRender(drawingContext);

            if (AdornedElement != null)
            {
                var screenPos = new Win32.POINT();
                if (Win32.GetCursorPos(ref screenPos))
                {
                    var pos = AdornedElement.PointFromScreen(new Point(screenPos.X + 10, screenPos.Y + 10));

                    var ft   = DrawUtil.DrawText(_tip, _fgBrush);
                    var rect = new Rect(pos.X, pos.Y, ft.Width + 10, ft.Height + 6);

                    drawingContext.DrawRectangle(_bgBrush, null, rect);
                    drawingContext.DrawText(ft, new Point(pos.X + 5, pos.Y + 3));
                }
            }
        }
コード例 #27
0
        protected override void OnRender(DrawingContext drawingContext)
        {
            base.OnRender(drawingContext);

            if (AdornedElement == null || _pen == null || DoubleUtil.IsZero(_length))
            {
                return;
            }

            var screenPos = new Utils.Win32.POINT();

            if (Utils.Win32.GetCursorPos(ref screenPos))
            {
                var pos = AdornedElement.PointFromScreen(new Point(screenPos.X, screenPos.Y));

                drawingContext.DrawLine(_pen, new Point(pos.X, 0), new Point(pos.X, _length));
                drawingContext.DrawLine(_pen, new Point(0, pos.Y), new Point(_length, pos.Y));
            }
        }
コード例 #28
0
        private void AdornedElement_MouseMove(object sender, MouseEventArgs e)
        {
            if (dragging)
            {
                Point mousePosition = e.GetPosition(null);

                Vector offset = mousePosition - dragStartMousePosition;

                TranslateTransform transform = AdornedElement.RenderTransform as TranslateTransform;

                transform.X = dragStartElementPosition.X + offset.X;
                transform.Y = dragStartElementPosition.Y + offset.Y;

                transform.X -= transform.X % CellSize;
                transform.Y -= transform.Y % CellSize;

                AdornedElement.InvalidateVisual();
            }
        }
コード例 #29
0
        protected override Size ArrangeOverride(Size finalSize)
        {
            Window referenceWindow   = Window.GetWindow(AdornedElement);
            Point  referenceLocation = AdornedElement.TranslatePoint(new Point(0, 0), referenceWindow);

            double referenceWidth  = ((FrameworkElement)AdornedElement).ActualWidth / 2.0;
            double referenceHeight = ((FrameworkElement)AdornedElement).Height;
            double referenceX      = referenceLocation.X + referenceWidth;
            double halfWidth       = finalSize.Width / 2.0;
            double maxOffset       = referenceWindow.Width - halfWidth;

            double offset = (referenceX < halfWidth ? referenceX
                                                    : (((referenceX + (referenceWidth * 2)) > maxOffset)
                                                        ? halfWidth - ((maxOffset - referenceX) - (referenceWidth * 2))
                                                        : halfWidth));

            _colorSelector.Arrange(new Rect(new Point(referenceWidth - offset, referenceHeight), finalSize));
            return(_colorSelector.RenderSize);
        }
コード例 #30
0
ファイル: StoryboardLayer.cs プロジェクト: sunfom/DeXign
        private void Element_Loaded(object sender, RoutedEventArgs e)
        {
            var element = sender as FrameworkElement;

            if (!element.IsVisible)
            {
                return;
            }

            element.Loaded -= Element_Loaded;

            this.Storyboard = AdornedElement
                              .FindLogicalParents <Storyboard>()
                              .FirstOrDefault();

            OnLoaded((FrameworkElement)AdornedElement);

            RendererLoaded?.Invoke(this, e);
        }
コード例 #31
0
 private void RemoveAdorner()
 {
     if (currentAdorner != null)
     {
         if (currentAdorner.ElementContainerControl != null && currentAdorner.ElementContainerControl.Element != null)
         {
             currentAdorner.ElementContainerControl.Element.Deleted -= AdornedElementDeleted;
         }
     
         currentAdorner.Dispose();
         currentAdorner = null;
     }
 }
コード例 #32
0
        internal void AdornSelectedElement(ElementModelContainer elementContainer)
        {
            RemoveAdorner();

            if (elementContainer.Element == null) return;

            currentAdorner = new AdornedElement(elementContainer, RelationshipCanvas);
            currentAdorner.ElementContainerControl.Element.Deleted += AdornedElementDeleted;
            currentAdorner.DrawRelationships();
        }
コード例 #33
0
 public AdornedElementWithRelationshipLine(AdornedElement root, Canvas rootCanvas, ElementModelContainer destinationControl)
     : base(destinationControl, rootCanvas)
 {
     this.root = root;
     this.destinationControl = destinationControl;
     this.rootCanvas = rootCanvas;
     this.destinationControl.Element.Deleted += ElementDeleted;
 }