Example #1
0
		private static void DrawBorderLine(Graphics g,Point[] p,eStyleBorderType border,int lineWidth, Color colorStart, Color colorEnd, Color colorLightStart, Color colorLightEnd, eBorderSide side)
		{
            if (border == eStyleBorderType.Etched || border == eStyleBorderType.Double)
            {
                if (colorLightStart.IsEmpty)
                {
                    colorLightStart = System.Windows.Forms.ControlPaint.Light(colorStart);
                    colorStart = System.Windows.Forms.ControlPaint.Dark(colorStart);
                }

                if (side == eBorderSide.Bottom || side == eBorderSide.Right)
                {
                    Color ct1 = colorStart;
                    Color ct2 = colorEnd;
                    colorStart = colorLightStart;
                    colorEnd = colorLightEnd;
                    colorLightStart = ct1;
                    colorLightEnd = ct2;
                }

                DisplayHelp.DrawGradientLine(g, p[0], p[1], colorStart, colorEnd, 90, lineWidth);
                
                if (side == eBorderSide.Top)
                {
                    p[0].Y+=lineWidth;
                    p[1].Y += lineWidth;
                }
                else if (side == eBorderSide.Bottom)
                {
                    p[0].Y -= lineWidth;
                    p[1].Y -= lineWidth;
                }
                else if (side == eBorderSide.Left || side == eBorderSide.BottomLeft || side == eBorderSide.TopLeft)
                {
                    p[0].X += lineWidth;
                    p[1].X += lineWidth;
                }
                else if (side == eBorderSide.Right || side == eBorderSide.BottomRight || side == eBorderSide.TopRight)
                {
                    p[0].X -= lineWidth;
                    p[1].X -= lineWidth;
                }

                DisplayHelp.DrawGradientLine(g, p[0], p[1], colorLightStart, colorLightEnd, 90, lineWidth);
            }
            else
            {
                DisplayHelp.DrawGradientLine(g, p[0], p[1], colorStart, colorEnd, 90, lineWidth);
            }
		}
Example #2
0
        internal static void DrawBorder(Graphics g, eBorderType bordertype, Rectangle r, Color singleLineColor, eBorderSide side, System.Drawing.Drawing2D.DashStyle borderDashStyle, int lineWidth)
        {
            if (lineWidth <= 0) return;
            System.Windows.Forms.Border3DSide border3dside;
            if (side == eBorderSide.All)
                border3dside = System.Windows.Forms.Border3DSide.All;
            else
                border3dside = (((side | eBorderSide.Left) != 0) ? System.Windows.Forms.Border3DSide.Left : 0) |
                (((side | eBorderSide.Right) != 0) ? System.Windows.Forms.Border3DSide.Right : 0) |
                (((side | eBorderSide.Top) != 0) ? System.Windows.Forms.Border3DSide.Top : 0) |
                (((side | eBorderSide.Bottom) != 0) ? System.Windows.Forms.Border3DSide.Bottom : 0);

            switch (bordertype)
            {
                case eBorderType.Bump:
                    {
                        System.Windows.Forms.ControlPaint.DrawBorder3D(g, r, System.Windows.Forms.Border3DStyle.Bump, border3dside);
                        break;
                    }
                case eBorderType.Etched:
                    System.Windows.Forms.ControlPaint.DrawBorder3D(g, r, System.Windows.Forms.Border3DStyle.Etched, border3dside);
                    break;
                case eBorderType.Raised:
                    System.Windows.Forms.ControlPaint.DrawBorder3D(g, r, System.Windows.Forms.Border3DStyle.RaisedInner, border3dside);
                    break;
                case eBorderType.Sunken:
                    System.Windows.Forms.ControlPaint.DrawBorder3D(g, r, System.Windows.Forms.Border3DStyle.SunkenOuter, border3dside);
                    break;
                case eBorderType.SingleLine:
                    {
                        SmoothingMode sm = g.SmoothingMode;
                        g.SmoothingMode = SmoothingMode.None;
                        using (Pen pen = new Pen(singleLineColor, lineWidth))
                        {
                            pen.DashStyle = borderDashStyle;
                            int offset = lineWidth / 2;
                            if ((side & eBorderSide.Left) != 0)
                                g.DrawLine(pen, r.X + offset, r.Y, r.X + offset, r.Bottom - 1);
                            if ((side & eBorderSide.Top) != 0)
                                g.DrawLine(pen, r.X, r.Y + offset, r.Right - 1, r.Y + offset);
                            if (offset == 0) offset = 1;
                            if ((side & eBorderSide.Right) != 0)
                                g.DrawLine(pen, r.Right - offset, r.Y, r.Right - offset, r.Bottom - 1);
                            if ((side & eBorderSide.Bottom) != 0)
                                g.DrawLine(pen, r.X, r.Bottom - offset, r.Right - 1, r.Bottom - offset);
                        }
                        g.SmoothingMode = sm;
                        break;
                    }
                case eBorderType.DoubleLine:
                    {
                        using (Pen pen = new Pen(singleLineColor, lineWidth))
                        {
                            pen.DashStyle = borderDashStyle;
                            for (int i = 0; i < lineWidth + 1; i += lineWidth)
                            {
                                if ((side & eBorderSide.Left) != 0)
                                    g.DrawLine(pen, r.X, r.Y, r.X, r.Bottom - 1);
                                if ((side & eBorderSide.Top) != 0)
                                    g.DrawLine(pen, r.X, r.Y, r.Right - 1, r.Y);
                                if ((side & eBorderSide.Right) != 0)
                                    g.DrawLine(pen, r.Right - 1, r.Y, r.Right - 1, r.Bottom - 1);
                                if ((side & eBorderSide.Bottom) != 0)
                                    g.DrawLine(pen, r.X, r.Bottom - 1, r.Right - 1, r.Bottom - 1);
                                r.Inflate(-1, -1);
                            }

                        }
                        break;
                    }
                default:
                    break;
            }
        }
