예제 #1
0
        private void LayoutElements(IDeviceContext g, Rectangle clipRect)
        {
            if (btnRnd == null)
            {
                return;
            }
            var state = (int)ButtonState;

            if (state == 4)
            {
                state = Collapsed ? 7 : 8;
            }
            else if (!Collapsed)
            {
                state += 3;
            }
            btnRnd.SetState(state);
            state = (ButtonState == PushButtonState.Hot || ButtonState == PushButtonState.Pressed) ? 2 : 1;
            bgRnd.SetState(state);
            var r = txtRnd.GetTextExtent(g, "W", TextFormatFlags.Default);

            headerHeight = (tbpadding * 2) + r.Height;
            imgSz        = new Size(btnRnd.GetInteger(IntegerProperty.Width), btnRnd.GetInteger(IntegerProperty.Height));
            buttonBounds = new Rectangle(clipRect.Width - imgSz.Width - HorzPadding, (headerHeight - imgSz.Height) / 2, imgSz.Width, imgSz.Height);
            textBounds   = new Rectangle(HorzPadding, tbpadding, clipRect.Width - HorzPadding - imgSz.Width, tbpadding + r.Height);
            Height       = headerHeight;
        }
예제 #2
0
 private void PaintAction(Graphics graphics, Rectangle bounds, PushButtonState currentstate, TextFormatFlags tff)
 {
     ButtonRenderer.DrawParentBackground(graphics, bounds, this);
     ButtonRenderer.DrawButton(graphics, bounds, currentstate);
     rnd.SetState((int)currentstate);
     graphics.DrawImageAndText(bounds, Text, StyledFont, Image, TextAlign, ImageAlign, TextImageRelation, StyledForeColor, false, 0, Enabled, tff);
     if (Focused)
     {
         ControlPaint.DrawFocusRectangle(graphics, Rectangle.Inflate(bounds, -3, -3));
     }
     System.Diagnostics.Debug.WriteLine($"Painting CustomBtn: {currentstate}");
 }