public List<StyleInfo> GUIAddStyles(GUISkin skin, List<StyleInfo> customStyles )
	{
		foreach (GUIStyle style in skin.customStyles)
		{
			StyleInfo info = new StyleInfo(skin.name,skin,style);
			if ( style != null && HasStyle(customStyles,style.name) == false )
				customStyles.Add(info);
		}
		return customStyles;
	}
示例#2
0
 public StyleInfo Clone()
 {
     StyleInfo si = new StyleInfo();
     si.pft = this.pft;
     si.brushClr = this.brushClr;
     si.dashArray = this.dashArray;
     si.penClr = this.penClr;
     si.penWidth = this.penWidth;
     si.showCoords = this.showCoords;
     return si;
 }
	public List<StyleInfo> GUIGetStyles(List<StyleInfo> customStyles)
	{
		foreach( GUIScreen screen in ScreenInfo.Screens )
		{
			StyleInfo info = new StyleInfo(screen.name,screen.Skin,screen.Style);
			if ( screen.Style != null && HasStyle(customStyles,screen.Style.name) == false )
				customStyles.Add(info);
		
			foreach( GUIObject element in screen.Elements )
			{
				FindStyles(element,customStyles);
			}
		}
		
		return customStyles;
	}
示例#4
0
 public SVGBuilder()
 {
     PolyInfoList = new List <PolyInfo>();
     style        = new StyleInfo();
 }
示例#5
0
 /// <summary>
 /// Creates a new unique rule with specified parameters.
 /// </summary>
 /// <param name="style">The style.</param>
 /// <returns>The new unique rule.</returns>
 public static DuplicateRule Create(StyleInfo style)
 {
     return(new DuplicateRule(style));
 }
        private void DrawString(PageText pt, StringBuilder sb, Rectangle r)
        {
            StyleInfo si = pt.SI;
            string    s  = pt.Text;

            /*
             *          <Canvas Name ="obj3" Canvas.Left="10" Canvas.Top="2" Height="20" Width="180" Background="Blue"
             *                          MouseLeftButtonDown="riDown" MouseMove="riMove" MouseLeftButtonUp="riUp" >
             *                  <Canvas.Clip>
             *                          <RectangleGeometry Rect="0,0,180,20" />
             *                  </Canvas.Clip>
             *
             *                  <TextBlock FontFamily="Arial"
             *                     FontSize="25" Text="This text is in xxx footer">
             *                  </TextBlock>
             *          </Canvas>
             * */

            // adjust drawing rectangle based on padding
            Rectangle r2;

            //if (si.WritingMode == WritingModeEnum.tb_rl)
            //{   // we're going to rotate the text so width will be height and height will be width
            //    r2 = new Rectangle(r.Left + PixelsX(si.PaddingLeft),
            //                               r.Top + PixelsY(si.PaddingTop),
            //                               r.Height - PixelsY(si.PaddingTop - si.PaddingBottom),
            //                               r.Width - PixelsX(si.PaddingLeft - si.PaddingRight));
            //}
            //else
            r2 = new Rectangle(r.Left + PixelsX(si.PaddingLeft),
                               r.Top + PixelsY(si.PaddingTop),
                               r.Width - PixelsX(si.PaddingLeft - si.PaddingRight),
                               r.Height - PixelsY(si.PaddingTop - si.PaddingBottom));
            if (r2.Height == 0 || r2.Width == 0)
            {
                sb.AppendFormat("<Canvas Name=\"{0}\" Canvas.Left=\"{1}\" Canvas.Top=\"{2}\" Background=\"{3}\" >",
                                GetName(pt), r2.Left, r2.Top, GetColor(si.BackgroundColor));
            }
            else
            {
                sb.AppendFormat("<Canvas Name=\"{0}\" Canvas.Left=\"{1}\" Canvas.Top=\"{2}\" Height=\"{3}\" Width=\"{4}\" Background=\"{5}\" >",
                                GetName(pt), r2.Left, r2.Top, r2.Height, r2.Width, GetColor(si.BackgroundColor));
                //            DrawBackground(sb, si);  // this would need some additional work to support gradient and textblock

                sb.AppendFormat("<Canvas.Clip><RectangleGeometry Rect=\"0,0,{0},{1}\" /></Canvas.Clip>", PixelsX(pt.W), PixelsY(pt.H));
            }

            sb.AppendFormat("<TextBlock TextWrapping=\"Wrap\" FontFamily=\"{0}\" Foreground=\"{1}\" FontSize=\"{2}\"",
                            si.FontFamily, GetColor(si.Color), si.FontSize);

            if (si.FontStyle == FontStyleEnum.Italic)
            {
                sb.Append(" FontStyle=\"Italic\"");
            }

            if (si.TextDecoration == TextDecorationEnum.Underline)
            {
                sb.Append(" TextDecorations=\"Underline\"");
            }

            if (si.WritingMode == WritingModeEnum.tb_rl)        // we need to rotate text
            {
                sb.AppendFormat(" RenderTransformOrigin=\"0.0,0.0\" Canvas.Left=\"{0}\"", r2.Width);
            }

            // WEIGHT
            switch (si.FontWeight)
            {
            case FontWeightEnum.Lighter:
                sb.Append(" FontWeight=\"Light\"");
                break;

            case FontWeightEnum.W500:
            case FontWeightEnum.Bold:
                sb.Append(" FontWeight=\"Bold\"");
                break;

            case FontWeightEnum.Bolder:
                sb.Append(" FontWeight=\"ExtraBold\"");
                break;

            case FontWeightEnum.W600:
            case FontWeightEnum.W700:
                sb.Append(" FontWeight=\"Black\"");
                break;

            case FontWeightEnum.W800:
            case FontWeightEnum.W900:
                sb.Append(" FontWeight=\"ExtraBlack\"");
                break;

            case FontWeightEnum.Normal:
            default:
                sb.Append(" FontWeight=\"Normal\"");
                break;
            }

            /*
             * // ALIGNMENT not supported in SilverLight 1.0
             *  switch (si.TextAlign)
             *  {
             *      case TextAlignEnum.Right:
             *          break;
             *      case TextAlignEnum.Center:
             *          break;
             *      case TextAlignEnum.Left:
             *      default:
             *          break;
             *  }
             *  switch (si.VerticalAlign)
             *  {
             *      case VerticalAlignEnum.Bottom:
             *          break;
             *      case VerticalAlignEnum.Middle:
             *          break;
             *      case VerticalAlignEnum.Top:
             *      default:
             *          break;
             *  }
             */
            sb.Append("><Run>");
            sb.Append(fyiReporting.RDL.XmlUtil.XmlAnsi(pt.Text));
            sb.Append("</Run>");
            if (si.WritingMode == WritingModeEnum.tb_rl)
            {
                sb.AppendFormat("<TextBlock.RenderTransform><RotateTransform Angle=\"90\"/></TextBlock.RenderTransform>");
                //sb.AppendFormat("<TextBlock.RenderTransform><RotateTransform Angle=\"90\" CenterX=\"{0}\" CenterY=\"{1}\"/></TextBlock.RenderTransform>",
                //    r2.Width, r2.Height);
            }
            sb.Append("</TextBlock>");
            sb.Append("</Canvas>");
        }
示例#7
0
        private void DrawBackground(Xwt.Drawing.Context g, Xwt.Rectangle rect, StyleInfo si)
        {
            //            LinearGradientBrush linGrBrush = null;
            //            SolidBrush sb = null;
            if (si.BackgroundColor.IsEmpty)
            {
                return;
            }

            g.Save();

            Xwt.Drawing.Color c = XwtColor.SystemColorToXwtColor(si.BackgroundColor);

            Xwt.Drawing.Gradient gradient = null;

            if (si.BackgroundGradientType != BackgroundGradientTypeEnum.None &&
                !si.BackgroundGradientEndColor.IsEmpty)
            {
                Xwt.Drawing.Color ec = XwtColor.SystemColorToXwtColor(si.BackgroundGradientEndColor);

                switch (si.BackgroundGradientType)
                {
                case BackgroundGradientTypeEnum.LeftRight:
                    //                            linGrBrush = new LinearGradientBrush(rect, c, ec, LinearGradientMode.Horizontal);
                    gradient = new Xwt.Drawing.LinearGradient(rect.X, rect.Y, rect.X + rect.Width, rect.Y);
                    break;

                case BackgroundGradientTypeEnum.TopBottom:
                    //                            linGrBrush = new LinearGradientBrush(rect, c, ec, LinearGradientMode.Vertical);
                    gradient = new Xwt.Drawing.LinearGradient(rect.X, rect.Y, rect.X, rect.Y + rect.Height);
                    break;

                case BackgroundGradientTypeEnum.Center:
                    //                            linGrBrush = new LinearGradientBrush(rect, c, ec, LinearGradientMode.Horizontal);
                    throw new NotSupportedException();

                //                            break;
                case BackgroundGradientTypeEnum.DiagonalLeft:
                    //                            linGrBrush = new LinearGradientBrush(rect, c, ec, LinearGradientMode.ForwardDiagonal);
                    gradient = new Xwt.Drawing.LinearGradient(rect.X, rect.Y, rect.X + rect.Width, rect.Y + rect.Height);
                    break;

                case BackgroundGradientTypeEnum.DiagonalRight:
                    //                            linGrBrush = new LinearGradientBrush(rect, c, ec, LinearGradientMode.BackwardDiagonal);
                    gradient = new Xwt.Drawing.LinearGradient(rect.X + rect.Width, rect.Y + rect.Height, rect.X, rect.Y);
                    break;

                case BackgroundGradientTypeEnum.HorizontalCenter:
                    //                            linGrBrush = new LinearGradientBrush(rect, c, ec, LinearGradientMode.Horizontal);
                    throw new NotSupportedException();

                //							break;
                case BackgroundGradientTypeEnum.VerticalCenter:
                    //                            linGrBrush = new LinearGradientBrush(rect, c, ec, LinearGradientMode.Vertical);
                    throw new NotSupportedException();

                //							break;
                default:
                    break;
                }

                gradient.AddColorStop(0, c);
                gradient.AddColorStop(1, ec);
            }

            if (gradient != null)
            {
                // TODO: Fix
                //g.FillRectangle(rect, gradient);
            }
            else if (!si.BackgroundColor.IsEmpty)
            {
                // TODO: Fix
                //g.FillRectangle(rect, c);
            }
            g.Restore();
        }
