コード例 #1
0
ファイル: ColorSlider.cs プロジェクト: yanfudi/mcskin3d
 public override void Render(Graphics g)
 {
     if (!Slider.Enabled)
     {
         Color[] desaturatedColors = ColorSlider.DesaturateColors(thumbOuterColor, thumbInnerColor, thumbPenColor,
                                                                  barOuterColor, barInnerColor, barPenColor,
                                                                  elapsedOuterColor, elapsedInnerColor);
         DrawColorSlider(g, desaturatedColors[0], desaturatedColors[1], desaturatedColors[2],
                         desaturatedColors[3],
                         desaturatedColors[4], desaturatedColors[5], desaturatedColors[6], desaturatedColors[7]);
     }
     else
     {
         if (mouseEffects && Slider.MouseInRegion)
         {
             Color[] lightenedColors = ColorSlider.LightenColors(thumbOuterColor, thumbInnerColor, thumbPenColor,
                                                                 barOuterColor, barInnerColor, barPenColor,
                                                                 elapsedOuterColor, elapsedInnerColor);
             DrawColorSlider(g, lightenedColors[0], lightenedColors[1], lightenedColors[2], lightenedColors[3],
                             lightenedColors[4], lightenedColors[5], lightenedColors[6], lightenedColors[7]);
         }
         else
         {
             DrawColorSlider(g, thumbOuterColor, thumbInnerColor, thumbPenColor,
                             barOuterColor, barInnerColor, barPenColor,
                             elapsedOuterColor, elapsedInnerColor);
         }
     }
 }
コード例 #2
0
ファイル: HueSliderRenderer.cs プロジェクト: rmbzlib/mcskin3d
 public HueSliderRenderer(ColorSlider slider)
     : base(slider)
 {
 }
コード例 #3
0
 public SaturationSliderRenderer(ColorSlider slider)
     : base(slider)
 {
 }
コード例 #4
0
ファイル: ColorSlider.cs プロジェクト: rmbzlib/mcskin3d
 public DefaultSliderRenderer(ColorSlider slider)
     : base(slider)
 {
     Slider.OrientationChanged += slider_OrientationChanged;
 }
コード例 #5
0
ファイル: ColorSlider.cs プロジェクト: rmbzlib/mcskin3d
 public WindowsSliderRenderer(ColorSlider slider)
     : base(slider)
 {
 }
コード例 #6
0
ファイル: ColorSlider.cs プロジェクト: rmbzlib/mcskin3d
 public SliderRenderer(ColorSlider slider)
 {
     _slider = slider;
 }
コード例 #7
0
		public AlphaSliderRenderer(ColorSlider slider) :
			base(slider)
		{
		}
コード例 #8
0
ファイル: ColorSlider.cs プロジェクト: yanfudi/mcskin3d
 public DefaultSliderRenderer(ColorSlider slider) :
     base(slider)
 {
     Slider.OrientationChanged += slider_OrientationChanged;
 }
コード例 #9
0
ファイル: ColorSlider.cs プロジェクト: yanfudi/mcskin3d
 public WindowsSliderRenderer(ColorSlider slider) :
     base(slider)
 {
 }
コード例 #10
0
ファイル: ColorSlider.cs プロジェクト: yanfudi/mcskin3d
 public SliderRenderer(ColorSlider slider)
 {
     _slider = slider;
 }
