コード例 #1
0
        protected override Size MeasureOverride(Size constraint)
        {
            _constraint = constraint;
            var adornedHeight           = AdornedElement.RenderSize.Height;
            var relativeAdornedLocation = AdornedElement.TranslatePoint(new Point(), _adornerLayer);

            _child.Measure(new Size(AdornedElement.RenderSize.Width, constraint.Height - adornedHeight - relativeAdornedLocation.Y));
            return(new Size(AdornedElement.RenderSize.Width, Math.Max(_child.DesiredSize.Height, adornedHeight)));
        }
コード例 #2
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;
            }
        }
コード例 #3
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);
        }
コード例 #4
0
        protected override void OnRender(DrawingContext drawingContext)
        {
            base.OnRender(drawingContext);

            if (!AdornedElement.IsKeyboardFocusWithin)
            {
                return;
            }
            var top = AdornedElement.TranslatePoint(new Point(0, 0), CurrentWindow);

            drawingContext.DrawGeometry(MaskBrush, null, new GeometryGroup()
            {
                Children =
                {
                    new RectangleGeometry(new Rect(new Point(-top.X, -top.Y), CurrentWindow.RenderSize)),
                    new RectangleGeometry(new Rect(new Point(0,           0), AdornedElement.RenderSize))
                }
            });
        }
コード例 #5
0
        private bool ShouldOpenOnTop()
        {
            FrameworkElement container = AdornedElement.FindParent <VirtualizingStackPanel>();

            if (container == null)
            {
                container = AdornedElement.FindParent <Window>();
            }

            if (container != null)
            {
                Point relativeLocation = AdornedElement.TranslatePoint(new Point(0, 0), container);
                if (_openPreference == PopupOpenPreference.Top)
                {
                    //double heightAbove = container.ActualHeight - (relativeLocation.Y + (AdornedElement as FrameworkElement).ActualHeight);
                    double heightAbove = relativeLocation.Y;
                    if (heightAbove >= _content.DesiredSize.Height)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else if (_openPreference == PopupOpenPreference.Bottom)
                {
                    double heightBelow = container.ActualHeight - (relativeLocation.Y + (AdornedElement as FrameworkElement).ActualHeight);
                    if (heightBelow >= _content.DesiredSize.Height)
                    {
                        return(false);
                    }
                    else
                    {
                        return(true);
                    }
                }
            }

            return(true);
        }
コード例 #6
0
        /// <summary>
        /// Ensures our point does not escape the parent boundaries.
        /// </summary>
        /// <param name="pt"></param>
        private void BoundPointToContainer(ref Point pt)
        {
            Point boundedPt = AdornedElement.TranslatePoint(pt, _parentContainer);

            if (boundedPt.X < 0)
            {
                boundedPt.X = 0;
            }
            else if (boundedPt.X > _parentContainer.RenderSize.Width)
            {
                boundedPt.X = _parentContainer.RenderSize.Width;
            }
            if (boundedPt.Y < 0)
            {
                boundedPt.Y = 0;
            }
            else if (boundedPt.Y > _parentContainer.RenderSize.Height)
            {
                boundedPt.Y = _parentContainer.RenderSize.Height;
            }
            pt = _parentContainer.TranslatePoint(boundedPt, AdornedElement);
        }
コード例 #7
0
        internal IEnumerable <Guideline> GetSizeGuidableLines()
        {
            Point relative = AdornedElement.TranslatePoint(new Point(), Storyboard);

            // left
            yield return(new Guideline(
                             relative,
                             new Point(relative.X, relative.Y + AdornedElement.RenderSize.Height))
            {
                Direction = GuidelineDirection.Left
            });

            // right
            yield return(new Guideline(
                             new Point(relative.X + AdornedElement.RenderSize.Width, relative.Y),
                             Point.Add(relative, (Vector)AdornedElement.RenderSize))
            {
                Direction = GuidelineDirection.Right
            });

            // top
            yield return(new Guideline(
                             relative,
                             new Point(relative.X + AdornedElement.RenderSize.Width, relative.Y))
            {
                Direction = GuidelineDirection.Top
            });

            // bottom
            yield return(new Guideline(
                             new Point(relative.X, relative.Y + AdornedElement.RenderSize.Height),
                             Point.Add(relative, (Vector)AdornedElement.RenderSize))
            {
                Direction = GuidelineDirection.Bottom
            });
        }
コード例 #8
0
ファイル: InfoAdorner.cs プロジェクト: AndreiBer/MSOM2
        //bool _visibleZeroY = false;
        //bool _visibleZeroX = false;

        private void refreshLengthsMeasures()
        {
            _xPixelSizeMM = Math.Abs(HighLimit - LowLimit) / AdornedElement.RenderSize.Width;
            _yPixelSizeMM = Math.Abs(HighVolumeZLimit - LowVolumeZLimit) / AdornedElement.RenderSize.Height;

            _verticalDirection   = HighVolumeZLimit < LowVolumeZLimit ? 1 : -1;
            _horizontalDirection = LowLimit < HighLimit ? 1 : -1;

            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;
            }

            _xLength = AdornedElement.RenderSize.Width;
            if (_xLength > _parentElement.ActualWidth - _parentDrawAreaMargin)
            {
                _xLength = _parentElement.ActualWidth - _parentDrawAreaMargin;
            }

            _yMM = _yPixelSizeMM * _yLength;
            _xMM = _xPixelSizeMM * _xLength;

            _topMeasure    = HighVolumeZLimit - VolumeOffset * 1000 + _verticalDirection * _yPixelSizeMM * _yOffset;
            _bottomMeasure = _topMeasure + _verticalDirection * _yMM;
            //_visibleZeroY = _verticalDirection * _topMeasure < 0 && _verticalDirection * _bottomMeasure > 0 ? true : false;

            _leftMeasure  = LowLimit - LimitOffset * 1000 + _horizontalDirection * _xPixelSizeMM * _xOffset;
            _rightMeasure = _leftMeasure + _horizontalDirection * _xMM;
            //_visibleZeroX = _horizontalDirection * _leftMeasure < 0 && _horizontalDirection * _rightMeasure > 0 ? true : false;
        }