示例#8
0
 /// <summary>
 /// Creates a cell value data rule with specified parameters.
 /// </summary>
 /// <param name="op">
 /// The comparison operator <see cref="T:Dt.Cells.Data.ComparisonOperator" /> for the text rule.
 /// </param>
 /// <param name="value1">The first object.</param>
 /// <param name="value2">The second object.</param>
 /// <param name="style">The style that is set by the rule.</param>
 /// <returns>The new cell value rule.</returns>
 public static CellValueRule Create(ComparisonOperator op, object value1, object value2, StyleInfo style)
 {
     return(new CellValueRule(op, value1, value2, style));
 }
 private static bool CellFormatsAreEqual(CellFormat f, StyleInfo styleInfo)
 {
     return
         f.BorderId != null && styleInfo.BorderId == f.BorderId
         && f.FillId != null && styleInfo.FillId == f.FillId
         && f.FontId != null && styleInfo.FontId == f.FontId
         && f.NumberFormatId != null && styleInfo.NumberFormatId == f.NumberFormatId
         && f.ApplyNumberFormat != null && f.ApplyNumberFormat == false
         && f.ApplyAlignment != null && f.ApplyAlignment == false
         && f.ApplyFill != null && f.ApplyFill == ApplyFill(styleInfo)
         && f.ApplyBorder != null && f.ApplyBorder == ApplyBorder(styleInfo)
         && AlignmentsAreEqual(f.Alignment, styleInfo.Style.Alignment)
         && ProtectionsAreEqual(f.Protection, styleInfo.Style.Protection)
         ;
 }
示例#10
0
文件: FormulaRule.cs 项目: Daoting/dt
 /// <summary>
 /// Creates a new text rule with the specified comparison operator, text, and style.
 /// </summary>
 /// <param name="formula">Formula.</param>
 /// <param name="style">Cell style.</param>
 internal FormulaRule(string formula, StyleInfo style) : base(style)
 {
     this.formula = formula;
 }
示例#11
0
        private void SelectionChanged(object sender, System.EventArgs e)
        {
            // handle edit tab first
            if (rdlEditPreview1.DesignTab == DesignTabs.Edit)
            {
                SetStatusNameAndPosition();
                return;
            }

            bSuppressChange = true;                     // don't process changes in status bar

            SetStatusNameAndPosition();
            this.EnableEditTextBox();   // handling enabling/disabling of textbox

            StyleInfo si = rdlEditPreview1.SelectedStyle;

            if (si == null)
            {
                return;
            }

            if (centerAlignToolStripButton2 != null)
            {
                centerAlignToolStripButton2.Checked = si.TextAlign == TextAlignEnum.Center ? true : false;
            }
            if (leftAlignToolStripButton2 != null)
            {
                leftAlignToolStripButton2.Checked = si.TextAlign == TextAlignEnum.Left ? true : false;
            }
            if (rightAlignToolStripButton3 != null)
            {
                rightAlignToolStripButton3.Checked = si.TextAlign == TextAlignEnum.Right ? true : false;
            }
            if (boldToolStripButton1 != null)
            {
                boldToolStripButton1.Checked = si.IsFontBold() ? true : false;
            }
            if (italiacToolStripButton1 != null)
            {
                italiacToolStripButton1.Checked = si.FontStyle == FontStyleEnum.Italic ? true : false;
            }
            if (underlineToolStripButton2 != null)
            {
                underlineToolStripButton2.Checked = si.TextDecoration == TextDecorationEnum.Underline ? true : false;
            }
            if (fontToolStripComboBox1 != null)
            {
                fontToolStripComboBox1.Text = si.FontFamily;
            }
            if (fontSizeToolStripComboBox1 != null)
            {
                string rs = string.Format(NumberFormatInfo.InvariantInfo, "{0:0.#}", si.FontSize);
                fontSizeToolStripComboBox1.Text = rs;
            }
            if (foreColorPicker1 != null)
            {
                foreColorPicker1.Text = si.Color.IsEmpty ? si.ColorText : ColorTranslator.ToHtml(si.Color);
            }
            if (backColorPicker1 != null)
            {
                backColorPicker1.Text = si.BackgroundColor.IsEmpty ? si.BackgroundColorText : ColorTranslator.ToHtml(si.BackgroundColor);
            }

            bSuppressChange = false;
        }
示例#12
0
        private void DrawString(PageText pt, Cairo.Context g, Cairo.Rectangle r)
        {
            StyleInfo si = pt.SI;
            string    s  = pt.Text;

            g.Save();

            layout = Pango.CairoHelper.CreateLayout(g);

//            Font drawFont = null;
//            StringFormat drawFormat = null;
//            Brush drawBrush = null;


            // STYLE
//                System.Drawing.FontStyle fs = 0;
//                if (si.FontStyle == FontStyleEnum.Italic)
//                    fs |= System.Drawing.FontStyle.Italic;
            //Pango fonts are scaled to 72dpi, Windows fonts uses 96dpi
            float fontsize = (si.FontSize * 72 / 96);
            var   font     = Pango.FontDescription.FromString(string.Format("{0} {1}", si.GetFontFamily().Name,
                                                                            fontsize * PixelsX(1)));

            if (si.FontStyle == FontStyleEnum.Italic)
            {
                font.Style = Pango.Style.Italic;
            }
//
//                switch (si.TextDecoration)
//                {
//                    case TextDecorationEnum.Underline:
//                        fs |= System.Drawing.FontStyle.Underline;
//                        break;
//                    case TextDecorationEnum.LineThrough:
//                        fs |= System.Drawing.FontStyle.Strikeout;
//                        break;
//                    case TextDecorationEnum.Overline:
//                    case TextDecorationEnum.None:
//                        break;
//                }


            // WEIGHT
//                switch (si.FontWeight)
//                {
//                    case FontWeightEnum.Bold:
//                    case FontWeightEnum.Bolder:
//                    case FontWeightEnum.W500:
//                    case FontWeightEnum.W600:
//                    case FontWeightEnum.W700:
//                    case FontWeightEnum.W800:
//                    case FontWeightEnum.W900:
//                        fs |= System.Drawing.FontStyle.Bold;
//                        break;
//                    default:
//                        break;
//                }
//                try
//                {
//                    drawFont = new Font(si.GetFontFamily(), si.FontSize, fs);   // si.FontSize already in points
//                }
//                catch (ArgumentException)
//                {
//                    drawFont = new Font("Arial", si.FontSize, fs);   // if this fails we'll let the error pass thru
//                }
            //font.AbsoluteSize = (int)(PixelsX (si.FontSize));

            switch (si.FontWeight)
            {
            case FontWeightEnum.Bold:
            case FontWeightEnum.Bolder:
            case FontWeightEnum.W500:
            case FontWeightEnum.W600:
            case FontWeightEnum.W700:
            case FontWeightEnum.W800:
            case FontWeightEnum.W900:
                font.Weight = Pango.Weight.Bold;
                break;
            }

            Pango.FontDescription oldfont = layout.FontDescription;
            layout.FontDescription = font;

            // ALIGNMENT
//                drawFormat = new StringFormat();
//                switch (si.TextAlign)
//                {
//                    case TextAlignEnum.Right:
//                        drawFormat.Alignment = StringAlignment.Far;
//                        break;
//                    case TextAlignEnum.Center:
//                        drawFormat.Alignment = StringAlignment.Center;
//                        break;
//                    case TextAlignEnum.Left:
//                    default:
//                        drawFormat.Alignment = StringAlignment.Near;
//                        break;
//                }

            switch (si.TextAlign)
            {
            case TextAlignEnum.Right:
                layout.Alignment = Pango.Alignment.Right;
                break;

            case TextAlignEnum.Center:
                layout.Alignment = Pango.Alignment.Center;
                break;

            case TextAlignEnum.Left:
            default:
                layout.Alignment = Pango.Alignment.Left;
                break;
            }

            layout.Width = Pango.Units.FromPixels((int)(r.Width - si.PaddingLeft - si.PaddingRight - 2));
//				layout.Width =  (int)Pango.Units.FromPixels((int)r.Width);

            layout.SetText(s);


//                if (pt.SI.WritingMode == WritingModeEnum.tb_rl)
//                {
//                    drawFormat.FormatFlags |= StringFormatFlags.DirectionRightToLeft;
//                    drawFormat.FormatFlags |= StringFormatFlags.DirectionVertical;
//                }
//                switch (si.VerticalAlign)
//                {
//                    case VerticalAlignEnum.Bottom:
//                        drawFormat.LineAlignment = StringAlignment.Far;
//                        break;
//                    case VerticalAlignEnum.Middle:
//                        drawFormat.LineAlignment = StringAlignment.Center;
//                        break;
//                    case VerticalAlignEnum.Top:
//                    default:
//                        drawFormat.LineAlignment = StringAlignment.Near;
//                        break;
//                }
//
            Pango.Rectangle logical;
            Pango.Rectangle ink;
            layout.GetExtents(out ink, out logical);
            double height = logical.Height / Pango.Scale.PangoScale;
            double y      = 0;

            switch (si.VerticalAlign)
            {
            case VerticalAlignEnum.Top:
                y = r.Y + si.PaddingTop;
                break;

            case VerticalAlignEnum.Middle:
                y = r.Y + (r.Height - height) / 2;
                break;

            case VerticalAlignEnum.Bottom:
                y = r.Y + (r.Height - height) - si.PaddingBottom;
                break;
            }
            // draw the background
            DrawBackground(g, r, si);

            // adjust drawing rectangle based on padding
//                Cairo.Rectangle r2 = new Cairo.Rectangle(r.X + si.PaddingLeft,
//                                               r.Y + si.PaddingTop,
//                                               r.Width - si.PaddingLeft - si.PaddingRight,
//                                               r.Height - si.PaddingTop - si.PaddingBottom);
            Cairo.Rectangle box = new Cairo.Rectangle(
                r.X + si.PaddingLeft + 1,
                y,
                r.Width,
                r.Height);

            //drawBrush = new SolidBrush(si.Color);
            g.Color = si.Color.ToCairoColor();
//                if (pt.NoClip)   // request not to clip text
//                {
//                    g.DrawString(pt.Text, drawFont, drawBrush, new PointF(r.Left, r.Top), drawFormat);
//                    //HighlightString(g, pt, new RectangleF(r.Left, r.Top, float.MaxValue, float.MaxValue),drawFont, drawFormat);
//                }
//                else
//                {
//                    g.DrawString(pt.Text, drawFont, drawBrush, r2, drawFormat);
//                    //HighlightString(g, pt, r2, drawFont, drawFormat);
//                }

            g.MoveTo(box.X, box.Y);

            Pango.CairoHelper.ShowLayout(g, layout);

            layout.FontDescription = oldfont;
            g.Restore();
        }
