Esempio n. 1
0
        /// <summary>
        /// Discover the preferred size of the element.
        /// </summary>
        /// <param name="context">Layout context.</param>
        public override Size GetPreferredSize(ViewLayoutContext context)
        {
            Debug.Assert(context != null);

            // Validate incoming reference
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            // Ensure any content children have correct composition setting
            foreach (ViewBase child in this)
            {
                if (child is ViewDrawContent)
                {
                    ViewDrawContent viewContent = (ViewDrawContent)child;
                    viewContent.DrawContentOnComposition = DrawCanvasOnComposition;
                    viewContent.Glowing = viewContent.DrawContentOnComposition;
                }
            }

            // Let base class find preferred size of the children
            Size preferredSize = base.GetPreferredSize(context);

            // Apply space the border takes up
            if (DrawTabBorder)
            {
                preferredSize = CommonHelper.ApplyPadding(Orientation, preferredSize, context.Renderer.RenderTabBorder.GetTabBorderDisplayPadding(context, _paletteBorder, State, Orientation, TabBorderStyle));
            }
            else
            {
                preferredSize = CommonHelper.ApplyPadding(Orientation, preferredSize, context.Renderer.RenderStandardBorder.GetBorderDisplayPadding(_paletteBorder, State, Orientation));
            }

            // Do we have a metric source for additional padding?
            if (_paletteMetric != null)
            {
                // Apply padding needed outside the border of the canvas
                preferredSize = CommonHelper.ApplyPadding(Orientation, preferredSize, _paletteMetric.GetMetricPadding(State, _metricPadding));
            }

            return(preferredSize);
        }
        /// <summary>
        /// Perform rendering before child elements are rendered.
        /// </summary>
        /// <param name="context">Rendering context.</param>
        /// <exception cref="ArgumentNullException"></exception>
        public override void RenderBefore(RenderContext context)
        {
            Debug.Assert(context != null);

            // Validate reference parameter
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            // Ensure we are using the correct palette
            CheckPaletteState();

            // Apply padding needed outside the border of the separator
            Rectangle rect = CommonHelper.ApplyPadding(Orientation, ClientRectangle,
                                                       _metric.GetMetricPadding(ElementState, MetricPadding));

            // Ask the renderer to perform drawing of the separator glyph
            context.Renderer.RenderGlyph.DrawSeparator(context, rect, _palette.PaletteBack, _palette.PaletteBorder,
                                                       Orientation, State, ((Source == null) || Source.SeparatorCanMove));
        }
Esempio n. 3
0
 /// <summary>
 /// Gets a padding metric value.
 /// </summary>
 /// <param name="state">Palette value should be applicable to this state.</param>
 /// <param name="metric">Requested metric.</param>
 /// <returns>Padding value.</returns>
 public Padding GetMetricPadding(PaletteState state, PaletteMetricPadding metric)
 {
     // Always pass onto the inheritance
     return(_inherit.GetMetricPadding(state, metric));
 }
Esempio n. 4
0
        /// <summary>
        /// Gets a padding metric value.
        /// </summary>
        /// <param name="state">Palette value should be applicable to this state.</param>
        /// <param name="metric">Requested metric.</param>
        /// <returns>Padding value.</returns>
        public override Padding GetMetricPadding(PaletteState state, PaletteMetricPadding metric)
        {
            IPaletteMetric inherit = GetInherit(state);

            return(inherit?.GetMetricPadding(state, metric) ?? Target.GetMetricPadding(state, metric));
        }
 /// <summary>
 /// Populate values from the base palette.
 /// </summary>
 /// <param name="state">Which state to populate from.</param>
 /// <param name="metric">Which metric should be used for padding.</param>
 public void PopulateFromBase(PaletteState state, PaletteMetricPadding metric)
 {
     base.PopulateFromBase(state);
     Padding = _inherit.GetMetricPadding(state, metric);
 }
 /// <summary>
 /// Gets a padding metric value.
 /// </summary>
 /// <param name="state">Palette value should be applicable to this state.</param>
 /// <param name="metric">Requested metric.</param>
 /// <returns>Padding value.</returns>
 public Padding GetMetricPadding(PaletteState state, PaletteMetricPadding metric) =>
 // Always pass onto the inheritance
 _inherit.GetMetricPadding(state, metric);