コード例 #9
0
        protected override Size ArrangeOverride(Size finalSize)
        {
            //if (Visibility == Visibility.Hidden) return finalSize;
            var ro = new Rect(0, 0, AdornedElement.DesiredSize.Width, AdornedElement.DesiredSize.Height);

            //Rect ro = LayoutInformation.GetLayoutSlot(AdornedElement as FrameworkElement);
            foreach (FrameworkElement control in visualChildren)
            {
                var aligmentRect = new Rect
                {
                    Width  = control.Width,
                    Height = control.Height,
                    Y      = ro.Y, X = ro.X
                };
                switch (control.VerticalAlignment)
                {
                case VerticalAlignment.Top: aligmentRect.Y += 0;
                    break;

                case VerticalAlignment.Bottom: aligmentRect.Y += ro.Height;
                    break;

                case VerticalAlignment.Center: aligmentRect.Y += ro.Height / 2;
                    break;

                case VerticalAlignment.Stretch: aligmentRect.Height = ro.Height;    // *Math.Abs((AdornedElement.RenderTransform as TransformGroup).Children[0].Value.M22);
                    break;

                default:
                    break;
                }
                switch (control.HorizontalAlignment)
                {
                case HorizontalAlignment.Left: aligmentRect.X += 0;
                    break;

                case HorizontalAlignment.Right: aligmentRect.X += ro.Width;
                    break;

                case HorizontalAlignment.Center: aligmentRect.X += ro.Width / 2;
                    break;

                case HorizontalAlignment.Stretch: aligmentRect.Width = ro.Width;    // *Math.Abs((AdornedElement.RenderTransform as TransformGroup).Children[0].Value.M11);
                    break;

                default:
                    break;
                }

                if (control.Cursor == Cursors.SizeAll)
                {
                    control.RenderTransform = AdornedElement.TransformToVisual(this) as System.Windows.Media.MatrixTransform;
                }

                var p = AdornedElement.TranslatePoint(new Point(aligmentRect.X, aligmentRect.Y), this);
                p.X -= control.RenderTransform.Value.OffsetX;
                p.Y -= control.RenderTransform.Value.OffsetY;

                aligmentRect.X = p.X - (double.IsNaN(control.Width) ? 0 : control.Width) / 2;
                aligmentRect.Y = p.Y - (double.IsNaN(control.Height) ? 0 : control.Height) / 2;

                //aligmentRect.X -= (double.IsNaN(control.Width) ? 0 : control.Width) / 2;
                //aligmentRect.Y -= (double.IsNaN(control.Height) ? 0 : control.Height) / 2;
                control.Arrange(aligmentRect);
            }
            return(finalSize);
        }