Beispiel #1
0
		protected override void OnDrawItem(DrawItemEventArgs e)
		{
			base.OnDrawItem(e);
			if(m_Items==null || e.Index<0)
				return;

			BaseItem objItem=this.Items[e.Index] as BaseItem;
			e.DrawBackground();
			if(objItem==null)
			{
				//e.DrawBackground();
				return;
			}
			objItem.LeftInternal=e.Bounds.Left;
			objItem.TopInternal=e.Bounds.Top;
			
			objItem.WidthInternal=e.Bounds.Width;

            if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
            {
                objItem.InternalMouseEnter();
                objItem.InternalMouseMove(new MouseEventArgs(MouseButtons.None, 0, objItem.LeftInternal + 2, objItem.TopInternal + 2, 0));
            }
			ItemPaintArgs pa=new ItemPaintArgs(null,this,e.Graphics,new ColorScheme(Style)); // TODO: ADD COLOR SCHEME
            pa.Renderer = GetRenderer();
			objItem.Paint(pa);

			if((e.State & DrawItemState.Selected)==DrawItemState.Selected)
				objItem.InternalMouseLeave();
		}
Beispiel #2
0
        public override void Paint(ItemPaintArgs p)
        {
            Rectangle bounds = this.Bounds;
            if (bounds.Width < 1 || bounds.Height < 1) return;

            Color colorLine = p.Colors.ItemSeparator;
            Color colorShade = p.Colors.ItemSeparatorShade;
            Graphics g=p.Graphics;
            Rectangle r;
            if (this.Orientation == eOrientation.Vertical)
            {
                r=new Rectangle(bounds.X + _Padding.Left, bounds.Y + _Padding.Top + bounds.Height / 2, bounds.Width - _Padding.Right, 1);
                if (!colorLine.IsEmpty)
                    DisplayHelp.DrawLine(g, r.X, r.Y, r.Right, r.Y, colorLine, 1);
            }
            else
            {
                r = new Rectangle(bounds.X + _Padding.Left + bounds.Width / 2, 
                    bounds.Y + _Padding.Top + (bounds.Height - _FixedSize.Height)/2, 1, _FixedSize.Height);
                if (!colorLine.IsEmpty)
                    DisplayHelp.DrawLine(g, r.X, r.Y, r.X, r.Bottom, colorLine, 1);
            }

            if (!colorShade.IsEmpty)
            {
                r.Inflate(1, 1);
                DisplayHelp.DrawRectangle(g, colorShade, r);
            }
        
        }
Beispiel #3
0
 protected override Rectangle GetTextRectangle(ButtonItem button, ItemPaintArgs pa, eTextFormat stringFormat, CompositeImage image)
 {
     Rectangle r = base.GetTextRectangle(button, pa, stringFormat, image);
     if (image == null && string.IsNullOrEmpty(button.Symbol))
         r.Inflate(-3, 0);
     return r;
 }
Beispiel #4
0
        /// <summary>
        /// Must be overridden by class that is inheriting to provide the painting for the item.
        /// </summary>
        public override void Paint(ItemPaintArgs p)
        {
            Graphics g = p.Graphics;
            Region oldClip = null;
            bool clipSet = false;

            PaintBackground(p);

            Rectangle clip = GetClipRectangle();
            oldClip = g.Clip;
            g.SetClip(clip, CombineMode.Intersect);
            clipSet = true;

            ItemDisplay display = GetItemDisplay();
            display.Paint(this, p);

            if (clipSet)
            {
                if (oldClip != null)
                    g.Clip = oldClip;
                else
                    g.ResetClip();
            }

            if (oldClip != null)
                oldClip.Dispose();

            this.DrawInsertMarker(p.Graphics);
        }
Beispiel #5
0
        public override void PaintButtonBackground(ButtonItem button, ItemPaintArgs pa, CompositeImage image)
		{
            bool isOnMenu = IsOnMenu(button, pa);
			if(isOnMenu)
				base.PaintButtonBackground(button,pa, image);
			else
				PaintButtonCheck(button,pa,image,button.DisplayRectangle);
		}
Beispiel #6
0
 /// <summary>
 /// Paints state of the button, either hot, pressed or checked
 /// </summary>
 /// <param name="button"></param>
 /// <param name="pa"></param>
 /// <param name="image"></param>
 public override void PaintButtonMouseOver(ButtonItem button, ItemPaintArgs pa, CompositeImage image, Rectangle r)
 {
     if (IsOffice2003Rendering(button, pa))
     {
         base.PaintButtonMouseOver(button, pa, image, r);
         return;
     }
     //PaintState(button, pa, image, r, button.IsMouseDown);
 }