Example #3
0
 internal static void DrawBorder(Graphics g, eBorderType bordertype, Rectangle r, Color singleLineColor, eBorderSide side, System.Drawing.Drawing2D.DashStyle borderDashStyle)
 {
     DrawBorder(g, bordertype, r, singleLineColor, side, borderDashStyle, 1);
 }
Example #4
0
        private static void DrawBorderLine(Graphics g, Point[] p, eStyleBorderType border, int lineWidth, Color colorStart, Color colorEnd, Color colorLightStart, Color colorLightEnd, eBorderSide side, BorderDrawInfo drawInfo)
        {
            if (border == eStyleBorderType.Etched || border == eStyleBorderType.Double)
            {
                if (colorLightStart.IsEmpty)
                {
                    colorLightStart = System.Windows.Forms.ControlPaint.Light(colorStart);
                    colorStart = System.Windows.Forms.ControlPaint.Dark(colorStart);
                }

                if (drawInfo.IsTwistedDoubleBorder && (side == eBorderSide.Bottom || side == eBorderSide.Right))
                {
                    Color ct1 = colorStart;
                    Color ct2 = colorEnd;
                    colorStart = colorLightStart;
                    colorEnd = colorLightEnd;
                    colorLightStart = ct1;
                    colorLightEnd = ct2;
                }

                DisplayHelp.DrawGradientLine(g, p[0], p[1], colorStart, colorEnd, 90, lineWidth);

                if (side == eBorderSide.Top)
                {
                    p[0].Y += lineWidth;
                    p[1].Y += lineWidth;
                    if (drawInfo.HasLeftBorder)
                        p[0].X += 1;
                    if (drawInfo.HasRightBorder)
                        p[1].X -= 1;
                }
                else if (side == eBorderSide.Bottom)
                {
                    p[0].Y -= lineWidth;
                    p[1].Y -= lineWidth;
                    if (!drawInfo.IsTwistedDoubleBorder)
                    {
                        if (drawInfo.HasLeftBorder)
                            p[0].X += 1;
                        if (drawInfo.HasRightBorder)
                            p[1].X -= 1;
                    }
                }
                else if (side == eBorderSide.Left || side == eBorderSide.BottomLeft || side == eBorderSide.TopLeft)
                {
                    p[0].X += lineWidth;
                    p[1].X += lineWidth;
                    if (drawInfo.HasTopBorder)
                        p[0].Y += 1;
                    if (drawInfo.HasBottomBorder)
                        p[1].Y -= 1;
                }
                else if (side == eBorderSide.Right || side == eBorderSide.BottomRight || side == eBorderSide.TopRight)
                {
                    p[0].X -= lineWidth;
                    p[1].X -= lineWidth;
                    if (!drawInfo.IsTwistedDoubleBorder)
                    {
                        if (drawInfo.HasTopBorder)
                            p[0].Y += 1;
                        if (drawInfo.HasBottomBorder)
                            p[1].Y -= 1;
                    }
                }

                DisplayHelp.DrawGradientLine(g, p[0], p[1], colorLightStart, colorLightEnd, 90, lineWidth);
            }
            else
            {
                if (colorEnd.IsEmpty)
                {
                    SmoothingMode sm = g.SmoothingMode;
                    g.SmoothingMode = SmoothingMode.None;
                    using (Pen pen = CreatePen(border, lineWidth, colorStart))
                        g.DrawLine(pen, p[0], p[1]);
                    g.SmoothingMode = sm;
                }
                else
                    DisplayHelp.DrawGradientLine(g, p[0], p[1], colorStart, colorEnd, 90, lineWidth);
            }
        }
