/// <summary> /// Appends the specified style parts to the current one. The parts can be instances of sub-classes like Border or CellXf or a Style instance. Only the altered properties of the specified style or style part that differs from a new / untouched style instance will be appended. This enables method chaining /// </summary> /// <param name="styleToAppend">The style to append or a sub-class of Style</param> /// <returns>Current style with appended style parts</returns> public Style Append(AbstractStyle styleToAppend) { if (styleToAppend.GetType() == typeof(Border)) { CurrentBorder.CopyProperties<Border>((Border)styleToAppend, new Border()); } else if (styleToAppend.GetType() == typeof(CellXf)) { CurrentCellXf.CopyProperties<CellXf>((CellXf)styleToAppend, new CellXf()); } else if (styleToAppend.GetType() == typeof(Fill)) { CurrentFill.CopyProperties<Fill>((Fill)styleToAppend, new Fill()); } else if (styleToAppend.GetType() == typeof(Font)) { CurrentFont.CopyProperties<Font>((Font)styleToAppend, new Font()); } else if (styleToAppend.GetType() == typeof(NumberFormat)) { CurrentNumberFormat.CopyProperties<NumberFormat>((NumberFormat)styleToAppend, new NumberFormat()); } else if (styleToAppend.GetType() == typeof(Style)) { CurrentBorder.CopyProperties<Border>(((Style)styleToAppend).CurrentBorder, new Border()); CurrentCellXf.CopyProperties<CellXf>(((Style)styleToAppend).CurrentCellXf, new CellXf()); CurrentFill.CopyProperties<Fill>(((Style)styleToAppend).CurrentFill, new Fill()); CurrentFont.CopyProperties<Font>(((Style)styleToAppend).CurrentFont, new Font()); CurrentNumberFormat.CopyProperties<NumberFormat>(((Style)styleToAppend).CurrentNumberFormat, new NumberFormat()); } return this; }
protected override void OnShown(EventArgs e) { base.OnShown(e); if (CurrentFont.Chars.Count == 0) { return; } charSelectUpDown.Maximum = CurrentFont.Chars.Count - 1; charSelectUpDown_ValueChanged(null, new EventArgs()); Master.ImportedFont = CurrentFont.MakeMfeFont(CodePageTable.CopyFromFont(new Font())); destCharPreviewer.Char = ImportedFont[(int)destSelectUpDown.Value]; Master.Chart.RefreshData(); }
public void SetFont(FontFace font) { if (_fonts.Count > 0) { if (CurrentFont.Equals(font)) { return; } } ImportFont(font); CurrentFontIndex = _fonts.IndexOf(font); }
/// <summary> /// Method to copy the current object to a new one without casting /// </summary> /// <returns>Copy of the current object without the internal ID</returns> public override AbstractStyle Copy() { if (CurrentBorder == null || CurrentCellXf == null || CurrentFill == null || CurrentFont == null || CurrentNumberFormat == null) { throw new StyleException("MissingReferenceException", "The style could not be copied because one or more components are missing as references"); } Style copy = new Style(); copy.CurrentBorder = CurrentBorder.CopyBorder(); copy.CurrentCellXf = CurrentCellXf.CopyCellXf(); copy.CurrentFill = CurrentFill.CopyFill(); copy.CurrentFont = CurrentFont.CopyFont(); copy.CurrentNumberFormat = CurrentNumberFormat.CopyNumberFormat(); return copy; }
private void defaultCpButton_Click(object sender, EventArgs e) { try { // Ugly kludge, but whatever Master.ImportedFont = CurrentFont.MakeMfeFont(CodePageTable.CopyFromFont(new Font())); destCharPreviewer.Char = ImportedFont[(int)destSelectUpDown.Value]; Master.Chart.RefreshData(); } catch (Exception f) { MessageBox.Show("Error: " + f.ToString(), "Error Loading Codepage File", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// save the asset to the manager /// </summary> public override void Save() { StringBuilder sb = new StringBuilder(); using (XmlWriter writer = XmlWriter.Create(sb)) CurrentFont.Save(writer); string xml = sb.ToString(); XmlDocument doc = new XmlDocument(); doc.LoadXml(xml); ResourceManager.AddAsset <ArcEngine.Asset.BitmapFont>(CurrentFont.Name, doc.DocumentElement); }
public override void DrawString(String stringToPrint, float x, float y) { if (stringToPrint == null) { return; } //Prepare openGL for rendering the font characters PushOrthoProjection(); Gl.glPushAttrib(Gl.GL_LIST_BIT | Gl.GL_CURRENT_BIT | Gl.GL_ENABLE_BIT | Gl.GL_TRANSFORM_BIT); Gl.glMatrixMode(Gl.GL_MODELVIEW); Gl.glDisable(Gl.GL_LIGHTING); Gl.glEnable(Gl.GL_TEXTURE_2D); Gl.glDisable(Gl.GL_DEPTH_TEST); Gl.glEnable(Gl.GL_BLEND); Gl.glBlendFunc(Gl.GL_SRC_ALPHA, Gl.GL_ONE_MINUS_SRC_ALPHA); float[] modelview_matrix = new float[16]; Gl.glGetFloatv(Gl.GL_MODELVIEW_MATRIX, modelview_matrix); Gl.glPushMatrix(); Gl.glLoadIdentity(); Gl.glTranslatef(x, y, 0); Gl.glMultMatrixf(modelview_matrix); Gl.glColor4f(m_Color.RedF, m_Color.GreenF, m_Color.BlueF, m_Color.AlphaF); for (int i = 0; i < stringToPrint.Length; i++) { int unicodeCharacter = stringToPrint[i]; Image characterImage = CurrentFont.GetCharacterImage(unicodeCharacter); ImageGLDisplayListPlugin GLDisplayForImage = ImageGLDisplayListPlugin.GetImageGLDisplayListPlugin(characterImage); Gl.glTranslatef(CurrentFont.GetCharacterLeftOffset(unicodeCharacter), 0, 0); Gl.glPushMatrix(); Gl.glTranslatef(0, CurrentFont.GetCharacterTopOffset(unicodeCharacter) - characterImage.Height, 0); Gl.glCallList(GLDisplayForImage.GLDisplayList); Gl.glPopMatrix(); //Advance for the next character Gl.glTranslatef(characterImage.Width, 0, 0); } Gl.glColor4f(1, 1, 1, 1); //Restore openGL state Gl.glPopMatrix(); Gl.glPopAttrib(); PopOrthoProjection(); }
/// <summary> /// Function to select the font object into the device context. /// </summary> private void SelectFont() { if (_hDc == IntPtr.Zero) { _hDc = _graphics.GetHdc(); } if (_hFont == IntPtr.Zero) { _hFont = CurrentFont.ToHfont(); } if (_prevHObj == IntPtr.Zero) { _prevHObj = Win32API.SelectObject(_hDc, _hFont); } }
private void loadCpButton_Click(object sender, EventArgs e) { if (loadCodepageDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { try { ImportedFont = CurrentFont.MakeMfeFont( CodePageTable.FromFile(loadCodepageDialog.FileName) ); destCharPreviewer.Char = ImportedFont[(int)destSelectUpDown.Value]; Master.Chart.RefreshData(); } catch (Exception f) { MessageBox.Show("Error: " + f.ToString(), "Error Loading Codepage File", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
/// <summary> /// Imports the specified <see cref="FontFace"/> into this <see cref="TextFactory"/> if it hasn't already been imported. /// </summary> public void ImportFont(FontFace font) { if (font is null) { return; } if (_fonts.Count > 0) { if (CurrentFont.Equals(font)) { return; } } if (!_fonts.Contains(font)) { _fonts.Add(font); } }
/// <summary> /// Form closing /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BitmapFontForm_FormClosed(object sender, FormClosedEventArgs e) { if (Batch != null) { Batch.Dispose(); } Batch = null; if (CurrentFont != null) { CurrentFont.Dispose(); } CurrentFont = null; if (CheckerBoard != null) { CheckerBoard.Dispose(); } CheckerBoard = null; }
/// <summary> /// Override method to calculate the hash of this component /// </summary> /// <returns>Calculated hash as string</returns> public sealed override string CalculateHash() { StringBuilder sb = new StringBuilder(); if (CurrentBorder == null || CurrentCellXf == null || CurrentFill == null || CurrentFont == null || CurrentNumberFormat == null) { throw new StyleException("MissingReferenceException", "The hash of the style could not be created because one or more components are missing as references"); } sb.Append(StyleManager.STYLEPREFIX); if (InternalID.HasValue == true) { sb.Append(InternalID.Value); sb.Append(':'); } sb.Append(CurrentBorder.CalculateHash()); sb.Append(CurrentCellXf.CalculateHash()); sb.Append(CurrentFill.CalculateHash()); sb.Append(CurrentFont.CalculateHash()); sb.Append(CurrentNumberFormat.CalculateHash()); return(sb.ToString()); }