Beispiel #7
0
        protected virtual IShapeDescriptor GetButtonShape(ButtonItem button, ItemPaintArgs pa)
        {
            IShapeDescriptor shape = Office2007ButtonItemPainter.GetButtonShape(button);

            if (pa.ContainerControl is ButtonX)
                shape = ((ButtonX)pa.ContainerControl).GetButtonShape();
            else if (pa.ContainerControl is NavigationBar)
                shape = ((NavigationBar)pa.ContainerControl).ButtonShape;
            return shape;
        }
Beispiel #8
0
 public RibbonTabGroupRendererEventArgs(Graphics g, RibbonTabItemGroup group, Rectangle bounds, Rectangle groupBounds, Font font, ItemPaintArgs pa, eDotNetBarStyle effectiveStyle)
 {
     this.Graphics = g;
     this.RibbonTabItemGroup = group;
     this.Bounds = bounds;
     this.GroupBounds = groupBounds;
     this.GroupFont = font;
     this.ItemPaintArgs = pa;
     this.EffectiveStyle = effectiveStyle;
 }
Beispiel #9
0
        internal void PaintImage(ItemPaintArgs p, Image image, eLabelPartAlignment imageAlign)
        {
            if (image == null) return;
            Graphics g = p.Graphics;

            Rectangle imageRect = GetAlignedRect(this.DisplayRectangle, image.Size, imageAlign);
            CompositeImage ci = new CompositeImage(image, false);
            ci.DrawImage(g, imageRect);
            ci.Dispose();
            _ImageRenderBounds = imageRect;
        }
Beispiel #10
0
 public override void PaintButtonCheck(ButtonItem button, ItemPaintArgs pa, CompositeImage image, Rectangle r)
 {
     if (IsOffice2003Rendering(button, pa))
     {
         base.PaintButtonCheck(button, pa, image, r);
         return;
     }
     bool isOnMenu = IsOnMenu(button, pa);
     if (isOnMenu)
         base.PaintButtonCheck(button, pa, image, r);
     //else
     //    PaintState(button, pa, image, r, button.IsMouseDown);
 }
Beispiel #11
0
 internal ItemPaintArgs GetItemPaintArgs(System.Drawing.Graphics g)
 {
     ItemPaintArgs pa = new ItemPaintArgs(this as IOwner, this, g, GetColorScheme());
     pa.Renderer = this.GetRenderer();
     if (_DisplayItem.DesignMode)
     {
         ISite site = this.GetSite();
         if (site != null && site.DesignMode)
             pa.DesignerSelection = true;
     }
     pa.GlassEnabled = !this.DesignMode && WinApi.IsGlassEnabled;
     return pa;
 }
 protected override void RenderButton(ItemPaintArgs p)
 {
     if (!p.IsOnMenu)
     {
         Rendering.BaseRenderer renderer = p.Renderer;
         if (renderer != null)
         {
             p.ButtonItemRendererEventArgs.Graphics = p.Graphics;
             p.ButtonItemRendererEventArgs.ButtonItem = this;
             p.ButtonItemRendererEventArgs.ItemPaintArgs = p;
             renderer.DrawCrumbBarOverflowItem(p.ButtonItemRendererEventArgs);
             return;
         }
     }
     base.RenderButton(p);
 }
Beispiel #13
0
		public static Color GetTextColor(ButtonItem button, ItemPaintArgs pa)
		{
			Color textColor=SystemColors.ControlText;

			if(!ButtonItemPainter.IsItemEnabled(button, pa))
			{
				if(!pa.Colors.ItemDisabledText.IsEmpty)
					textColor=pa.Colors.ItemDisabledText;
				else
					textColor=SystemColors.ControlDark;
			}
			else if(button.IsMouseDown && !pa.Colors.ItemPressedText.IsEmpty)
			{
				textColor=pa.Colors.ItemPressedText;
			}
			else if(button.IsMouseOver)
			{
				if(!button.HotForeColor.IsEmpty)
					textColor=button.HotForeColor;
				else
					textColor=pa.Colors.ItemHotText;
			}
			else if(button.Expanded && !pa.Colors.ItemExpandedText.IsEmpty)
			{
				textColor=pa.Colors.ItemExpandedText;
			}
			else if(button.Checked && !pa.Colors.ItemCheckedText.IsEmpty)
			{
				textColor=pa.Colors.ItemCheckedText;
			}
			else
			{
				if(!button.ForeColor.IsEmpty)
					textColor=button.ForeColor;
				else
				{
					if(button.IsThemed && button.IsOnMenuBar && pa.Colors.ItemText==SystemColors.ControlText)
						textColor=SystemColors.MenuText;
					else
						textColor=pa.Colors.ItemText;
				}
			}

			return textColor;
		}