Example #5
0
		public override void Deserialize(ItemSerializationContext context)
		{
			base.Deserialize(context);

            System.Xml.XmlElement ItemXmlSource = context.ItemXmlElement;

			m_BorderType=(eBorderType)System.Xml.XmlConvert.ToInt32(ItemXmlSource.GetAttribute("bt"));

            if (ItemXmlSource.HasAttribute("BorderSide"))
                m_BorderSide = (eBorderSide)System.Xml.XmlConvert.ToInt32(ItemXmlSource.GetAttribute("BorderSide"));
            else
                m_BorderSide = DEFAULT_BORDERSIDE;

			if(ItemXmlSource.HasAttribute("bc"))
                m_BackColor=BarFunctions.ColorFromString(ItemXmlSource.GetAttribute("bc"));
			else
				m_BackColor=Color.Empty;
			m_ForeColor=BarFunctions.ColorFromString(ItemXmlSource.GetAttribute("fc"));

            if (ItemXmlSource.HasAttribute("sc"))
            {
                m_SingleLineColor = BarFunctions.ColorFromString(ItemXmlSource.GetAttribute("sc"));
                if (m_SingleLineColor != SystemColors.ControlDark)
                    m_SingleLineColorCustom = true;
            }
            else
            {
                m_SingleLineColorCustom = false;
                m_SingleLineColor = SystemColors.ControlDark;
            }

			m_TextAlignment=(StringAlignment)System.Xml.XmlConvert.ToInt32(ItemXmlSource.GetAttribute("ta"));
			m_TextLineAlignment=(StringAlignment)System.Xml.XmlConvert.ToInt32(ItemXmlSource.GetAttribute("tla"));

			m_DividerStyle=System.Xml.XmlConvert.ToBoolean(ItemXmlSource.GetAttribute("ds"));

            m_PaddingLeft=System.Xml.XmlConvert.ToInt32(ItemXmlSource.GetAttribute("pl"));
			m_PaddingRight=System.Xml.XmlConvert.ToInt32(ItemXmlSource.GetAttribute("pr"));
			m_PaddingTop=System.Xml.XmlConvert.ToInt32(ItemXmlSource.GetAttribute("pt"));
			m_PaddingBottom=System.Xml.XmlConvert.ToInt32(ItemXmlSource.GetAttribute("pb"));

			m_Width=System.Xml.XmlConvert.ToInt32(ItemXmlSource.GetAttribute("w"));
			m_Height=System.Xml.XmlConvert.ToInt32(ItemXmlSource.GetAttribute("h"));

			// Load font information if it exists
			if(ItemXmlSource.HasAttribute("fontname"))
			{
				string FontName=ItemXmlSource.GetAttribute("fontname");
				float FontSize=System.Xml.XmlConvert.ToSingle(ItemXmlSource.GetAttribute("fontemsize"));
				System.Drawing.FontStyle FontStyle=(System.Drawing.FontStyle)System.Xml.XmlConvert.ToInt32(ItemXmlSource.GetAttribute("fontstyle"));
				try
				{
					this.Font=new Font(FontName,FontSize,FontStyle);
				}
				catch(Exception)
				{
                    this.Font = SystemFonts.DefaultFont; // System.Windows.Forms.SystemInformation.MenuFont.Clone() as Font;
				}
			}

			// Load Images
			foreach(System.Xml.XmlElement xmlElem in ItemXmlSource.ChildNodes)
			{
				if(xmlElem.Name=="images")
				{
					if(xmlElem.HasAttribute("imageindex"))
						m_ImageIndex=System.Xml.XmlConvert.ToInt32(xmlElem.GetAttribute("imageindex"));

					foreach(System.Xml.XmlElement xmlElem2 in xmlElem.ChildNodes)
					{
						switch(xmlElem2.GetAttribute("type"))
						{
							case "default":
							{
								m_Image=BarFunctions.DeserializeImage(xmlElem2);
								m_ImageIndex=-1;
								break;
							}
							case "icon":
							{
								m_Icon=BarFunctions.DeserializeIcon(xmlElem2);
								m_ImageIndex=-1;
								break;
							}
						}
					}
					break;
				}
			}
		}
