Ejemplo n.º 1
0
        /// <summary>
        /// Render Bevel control.
        /// Return true if failed.
        /// </summary>
        /// <param name="r.Canvas">Parent r.Canvas</param>
        /// <param name="uiCtrl">UIControl</param>
        /// <returns>Success = false, Failure = true</returns>
        public static void RenderBevel(RenderInfo r, UIControl uiCtrl)
        {
            Debug.Assert(uiCtrl.Info.GetType() == typeof(UIInfo_Bevel));
            UIInfo_Bevel info = uiCtrl.Info as UIInfo_Bevel;

            Border bevel = new Border()
            {
                IsHitTestVisible = false,
                Background       = Brushes.Transparent,
                BorderThickness  = new Thickness(1),
                BorderBrush      = Brushes.Gray,
                ToolTip          = info.ToolTip,
            };

            DrawToCanvas(r, bevel, uiCtrl.Rect);

            if (DisableBevelCaption == false &&
                !uiCtrl.Text.Equals(uiCtrl.Key, StringComparison.Ordinal) && !string.IsNullOrWhiteSpace(uiCtrl.Text))
            { // PEBakery Extension - see https://github.com/pebakery/pebakery/issues/34
                int fontSize = DefaultFontPoint;
                if (info.FontSize != null)
                {
                    fontSize = (int)info.FontSize;
                }

                UIInfo_BevelCaption_Style style = UIInfo_BevelCaption_Style.Normal;
                if (info.Style != null)
                {
                    style = (UIInfo_BevelCaption_Style)info.Style;
                }

                Border textBorder = new Border()
                {
                    BorderThickness = new Thickness(CalcFontPointScale() / 3), // Don't use info.FontSize for border thickness. It throws off X Pos.
                    BorderBrush     = Brushes.Transparent,
                };
                TextBlock textBlock = new TextBlock()
                {
                    Text       = uiCtrl.Text,
                    FontSize   = CalcFontPointScale(fontSize),
                    Padding    = new Thickness(CalcFontPointScale(fontSize) / 3, 0, CalcFontPointScale(fontSize) / 3, 0),
                    Background = Brushes.White,
                };
                textBorder.Child = textBlock;
                if (info.Style == UIInfo_BevelCaption_Style.Bold)
                {
                    textBlock.FontWeight = FontWeights.Bold;
                }

                Rect blockRect = new Rect()
                {
                    X      = uiCtrl.Rect.X + (CalcFontPointScale(fontSize) / 3),
                    Y      = uiCtrl.Rect.Y - CalcFontPointScale(fontSize),
                    Width  = double.NaN,
                    Height = double.NaN,
                };
                DrawToCanvas(r, textBorder, blockRect);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Render Bevel control.
        /// Return true if failed.
        /// </summary>
        /// <param name="r.Canvas">Parent r.Canvas</param>
        /// <param name="uiCmd">UICommand</param>
        /// <returns>Success = false, Failure = true</returns>
        public static void RenderBevel(RenderInfo r, UICommand uiCmd)
        {
            Debug.Assert(uiCmd.Info.GetType() == typeof(UIInfo_Bevel));
            UIInfo_Bevel info = uiCmd.Info as UIInfo_Bevel;

            Border bevel = new Border()
            {
                IsHitTestVisible = false,
                Background       = Brushes.Transparent,
                BorderThickness  = new Thickness(1),
                BorderBrush      = Brushes.Gray,
                ToolTip          = info.ToolTip,
            };

            DrawToCanvas(r, bevel, uiCmd.Rect);
        }