Beispiel #14
0
 public override void Paint(ItemPaintArgs p)
 {
     Rendering.BaseRenderer renderer = p.Renderer;
     if (renderer != null)
     {
         ColorItemRendererEventArgs e = new ColorItemRendererEventArgs(p.Graphics, this);
         renderer.DrawColorItem(e);
     }
     else
     {
         Rendering.ColorItemPainter painter = PainterFactory.CreateColorItemPainter(this);
         if (painter != null)
         {
             ColorItemRendererEventArgs e = new ColorItemRendererEventArgs(p.Graphics, this);
             painter.PaintColorItem(e);
         }
     }
 }
Beispiel #15
0
 public void Paint(BaseItem container, ItemPaintArgs p)
 {
     foreach (BaseItem item in container.SubItems)
     {
         if (item.Visible && item.Displayed)
         {
             if (p.ClipRectangle.IsEmpty || p.ClipRectangle.IntersectsWith(item.DisplayRectangle))
             {
                 Region oldClip = p.Graphics.Clip; //.Clone() as Region;
                 p.Graphics.SetClip(item.DisplayRectangle, CombineMode.Intersect);
                 item.Paint(p);
                 p.Graphics.Clip = oldClip;
                 if (oldClip != null)
                     oldClip.Dispose();
             }
         }
     }
 }
Beispiel #16
0
        /// <summary>
		/// Overriden. Draws the item.
		/// </summary>
		/// <param name="g">Target Graphics object.</param>
        public override void Paint(ItemPaintArgs p)
        {
            Rendering.BaseRenderer renderer = p.Renderer;
            if (renderer != null)
            {
                renderer.DrawQatOverflowItem(new QatOverflowItemRendererEventArgs(this, p.Graphics));
                return;
            }
            else
            {
                Rendering.QatOverflowPainter painter = PainterFactory.CreateQatOverflowItemPainter(this);
                if (painter != null)
                {
                    painter.Paint(new QatOverflowItemRendererEventArgs(this, p.Graphics));
                    return;
                }
            }

            base.Paint(p);
        }
Beispiel #17
0
		/// <summary>
		/// Must be overriden by class that is inheriting to provide the painting for the item.
		/// </summary>
		public override void Paint(ItemPaintArgs p)
		{
			ItemDisplay display=GetItemDisplay();
			display.Paint(this,p);

			if(this.DesignMode && !this.SystemContainer && p.DesignerSelection)
			{
				Graphics g=p.Graphics;
				Rectangle r=this.DisplayRectangle;
				using(Pen pen=new Pen(Color.FromArgb(120,Color.Red),1))
				{
					pen.DashStyle=DashStyle.Dash;
					Display.DrawRoundedRectangle(g,pen,r,3);
				}

				Image image=BarFunctions.LoadBitmap("SystemImages.AddMoreItemsContainer.png");
				g.DrawImageUnscaled(image,r.X+1,r.Y+1);
				return;
			}
		}
Beispiel #18
0
        public override void Paint(ItemPaintArgs pa)
        {
            if (this.SuspendLayout)
                return;

            if (_QueryIconOnPaint && pa.ContainerControl!=null)
            {
                Form parentForm = pa.ContainerControl.FindForm();
                if (parentForm != null)
                {
                    this.SetIcon(parentForm.Icon);
                }
            }

            m_GlassEnabled = pa.GlassEnabled;

            if (pa.Renderer != null)
                pa.Renderer.DrawSystemCaptionItem(new SystemCaptionItemRendererEventArgs(pa.Graphics, this, pa.GlassEnabled));
            else
                base.Paint(pa);
        }
Beispiel #19
0
        public override void Paint(ItemPaintArgs p)
        {
            DayPaintEventArgs e = new DayPaintEventArgs(p, this);
            OnPaintLabel(e);
            if (e.RenderParts == eDayPaintParts.None) return;
            SingleMonthCalendar month = this.Parent as SingleMonthCalendar;
            if (month != null)
            {
                month.OnPaintLabel(this, e);
            }
            if (e.RenderParts == eDayPaintParts.None) return;

            if (this.Enabled && (e.RenderParts & eDayPaintParts.Background) == eDayPaintParts.Background)
                PaintBackground(p);

            if ((e.RenderParts & eDayPaintParts.Text) == eDayPaintParts.Text)
                PaintText(p, null, Color.Empty, _TextAlign);

            if ((e.RenderParts & eDayPaintParts.Image) == eDayPaintParts.Image)
                PaintImage(p, _Image, _ImageAlign);
        }