示例#13
0
            void IStyleSheet.RegisterStyle(Style style, IUrlResolutionService urlResolver) {
                if (style == null) {
                    throw new ArgumentNullException("style");
                }

                if (_styles == null) {
                    _styles = new ArrayList();
                }
                else if (style.RegisteredCssClass.Length != 0) {
                    // if it's already registered, throw an exception
                    throw new InvalidOperationException(SR.GetString(SR.HtmlHead_StyleAlreadyRegistered));
                }

                if (urlResolver == null) {
                    urlResolver = this;
                }

                StyleInfo styleInfo = new StyleInfo();
                styleInfo.style = style;
                styleInfo.urlResolver = urlResolver;

                int index = _autoGenCount++;
                string name = "aspnet_s" + index.ToString(NumberFormatInfo.InvariantInfo);

                style.SetRegisteredCssClass(name);
                _styles.Add(styleInfo);
            }
	public void FindStyles(GUIObject guiObject,List<StyleInfo> customStyles)
	{
		if ( guiObject == null )
			return;
		
		GUIContainer container = guiObject as GUIContainer;
		if ( container != null )
		{
			// add style of container
			StyleInfo info = new StyleInfo(guiObject.name,guiObject.Skin,guiObject.Style);
			if ( guiObject.Style != null && HasStyle(customStyles,guiObject.Style.name) == false )
				customStyles.Add(info);
			
			foreach( GUIObject element in container.Elements )
			{
				FindStyles(element,customStyles);
			}
		}
		else
		{
			StyleInfo info = new StyleInfo(guiObject.name,guiObject.Skin,guiObject.Style);
			if ( guiObject.Style != null && HasStyle(customStyles,guiObject.Style.name) == false )
				customStyles.Add(info);
		}
	}
 private static bool ApplyBorder(StyleInfo styleInfo)
 {
     var opBorder = styleInfo.Style.Border;
     return (opBorder.BottomBorder.ToOpenXml() != BorderStyleValues.None
             || opBorder.DiagonalBorder.ToOpenXml() != BorderStyleValues.None
             || opBorder.RightBorder.ToOpenXml() != BorderStyleValues.None
             || opBorder.LeftBorder.ToOpenXml() != BorderStyleValues.None
             || opBorder.TopBorder.ToOpenXml() != BorderStyleValues.None);
 }
 private static CellFormat GetCellFormat(StyleInfo styleInfo)
 {
     var cellFormat = new CellFormat
     {
         NumberFormatId = (UInt32)styleInfo.NumberFormatId,
         FontId = styleInfo.FontId,
         FillId = styleInfo.FillId,
         BorderId = styleInfo.BorderId,
         ApplyNumberFormat = false,
         ApplyFill = ApplyFill(styleInfo),
         ApplyBorder = ApplyBorder(styleInfo),
         ApplyAlignment = false,
         ApplyProtection = ApplyProtection(styleInfo)
     };
     return cellFormat;
 }
示例#17
0
文件: FormulaRule.cs 项目: Daoting/dt
 /// <summary>
 /// Creates a new formula rule with specified parameters.
 /// </summary>
 /// <param name="formula">The condition formula.</param>
 /// <param name="style">The style that is set by the rule.</param>
 /// <returns>The new formula rule.</returns>
 public static FormulaRule Create(string formula, StyleInfo style)
 {
     return(new FormulaRule(formula, style));
 }
        private void DrawString(string s, Cairo.Context g, Cairo.Rectangle r)
        {
            StyleInfo si = new StyleInfo();

            g.Save();

            Pango.Layout layout;

            layout = Pango.CairoHelper.CreateLayout(g);

            float fontsize = (si.FontSize * 72 / 96);
            var   font     = Pango.FontDescription.FromString(string.Format("{0} {1}", si.GetFontFamily().Name,
                                                                            fontsize * PixelsX(1)));

            if (si.FontStyle == FontStyleEnum.Italic)
            {
                font.Style = Pango.Style.Italic;
            }

            switch (si.FontWeight)
            {
            case FontWeightEnum.Bold:
            case FontWeightEnum.Bolder:
            case FontWeightEnum.W500:
            case FontWeightEnum.W600:
            case FontWeightEnum.W700:
            case FontWeightEnum.W800:
            case FontWeightEnum.W900:
                font.Weight = Pango.Weight.Bold;
                break;
            }

            Pango.FontDescription oldfont = layout.FontDescription;
            layout.FontDescription = font;

            switch (si.TextAlign)
            {
            case TextAlignEnum.Right:
                layout.Alignment = Pango.Alignment.Right;
                break;

            case TextAlignEnum.Center:
                layout.Alignment = Pango.Alignment.Center;
                break;

            case TextAlignEnum.Left:
            default:
                layout.Alignment = Pango.Alignment.Left;
                break;
            }

            layout.Width = Pango.Units.FromPixels((int)(r.Width - si.PaddingLeft - si.PaddingRight - 2));
            //				layout.Width =  (int)Pango.Units.FromPixels((int)r.Width);

            layout.SetText(s);

            Pango.Rectangle logical;
            Pango.Rectangle ink;
            layout.GetExtents(out ink, out logical);
            double height = logical.Height / Pango.Scale.PangoScale;
            double y      = 0;

            switch (si.VerticalAlign)
            {
            case VerticalAlignEnum.Top:
                y = r.Y + si.PaddingTop;
                break;

            case VerticalAlignEnum.Middle:
                y = r.Y + (r.Height - height) / 2;
                break;

            case VerticalAlignEnum.Bottom:
                y = r.Y + (r.Height - height) - si.PaddingBottom;
                break;
            }

            Cairo.Rectangle box = new Cairo.Rectangle(
                r.X + si.PaddingLeft + 1,
                y,
                r.Width,
                r.Height);

            g.Color = si.Color.ToCairoColor();

            g.MoveTo(box.X, box.Y);

            Pango.CairoHelper.ShowLayout(g, layout);

            layout.FontDescription = oldfont;
            g.Restore();
        }
