예제 #1
0
 protected override void OnRender(DrawingContext dc)
 {
     if (!Utils.StringIsNullOrEmpty(activeBrushID))
     {
         Brush brush = (Brush)brushes[activeBrushID];
         if (brush != null)
             dc.DrawRectangle(brush, null, 0, 0, Width, Height);
     }
 }
예제 #2
0
        protected override void OnRender(DrawingContext dc)
        {
            dc.DrawRectangle(background, border, 0, 0, Width, Height);

            if (Bitmap != null)
                dc.DrawRectangle(brush, border, 0, 0, Width, Height);
        }
예제 #3
0
 public override void OnRender(DrawingContext dc)
 {
     if (background != null)
         dc.DrawRectangle(background, null, 0, 0, Width, Height);
 }
예제 #4
0
        protected override void OnRender(DrawingContext dc)
        {
            dc.DrawRectangle(background, null, 0, 0, Width, Height);

            if (foreground != null)
            {
                bool horizontal = orientation == Orientation.Horizontal;
                int w = horizontal ? Width * value / 100 : Width;
                int h = horizontal ? Height : Height * value / 100;
                int y = horizontal ? 0 : Height - h;

                dc.DrawRectangle(foreground, null, 0, y, w, h);
            }

            dc.DrawRectangle(null, border, 0, 0, Width, Height);
        }
예제 #5
0
        public override void OnRender(DrawingContext dc)
        {
            if (isChecked)
            {
                if (backgroundChecked != null)
                    dc.DrawRectangle(backgroundChecked, border, 0, 0, Width, Height);
                else
                {
                    dc.DrawRectangle(backgroundUnchecked, border, 0, 0, Width, Height);

                    int offset = 2;
                    LinearGradientBrush b = new LinearGradientBrush(Color.LimeGreen, Color.Black);
                    dc.DrawRectangle(b, null, offset, offset, Width - 2 * offset, Height - 2 * offset);
                }
            }
            else
            {
                dc.DrawRectangle(backgroundUnchecked, border, 0, 0, Width, Height);
            }
        }
예제 #6
0
        protected override void OnRender(DrawingContext dc)
        {
            if (background != null)
                dc.DrawRectangle(background, null, 0, 0, Width, Height);

            if (font != null && !Utils.StringIsNullOrEmpty(text))
            {
                string s = text; // this is important to take a copy!!! don't change!!!
                dc.DrawText(ref s, font, foreColor, 0, textOffsetY, Width, wordWrap ? Height : font.Height, alignment, trimming, wordWrap);
            }
        }
예제 #7
0
 protected override void OnRender(DrawingContext dc)
 {
     dc.DrawRectangle(background, border, 0, 0, Width, Height, borderRadius, borderRadius);
 }
예제 #8
0
        protected override void OnRender(DrawingContext dc)
        {
            int centerX = Width / 2;
            int centerY = Height / 2;
            int radiusX = centerX;
            int radiusY = centerY;
            int ratio = 2;

            if (isChecked)
            {
                if (backgroundChecked != null)
                    dc.DrawRectangle(backgroundChecked, border, 0, 0, Width, Height);
                else
                {
                    dc.DrawEllipse(backgroundUnchecked, border, centerX, centerY, radiusX, radiusY);

                    SolidColorBrush b = new SolidColorBrush(Color.LimeGreen);
                    dc.DrawEllipse(b, border, centerX, centerY, radiusX / ratio, radiusY / ratio);
                }
            }
            else
            {
                dc.DrawEllipse(backgroundUnchecked, border, centerX, centerY, radiusX, radiusY);
            }
        }
예제 #9
0
        public override void OnRender(DrawingContext dc)
        {
            if (background != null)
                dc.DrawRectangle(background, null, 0, 0, Width, Height);

            if (Bitmap != null)
                dc.DrawRectangle(brush, null, 0, 0, Width, Height);

            if (border != null)
                dc.DrawRectangle(null, border, 0, 0, Width, Height);
        }
예제 #10
0
 protected override void OnRender(DrawingContext dc)
 {
     if (Orientation == Orientation.Horizontal)
     {
         barThickness = (Width - gap * (barCount - 1)) / barCount;
         int x = 0;
         for (int i = 1; i <= barCount; i++)
         {
             int val = Height * i / barCount;
             dc.DrawRectangle(
                 i <= activeBarCount ? foreground : background,
                 null,
                 x, Height - val,
                 barThickness, val);
             x += barThickness + gap;
         }
     }
     else
     {
         barThickness = (Height - gap * (barCount - 1)) / barCount;
         int y = Height - barThickness;
         for (int i = 1; i <= barCount; i++)
         {
             int val = Width * i / barCount;
             dc.DrawRectangle(
                 i <= activeBarCount ? foreground : background,
                 null,
                 Width - val, y,
                 val, barThickness);
             y -= barThickness + gap;
         }
     }
 }
예제 #11
0
        protected override void OnRender(DrawingContext dc)
        {
            #region Background
            int b = border != null ? 1 : 0;
            dc.DrawRectangle(TouchCapture.Captured == this ? backgroundPressed : backgroundUnpressed, null, b, b, Width - 2 * b, Height - 2 * b);
            #endregion

            bool hasForeground = foreground != null;
            bool hasText = font != null && !Utils.StringIsNullOrEmpty(text);

            if (hasForeground && !hasText)
            {
                // image only
                ushort originalOpacity = foreground.Opacity;
                if (!IsEnabled)
                    foreground.Opacity = (ushort)(originalOpacity / 2);

                int a = (Width < Height ? Width : Height) - 2;
                dc.DrawRectangle(foreground, null, (Width - a) / 2, (Height - a) / 2, a, a);

                foreground.Opacity = originalOpacity;
            }
            else if (!hasForeground && hasText)
            {
                // text only
                int w = 0, h = 0;
                font.ComputeExtent(text, out w, out h);
                string s = text;
                dc.DrawText(ref s, font, foreColor, 0, (Height - h) / 2, Width, h, TextAlignment.Center, TextTrimming.None, false);
            }
            else if (hasForeground && hasText)
            {
                if (textBelow)
                {

                }
                else
                {

                }
            }

            #region Border
            //if (border != null)
            //{
            //    int corner = 3;
            //    dc.DrawFrame(border, 0, 0, Width, Height, corner, corner);
            //}
            #endregion
        }
예제 #12
0
        protected override void OnRender(DrawingContext dc)
        {
            bool horizontal = orientation == Orientation.Horizontal;

            // background
            int trackRatio = 7;
            int a = horizontal ? Height / trackRatio : Width / trackRatio;
            if (horizontal)
                trackArea = new Rect(0, (Height - a) / 2, Width, a);
            else
                trackArea = new Rect((Width - a) / 2, 0, a, Height);

            Brush b = background ?? new SolidColorBrush(Color.DarkGray);
            Pen border = new Pen(Color.Gray, 0);
            dc.DrawRectangle(b, border, trackArea.X, trackArea.Y, trackArea.Width, trackArea.Height);

            // thumb
            int workarea = horizontal ? Width - thumbSize : Height - thumbSize;
            int x = horizontal ? workarea * value / 100 : 0;
            int y = horizontal ? 0 : Height - thumbSize - workarea * value / 100;
            if (horizontal)
                thumbArea = new Rect(x, y, thumbSize, Height);
            else
                thumbArea = new Rect(x, y, Width, thumbSize);

            Brush bb = foreground ?? new LinearGradientBrush(Color.LightGray, Color.Black);
            dc.DrawRectangle(bb, thumbBorder, thumbArea.X, thumbArea.Y, thumbArea.Width, thumbArea.Height);
        }