Beispiel #20
0
		public void Paint(ItemContainer container, ItemPaintArgs p)
		{
			foreach(BaseItem item in container.SubItems)
			{
				if(item.Visible && item.Displayed)
				{
                    if (item.BeginGroup)
                    {
                        if (p.Renderer != null)
                            p.Renderer.DrawItemContainerSeparator(new ItemContainerSeparatorRendererEventArgs(p.Graphics, container, item));
                    }
                    if (p.ClipRectangle.IsEmpty || p.ClipRectangle.IntersectsWith(item.DisplayRectangle))
                    {
                        Region oldClip = p.Graphics.Clip as Region;
                        p.Graphics.SetClip(item.DisplayRectangle, CombineMode.Intersect);
                        if (!p.Graphics.IsClipEmpty)
                            item.Paint(p);
                        p.Graphics.Clip = oldClip;
                        if (oldClip != null) oldClip.Dispose();
                    }
				}
			}
		}
Beispiel #21
0
        public override void Paint(ItemPaintArgs e)
        {
            //e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
            //e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;

            if (_ProgressBarType == eCircularProgressType.Line)
            {
                PaintLineProgressBar(e);
            }
            else if (_ProgressBarType == eCircularProgressType.Dot)
            {
                PaintDotProgressBar(e);
            }
            else if (_ProgressBarType == eCircularProgressType.Donut)
            {
                PaintDonutProgressBar(e);
            }
            else if (_ProgressBarType == eCircularProgressType.Spoke)
            {
                PaintSpokeProgressBar(e);
            }
            else if (_ProgressBarType == eCircularProgressType.Pie)
            {
                PaintPieProgressBar(e);
            }

            PaintLabel(e);
            
            if (this.Focused && this.DesignMode)
            {
                Rectangle r = this.DisplayRectangle;
                r.Inflate(-1, -1);
                DesignTime.DrawDesignTimeSelection(e.Graphics, r, e.Colors.ItemDesignTimeBorder);
            }

            this.DrawInsertMarker(e.Graphics);
        }
