void PutFont(FontParams fp, MSWord.Selection sel) { MSWord.Font pFont = sel.Font; if (fp.styleName != "") { sel.set_Style(m_pDoc.Styles[fp.styleName]); } if (fp.fontName != "") { pFont.Name = fp.fontName; } if (fp.bold != null) { if ((bool)fp.bold) { pFont.Bold = 1; } else { pFont.Bold = 0; } } if (fp.italic != null) { if ((bool)fp.italic) { pFont.Italic = 1; } else { pFont.Italic = 0; } } if (fp.underline != null) { if ((bool)fp.underline) { pFont.Underline = MSWord.WdUnderline.wdUnderlineSingle; } else { pFont.Underline = MSWord.WdUnderline.wdUnderlineNone; } } if (fp.fontHeight > 0) { pFont.Size = fp.fontHeight; } }
/*public void ConvertToTable(string strTable) * { * if (m_pSelection == null) * { * if (m_pDoc == null) m_pDoc = m_pApp.ActiveDocument; * if (m_pApp == null) return; * * m_pDoc.Select(); * m_pSelection = m_pApp.Selection; * if (m_pSelection == null) return; * } * * if (m_pSelection == null) return; * m_pSelection.Collapse(0); * * object varInfo = m_pSelection.get_Information(MSWord.WdInformation.wdWithInTable); * if (Convert.ToBoolean(varInfo) == true) * { * m_pDoc.Select(); * m_pSelection = m_pApp.Selection; * if (m_pSelection == null) return; * m_pSelection.Collapse(0); * } * * m_pSelection.Font.Bold = 0; * m_pSelection.Text = strTable; * * m_pSelection.Paragraphs.SpaceAfter = 0; * m_pSelection.Paragraphs.SpaceBefore = 0; * * m_pTable = m_pSelection.ConvertToTable(1, Type.Missing, Type.Missing, Type.Missing, Type.Missing, * Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, * Type.Missing, 0, 0); * * if (m_pTable == null) return; * * MSWord.Rows pRows = m_pSelection.Rows; * pRows.AllowBreakAcrossPages = 0; * //m_pApp.WordBasic.OpenOrCloseParaBelow; * //m_pApp.WordBasic.OpenOrCloseParaAbove; * * m_pSelection.Collapse(); * * MSWord.Borders pBorders = m_pTable.Borders; * if (pBorders == null) return; * pBorders.Enable = 1; * }*/ public void SetTableFont(FontParams fp, int indTable = -1) { GetTableReference(indTable); m_pTable.Select(); PutFont(fp, m_pApp.Selection); if (fp.styleName != "") { m_pSelection = m_pApp.Selection; m_pSelection.Paragraphs.SpaceAfter = 0; m_pSelection.Paragraphs.SpaceBefore = 0; m_pSelection.Paragraphs.LineSpacingRule = MSWord.WdLineSpacing.wdLineSpaceSingle; } }
public void SetText(string strText, MSWord.WdParagraphAlignment hAlignment, FontParams font = null) { if (m_pSelection == null) { if (m_pDoc == null) { m_pDoc = m_pApp.ActiveDocument; } if (m_pApp == null) { return; } m_pDoc.Select(); m_pSelection = m_pApp.Selection; if (m_pSelection == null) { return; } } object varInfo = m_pSelection.get_Information(MSWord.WdInformation.wdWithInTable); if (Convert.ToBoolean(varInfo) == true) { m_pDoc.Select(); m_pSelection = m_pApp.Selection; if (m_pSelection == null) { return; } m_pSelection.Collapse(0); } MSWord.ParagraphFormat pf = m_pSelection.ParagraphFormat; pf.Alignment = hAlignment; m_pSelection.Text = strText; if (font != null) { PutFont(font, m_pSelection); } m_pSelection.Collapse(0); }
/// <summary> /// Creates DXFont from params /// </summary> public void CreateDXFont() { switch (FontSource) { case GuiFontType.SystemFont: { string name = "Tahoma"; float size = 12.0f; System.Drawing.FontStyle style = System.Drawing.FontStyle.Regular; if (FontParams.ContainsKey("FontName")) { name = FontParams["FontName"]; } if (FontParams.ContainsKey("FontSize")) { float.TryParse(FontParams["FontSize"], out size); } if (FontParams.ContainsKey("FontStyle")) { style = (System.Drawing.FontStyle)System.Drawing.FontStyle.Parse(style.GetType(), FontParams["FontStyle"]); } this.dxFont = new Microsoft.DirectX.Direct3D.Font(GameEngine.Instance.RenderEngine.Device, new System.Drawing.Font(name, size, style)); break; } default: { this.dxFont = new Microsoft.DirectX.Direct3D.Font(GameEngine.Instance.RenderEngine.Device, GameEngine.Instance.Target.Font); Console.Write("\t\tUnknown FontSource: " + FontSource.ToString()); break; } } }
public void FromXml(XmlNode node) { if (node["Id"] != null) { this.id = node["Id"].InnerText; } if (node["Source"] != null) { this.FontSource = (GuiFontType)GuiFontType.Parse(typeof(GuiFontType), node["Source"].InnerText); } if (node["Params"] != null) { FontParams.Clear(); foreach (XmlElement el in node["Params"].ChildNodes) { FontParams.Add(el.Name, el.InnerText); } } CreateDXFont(); }
public void SetCellsFont(int FirstColumn, int LastColumn, int FirstRow, int LastRow, FontParams fp, int indTable = -1) { GetTableReference(indTable); MSWord.Cell pCellBegin = m_pTable.Cell(FirstRow, FirstColumn); MSWord.Cell pCellEnd = m_pTable.Cell(LastRow, LastColumn); if (pCellBegin == null) { return; } if (pCellEnd == null) { return; } MSWord.Range range = m_pDoc.Range(pCellBegin.Range.Start, pCellEnd.Range.End); range.Select(); PutFont(fp, m_pApp.Selection); }
public void Initialize( ) { mFont = new FontParams( ); }