コード例 #11
0
ファイル: ColorSlider.cs プロジェクト: yanfudi/mcskin3d
        private void DrawColorSlider(Graphics g, Color thumbOuterColorPaint, Color thumbInnerColorPaint,
                                     Color thumbPenColorPaint, Color barOuterColorPaint, Color barInnerColorPaint,
                                     Color barPenColorPaint, Color elapsedOuterColorPaint, Color elapsedInnerColorPaint)
        {
            try
            {
                //adjust drawing rects
                barRect       = Slider.ClientRectangle;
                thumbHalfRect = Slider.ThumbRect;
                LinearGradientMode gradientOrientation;
                if (Slider.Orientation == Orientation.Horizontal)
                {
                    barRect.Inflate(-1, -barRect.Height / 3);
                    barHalfRect           = barRect;
                    barHalfRect.Height   /= 2;
                    gradientOrientation   = LinearGradientMode.Vertical;
                    thumbHalfRect.Height /= 2;
                    elapsedRect           = barRect;
                    elapsedRect.Width     = Slider.ThumbRect.Left + Slider.ThumbSize / 2;
                }
                else
                {
                    barRect.Inflate(-barRect.Width / 3, -1);
                    barHalfRect          = barRect;
                    barHalfRect.Width   /= 2;
                    gradientOrientation  = LinearGradientMode.Horizontal;
                    thumbHalfRect.Width /= 2;
                    elapsedRect          = barRect;
                    elapsedRect.Height   = Slider.ThumbRect.Top + Slider.ThumbSize / 2;
                }
                //get thumb shape path
                GraphicsPath thumbPath;
                if (thumbCustomShape == null)
                {
                    thumbPath = ColorSlider.CreateRoundRectPath(Slider.ThumbRect, thumbRoundRectSize);
                }
                else
                {
                    thumbPath = thumbCustomShape;
                    var m = new Matrix();
                    m.Translate(Slider.ThumbRect.Left - thumbPath.GetBounds().Left, Slider.ThumbRect.Top - thumbPath.GetBounds().Top);
                    thumbPath.Transform(m);
                }

                //draw bar
                using (
                    var lgbBar =
                        new LinearGradientBrush(barHalfRect, barOuterColorPaint, barInnerColorPaint, gradientOrientation)
                    )
                {
                    lgbBar.WrapMode = WrapMode.TileFlipXY;
                    g.FillRectangle(lgbBar, barRect);
                    //draw elapsed bar
                    using (
                        var lgbElapsed =
                            new LinearGradientBrush(barHalfRect, elapsedOuterColorPaint, elapsedInnerColorPaint,
                                                    gradientOrientation))
                    {
                        lgbElapsed.WrapMode = WrapMode.TileFlipXY;
                        if (Slider.Capture && drawSemitransparentThumb)
                        {
                            var elapsedReg = new Region(elapsedRect);
                            elapsedReg.Exclude(thumbPath);
                            g.FillRegion(lgbElapsed, elapsedReg);
                        }
                        else
                        {
                            g.FillRectangle(lgbElapsed, elapsedRect);
                        }
                    }
                    //draw bar band
                    using (var barPen = new Pen(barPenColorPaint, 0.5f))
                        g.DrawRectangle(barPen, barRect);
                }

                //draw thumb
                Color newthumbOuterColorPaint = thumbOuterColorPaint, newthumbInnerColorPaint = thumbInnerColorPaint;
                if (Slider.Capture && drawSemitransparentThumb)
                {
                    newthumbOuterColorPaint = Color.FromArgb(175, thumbOuterColorPaint);
                    newthumbInnerColorPaint = Color.FromArgb(175, thumbInnerColorPaint);
                }
                using (
                    var lgbThumb =
                        new LinearGradientBrush(thumbHalfRect, newthumbOuterColorPaint, newthumbInnerColorPaint,
                                                gradientOrientation))
                {
                    lgbThumb.WrapMode = WrapMode.TileFlipXY;
                    g.SmoothingMode   = SmoothingMode.AntiAlias;
                    g.FillPath(lgbThumb, thumbPath);
                    //draw thumb band
                    Color newThumbPenColor = thumbPenColorPaint;
                    if (mouseEffects && (Slider.Capture || Slider.MouseInThumbRegion))
                    {
                        newThumbPenColor = ControlPaint.Dark(newThumbPenColor);
                    }
                    using (var thumbPen = new Pen(newThumbPenColor))
                        g.DrawPath(thumbPen, thumbPath);
                    //gp.Dispose();

                    /*if (Capture || mouseInThumbRegion)
                     *      using (LinearGradientBrush lgbThumb2 = new LinearGradientBrush(thumbHalfRect, Color.FromArgb(150, Color.Blue), Color.Transparent, gradientOrientation))
                     *      {
                     *              lgbThumb2.WrapMode = WrapMode.TileFlipXY;
                     *              e.Graphics.FillPath(lgbThumb2, gp);
                     *      }*/
                }

                //draw focusing rectangle
                if (Slider.Focused & drawFocusRectangle)
                {
                    using (var p = new Pen(Color.FromArgb(200, barPenColorPaint)))
                    {
                        p.DashStyle = DashStyle.Dot;
                        Rectangle r = Slider.ClientRectangle;
                        r.Width -= 2;
                        r.Height--;
                        r.X++;
                        //ControlPaint.DrawFocusRectangle(e.Graphics, r);
                        using (GraphicsPath gpBorder = ColorSlider.CreateRoundRectPath(r, borderRoundRectSize))
                        {
                            g.SmoothingMode = SmoothingMode.AntiAlias;
                            g.DrawPath(p, gpBorder);
                        }
                    }
                }
            }
            catch
            {
                //	Console.WriteLine("DrawBackGround Error in " + Slider.Name + ":" + Err.Message);
            }
            finally
            {
            }
        }