Beispiel #22
0
        protected override void PaintState(ButtonItem button, ItemPaintArgs pa, CompositeImage image, Rectangle r, bool isMouseDown)
        {
            if (r.IsEmpty || !IsItemEnabled(button, pa) || r.Width == 0 || r.Height == 0)
                return;

            RibbonTabItem tab = button as RibbonTabItem;
            if (tab == null || IsOnMenu(button, pa))
            {
                base.PaintState(button, pa, image, r, isMouseDown);
                return;
            }

            bool isOnMenu = pa.IsOnMenu;
            Office2007RibbonTabItemColorTable tabColorTable = GetColorTable(tab);
            if (tabColorTable == null)
                return;
            bool ribbonExpanded = pa.ControlExpanded;

            Office2007RibbonTabItemStateColorTable stateColors = GetStateColorTable(tabColorTable, tab, ribbonExpanded);

            if (stateColors == null)
                return;

            Graphics g = pa.Graphics;
            int cornerSize = tabColorTable.CornerSize;
            Region oldClip = g.Clip;
            try
            {
                Rectangle rClip = r;
                rClip.Inflate(1, 0);
                g.SetClip(rClip, CombineMode.Replace);

                if (stateColors != null)
                {
                    eDotNetBarStyle effectiveStyle = button.EffectiveStyle;
                    using (GraphicsPath path = GetTabPath(r, cornerSize, true, effectiveStyle))
                    {
                        DisplayHelp.FillPath(g, path, stateColors.Background);
                        DisplayHelp.DrawGradientPathBorder(g, path, stateColors.OuterBorder, 1);
                    }
                    if (effectiveStyle != eDotNetBarStyle.Metro && tab.Checked && ribbonExpanded && tab.RenderTabState /*|| tab.IsMouseOver*/)
                    {
                        SmoothingMode sm = g.SmoothingMode;
                        g.SmoothingMode = SmoothingMode.Default;

                        if (this.ColorTable.RibbonControl.TabsBackground.Start.GetBrightness() > .5 && !stateColors.OuterBorder.IsEmpty)
                        {
                            using (GraphicsPath path = new GraphicsPath())
                            {
                                path.AddRectangle(new Rectangle(r.Right - 1, r.Y + cornerSize + 1, 1, r.Height - cornerSize - 3));
                                DisplayHelp.FillPath(g, path, Color.FromArgb(96, stateColors.OuterBorder.Start), Color.FromArgb(32, stateColors.OuterBorder.End), 90);
                            }
                            using (GraphicsPath path = new GraphicsPath())
                            {
                                path.AddRectangle(new Rectangle(r.X + 1, r.Y + cornerSize + 1, 1, r.Height - cornerSize - 3));
                                DisplayHelp.FillPath(g, path, Color.FromArgb(32, stateColors.OuterBorder.Start), Color.FromArgb(8, stateColors.OuterBorder.End), 90);
                            }
                        }
                        g.SmoothingMode = sm;
                    }

                    Rectangle r1 = r;
                    r1.Inflate(-1, 0);
                    r1.Height--;
                    r1.Y++;
                    using (GraphicsPath path = GetTabPath(r1, cornerSize, true, effectiveStyle))
                    {
                        DisplayHelp.DrawGradientPathBorder(g, path, stateColors.InnerBorder, 1);
                    }

                    if (tab.Checked && ribbonExpanded && tab.RenderTabState)
                    {
                        using (SolidBrush brush = new SolidBrush(stateColors.InnerBorder.Start))
                        {
                            SmoothingMode sm = g.SmoothingMode;
                            g.SmoothingMode = SmoothingMode.None;
                            g.FillRectangle(brush, new Rectangle(r1.X + cornerSize, r1.Y + 1, r1.Width - cornerSize * 2, 2));
                            g.SmoothingMode = sm;
                        }
                    }

                    float topSplit = .6f;
                    float bottomSplit = .4f;

                    Rectangle fillRectangle = r;
                    Rectangle backRect = new Rectangle(fillRectangle.X, fillRectangle.Y + (int)(fillRectangle.Height * topSplit), fillRectangle.Width, (int)(fillRectangle.Height * bottomSplit));

                    if (!stateColors.BackgroundHighlight.IsEmpty)
                    {
                        Rectangle ellipse = new Rectangle(backRect.X, backRect.Y, fillRectangle.Width, fillRectangle.Height);
                        GraphicsPath path = new GraphicsPath();
                        path.AddEllipse(ellipse);
                        PathGradientBrush brush = new PathGradientBrush(path);
                        brush.CenterColor = stateColors.BackgroundHighlight.Start;
                        brush.SurroundColors = new Color[] { stateColors.BackgroundHighlight.End };
                        brush.CenterPoint = new PointF(ellipse.X + ellipse.Width / 2, fillRectangle.Bottom + 2);
                        Blend blend = new Blend();
                        blend.Factors = new float[] { 0f, .8f, 1f };
                        blend.Positions = new float[] { .0f, .55f, 1f };
                        brush.Blend = blend;
                        g.FillRectangle(brush, backRect);
                        brush.Dispose();
                        path.Dispose();
                    }
                }

                if (tab.ReducedSize && !tab.Checked && !tab.IsMouseOver && tabColorTable != null && tabColorTable.Selected != null)
                {
                    Color c = this.ColorTable.RibbonControl.OuterBorder.Start;
                    if (!c.IsEmpty)
                        DisplayHelp.DrawGradientLine(g, new Point(r.Right - 1, r.Y), new Point(r.Right - 1, r.Bottom - 1),
                            Color.Transparent, c, 90, 1, new float[] { 0, .8f, 1f }, new float[] { 0, .50f, 1f });
                }

                g.Clip = oldClip;
            }
            finally
            {
                if (oldClip != null) oldClip.Dispose();
            }
        }
Beispiel #23
0
        public override void PaintButtonText(ButtonItem button, ItemPaintArgs pa, Color textColor, CompositeImage image)
        {
            eDotNetBarStyle effectiveStyle = button.EffectiveStyle;
            if (!((effectiveStyle == eDotNetBarStyle.Office2010 || effectiveStyle == eDotNetBarStyle.Metro) && pa.GlassEnabled))
            {
                base.PaintButtonText(button, pa, textColor, image);
                return;
            }

            Rectangle r = GetTextRectangle(button, pa, eTextFormat.HorizontalCenter | eTextFormat.VerticalCenter, image);
            //r.Offset(0, 3);
            //r.Height -= 2;
            ThemeTextFormat textFormat = ThemeTextFormat.Center | ThemeTextFormat.VCenter | ThemeTextFormat.HidePrefix | ThemeTextFormat.SingleLine;
            bool renderGlow = true;
            //if (effectiveStyle == eDotNetBarStyle.Office2010 && StyleManager.Style == eStyle.Office2010Black)
            //    renderGlow = false;
            Office2007RibbonControlPainter.PaintTextOnGlass(pa.Graphics, button.Text, pa.Font, r, textFormat, textColor, true, renderGlow, 10);
        }