示例#19
0
        //25072008 GJL Draw a bezier curve
        internal void AddCurve(float X1, float Y1, float X2, float Y2, float X3, float Y3, float X4, float Y4, StyleInfo si, string url)
        {
            string linestyle;

            switch (si.BStyleTop)
            {
            case BorderStyleEnum.Dashed:
                linestyle = "[3 2] 0 d";
                break;

            case BorderStyleEnum.Dotted:
                linestyle = "[2] 0 d";
                break;

            case BorderStyleEnum.Solid:
            default:
                linestyle = "[] 0 d";
                break;
            }

            elements.AppendFormat("\r\nq\t");
            if (si.BStyleTop != BorderStyleEnum.None)
            {
                elements.AppendFormat("{0} w\t {1} \t", si.BWidthTop, linestyle);
                elements.AppendFormat("{0} {1} {2} RG\t", Math.Round(si.BColorTop.R / 255.0, 3), Math.Round(si.BColorTop.G / 255.0, 3), Math.Round(si.BColorTop.B / 255.0, 3));                 //Set Stroking colours
            }
            if (!si.BackgroundColor.IsEmpty)
            {
                elements.AppendFormat("{0} {1} {2} rg\t", Math.Round(si.BackgroundColor.R / 255.0, 3), Math.Round(si.BackgroundColor.G / 255.0, 3), Math.Round(si.BackgroundColor.B / 255.0, 3)); //Set Non Stroking colours
            }
            elements.AppendFormat("{0} {1} m\t", X1, pSize.yHeight - Y1);                                                                                                                         //FirstPoint..
            elements.AppendFormat("{0} {1} {2} {3} {4} {5}  c\t", X2, pSize.yHeight - Y2, X3, pSize.yHeight - Y3, X4, pSize.yHeight - Y4);
            if (!si.BackgroundColor.IsEmpty && si.BStyleTop != BorderStyleEnum.None)
            {
                //Line and fill
                elements.AppendFormat("B\t");
            }
            else if (si.BStyleTop != BorderStyleEnum.None)
            {
                //Line
                elements.AppendFormat("S\t");
            }
            else if (!si.BackgroundColor.IsEmpty)
            {
                //fill
                elements.AppendFormat("f\t");
            }
            elements.AppendFormat("Q\t");
        }
示例#20
0
        private void DrawImageBackground(PageImage pi, StyleInfo si, Graphics g, RectangleF r)
        {
            Stream strm = null;

            System.Drawing.Image im = null;
            try
            {
                strm = new MemoryStream(pi.ImageData);
                im   = System.Drawing.Image.FromStream(strm);

                // http://www.fyireporting.com/forum/viewtopic.php?t=892
                //A.S.> convert pt to px if needed(when printing we need px, when draw preview - pt)

                RectangleF r2;
                if (g.PageUnit == GraphicsUnit.Pixel)
                {
                    r2 = new RectangleF(r.Left + (si.PaddingLeft * g.DpiX) / 72,
                                        r.Top + (si.PaddingTop * g.DpiX) / 72,
                                        r.Width - ((si.PaddingLeft + si.PaddingRight) * g.DpiX) / 72,
                                        r.Height - ((si.PaddingTop + si.PaddingBottom) * g.DpiX) / 72);
                }
                else
                {
                    // adjust drawing rectangle based on padding
                    r2 = new RectangleF(r.Left + si.PaddingLeft,
                                        r.Top + si.PaddingTop,
                                        r.Width - si.PaddingLeft - si.PaddingRight,
                                        r.Height - si.PaddingTop - si.PaddingBottom);
                }


                int repeatX = 0;
                int repeatY = 0;
                switch (pi.Repeat)
                {
                case ImageRepeat.Repeat:
                    repeatX = (int)Math.Floor(r2.Width / pi.SamplesW);
                    repeatY = (int)Math.Floor(r2.Height / pi.SamplesH);
                    break;

                case ImageRepeat.RepeatX:
                    repeatX = (int)Math.Floor(r2.Width / pi.SamplesW);
                    repeatY = 1;
                    break;

                case ImageRepeat.RepeatY:
                    repeatY = (int)Math.Floor(r2.Height / pi.SamplesH);
                    repeatX = 1;
                    break;

                case ImageRepeat.NoRepeat:
                default:
                    repeatX = repeatY = 1;
                    break;
                }

                //make sure the image is drawn at least 1 times
                repeatX = Math.Max(repeatX, 1);
                repeatY = Math.Max(repeatY, 1);

                float startX = r2.Left;
                float startY = r2.Top;

                Region saveRegion = g.Clip;
                Region clipRegion = new Region(g.Clip.GetRegionData());
                clipRegion.Intersect(r2);
                g.Clip = clipRegion;

                for (int i = 0; i < repeatX; i++)
                {
                    for (int j = 0; j < repeatY; j++)
                    {
                        float currX = startX + i * pi.SamplesW;
                        float currY = startY + j * pi.SamplesH;
                        g.DrawImage(im, new RectangleF(currX, currY, pi.SamplesW, pi.SamplesH));
                    }
                }
                g.Clip = saveRegion;
            }
            finally
            {
                if (strm != null)
                {
                    strm.Close();
                }
                if (im != null)
                {
                    im.Dispose();
                }
            }
        }
示例#21
0
        //25072008 GJL Draw 4 bezier curves to approximate a circle
        internal void AddEllipse(float x, float y, float height, float width, StyleInfo si, string url)
        {
            //Ok we need to draw 4 bezier curves - Unfortunately we cant call drawcurve 4 times because of the fill - we would end up drawing 4 filled arcs with an empty diamond in the middle
            //but we will still include a drawcurve function - it may be usefull one day
            float k       = 0.5522847498f;
            float RadiusX = (width / 2.0f);
            float RadiusY = (height / 2.0f);
            float kRy     = k * RadiusY;
            float kRx     = k * RadiusX;

            float Y4 = y;
            float X1 = x;
            float Y1 = Y4 + RadiusY;
            float X4 = X1 + RadiusX;
            //Control Point 1 will be on the same X as point 1 and be -kRy Y
            float X2 = X1;
            float Y2 = Y1 - kRy;
            float X3 = X4 - kRx;
            float Y3 = Y4;

            elements.AppendFormat("\r\nq\t");
            elements.AppendFormat("{0} {1} m\t", X1, pSize.yHeight - Y1);  //FirstPoint..

            if (si.BStyleTop != BorderStyleEnum.None)
            {
                string linestyle;
                switch (si.BStyleTop)
                {
                case BorderStyleEnum.Dashed:
                    linestyle = "[3 2] 0 d";
                    break;

                case BorderStyleEnum.Dotted:
                    linestyle = "[2] 0 d";
                    break;

                case BorderStyleEnum.Solid:
                default:
                    linestyle = "[] 0 d";
                    break;
                }
                elements.AppendFormat("{0} w\t {1} \t", si.BWidthTop, linestyle);
                elements.AppendFormat("{0} {1} {2} RG\t", Math.Round(si.BColorTop.R / 255.0, 3), Math.Round(si.BColorTop.G / 255.0, 3), Math.Round(si.BColorTop.B / 255.0, 3));                         //Set Stroking colours
            }
            if (!si.BackgroundColor.IsEmpty)
            {
                elements.AppendFormat("{0} {1} {2} rg\t", Math.Round(si.BackgroundColor.R / 255.0, 3), Math.Round(si.BackgroundColor.G / 255.0, 3), Math.Round(si.BackgroundColor.B / 255.0, 3));                         //Set Non Stroking colours
            }
            elements.AppendFormat("{0} {1} {2} {3} {4} {5}  c\t", X2, pSize.yHeight - Y2, X3, pSize.yHeight - Y3, X4, pSize.yHeight - Y4);


            X1 += 2 * RadiusX;
            X2  = X1;
            X3 += 2 * kRx;

            elements.AppendFormat("{0} {1} {2} {3} {4} {5}  c\t", X3, pSize.yHeight - Y3, X2, pSize.yHeight - Y2, X1, pSize.yHeight - Y1);


            Y2 += 2 * kRy;
            Y3 += 2 * RadiusY;
            Y4  = Y3;

            elements.AppendFormat("{0} {1} {2} {3} {4} {5}  c\t", X2, pSize.yHeight - Y2, X3, pSize.yHeight - Y3, X4, pSize.yHeight - Y4);


            X1 -= 2 * RadiusX;
            X2  = X1;
            X3 -= 2 * kRx;

            elements.AppendFormat("{0} {1} {2} {3} {4} {5}  c\t", X3, pSize.yHeight - Y3, X2, pSize.yHeight - Y2, X1, pSize.yHeight - Y1);


            if (!si.BackgroundColor.IsEmpty && si.BStyleTop != BorderStyleEnum.None)
            {
                //Line and fill
                elements.AppendFormat("B\t");
            }
            else if (si.BStyleTop != BorderStyleEnum.None)
            {
                //Line
                elements.AppendFormat("S\t");
            }
            else if (!si.BackgroundColor.IsEmpty)
            {
                //fill
                elements.AppendFormat("f\t");
            }

            elements.AppendFormat("Q\t");
        }
