Example #1
0
        /// <summary>
        /// Draws the Slider item. If you need to provide custom rendering this is the method that you should override in your custom rendered. If you
        /// do not want default rendering to occur do not call the base implementation. You can call OnRenderSliderItem method so events can occur.
        /// </summary>
        /// <param name="e">Provides context information.</param>
        public override void DrawSliderItem(SliderItemRendererEventArgs e)
        {
            SliderPainter painter = PainterFactory.CreateSliderPainter(e.SliderItem);

            if (painter == null)
                return;

            if (painter is IOffice2007Painter)
                ((IOffice2007Painter)painter).ColorTable = m_ColorTable;

            painter.Paint(e);

            base.DrawSliderItem(e);
        }
Example #2
0
 public virtual void Paint(SliderItemRendererEventArgs e) { }
Example #3
0
 /// <summary>
 /// Raises RenderSliderItem event.
 /// </summary>
 /// <param name="e">Provides context information.</param>
 protected virtual void OnRenderSliderItem(SliderItemRendererEventArgs e)
 {
     if (RenderSliderItem!= null)
         RenderSliderItem(this, e);
 }
Example #4
0
 /// <summary>
 /// Draws the Slider item. If you need to provide custom rendering this is the method that you should override in your custom rendered. If you
 /// do not want default rendering to occur do not call the base implementation. You can call OnRenderSliderItem method so events can occur.
 /// </summary>
 /// <param name="e">Provides context information.</param>
 public virtual void DrawSliderItem(SliderItemRendererEventArgs e)
 {
     OnRenderSliderItem(e);
 }