Beispiel #24
0
 public override eTextFormat GetStringFormat(ButtonItem button, ItemPaintArgs pa, CompositeImage image)
 {
     eTextFormat sf = base.GetStringFormat(button, pa, image);
     sf &= ~(sf & eTextFormat.EndEllipsis);
     return sf;
 }
Beispiel #25
0
        protected override Color GetTextColor(ButtonItem button, ItemPaintArgs pa)
        {
            if (!IsItemEnabled(button, pa) || !(button is RibbonTabItem))
                return base.GetTextColor(button, pa);

            RibbonTabItem tab = button as RibbonTabItem;

            Color textColor = Color.Empty;

            Office2007RibbonTabItemStateColorTable ct = GetStateColorTable(GetColorTable(tab), tab, pa.ControlExpanded);

            if (ct != null)
            {
                if (pa.GlassEnabled && !ct.GlassText.IsEmpty)
                    return ct.GlassText;
                textColor = ct.Text;
            }

            if (textColor.IsEmpty)
                return base.GetTextColor(button, pa);

            return textColor;
        }
Beispiel #26
0
        private void PaintCircular(ItemPaintArgs p)
        {
            Graphics g = p.Graphics;

            Rectangle radialMenuBounds = this.Bounds;
            radialMenuBounds.Width--;
            radialMenuBounds.Height--;

            if (_OpenState < 100)  // Open animation transform setup
            {
                g.ResetTransform();
                g.RotateTransform(-16 * (float)(100 - _OpenState) / 100);
                g.ScaleTransform(((float)Math.Max(1, _OpenState)) / 100, ((float)Math.Max(1, _OpenState)) / 100, MatrixOrder.Append);
                g.TranslateTransform((this.WidthInternal / 2) * (float)(100 - _OpenState) / 100, (this.HeightInternal / 2) * (float)(100 - _OpenState) / 100, MatrixOrder.Append);
            }
            else if (_InnerScale < 100) // For expand animation of inner content
            {
                int openState = _InnerScale;
                g.ScaleTransform(((float)openState) / 100, ((float)openState) / 100, MatrixOrder.Append);
                g.TranslateTransform((this.WidthInternal / 2) * (float)(100 - openState) / 100, (this.HeightInternal / 2) * (float)(100 - openState) / 100, MatrixOrder.Append);
            }
            SubItemsCollection displayCollection = GetDisplayCollection();
            for (int i = 0; i < displayCollection.Count; i++)
            {
                BaseItem item = displayCollection[i];
                if (item.Visible && item.Displayed)
                {
                    if (p.ClipRectangle.IsEmpty || p.ClipRectangle.IntersectsWith(item.DisplayRectangle))
                    {
                        Region oldClip = g.Clip as Region;
                        g.SetClip(item.DisplayRectangle, CombineMode.Intersect);
                        if (!g.IsClipEmpty)
                            item.Paint(p);
                        g.Clip = oldClip;
                        if (oldClip != null) oldClip.Dispose();
                    }
                    //if (_SubItemsInfo != null && _SubItemsInfo[i] != null)
                    //{
                    //    if (_HotSubItemInfoIndex == i)
                    //    {
                    //        g.FillPath(expandMouseOverBrush, _SubItemsInfo[i].Path);
                    //        g.FillPath(expandSignBrush, _SubItemsInfo[i].SignPath);
                    //    }
                    //    else
                    //    {
                    //        g.FillPath(borderBrush, _SubItemsInfo[i].Path);
                    //        g.FillPath(expandSignBrush, _SubItemsInfo[i].SignPath);
                    //    }
                    //}
                }
            }

            g.ResetTransform();
        }