示例#22
0
        private void DrawString(PageText pt, Xwt.Drawing.Context g, Xwt.Rectangle r)
        {
            StyleInfo si = pt.SI;
            string    s  = pt.Text;

            g.Save();
            layout      = new Xwt.Drawing.TextLayout(g);
            layout.Font = g.Font;


            float fontsize = (si.FontSize * 72 / 96);

            layout.Font.WithFamily(si.GetFontFamily().Name);
            layout.Font.WithPixelSize(fontsize * PixelsX(1));

            if (si.FontStyle == FontStyleEnum.Italic)
            {
                layout.Font.WithStyle(Xwt.Drawing.FontStyle.Italic);
            }

            switch (si.FontWeight)
            {
            case FontWeightEnum.Bold:
            case FontWeightEnum.Bolder:
            case FontWeightEnum.W500:
            case FontWeightEnum.W600:
            case FontWeightEnum.W700:
            case FontWeightEnum.W800:
            case FontWeightEnum.W900:
                layout.Font.WithWeight(Xwt.Drawing.FontWeight.Bold);
                break;
            }

            // TODO: Fix Alignment
            //switch (si.TextAlign)
            //{
            //    case TextAlignEnum.Right:
            //        layout.Alignment = Pango.Alignment.Right;
            //        break;
            //    case TextAlignEnum.Center:
            //        layout.Alignment = Pango.Alignment.Center;
            //        break;
            //    case TextAlignEnum.Left:
            //    default:
            //        layout.Alignment = Pango.Alignment.Left;
            //        break;
            //}

            // TODO: Fix with
            //layout.Width = Pango.Units.FromPixels((int)(r.Width - si.PaddingLeft - si.PaddingRight - 2));

            layout.Text = s;



            //Xwt.Rectangle logical;
            // Xwt.Rectangle ink;

            // TODO: Fix
            //layout.GetExtents(out ink, out logical);
            double height = 12; // logical.Height / Pango.Scale.PangoScale;

            double y = 0;

            switch (si.VerticalAlign)
            {
            case VerticalAlignEnum.Top:
                y = r.Y + si.PaddingTop;
                break;

            case VerticalAlignEnum.Middle:
                y = r.Y + (r.Height - height) / 2;
                break;

            case VerticalAlignEnum.Bottom:
                y = r.Y + (r.Height - height) - si.PaddingBottom;
                break;
            }

            // draw the background
            DrawBackground(g, r, si);

            Xwt.Rectangle box = new Xwt.Rectangle(
                r.X + si.PaddingLeft + 1,
                y,
                r.Width,
                r.Height);

            Xwt.Drawing.Color sicolor = XwtColor.SystemColorToXwtColor(si.Color);
            g.SetColor(sicolor);

            g.MoveTo(box.X, box.Y);
            g.DrawTextLayout(layout, box.X, box.Y);
            g.Restore();
        }
示例#23
0
        /// <summary>
        /// Page Text element at the X Y position; multiple lines handled
        /// </summary>
        /// <returns></returns>
        internal void AddText(float x, float y, float height, float width, string[] sa,
                              StyleInfo si, PdfFonts fonts, float[] tw, bool bWrap, string url, bool bNoClip, string tooltip)
        {
            // Calculate the RGB colors e.g. RGB(255, 0, 0) = red = 1 0 0 rg
            double r = si.Color.R;
            double g = si.Color.G;
            double b = si.Color.B;

            r = Math.Round((r / 255), 3);
            g = Math.Round((g / 255), 3);
            b = Math.Round((b / 255), 3);

            string pdfFont = fonts.GetPdfFont(si);              // get the pdf font resource name

            // Loop thru the lines of text
            for (int i = 0; i < sa.Length; i++)
            {
                string text      = sa[i];
                float  textwidth = tw[i];
                // Calculate the x position
                float startX = x + si.PaddingLeft;                                      // TODO: handle tb_rl
                float startY = y + si.PaddingTop + (i * si.FontSize);                   // TODO: handle tb_rl

                if (si.WritingMode == WritingModeEnum.lr_tb)
                {                       // TODO: not sure what alignment means with tb_lr so I'll leave it out for now
                    switch (si.TextAlign)
                    {
                    case TextAlignEnum.Center:
                        if (width > 0)
                        {
                            startX = x + si.PaddingLeft + (width - si.PaddingLeft - si.PaddingRight) / 2 - textwidth / 2;
                        }
                        break;

                    case TextAlignEnum.Right:
                        if (width > 0)
                        {
                            startX = x + width - textwidth - si.PaddingRight;
                        }
                        break;

                    case TextAlignEnum.Left:
                    default:
                        break;
                    }

                    // Calculate the y position
                    switch (si.VerticalAlign)
                    {
                    case VerticalAlignEnum.Middle:
                        if (height <= 0)
                        {
                            break;
                        }

                        // calculate the middle of the region
                        startY = y + si.PaddingTop + (height - si.PaddingTop - si.PaddingBottom) / 2 - si.FontSize / 2;
                        // now go up or down depending on which line
                        if (sa.Length == 1)
                        {
                            break;
                        }
                        if (sa.Length % 2 == 0)                                 // even number
                        {
                            startY = startY - ((sa.Length / 2 - i) * si.FontSize) + si.FontSize / 2;
                        }
                        else
                        {
                            startY = startY - ((sa.Length / 2 - i) * si.FontSize);
                        }
                        break;

                    case VerticalAlignEnum.Bottom:
                        if (height <= 0)
                        {
                            break;
                        }

                        startY = y + height - si.PaddingBottom - (si.FontSize * (sa.Length - i));
                        break;

                    case VerticalAlignEnum.Top:
                    default:
                        break;
                    }
                }
                else
                {
                    //25072008 GJL - Move x in a little - it draws to close to the edge of the rectangle (25% of the font size seems to work!) and Center or right align vertical text
                    startX += si.FontSize / 4;

                    switch (si.TextAlign)
                    {
                    case TextAlignEnum.Center:
                        if (height > 0)
                        {
                            startY = y + si.PaddingLeft + (height - si.PaddingLeft - si.PaddingRight) / 2 - textwidth / 2;
                        }
                        break;

                    case TextAlignEnum.Right:
                        if (width > 0)
                        {
                            startY = y + height - textwidth - si.PaddingRight;
                        }
                        break;

                    case TextAlignEnum.Left:
                    default:
                        break;
                    }
                }

                // Draw background rectangle if needed (only put out on the first line, since we do whole rectangle)
                if (!si.BackgroundColor.IsEmpty && height > 0 && width > 0 && i == 0)
                {                       // background color, height and width are specified
                    AddFillRect(x, y, width, height, si.BackgroundColor);
                }

                // Set the clipping path
                if (height > 0 && width > 0)
                {
                    if (bNoClip)                        // no clipping but we still want URL checking
                    {
                        elements.Append("\r\nq\t");
                    }
                    else
                    {
                        elements.AppendFormat(NumberFormatInfo.InvariantInfo,
                                              "\r\nq\t{0} {1} {2} {3} re W n",
                                              x, pSize.yHeight - y - height, width, height);
                    }
                    if (url != null)
                    {
                        p.AddHyperlink(x, pSize.yHeight - y, height, width, url);
                    }
                    if (tooltip != null)
                    {
                        p.AddToolTip(x, pSize.yHeight - y, height, width, tooltip);
                    }
                }
                else
                {
                    elements.Append("\r\nq\t");
                }

                // Escape the text
                string newtext = PdfUtility.UTF16StringQuoter(text);
                //string newtext = text.Replace("\\", "\\\\");
                //newtext = newtext.Replace("(", "\\(");
                //newtext = newtext.Replace(")", "\\)");
                if (si.WritingMode == WritingModeEnum.lr_tb)
                {
                    elements.AppendFormat(NumberFormatInfo.InvariantInfo,
                                          "\r\nBT/{0} {1} Tf\t{5} {6} {7} rg\t{2} {3} Td \t({4}) Tj\tET\tQ\t",
                                          pdfFont, si.FontSize, startX, (pSize.yHeight - startY - si.FontSize), newtext, r, g, b);
                }
                else
                {                       // Rotate text -90 degrees=-.5 radians (this works for english don't know about true tb-rl language)
                                        //   had to play with reader to find best approximation for this rotation; didn't do what I expected
                                        //    see pdf spec section 4.2.2 pg 141  "Common Transformations"

                    elements.AppendFormat(NumberFormatInfo.InvariantInfo,
                                          "\r\nBT/{0} {1} Tf\t{5} {6} {7} rg\t{8} {9} {10} {11} {2} {3} Tm \t({4}) Tj\tET\tQ\t",
                                          pdfFont, si.FontSize, startX, (pSize.yHeight - startY), newtext, r, g, b,
                                          radsCos, radsSin, -radsSin, radsCos);
                }

                // Handle underlining etc.
                float maxX;
                switch (si.TextDecoration)
                {
                case TextDecorationEnum.Underline:
                    maxX = width > 0? Math.Min(x + width, startX + textwidth): startX + textwidth;
                    AddLine(startX, startY + si.FontSize + 1, maxX, startY + si.FontSize + 1, 1, si.Color, BorderStyleEnum.Solid);
                    break;

                case TextDecorationEnum.LineThrough:
                    maxX = width > 0? Math.Min(x + width, startX + textwidth): startX + textwidth;
                    AddLine(startX, startY + (si.FontSize / 2) + 1, maxX, startY + (si.FontSize / 2) + 1, 1, si.Color, BorderStyleEnum.Solid);
                    break;

                case TextDecorationEnum.Overline:
                    maxX = width > 0? Math.Min(x + width, startX + textwidth): startX + textwidth;
                    AddLine(startX, startY + 1, maxX, startY + 1, 1, si.Color, BorderStyleEnum.Solid);
                    break;

                case TextDecorationEnum.None:
                default:
                    break;
                }
            }

            AddBorder(si, x, y, height, width);                                 // add any required border

            return;
        }
        private void DrawImageBackground(PageImage pi, StyleInfo si, StringBuilder sb, Rectangle r)
        {
            //Stream strm = null;
            //System.Drawing.Image im = null;
            //try
            //{
            //    strm = new MemoryStream(pi.ImageData);
            //    im = System.Drawing.Image.FromStream(strm);

            //    Rectangle r2 = new Rectangle(r.Left + PixelsX(si.PaddingLeft),
            //        r.Top + PixelsY(si.PaddingTop),
            //        r.Width - PixelsX(si.PaddingLeft + si.PaddingRight),
            //        r.Height - PixelsY(si.PaddingTop + si.PaddingBottom));

            //    int repeatX = 0;
            //    int repeatY = 0;
            //    switch (pi.Repeat)
            //    {
            //        case ImageRepeat.Repeat:
            //            repeatX = (int)Math.Floor(r2.Width / pi.SamplesW);
            //            repeatY = (int)Math.Floor(r2.Height / pi.SamplesH);
            //            break;
            //        case ImageRepeat.RepeatX:
            //            repeatX = (int)Math.Floor(r2.Width / pi.SamplesW);
            //            repeatY = 1;
            //            break;
            //        case ImageRepeat.RepeatY:
            //            repeatY = (int)Math.Floor(r2.Height / pi.SamplesH);
            //            repeatX = 1;
            //            break;
            //        case ImageRepeat.NoRepeat:
            //        default:
            //            repeatX = repeatY = 1;
            //            break;
            //    }

            //    //make sure the image is drawn at least 1 times
            //    repeatX = Math.Max(repeatX, 1);
            //    repeatY = Math.Max(repeatY, 1);

            //    float startX = r2.Left;
            //    float startY = r2.Top;

            //    Region saveRegion = g.Clip;
            //    Region clipRegion = new Region(g.Clip.GetRegionData());
            //    clipRegion.Intersect(r2);
            //    g.Clip = clipRegion;

            //    for (int i = 0; i < repeatX; i++)
            //    {
            //        for (int j = 0; j < repeatY; j++)
            //        {
            //            float currX = startX + i * pi.SamplesW;
            //            float currY = startY + j * pi.SamplesH;
            //            g.DrawImage(im, new Rectangle(currX, currY, pi.SamplesW, pi.SamplesH));
            //        }
            //    }
            //    g.Clip = saveRegion;
            //}
            //finally
            //{
            //    if (strm != null)
            //        strm.Close();
            //    if (im != null)
            //        im.Dispose();
            //}
        }