コード例 #12
0
ファイル: DistributionBox.cs プロジェクト: jwezorek/Lifelike
        private Tuple<ColorSlider, Label, Button> AddSlider(FlowLayoutPanel pnlHistogram, int parentWidth, int leftColWd,
                            double value, string text, Color color, bool editColors)
        {
            int scrollWd = SystemInformation.VerticalScrollBarWidth;

            var slider = new ColorSlider();
            slider.BarOuterColor = Color.Gray;
            slider.BarInnerColor = Color.LightGray;
            slider.ElapsedInnerColor = GetHiliteColor(color);
            slider.ElapsedOuterColor = color;
            slider.Minimum = 0;
            slider.Maximum = 100;
            slider.Value = (int)Math.Round(100.0 * value);
            slider.ValueChanged += slider_ValueChanged;

            var panel = new FlowLayoutPanel();
            panel.FlowDirection = FlowDirection.LeftToRight;
            panel.ClientSize = new Size(0, PANEL_HGT);
            panel.Width = parentWidth - scrollWd - MARG;

            Button btn = null;
            if (!editColors)
            {
                var label = new Label();
                label.Size = new Size(leftColWd, PANEL_HGT);
                label.Text = text;
                label.TextAlign = ContentAlignment.MiddleRight;
                label.Parent = panel;
            }
            else
            {
                btn = new Button();
                btn.Size = new Size(leftColWd, BTN_HGT);
                btn.Text = text;
                btn.TextAlign = ContentAlignment.MiddleRight;
                btn.Parent = panel;
                btn.Click += btn_Click;
            }

            slider.Size = new Size(panel.Width - leftColWd - PCNT_LABEL_WD - 2 * MARG, PANEL_HGT);
            slider.Parent = panel;
            slider.Height = 35;
            panel.Parent = pnlHistogram;

            var lblPcnt = new Label();
            lblPcnt.Size = new Size(PCNT_LABEL_WD, PANEL_HGT);
            lblPcnt.TextAlign = ContentAlignment.MiddleRight;
            lblPcnt.Text = string.Format("{0}%", slider.Value);
            lblPcnt.Parent = panel;

            return new Tuple<ColorSlider, Label, Button>(slider, lblPcnt, btn);
        }
コード例 #13
0
ファイル: DistributionBox.cs プロジェクト: jwezorek/Lifelike
        private void AddExtraSlider(string label, double value, int parentWidth, int leftColWd)
        {
            var panel = new FlowLayoutPanel();
            panel.FlowDirection = FlowDirection.LeftToRight;
            panel.ClientSize = new Size(0, PANEL_HGT);
            panel.Width = parentWidth - SystemInformation.VerticalScrollBarWidth - MARG;

            var lbl = new Label();
            lbl.Size = new Size(leftColWd, PANEL_HGT);
            lbl.Text = label;
            lbl.TextAlign = ContentAlignment.MiddleRight;
            lbl.Parent = panel;

            _extraSlider = new ColorSlider();
            _extraSlider.BarOuterColor = Color.Gray;
            _extraSlider.BarInnerColor = Color.LightGray;
            _extraSlider.ElapsedInnerColor = GetHiliteColor(Color.Black);
            _extraSlider.ElapsedOuterColor = Color.Black;
            _extraSlider.Minimum = 0;
            _extraSlider.Maximum = 100;
            _extraSlider.Value = (int) Math.Round(100.0 * value);
            _extraSlider.ValueChanged += extraSlider_ValueChanged;
            _extraSlider.Size = new Size(panel.Width - leftColWd - PCNT_LABEL_WD - 2 * MARG, 35);
            _extraSlider.Parent = panel;

            _extraSliderLabel = new Label();
            _extraSliderLabel.Size = new Size(PCNT_LABEL_WD, PANEL_HGT);
            _extraSliderLabel.TextAlign = ContentAlignment.MiddleRight;
            _extraSliderLabel.Text = string.Format("{0}%", _extraSlider.Value);
            _extraSliderLabel.Parent = panel;

            panel.Parent = this;
            panel.Location = new Point(10, pnlHistogram.Bounds.Bottom);
        }