Beispiel #27
0
        public override void Paint(ItemPaintArgs p)
        {
            p.ContextData = _Colors; // Pass to the children
            p.ContextData2 = _MenuType;

#if TRIAL
            if (NativeFunctions.ColorExpAlt())
			{
				StringFormat format=new StringFormat(StringFormat.GenericDefault);
				format.Alignment=StringAlignment.Center;
				format.FormatFlags=format.FormatFlags & ~(format.FormatFlags & StringFormatFlags.NoWrap);	
				p.Graphics.DrawString("Trial period is over.",p.Font,SystemBrushes.Highlight,this.Bounds,format);
				format.Dispose();
				return;
			}
#endif

            if (_MenuType == eRadialMenuType.Circular)
            {
                PaintCircular(p);
                return;
            }

            Graphics g = p.Graphics;
            if (_OpenState < 100)  // Open animation transform setup
            {
                //p.Graphics.RotateTransform(-45 * (float)(100 - _OpenState) / 100);
                int openState = Math.Max(5, _OpenState);
                g.ScaleTransform(((float)openState) / 100, ((float)openState) / 100, MatrixOrder.Append);
                g.TranslateTransform((this.WidthInternal / 2) * (float)(100 - openState) / 100, (this.HeightInternal / 2) * (float)(100 - openState) / 100, MatrixOrder.Append);
            }
            bool drawBackButton = (this.ExpandedItem() != null);

            RadialMenuColorTable renderTable = RadialMenuContainer.GetColorTable();
            RadialMenuColorTable localTable = _Colors;

            Color borderColor = ColorScheme.GetColor(0x2B579A);
            Color borderInactiveColor = Color.FromArgb(128, borderColor);
            Color expandSignForeground = Color.White;
            Color expandMouseOverColor = Color.FromArgb(200, borderColor);
            Color backColor = Color.White;

            if (!localTable.RadialMenuBorder.IsEmpty)
                borderColor = localTable.RadialMenuBorder;
            else if (renderTable != null && !renderTable.RadialMenuBorder.IsEmpty)
                borderColor = renderTable.RadialMenuBorder;

            if (!localTable.RadialMenuBackground.IsEmpty)
                backColor = localTable.RadialMenuBackground;
            else if (renderTable != null && !renderTable.RadialMenuBackground.IsEmpty)
                backColor = renderTable.RadialMenuBackground;

            if (!localTable.RadialMenuInactiveBorder.IsEmpty)
                borderInactiveColor = localTable.RadialMenuInactiveBorder;
            else if (renderTable != null && !renderTable.RadialMenuInactiveBorder.IsEmpty)
                borderInactiveColor = renderTable.RadialMenuInactiveBorder;

            if (!localTable.RadialMenuExpandForeground.IsEmpty)
                expandSignForeground = localTable.RadialMenuExpandForeground;
            else if (renderTable != null && !renderTable.RadialMenuExpandForeground.IsEmpty)
                expandSignForeground = renderTable.RadialMenuExpandForeground;

            if (!localTable.RadialMenuMouseOverBorder.IsEmpty)
                expandMouseOverColor = localTable.RadialMenuMouseOverBorder;
            else if (renderTable != null && !renderTable.RadialMenuMouseOverBorder.IsEmpty)
                expandMouseOverColor = renderTable.RadialMenuMouseOverBorder;


            Brush expandSignBrush = new SolidBrush(expandSignForeground);
            Brush expandMouseOverBrush = new SolidBrush(expandMouseOverColor);
            Brush borderBrush = new SolidBrush(borderColor);


            Rectangle radialMenuBounds = this.Bounds;
            radialMenuBounds.Width--;
            radialMenuBounds.Height--;

            using (GraphicsPath path = new GraphicsPath())
            {
                Rectangle b = radialMenuBounds;
                path.AddEllipse(b);
                Rectangle inner = b;
                inner.Inflate(-(_Diameter - _CenterButtonDiameter) / 2, -(_Diameter - _CenterButtonDiameter) / 2);
                b.Inflate(-_SubMenuEdgeWidth, -_SubMenuEdgeWidth);
                using (GraphicsPath clipPath = new GraphicsPath())
                {
                    if (!drawBackButton && this.Parent == null && string.IsNullOrEmpty(_Symbol) && _Image == null)
                    {
                        clipPath.AddEllipse(inner);
                        g.SetClip(clipPath, CombineMode.Exclude);
                    }
                    using (SolidBrush brush = new SolidBrush(backColor))
                        p.Graphics.FillPath(brush, path);
                    if (!drawBackButton)
                        g.ResetClip();
                }
                b.Inflate(-_SubMenuEdgeWidthAnimated, -_SubMenuEdgeWidthAnimated); // Used by animation to show transition from to sub-items
                path.AddEllipse(b);
                //p.Graphics.DrawEllipse(Pens.Red, this.Bounds);
                using (Brush brush = new SolidBrush(borderInactiveColor))
                {
                    g.FillPath(brush, path);
                    using (Pen pen = new Pen(borderColor, 2))
                        g.DrawEllipse(pen, inner);
                }

                if (drawBackButton)
                {
                    Font symFont = Symbols.GetFontAwesome(_BackSymbolSize);
                    Size symSize = TextDrawing.MeasureString(g, _BackSymbol, symFont);
                    int descent = (int)Math.Ceiling((symFont.FontFamily.GetCellDescent(symFont.Style) *
                        symFont.Size / symFont.FontFamily.GetEmHeight(symFont.Style)));
                    symSize.Height -= descent;
                    TextDrawing.DrawStringLegacy(g, _BackSymbol, symFont, borderColor,
                        new Rectangle(inner.X + (inner.Width - symSize.Width) / 2 + 1, inner.Y + (inner.Height - symSize.Height) / 2 + 1, 0, 0),
                        eTextFormat.Default);
                }
                else if (!string.IsNullOrEmpty(_Symbol))
                {
                    Font symFont = Symbols.GetFontAwesome(_SymbolSize);
                    if (_SymbolTextSize.IsEmpty)
                    {
                        _SymbolTextSize = TextDrawing.MeasureString(g, _Symbol, symFont);
                        int descent = (int)Math.Ceiling((symFont.FontFamily.GetCellDescent(symFont.Style) *
                            symFont.Size / symFont.FontFamily.GetEmHeight(symFont.Style)));
                        _SymbolTextSize.Height -= descent;
                    }
                    TextDrawing.DrawStringLegacy(g, _Symbol, symFont, borderColor,
                        new Rectangle(inner.X + (inner.Width - _SymbolTextSize.Width) / 2 + 1, inner.Y + (inner.Height - _SymbolTextSize.Height) / 2 + 1, 0, 0),
                        eTextFormat.Default);
                }
                else if (_Image != null)
                {
                    g.DrawImage(_Image, inner.X + (inner.Width - _Image.Width) / 2, inner.Y + (inner.Height - _Image.Height) / 2);
                }
            }

            if (_OpenState < 100)  // Open animation transform setup
            {
                g.ResetTransform();
                g.RotateTransform(-16 * (float)(100 - _OpenState) / 100);
                g.ScaleTransform(((float)Math.Max(1, _OpenState)) / 100, ((float)Math.Max(1, _OpenState)) / 100, MatrixOrder.Append);
                g.TranslateTransform((this.WidthInternal / 2) * (float)(100 - _OpenState) / 100, (this.HeightInternal / 2) * (float)(100 - _OpenState) / 100, MatrixOrder.Append);
            }
            else if (_InnerScale < 100) // For expand animation of inner content
            {
                int openState = _InnerScale;
                g.ScaleTransform(((float)openState) / 100, ((float)openState) / 100, MatrixOrder.Append);
                g.TranslateTransform((this.WidthInternal / 2) * (float)(100 - openState) / 100, (this.HeightInternal / 2) * (float)(100 - openState) / 100, MatrixOrder.Append);
            }
            SubItemsCollection displayCollection = GetDisplayCollection();
            for (int i = 0; i < displayCollection.Count; i++)
            {
                BaseItem item = displayCollection[i];
                if (item.Visible && item.Displayed)
                {
                    if (p.ClipRectangle.IsEmpty || p.ClipRectangle.IntersectsWith(item.DisplayRectangle))
                    {
                        Region oldClip = g.Clip as Region;
                        g.SetClip(item.DisplayRectangle, CombineMode.Intersect);
                        if (!g.IsClipEmpty)
                            item.Paint(p);
                        g.Clip = oldClip;
                        if (oldClip != null) oldClip.Dispose();
                    }
                    if (_SubItemsInfo != null && _SubItemsInfo[i] != null)
                    {
                        if (_HotSubItemInfoIndex == i)
                        {
                            g.FillPath(expandMouseOverBrush, _SubItemsInfo[i].Path);
                            g.FillPath(expandSignBrush, _SubItemsInfo[i].SignPath);
                        }
                        else
                        {
                            g.FillPath(borderBrush, _SubItemsInfo[i].Path);
                            g.FillPath(expandSignBrush, _SubItemsInfo[i].SignPath);
                        }
                    }
                }
            }

            expandSignBrush.Dispose();
            expandSignBrush = null;
            expandMouseOverBrush.Dispose();
            expandMouseOverBrush = null;
            borderBrush.Dispose();
            borderBrush = null;

            g.ResetTransform();
        }
Beispiel #28
0
 public override void Paint(ItemPaintArgs p)
 {
 }
Beispiel #29
0
 internal virtual ItemPaintArgs GetItemPaintArgs(Graphics g)
 {
     ItemPaintArgs pa = new ItemPaintArgs(this, this, g, GetColorScheme());
     pa.Renderer = this.GetRenderer();
     pa.ButtonStringFormat = pa.ButtonStringFormat & ~(pa.ButtonStringFormat & eTextFormat.SingleLine);
     pa.ButtonStringFormat |= (eTextFormat.WordBreak | eTextFormat.EndEllipsis);
     return pa;
 }
Beispiel #30
0
		/// <summary>
		/// Must be overridden by class that is inheriting to provide the painting for the item.
		/// </summary>
		public abstract void Paint(ItemPaintArgs p);