示例#1
0
        protected override Size MeasureOverride(Size constraint)
        {
            var desiredSize = AdornedElement.RenderSize;

            child?.Measure(desiredSize);

            return(desiredSize);
        }
示例#2
0
 protected override Size MeasureOverride(Size constraint)
 {
     // Cover the whole control
     _contentPresenter.Measure(Control.RenderSize);
     return(Control.RenderSize);
 }
示例#3
0
 /// <summary>
 /// Implements any custom measuring behavior for the adorner.
 /// </summary>
 /// <param name="constraint">A size to constrain the adorner to.</param>
 /// <returns>
 /// A <see cref="System.Windows.Size"/> object representing the amount
 /// of layout space needed by the adorner.
 /// </returns>
 protected override Size MeasureOverride(Size constraint)
 {
     presenter.Measure(constraint);
     return(presenter.DesiredSize);
 }
示例#4
0
 protected override Size MeasureOverride(Size constraint)
 {
     // Here's the secret to getting the adorner to cover the whole control
     contentPresenter.Measure(Control.RenderSize);
     return(Control.RenderSize);
 }
示例#5
0
 protected override Size MeasureOverride(Size constraint)
 {
     _contentPresenter.Measure(constraint);
     return(new Size(((FrameworkElement)AdornedElement).ActualWidth,
                     ((FrameworkElement)AdornedElement).ActualHeight));
 }
示例#6
0
 protected override Size MeasureOverride(Size availableSize)
 {
     content.Measure(availableSize);
     return(content.DesiredSize);
 }
示例#7
0
 /// <summary> Реализует любое ручное поведение процесса измерения слоя</summary>
 /// <param name="constraint">Необходимый размер</param>
 /// <returns><see cref="Size"/> - размер нужного для отображения слоя</returns>
 protected override Size MeasureOverride(Size constraint)
 {
     // Здесь секрет получения размера слоя, накрывающего весь компонент
     _ContentPresenter.Measure(Control.RenderSize);
     return(Control.RenderSize);
 }
示例#8
0
 protected override Size MeasureOverride(Size constraint)
 {
     _contentPresenter.Measure(AdornedElement.RenderSize);
     return(AdornedElement.RenderSize);
 }
        void ToggleDetailState()
        {
            if (cpContent == null)
            {
                pendingToggle = true;
                return;
            }
            cpContent.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
            Size sizeTitle = cpContent.DesiredSize;

            Visibility original = cpDetails.Visibility;

            cpDetails.Visibility = Visibility.Visible;

            cpDetails.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
            Size sizeDetails = cpDetails.DesiredSize;

            cpDetails.Visibility = original;

            pnlContainer.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
            Size currentSize = pnlContainer.DesiredSize;

            AnimateUtility.StopAnimation(pnlContainer, Panel.WidthProperty);
            AnimateUtility.StopAnimation(pnlContainer, Panel.HeightProperty);

            pnlContainer.Width  = currentSize.Width;
            pnlContainer.Height = currentSize.Height;

            Size expandedSize = new Size(sizeTitle.Width, sizeTitle.Height + sizeDetails.Height);

            if (sizeDetails.Width > sizeTitle.Width)
            {
                expandedSize.Width = sizeDetails.Width;
            }


            if (currentDetailState == ExpandingSurfaceVEPushPinDetailState.Full ||
                currentDetailState == ExpandingSurfaceVEPushPinDetailState.Growing)
            {
                // Hide pp details.
                if (Map != null)
                {
                    Map.SendToBack(this);
                }

                currentDetailState = ExpandingSurfaceVEPushPinDetailState.Shrinking;

                AnimateUtility.AnimateElementDouble(cpDetails, Panel.OpacityProperty, 0, 0, 1);
                AnimateUtility.AnimateElementDouble(pnlContainer, Panel.WidthProperty, sizeTitle.Width, 0, 1);
                AnimationClock shrinkClock = AnimateUtility.AnimateElementDouble(pnlContainer, Panel.HeightProperty, sizeTitle.Height, 0, 1);

                shrinkClock.CurrentTimeInvalidated += new EventHandler(currentTimeInvalidated);
                shrinkClock.Completed += new EventHandler(shrinkClock_Completed);
                SendOnCollapsing();
            }
            else
            {
                // Show pp details.
                if (Map != null)
                {
                    Map.SendToFront(this);
                }
                currentDetailState = ExpandingSurfaceVEPushPinDetailState.Growing;

                cpDetails.Visibility = Visibility.Visible;

                AnimateUtility.AnimateElementDouble(cpDetails, Panel.OpacityProperty, 1, 0, 1);
                AnimateUtility.AnimateElementDouble(pnlContainer, Panel.WidthProperty, expandedSize.Width, 0, 1);
                AnimationClock growClock = AnimateUtility.AnimateElementDouble(pnlContainer, Panel.HeightProperty, expandedSize.Height, 0, 1);

                growClock.CurrentTimeInvalidated += new EventHandler(currentTimeInvalidated);
                growClock.Completed += new EventHandler(growClock_Completed);
                SendOnExpanding();
            }
        }