示例#25
0
 /// <summary>
 /// Page line element at the X Y to X2 Y2 position
 /// </summary>
 /// <returns></returns>
 internal void AddLine(float x, float y, float x2, float y2, StyleInfo si)
 {
     AddLine(x, y, x2, y2, si.BWidthTop, si.BColorTop, si.BStyleTop);
 }
示例#26
0
 /// <summary>
 /// Creates a new text rule with the specified comparison operator, text, and style.
 /// </summary>
 /// <param name="style">Cell style.</param>
 internal DuplicateRule(StyleInfo style) : base(style)
 {
 }
示例#27
0
 /// <summary>
 /// Calls OnChanged to raise an ItemAdded event for the specified StyleInfo object.
 /// </summary>
 /// <param name="style">
 /// New StyleInfo object
 /// </param>
 void RaiseItemAdded(StyleInfo style)
 {
     this.OnChanged(new StyleInfoCollectionChangedEventArgs(StyleInfoCollectionChangedAction.ItemAdded, null, style));
 }
示例#28
0
 /// <summary>
 /// Calls OnChanged to raise an ItemChanged event with the specified arguments.
 /// </summary>
 /// <param name="oldstyle">
 /// Old StyleInfo object
 /// </param>
 /// <param name="newstyle">
 /// New StyleInfo object
 /// </param>
 void RaiseItemChanged(StyleInfo oldstyle, StyleInfo newstyle)
 {
     this.OnChanged(new StyleInfoCollectionChangedEventArgs(StyleInfoCollectionChangedAction.ItemChanged, oldstyle, newstyle));
 }
示例#29
0
 /// <summary>
 /// Calls OnChanged to raise an ItemRemoved event for the specified StyleInfo object.
 /// </summary>
 /// <param name="style">
 /// Old StyleInfo object
 /// </param>
 void RaiseItemRemoved(StyleInfo style)
 {
     this.OnChanged(new StyleInfoCollectionChangedEventArgs(StyleInfoCollectionChangedAction.ItemRemoved, style, null));
 }
 private static bool ApplyFill(StyleInfo styleInfo)
 {
     return styleInfo.Style.Fill.PatternType.ToOpenXml() == PatternValues.None;
 }
示例#31
0
        private void DrawImageSized(PageImage pi, Image im, Graphics g, RectangleF r)
        {
            float     height, width;            // some work variables
            StyleInfo si = pi.SI;

            // adjust drawing rectangle based on padding

            // http://www.fyireporting.com/forum/viewtopic.php?t=892
            //A.S.> convert pt to px if needed(when printing we need px, when draw preview - pt)

            RectangleF r2;

            if (g.PageUnit == GraphicsUnit.Pixel)
            {
                r2 = new RectangleF(r.Left + (si.PaddingLeft * g.DpiX) / 72,
                                    r.Top + (si.PaddingTop * g.DpiX) / 72,
                                    r.Width - ((si.PaddingLeft + si.PaddingRight) * g.DpiX) / 72,
                                    r.Height - ((si.PaddingTop + si.PaddingBottom) * g.DpiX) / 72);
            }
            else
            {
                // adjust drawing rectangle based on padding
                r2 = new RectangleF(r.Left + si.PaddingLeft,
                                    r.Top + si.PaddingTop,
                                    r.Width - si.PaddingLeft - si.PaddingRight,
                                    r.Height - si.PaddingTop - si.PaddingBottom);
            }

            Rectangle ir;       // int work rectangle

            ir = new Rectangle(Convert.ToInt32(r2.Left), Convert.ToInt32(r2.Top),
                               Convert.ToInt32(r2.Width), Convert.ToInt32(r2.Height));
            switch (pi.Sizing)
            {
            case ImageSizingEnum.AutoSize:
                // Note: GDI+ will stretch an image when you only provide
                //  the left/top coordinates.  This seems pretty stupid since
                //  it results in the image being out of focus even though
                //  you don't want the image resized.
                if (g.DpiX == im.HorizontalResolution &&
                    g.DpiY == im.VerticalResolution)
                {
                    ir = new Rectangle(Convert.ToInt32(r2.Left), Convert.ToInt32(r2.Top),
                                       im.Width, im.Height);
                }
                g.DrawImage(im, ir);

                break;

            case ImageSizingEnum.Clip:
                Region saveRegion = g.Clip;
                Region clipRegion = new Region(g.Clip.GetRegionData());
                clipRegion.Intersect(r2);
                g.Clip = clipRegion;
                if (g.DpiX == im.HorizontalResolution &&
                    g.DpiY == im.VerticalResolution)
                {
                    ir = new Rectangle(Convert.ToInt32(r2.Left), Convert.ToInt32(r2.Top),
                                       im.Width, im.Height);
                }
                g.DrawImage(im, ir);
                g.Clip = saveRegion;
                break;

            case ImageSizingEnum.FitProportional:
                float ratioIm = (float)im.Height / (float)im.Width;
                float ratioR  = r2.Height / r2.Width;
                height = r2.Height;
                width  = r2.Width;
                if (ratioIm > ratioR)
                {       // this means the rectangle width must be corrected
                    width = height * (1 / ratioIm);
                }
                else if (ratioIm < ratioR)
                {       // this means the ractangle height must be corrected
                    height = width * ratioIm;
                }
                r2 = new RectangleF(r2.X, r2.Y, width, height);
                g.DrawImage(im, r2);
                break;

            case ImageSizingEnum.Fit:
            default:
                g.DrawImage(im, r2);
                break;
            }

            //if (SelectTool && pi.AllowSelect && _SelectList.Contains(pi))
            //{
            //    g.FillRectangle(new SolidBrush(Color.FromArgb(50, _SelectItemColor)), ir);
            //}

            return;
        }
 private static bool ApplyProtection(StyleInfo styleInfo)
 {
     return styleInfo.Style.Protection != null;
 }