Example #5
0
        public override void Paint(SliderItemRendererEventArgs e)
        {
            SliderItem item = e.SliderItem;
            Office2007SliderColorTable ct = GetColorTable(item, e.ItemPaintArgs.ContainerControl);
            Office2007SliderStateColorTable decreaseCt = null;
            Office2007SliderStateColorTable increaseCt = null;
            Office2007SliderStateColorTable trackCt = null;
            eDotNetBarStyle effectiveStyle = item.EffectiveStyle;

            if (item.GetEnabled())
            {
                decreaseCt = ct.Default;
                increaseCt = ct.Default;
                trackCt = ct.Default;

                if (ct.DecreaseButtonPart != null)
                    decreaseCt = ct.DecreaseButtonPart.Default;
                if (ct.IncreaseButtonPart != null)
                    increaseCt = ct.IncreaseButtonPart.Default;
                if (ct.TrackPart != null)
                    trackCt = ct.TrackPart.Default;

                if (item.MouseDownPart == eSliderPart.DecreaseButton)
                {
                    if (ct.DecreaseButtonPart != null)
                        decreaseCt = ct.DecreaseButtonPart.Pressed;
                    else
                        decreaseCt = ct.Pressed;
                }
                else if (item.MouseDownPart == eSliderPart.IncreaseButton)
                {
                    if (ct.IncreaseButtonPart != null)
                        increaseCt = ct.IncreaseButtonPart.Pressed;
                    else
                        increaseCt = ct.Pressed;
                }
                else if (item.MouseDownPart == eSliderPart.TrackArea)
                {
                    if (ct.TrackPart != null)
                        trackCt = ct.TrackPart.Pressed;
                    else
                        trackCt = ct.Pressed;
                }
                else if (item.MouseOverPart == eSliderPart.DecreaseButton)
                {
                    if (ct.DecreaseButtonPart != null)
                        decreaseCt = ct.DecreaseButtonPart.MouseOver;
                    else
                        decreaseCt = ct.MouseOver;
                }
                else if (item.MouseOverPart == eSliderPart.IncreaseButton)
                {
                    if (ct.IncreaseButtonPart != null)
                        increaseCt = ct.IncreaseButtonPart.MouseOver;
                    else
                        increaseCt = ct.MouseOver;
                }
                else if (item.MouseOverPart == eSliderPart.TrackArea)
                {
                    if (ct.TrackPart != null)
                        trackCt = ct.TrackPart.MouseOver;
                    else
                        trackCt = ct.MouseOver;
                }
            }
            else
            {
                decreaseCt = ct.Disabled;
                increaseCt = ct.Disabled;
                trackCt = ct.Disabled;
            }

            Rectangle itemRect = item.DisplayRectangle;
            Rectangle r = item.LabelBounds;
            Graphics g = e.Graphics;

            string text = GetText(item);
            if (!r.IsEmpty && text.Length > 0)
            {
                r.Offset(itemRect.Location);
                eTextFormat tf = eTextFormat.Default | eTextFormat.WordEllipsis;
                if (item.LabelPosition == eSliderLabelPosition.Left)
                    tf |= eTextFormat.Left | eTextFormat.VerticalCenter;
                else if (item.LabelPosition == eSliderLabelPosition.Right)
                    tf |= eTextFormat.Right | eTextFormat.VerticalCenter;
                else if (item.LabelPosition == eSliderLabelPosition.Top)
                    tf |= eTextFormat.HorizontalCenter | eTextFormat.Top | eTextFormat.WordBreak;
                else if (item.LabelPosition == eSliderLabelPosition.Bottom)
                    tf |= eTextFormat.HorizontalCenter | eTextFormat.Bottom | eTextFormat.WordBreak;

                Color cl = trackCt.LabelColor;
                if (e.ItemPaintArgs.ContainerControl is DevComponents.DotNetBar.Controls.Slider)
                    cl = trackCt.SliderLabelColor;

                if (!item.TextColor.IsEmpty)
                    cl = item.TextColor;
                if (item.TextMarkupBody == null)
                {
#if FRAMEWORK20
                    if (e.ItemPaintArgs != null && e.ItemPaintArgs.GlassEnabled && item.Parent is CaptionItemContainer && !(e.ItemPaintArgs.ContainerControl is QatToolbar))
                    {
                        if (!e.ItemPaintArgs.CachedPaint)
                            Office2007RibbonControlPainter.PaintTextOnGlass(g, GetText(item), e.ItemPaintArgs.Font, r, TextDrawing.GetTextFormat(tf));
                    }
                    else
#endif
                    {
                        if (item.SliderOrientation == eOrientation.Vertical)
                        {
                            g.RotateTransform(90);
                            TextDrawing.DrawString(g, GetText(item), e.ItemPaintArgs.Font, cl, new Rectangle(r.Top, -r.Right, r.Height, r.Width), tf);
                            g.ResetTransform();
                        }
                        else
                            TextDrawing.DrawString(g, GetText(item), e.ItemPaintArgs.Font, cl, r, tf);
                    }
                }
                else
                {
                    if (item.SliderOrientation == eOrientation.Vertical)
                    {
                        g.RotateTransform(90);
                        TextMarkup.MarkupDrawContext d = new TextMarkup.MarkupDrawContext(g, e.ItemPaintArgs.Font, cl, e.ItemPaintArgs.RightToLeft);
                        d.HotKeyPrefixVisible = !((tf & eTextFormat.HidePrefix) == eTextFormat.HidePrefix);
                        item.TextMarkupBody.Bounds = new Rectangle(r.Top, -r.Right, item.TextMarkupBody.Bounds.Width, item.TextMarkupBody.Bounds.Height);
                        item.TextMarkupBody.Render(d);
                        g.ResetTransform();
                    }
                    else
                    {
                        TextMarkup.MarkupDrawContext d = new TextMarkup.MarkupDrawContext(g, e.ItemPaintArgs.Font, cl, e.ItemPaintArgs.RightToLeft);
                        d.HotKeyPrefixVisible = !((tf & eTextFormat.HidePrefix) == eTextFormat.HidePrefix);
                        item.TextMarkupBody.Bounds = r;
                        item.TextMarkupBody.Render(d);
                    }
                }
            }

            r = item.SlideBounds;
            if (!r.IsEmpty)
            {
                SmoothingMode sm = g.SmoothingMode;
                g.SmoothingMode = SmoothingMode.None;
                r.Offset(itemRect.Location);
                if (item.SliderOrientation == eOrientation.Horizontal)
                {
                    // Draw the track line
                    int ty = r.Y + r.Height / 2 - 1;
                    int tmx = r.X + r.Width / 2;
                    if (!trackCt.TrackLineColor.IsEmpty)
                    {
                        using (Pen pen = new Pen(trackCt.TrackLineColor))
                        {
                            g.DrawLine(pen, r.X - 1, ty, r.Right, ty);
                        }
                    }

                    if (!trackCt.TrackLineLightColor.IsEmpty)
                    {
                        ty++;
                        tmx++;
                        using (Pen pen = new Pen(trackCt.TrackLineLightColor))
                        {
                            if (item.TrackMarker)
                                g.DrawLine(pen, tmx, ty - 3, tmx, ty + 3);
                            g.DrawLine(pen, r.X - 1, ty, r.Right, ty);
                        }
                    }

                    if (!trackCt.TrackLineColor.IsEmpty && item.TrackMarker)
                    {
                        ty--;
                        tmx--;
                        using (Pen pen = new Pen(trackCt.TrackLineColor))
                        {
                            g.DrawLine(pen, tmx, ty - 3, tmx, ty + 3);
                        }
                    }
                    g.SmoothingMode = sm;

                    int tx = 0;
                    if (e.ItemPaintArgs.RightToLeft)
                        tx = (int)((r.Width - 11) * (1 - ((item.Maximum - item.Minimum == 0) ? 0 : (float)(item.Value - item.Minimum) / (item.Maximum - item.Minimum))));
                    else
                        tx = (int)((r.Width - 11) * ((item.Maximum - item.Minimum == 0) ? 0 : (float)(item.Value - item.Minimum) / (item.Maximum - item.Minimum)));

                    // Draw the tracker
                    Rectangle trackRect = r;
                    trackRect.X += tx;
                    trackRect.Width = 11;
                    trackRect.Height = 15;
                    trackRect.Y += (r.Height - trackRect.Height) / 2;
                    PaintSliderPart(trackCt, trackRect, g, eSliderPart.TrackArea, item.SliderOrientation, effectiveStyle);
                    item.TrackBounds = trackRect;
                }
                else
                {
                    // Draw the track line
                    int tx = r.X + r.Width / 2 - 1;
                    int tmy = r.Y + r.Height / 2;
                    if (!trackCt.TrackLineColor.IsEmpty)
                    {
                        using (Pen pen = new Pen(trackCt.TrackLineColor))
                        {
                            g.DrawLine(pen, tx, r.Y - 1, tx, r.Bottom);
                        }
                    }

                    if (!trackCt.TrackLineLightColor.IsEmpty)
                    {
                        tx++;
                        tmy++;
                        using (Pen pen = new Pen(trackCt.TrackLineLightColor))
                        {
                            if (item.TrackMarker)
                                g.DrawLine(pen, tx - 3, tmy, tx + 3, tmy);
                            g.DrawLine(pen, tx, r.Y - 1, tx, r.Bottom);
                        }
                    }

                    if (!trackCt.TrackLineColor.IsEmpty && item.TrackMarker)
                    {
                        tx--;
                        tmy--;
                        using (Pen pen = new Pen(trackCt.TrackLineColor))
                        {
                            g.DrawLine(pen, tx - 3, tmy, tx + 3, tmy);
                        }
                    }
                    g.SmoothingMode = sm;

                    int ty = 0;
                    ty = (r.Height - 16) - (int)((r.Height - 11) * ((item.Maximum - item.Minimum == 0) ? 0 : (float)(item.Value - item.Minimum) / (item.Maximum - item.Minimum)));

                    // Draw the tracker
                    Rectangle trackRect = r;
                    trackRect.Y += ty;
                    trackRect.Width = 15;
                    trackRect.Height = 11;
                    trackRect.X += (r.Width - trackRect.Width) / 2;
                    PaintSliderPart(trackCt, trackRect, g, eSliderPart.TrackArea, item.SliderOrientation, effectiveStyle);
                    item.TrackBounds = trackRect;
                }
            }

            r = item.DecreaseBounds;
            if (!r.IsEmpty)
            {
                r.Offset(itemRect.Location);
                r.Width--;
                r.Height--;
                PaintSliderPart(decreaseCt, r, g, eSliderPart.DecreaseButton, item.SliderOrientation, effectiveStyle);
            }

            r = item.IncreaseBounds;
            if (!r.IsEmpty)
            {
                r.Offset(itemRect.Location);
                r.Width--;
                r.Height--;
                PaintSliderPart(increaseCt, r, g, eSliderPart.IncreaseButton, item.SliderOrientation, effectiveStyle);
            }

            base.Paint(e);
        }