Example #6
0
		internal void ApplyStyle(ItemStyle style)
		{
			if(style==null)
				return;

			m_Alignment=style.Alignment;
			if(!style.BackColor1.IsEmpty)
				m_BackColor1=style.BackColor1;
			if(!style.BackColor2.IsEmpty)
				m_BackColor2=style.BackColor2;
			if(style.BackgroundImage!=null)
                m_BackgroundImage=style.BackgroundImage;
			if(style.BackgroundImageAlpha!=255)
				m_BackgroundImageAlpha=style.BackgroundImageAlpha;
			if(style.BackgroundImagePosition!=eBackgroundImagePosition.Stretch)
				m_BackgroundImagePosition=style.BackgroundImagePosition;
			if(style.Border!=eBorderType.None)
				m_Border=style.Border;
			if(style.BorderDashStyle!=DashStyle.Solid)
				m_BorderDashStyle=style.BorderDashStyle;
			if(!style.BorderColor.IsEmpty)
				m_BorderColor=style.BorderColor;
			if(style.BorderSide!=DEFAULT_BORDERSIDE)
				m_BorderSide=style.BorderSide;
			if(style.BorderWidth!=1)
				m_BorderWidth=style.BorderWidth;
			if(style.Font!=null)
				m_Font=style.Font;
			if(!style.ForeColor.IsEmpty)
				m_ForeColor=style.ForeColor;
			if(style.LineAlignment!=StringAlignment.Center)
				m_LineAlignment=style.LineAlignment;
			if(style.TextTrimming!=StringTrimming.EllipsisCharacter)
				m_TextTrimming=style.TextTrimming;
			if(style.WordWrap!=false)
				m_WordWrap=style.WordWrap;
			if(style.MarginBottom!=0)
				m_MarginBottom=style.MarginBottom;
			if(style.MarginLeft!=0)
				m_MarginLeft=style.MarginLeft;
			if(style.MarginRight!=0)
				m_MarginRight=style.MarginRight;
			if(style.MarginTop!=0)
				m_MarginTop=style.MarginTop;
            if(style.CornerType!=eCornerType.Square)
				m_CornerType=style.CornerType;
			if(style.CornerDiameter!=DEFAULT_CORNER_DIAMETER)
				m_CornerDiameter=style.CornerDiameter;
            if (style.VerticalText)
                m_VerticalText = style.VerticalText;
            if (!style.UseMnemonic)
                _UseMnemonic = style.UseMnemonic;
		}