示例#33
0
        private void DrawString(PageText pt, Graphics g, RectangleF r)
        {
            StyleInfo si = pt.SI;
            string    s  = pt.Text;

            Font         drawFont   = null;
            StringFormat drawFormat = null;
            Brush        drawBrush  = null;

            try
            {
                // STYLE
                System.Drawing.FontStyle fs = 0;
                if (si.FontStyle == FontStyleEnum.Italic)
                {
                    fs |= System.Drawing.FontStyle.Italic;
                }

                switch (si.TextDecoration)
                {
                case TextDecorationEnum.Underline:
                    fs |= System.Drawing.FontStyle.Underline;
                    break;

                case TextDecorationEnum.LineThrough:
                    fs |= System.Drawing.FontStyle.Strikeout;
                    break;

                case TextDecorationEnum.Overline:
                case TextDecorationEnum.None:
                    break;
                }

                // WEIGHT
                switch (si.FontWeight)
                {
                case FontWeightEnum.Bold:
                case FontWeightEnum.Bolder:
                case FontWeightEnum.W500:
                case FontWeightEnum.W600:
                case FontWeightEnum.W700:
                case FontWeightEnum.W800:
                case FontWeightEnum.W900:
                    fs |= System.Drawing.FontStyle.Bold;
                    break;

                default:
                    break;
                }
                try
                {
                    drawFont = new Font(si.GetFontFamily(), si.FontSize, fs);   // si.FontSize already in points
                }
                catch (ArgumentException)
                {
                    drawFont = new Font("Arial", si.FontSize, fs);      // if this fails we'll let the error pass thru
                }
                // ALIGNMENT
                drawFormat = new StringFormat();
                switch (si.TextAlign)
                {
                case TextAlignEnum.Right:
                    drawFormat.Alignment = StringAlignment.Far;
                    break;

                case TextAlignEnum.Center:
                    drawFormat.Alignment = StringAlignment.Center;
                    break;

                case TextAlignEnum.Left:
                default:
                    drawFormat.Alignment = StringAlignment.Near;
                    break;
                }
                if (pt.SI.WritingMode == WritingModeEnum.tb_rl)
                {
                    drawFormat.FormatFlags |= StringFormatFlags.DirectionRightToLeft;
                    drawFormat.FormatFlags |= StringFormatFlags.DirectionVertical;
                }
                switch (si.VerticalAlign)
                {
                case VerticalAlignEnum.Bottom:
                    drawFormat.LineAlignment = StringAlignment.Far;
                    break;

                case VerticalAlignEnum.Middle:
                    drawFormat.LineAlignment = StringAlignment.Center;
                    break;

                case VerticalAlignEnum.Top:
                default:
                    drawFormat.LineAlignment = StringAlignment.Near;
                    break;
                }
                // draw the background
                DrawBackground(g, r, si);

                // adjust drawing rectangle based on padding
                // http://www.fyireporting.com/forum/viewtopic.php?t=892
                //A.S.> convert pt to px if needed(when printing we need px, when draw preview - pt)
                RectangleF r2;
                if (g.PageUnit == GraphicsUnit.Pixel)
                {
                    r2 = new RectangleF(r.Left + (si.PaddingLeft * g.DpiX) / 72,
                                        r.Top + (si.PaddingTop * g.DpiX) / 72,
                                        r.Width - ((si.PaddingLeft + si.PaddingRight) * g.DpiX) / 72,
                                        r.Height - ((si.PaddingTop + si.PaddingBottom) * g.DpiX) / 72);
                }
                else
                {
                    // adjust drawing rectangle based on padding
                    r2 = new RectangleF(r.Left + si.PaddingLeft,
                                        r.Top + si.PaddingTop,
                                        r.Width - si.PaddingLeft - si.PaddingRight,
                                        r.Height - si.PaddingTop - si.PaddingBottom);
                }

                drawBrush = new SolidBrush(si.Color);
                if (si.TextAlign == TextAlignEnum.Justified)
                {
                    GraphicsExtended.DrawStringJustified(g, pt.Text, drawFont, drawBrush, r2);
                }
                else if (pt.NoClip)     // request not to clip text
                {
                    g.DrawString(pt.Text, drawFont, drawBrush, new PointF(r.Left, r.Top), drawFormat);
                    //HighlightString(g, pt, new RectangleF(r.Left, r.Top, float.MaxValue, float.MaxValue),
                    //    drawFont, drawFormat);
                }
                else
                {
                    g.DrawString(pt.Text, drawFont, drawBrush, r2, drawFormat);
                    //HighlightString(g, pt, r2, drawFont, drawFormat);
                }
                //if (SelectTool)
                //{
                //    if (pt.AllowSelect && _SelectList.Contains(pt))
                //        g.FillRectangle(new SolidBrush(Color.FromArgb(50, _SelectItemColor)), r2);
                //}
            }
            finally
            {
                if (drawFont != null)
                {
                    drawFont.Dispose();
                }
                if (drawFormat != null)
                {
                    drawFont.Dispose();
                }
                if (drawBrush != null)
                {
                    drawBrush.Dispose();
                }
            }
        }
 private static Protection GetProtection(StyleInfo styleInfo)
 {
     return new Protection
     {
         Locked = styleInfo.Style.Protection.Locked,
         Hidden = styleInfo.Style.Protection.Hidden
     };
 }
示例#35
0
 /// <summary>
 /// Not supported; calling this method throws an exception because the collection is read-only.
 /// </summary>
 /// <param name="index">The index at which to insert the style.</param>
 /// <param name="style">The style (<see cref="T:Dt.Cells.Data.StyleInfo" /> object) to insert in the collection.</param>
 public void Insert(int index, StyleInfo style)
 {
     throw new InvalidOperationException(ResourceStrings.StyleInfoChangeReadOnlyCollectionError);
 }
示例#36
0
        /// <summary>
        ///     設定 Cell 格式 (Detal時, 沒有 tr 和 td, 此時兩個參數傳入同一個物件, 不影響判斷)
        /// </summary>
        /// <param name="trInfo" />
        /// <param name="tdInfo" />
        private WritableCellFormat getCellFormat(AbstractStyleInfo trInfo, AbstractStyleInfo tdInfo)
        {
            //style 設定
            StyleInfo styleInfo = ((ExportConfigInfo)configInfo).StyleInfo;

            // 字體名稱
            WritableFont.FontName font = styleInfo.Font;
            if (tdInfo.Font != null)
            {
                font = tdInfo.Font;
            }
            else if (trInfo.Font != null)
            {
                font = trInfo.Font;
            }

            // 字體大小
            int size = 0;

            if (ExcelStringUtil.NotEmpty(tdInfo.Size))
            {
                size = Convert.ToInt32(ExcelStringUtil.SafeTrim(tdInfo.Size, "0"));
            }
            else if (ExcelStringUtil.NotEmpty(trInfo.Size))
            {
                size = Convert.ToInt32(ExcelStringUtil.SafeTrim(trInfo.Size, "0"));
            }
            if (size == 0)
            {
                size = Convert.ToInt32(styleInfo.Size);
            }

            // 粗體
            bool isBold = ("true".Equals(styleInfo.Bold, StringComparison.CurrentCultureIgnoreCase));

            if (ExcelStringUtil.NotEmpty(tdInfo.Bold))
            {
                isBold = ("true".Equals(tdInfo.Bold, StringComparison.CurrentCultureIgnoreCase));
            }
            else if (ExcelStringUtil.NotEmpty(trInfo.Bold))
            {
                isBold = ("true".Equals(trInfo.Bold, StringComparison.CurrentCultureIgnoreCase));
            }

            // 斜體
            bool isItalic = ("true".Equals(styleInfo.Italic, StringComparison.CurrentCultureIgnoreCase));

            if (ExcelStringUtil.NotEmpty(tdInfo.Italic))
            {
                isItalic = ("true".Equals(tdInfo.Italic, StringComparison.CurrentCultureIgnoreCase));
            }
            else if (ExcelStringUtil.NotEmpty(trInfo.Bold))
            {
                isItalic = ("true".Equals(trInfo.Italic, StringComparison.CurrentCultureIgnoreCase));
            }

            // 底線
            UnderlineStyle underlineStyle = styleInfo.Underline;

            if (tdInfo.Underline != null)
            {
                underlineStyle = tdInfo.Underline;
            }
            else if (trInfo.Underline != null)
            {
                underlineStyle = trInfo.Underline;
            }

            // 字體顏色
            Colour color = styleInfo.Color;

            if (tdInfo.Color != null)
            {
                color = tdInfo.Color;
            }
            else if (trInfo.Color != null)
            {
                color = trInfo.Color;
            }

            // 水平位置
            Alignment align = styleInfo.Align;

            if (tdInfo.Align != null)
            {
                align = tdInfo.Align;
            }
            else if (trInfo.Align != null)
            {
                align = trInfo.Align;
            }

            // 垂直位置
            VerticalAlignment valign = styleInfo.Valign;

            if (tdInfo.Valign != null)
            {
                valign = tdInfo.Valign;
            }
            else if (trInfo.Valign != null)
            {
                valign = trInfo.Valign;
            }

            // 文字換行
            bool isTextWrap = ("true".Equals(styleInfo.Wrap, StringComparison.CurrentCultureIgnoreCase));

            if (ExcelStringUtil.NotEmpty(tdInfo.Wrap))
            {
                isTextWrap = ("true".Equals(tdInfo.Wrap, StringComparison.CurrentCultureIgnoreCase));
            }
            else if (ExcelStringUtil.NotEmpty(trInfo.Wrap))
            {
                isTextWrap = ("true".Equals(trInfo.Wrap, StringComparison.CurrentCultureIgnoreCase));
            }

            // 邊線位置
            Border borderSide = styleInfo.BorderSide;

            if (tdInfo.BorderSide != null)
            {
                borderSide = tdInfo.BorderSide;
            }
            else if (trInfo.BorderSide != null)
            {
                borderSide = trInfo.BorderSide;
            }

            // 邊線樣式
            BorderLineStyle borderStyle = styleInfo.BorderStyle;

            if (tdInfo.BorderStyle != null)
            {
                borderStyle = tdInfo.BorderStyle;
            }
            else if (trInfo.Valign != null)
            {
                borderStyle = trInfo.BorderStyle;
            }

            // 背景顏色
            Colour background = styleInfo.Background;

            if (tdInfo.Background != null)
            {
                background = tdInfo.Background;
            }
            else if (trInfo.Background != null)
            {
                background = trInfo.Background;
            }

            // 產生字型設定
            var writableFont = new WritableFont(font, size, (isBold) ? WritableFont.BOLD : WritableFont.NO_BOLD,
                                                isItalic, underlineStyle, color);

            // 資料列cell格式
            var writableCellFormat = new WritableCellFormat(writableFont);

            // 水平置中
            writableCellFormat.setAlignment(align);
            // 垂直置中
            writableCellFormat.setVerticalAlignment(valign);
            // 換行
            writableCellFormat.setWrap(isTextWrap);
            // 背景顏色
            writableCellFormat.setBackground(background);
            // 邊線
            writableCellFormat.setBorder(borderSide, borderStyle);

            return(writableCellFormat);
        }
