Exemplo n.º 1
0
        private void cboLineSpacingStyle_SelectedIndexChanged(object sender, EventArgs e)
        {
            LineSpacingStyle style = (LineSpacingStyle)cboLineSpacingStyle.SelectedIndex;

            switch (style)
            {
            case LineSpacingStyle.SpaceSingle:
            case LineSpacingStyle.Space1pt5:
            case LineSpacingStyle.SpaceDouble:
            case LineSpacingStyle.SpaceExactly:
                txtLineSpacing.Value     = 0;
                txtLineSpacing.Enabled   = false;
                txtLineSpacing.Increment = 1m;
                lblBang.Visible          = false;
                break;

            case LineSpacingStyle.SpaceSpecify:
                txtLineSpacing.Enabled   = true;
                txtLineSpacing.Value     = (decimal)(GraphicsUnitConvert.ToTwips(_CommandParameter.LineSpacing, GraphicsUnit.Document) / 20.0);
                txtLineSpacing.Increment = 1m;
                lblBang.Visible          = true;
                break;

            case LineSpacingStyle.SpaceMultiple:
                txtLineSpacing.Value     = 3;
                txtLineSpacing.Increment = 0.25m;
                lblBang.Visible          = false;
                txtLineSpacing.Enabled   = true;
                break;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 输出嵌入在RTF文档中的文档元素对象
        /// </summary>
        /// <param name="element">文档元素对象</param>
        /// <param name="attributes">属性列表</param>
        /// <param name="resultImage">表示元素内容的图片对象</param>
        public void WriteEmbObject(
            DomElement element,
            Image resultImage)
        {
            bool disposeImage = false;

            if (resultImage == null)
            {
                resultImage  = element.CreateContentImage();
                disposeImage = true;
            }
            Size size = new Size(
                GraphicsUnitConvert.ToTwips(resultImage.Width, GraphicsUnit.Pixel),
                GraphicsUnitConvert.ToTwips(resultImage.Height, GraphicsUnit.Pixel));

            this.WriteStartGroup();
            this.WriteKeyword("object");
            this.WriteKeyword("objemb");
            this.WriteCustomAttribute("objclass", XWriterObjectPrefix + element.GetType().FullName, true);
            this.WriteKeyword("objw" + size.Width);
            this.WriteKeyword("objh" + size.Height);

            StringWriter  writer = new StringWriter();
            XmlSerializer ser    = Xml.MyXmlSerializeHelper.GetElementXmlSerializer(element.GetType());

            ser.Serialize(writer, element);
            writer.Close();
            string xmlText = writer.ToString();

            byte[] bs = Encoding.UTF8.GetBytes(xmlText);
            this.WriteStartGroup();
            this.WriteKeyword("objdata", true);
            this.WriteBytes(bs);
            this.WriteEndGroup();

            this.WriteStartGroup();

            this.WriteKeyword("result");
            this.WriteImage(
                resultImage,
                resultImage.Width,
                resultImage.Height,
                null,
                element.RuntimeStyle);
            this.WriteEndGroup();

            this.WriteEndGroup();

            if (disposeImage)
            {
                resultImage.Dispose();
            }
        }
Exemplo n.º 3
0
 private void dlgParagraphFormatcs_Load(object sender, EventArgs e)
 {
     if (_CommandParameter == null)
     {
         _CommandParameter = new ParagraphFormatCommandParameter();
     }
     this.txtLeftIndent.Value          = ( decimal )(GraphicsUnitConvert.ToTwips(_CommandParameter.LeftIndent, GraphicsUnit.Document) / 210.0);
     txtFirstLineIndent.Value          = (decimal)(GraphicsUnitConvert.Convert(_CommandParameter.FirstLineIndent, GraphicsUnit.Document, GraphicsUnit.Millimeter) / 10.0);
     txtSpacingBefore.Value            = (decimal)(GraphicsUnitConvert.ToTwips(_CommandParameter.SpacingBefore, GraphicsUnit.Document) / 312.0);
     txtSpacingAfter.Value             = (decimal)(GraphicsUnitConvert.ToTwips(_CommandParameter.SpacingAfter, GraphicsUnit.Document) / 312.0);
     cboLineSpacingStyle.SelectedIndex = (int)_CommandParameter.LineSpacingStyle;
     cboLineSpacingStyle_SelectedIndexChanged(null, null);
 }
Exemplo n.º 4
0
 public int ToTwips(float Value)
 {
     return(GraphicsUnitConvert.ToTwips(Value, this.MainDocument.DocumentGraphicsUnit));
 }
Exemplo n.º 5
0
        public static DocumentFormatInfo ToDocumentFormatInfo(
            DocumentContentStyle style,
            GraphicsUnit documentUnit)
        {
            if (style == null)
            {
                throw new ArgumentNullException("style");
            }
            DocumentFormatInfo result = new DocumentFormatInfo();

            switch (style.Align)
            {
            case DocumentContentAlignment.Left:
                result.Align = RTFAlignment.Left;
                break;

            case DocumentContentAlignment.Center:
                result.Align = RTFAlignment.Center;
                break;

            case DocumentContentAlignment.Right:
                result.Align = RTFAlignment.Right;
                break;

            case DocumentContentAlignment.Justify:
                result.Align = RTFAlignment.Justify;
                break;
            }
            result.BackColor    = style.BackgroundColor;
            result.Bold         = style.Bold;
            result.BulletedList = style.BulletedList;
            result.FontName     = style.FontName;
            result.FontSize     = style.FontSize;
            result.Italic       = style.Italic;

            result.LeftBorder    = style.BorderLeft;
            result.TopBorder     = style.BorderTop;
            result.RightBorder   = style.BorderRight;
            result.BottomBorder  = style.BorderBottom;
            result.BorderColor   = style.BorderColor;
            result.BorderStyle   = style.BorderStyle;
            result.BorderSpacing = (int)GraphicsUnitConvert.ToTwips(
                style.BorderSpacing,
                documentUnit);
            result.LeftIndent = (int)GraphicsUnitConvert.ToTwips(
                style.LeftIndent,
                documentUnit);
            result.LineSpacing = (int)GraphicsUnitConvert.ToTwips(
                style.LineSpacing,
                documentUnit);
            result.Link                     = style.Link;
            result.NumberedList             = style.NumberedList;
            result.ParagraphFirstLineIndent = (int)GraphicsUnitConvert.ToTwips(
                style.FirstLineIndent,
                documentUnit);
            result.Spacing = (int)GraphicsUnitConvert.ToTwips(
                style.Spacing,
                documentUnit);
            result.Strikeout   = style.Strikeout;
            result.Subscript   = style.Subscript;
            result.Superscript = style.Superscript;
            result.TextColor   = style.Color;
            result.Underline   = style.Underline;
            return(result);
        }