示例#10
0
        /// <summary>
        /// Measures the size in layout required for child elements and determines a size for the <see cref="FractionView"/>.
        /// </summary>
        /// <param name="constraint">The available size that this element can give to child elements. Infinity can be specified as a value to indicate that the element will size to whatever content is available.</param>
        /// <returns>The size that this element determines it needs during layout, based on its calculations of child element sizes.</returns>
        protected override Size MeasureOverride(Size constraint)
        {
            NumeratorView.Measure(constraint);
            DenominatorView.Measure(constraint);

            sizeN = NumeratorView.DesiredSize;
            sizeD = DenominatorView.DesiredSize;

            var frac = this.Fraction;

            if (frac != null && frac.Style == FractionStyle.Slanted)
            {
                var d  = this.FontFamilyBaseline * (this.FontSize - childFontSize);
                var dx = this.FontSize / 2.5;
                var dy = (sizeN.Height + sizeD.Height + this.FontSize) / 2.0 - d;

                // Normally, (1.0 - Y-ratio) yields offset, but this is too tight.
                offN = dx * (0.9 - sizeN.Height / dy);
                offD = dx * (0.9 - sizeD.Height / dy);

                sizeTotal        = new Size();
                sizeTotal.Width  = sizeN.Width + sizeD.Width + dx - offN - offD;
                sizeTotal.Height = dy;
            }
            else
            {
                sizeTotal        = new Size();
                sizeTotal.Width  = Math.Max(sizeN.Width, sizeD.Width);
                sizeTotal.Height = sizeN.Height + sizeD.Height;
            }

            SetValue(BlockView.BaseLineProperty, sizeN.Height + this.BaseLineDelta * this.FontSize);

            if (frac == null)
            {
                return(sizeTotal);
            }

            switch (frac.Style)
            {
            case FractionStyle.Default:
                Line.X1 = 0;
                Line.Y1 = sizeN.Height;
                Line.X2 = sizeTotal.Width;
                Line.Y2 = sizeN.Height;
#if SILVERLIGHT
                Line.Stroke = new SolidColorBrush(Colors.Black);
#else
                Line.Stroke = (Brush)GetValue(Control.ForegroundProperty);
#endif

                Line.Measure(sizeTotal);
                break;

            case FractionStyle.Slanted:
                Line.X1 = sizeN.Width - offN;
                Line.Y1 = sizeTotal.Height;
                Line.X2 = sizeTotal.Width - sizeD.Width + offD;
                Line.Y2 = 0;
#if SILVERLIGHT
                Line.Stroke = new SolidColorBrush(Colors.Black);
#else
                Line.Stroke = (Brush)GetValue(Control.ForegroundProperty);
#endif

                Line.Measure(sizeTotal);
                break;

            case FractionStyle.Binomial:
                // TODO @ FractionView: Add braces (...).
                break;
            }

            return(sizeTotal);
        }
示例#11
0
 protected override Size MeasureOverride(Size constraint)
 {
     // Cover the entire adorned control:
     userPromptPresenter.Measure(AdornedControl.RenderSize);
     return(AdornedControl.RenderSize);
 }