示例#37
0
 /// <summary>
 /// Not supported; calling this method throws an exception because the collection is read-only.
 /// </summary>
 /// <param name="value">The style (<see cref="T:Dt.Cells.Data.StyleInfo" /> object) to add to the collection.</param>
 public void Add(StyleInfo value)
 {
     throw new InvalidOperationException(ResourceStrings.StyleInfoChangeReadOnlyCollectionError);
 }
示例#38
0
 internal CellValueRule(ComparisonOperator op, object value1, object value2, StyleInfo style) : base(style)
 {
     this.op     = op;
     this.value1 = value1;
     this.value2 = value2;
 }
示例#39
0
 /// <summary>
 /// Determines whether the collection contains the specified style.
 /// </summary>
 /// <param name="style">The style information.</param>
 /// <returns>
 /// <c>true</c> if the collection contains the specified style; otherwise, <c>false</c>.
 /// </returns>
 public bool Contains(StyleInfo style)
 {
     return(this.IndexOf(style) > -1);
 }
示例#40
0
        private void DrawBackground(Graphics g, System.Drawing.RectangleF rect, StyleInfo si)
        {
            LinearGradientBrush linGrBrush = null;
            SolidBrush          sb         = null;
            HatchBrush          hb         = null;

            try
            {
                if (si.BackgroundGradientType != BackgroundGradientTypeEnum.None &&
                    !si.BackgroundGradientEndColor.IsEmpty &&
                    !si.BackgroundColor.IsEmpty)
                {
                    Color c  = si.BackgroundColor;
                    Color ec = si.BackgroundGradientEndColor;

                    switch (si.BackgroundGradientType)
                    {
                    case BackgroundGradientTypeEnum.LeftRight:
                        linGrBrush = new LinearGradientBrush(rect, c, ec, LinearGradientMode.Horizontal);
                        break;

                    case BackgroundGradientTypeEnum.TopBottom:
                        linGrBrush = new LinearGradientBrush(rect, c, ec, LinearGradientMode.Vertical);
                        break;

                    case BackgroundGradientTypeEnum.Center:
                        linGrBrush = new LinearGradientBrush(rect, c, ec, LinearGradientMode.Horizontal);
                        break;

                    case BackgroundGradientTypeEnum.DiagonalLeft:
                        linGrBrush = new LinearGradientBrush(rect, c, ec, LinearGradientMode.ForwardDiagonal);
                        break;

                    case BackgroundGradientTypeEnum.DiagonalRight:
                        linGrBrush = new LinearGradientBrush(rect, c, ec, LinearGradientMode.BackwardDiagonal);
                        break;

                    case BackgroundGradientTypeEnum.HorizontalCenter:
                        linGrBrush = new LinearGradientBrush(rect, c, ec, LinearGradientMode.Horizontal);
                        break;

                    case BackgroundGradientTypeEnum.VerticalCenter:
                        linGrBrush = new LinearGradientBrush(rect, c, ec, LinearGradientMode.Vertical);
                        break;

                    default:
                        break;
                    }
                }
                if (si.PatternType != patternTypeEnum.None)
                {
                    switch (si.PatternType)
                    {
                    case patternTypeEnum.BackwardDiagonal:
                        hb = new HatchBrush(HatchStyle.BackwardDiagonal, si.Color, si.BackgroundColor);
                        break;

                    case patternTypeEnum.CheckerBoard:
                        hb = new HatchBrush(HatchStyle.LargeCheckerBoard, si.Color, si.BackgroundColor);
                        break;

                    case patternTypeEnum.Cross:
                        hb = new HatchBrush(HatchStyle.Cross, si.Color, si.BackgroundColor);
                        break;

                    case patternTypeEnum.DarkDownwardDiagonal:
                        hb = new HatchBrush(HatchStyle.DarkDownwardDiagonal, si.Color, si.BackgroundColor);
                        break;

                    case patternTypeEnum.DarkHorizontal:
                        hb = new HatchBrush(HatchStyle.DarkHorizontal, si.Color, si.BackgroundColor);
                        break;

                    case patternTypeEnum.DiagonalBrick:
                        hb = new HatchBrush(HatchStyle.DiagonalBrick, si.Color, si.BackgroundColor);
                        break;

                    case patternTypeEnum.HorizontalBrick:
                        hb = new HatchBrush(HatchStyle.HorizontalBrick, si.Color, si.BackgroundColor);
                        break;

                    case patternTypeEnum.LargeConfetti:
                        hb = new HatchBrush(HatchStyle.LargeConfetti, si.Color, si.BackgroundColor);
                        break;

                    case patternTypeEnum.OutlinedDiamond:
                        hb = new HatchBrush(HatchStyle.OutlinedDiamond, si.Color, si.BackgroundColor);
                        break;

                    case patternTypeEnum.SmallConfetti:
                        hb = new HatchBrush(HatchStyle.SmallConfetti, si.Color, si.BackgroundColor);
                        break;

                    case patternTypeEnum.SolidDiamond:
                        hb = new HatchBrush(HatchStyle.SolidDiamond, si.Color, si.BackgroundColor);
                        break;

                    case patternTypeEnum.Vertical:
                        hb = new HatchBrush(HatchStyle.Vertical, si.Color, si.BackgroundColor);
                        break;
                    }
                }

                if (linGrBrush != null)
                {
                    g.FillRectangle(linGrBrush, rect);
                    linGrBrush.Dispose();
                }
                else if (hb != null)
                {
                    g.FillRectangle(hb, rect);
                    hb.Dispose();
                }
                else if (!si.BackgroundColor.IsEmpty)
                {
                    sb = new SolidBrush(si.BackgroundColor);
                    g.FillRectangle(sb, rect);
                    sb.Dispose();
                }
            }
            finally
            {
                if (linGrBrush != null)
                {
                    linGrBrush.Dispose();
                }
                if (sb != null)
                {
                    sb.Dispose();
                }
            }
            return;
        }
示例#41
0
        private void DrawImageSized(PageImage pi, Xwt.Drawing.Image im, Xwt.Drawing.Context g, Xwt.Rectangle r)
        {
            double    height, width;   // some work variables
            StyleInfo si = pi.SI;

            Xwt.Rectangle r2 = new Xwt.Rectangle(r.X + PixelsX(si.PaddingLeft),
                                                 r.Y + PixelsY(si.PaddingTop),
                                                 r.Width - PixelsX(si.PaddingLeft + si.PaddingRight),
                                                 r.Height - PixelsY(si.PaddingTop + si.PaddingBottom));

            Xwt.Rectangle ir;   // int work rectangle
            switch (pi.Sizing)
            {
            case ImageSizingEnum.AutoSize:

                float imwidth  = PixelsX((float)im.Size.Width);
                float imheight = PixelsX((float)im.Size.Height);
                ir = new Xwt.Rectangle(Convert.ToInt32(r2.X), Convert.ToInt32(r2.Y),
                                       imwidth, imheight);

                im.Scale((int)r2.Width, (int)r2.Height);
                g.DrawImage(im, ir);

                break;

            case ImageSizingEnum.Clip:
                g.Save();
                g.Rectangle(r2);
                g.Clip();


                ir = new Xwt.Rectangle(Convert.ToInt32(r2.X), Convert.ToInt32(r2.Y),
                                       im.Size.Width, im.Size.Height);

                g.DrawImage(im, ir);
                g.Restore();
                break;

            case ImageSizingEnum.FitProportional:
                double ratioIm = (float)im.Size.Height / (float)im.Size.Width;
                double ratioR  = r2.Height / r2.Width;
                height = r2.Height;
                width  = r2.Width;
                if (ratioIm > ratioR)
                {
                    // this means the rectangle width must be corrected
                    width = height * (1 / ratioIm);
                }
                else if (ratioIm < ratioR)
                {
                    // this means the ractangle height must be corrected
                    height = width * ratioIm;
                }
                r2 = new Xwt.Rectangle(r2.X, r2.Y, width, height);
                g.DrawImage(im, r2);
                break;

            case ImageSizingEnum.Fit:
            default:
                g.DrawImage(im, r2);
                break;
            }
        }
示例#42
0
 public SVGBuilder()
 {
     PolyInfoList = new List<PolyInfo>();
     style = new StyleInfo();
 }
 void IStyleSheet.RegisterStyle(Style style, IUrlResolutionService urlResolver)
 {
     if (style == null)
     {
         throw new ArgumentNullException("style");
     }
     if (this._styles == null)
     {
         this._styles = new ArrayList();
     }
     else if (style.RegisteredCssClass.Length != 0)
     {
         throw new InvalidOperationException(System.Web.SR.GetString("HtmlHead_StyleAlreadyRegistered"));
     }
     if (urlResolver == null)
     {
         urlResolver = this;
     }
     StyleInfo info = new StyleInfo {
         style = style,
         urlResolver = urlResolver
     };
     string cssClass = "aspnet_s" + this._autoGenCount++.ToString(NumberFormatInfo.InvariantInfo);
     style.SetRegisteredCssClass(cssClass);
     this._styles.Add(info);
 }