Franken_.App_Code.Font.AddEmptyGlyph C# (CSharp) Method

AddEmptyGlyph() public method

public AddEmptyGlyph ( string Unicode ) : string
Unicode string
return string
        public string AddEmptyGlyph(string Unicode)
        {
            Glyph G = new Glyph();
            G.FontID = this.ID;
            G.Unicode = Unicode;
            G.Save(false);
            return G.ID;
        }

Usage Example

Example #1
0
        private void okButton_Click(object sender, EventArgs e)
        {
            string newGlyphID = "";

            if (comboButton.Checked)
            {
                if (comboBox.SelectedItem != null)
                {
                    newGlyphID = (comboBox.SelectedItem as Glyph).ID;
                }
                else
                {
                    MessageBox.Show("Please choose a new character for reclassification.");
                }
            }
            else
            {
                if (boxBox.Text != "")
                {
                    for (int x = 0; x < myFont.Glyphs.Count; x++)
                    {
                        if (myFont.Glyphs[x].Unicode == boxBox.Text)
                        {
                            newGlyphID = myFont.Glyphs[x].ID;
                            break;
                        }
                    }

                    if (newGlyphID == "")
                    {
                        newGlyphID = myFont.AddEmptyGlyph(boxBox.Text.Trim());
                    }
                }
                else
                {
                    MessageBox.Show("Please enter a new character for reclassification.");
                }
            }

            if (newGlyphID != "")
            {
                if (modeReclassButton.Checked)
                {
                    db.ExecuteCommand("update images set img_glyph_id = " + newGlyphID + " where img_glyph_id = " + glyphToReclassifyID);
                    db.ExecuteCommand("delete from glyphs where glyph_id = " + glyphToReclassifyID);
                }
                else
                {
                    if (db.GetRows("select * from images where img_glyph_id = " + glyphToReclassifyID))
                    {
                        DataTable Gs = db.Bucket.Copy();
                        foreach (DataRow G in Gs.Rows)
                        {
                            string gID = db.GetNewID("images");
                            db.ExecuteCommand("INSERT INTO images " +
                                              "(img_id, img_glyph_id, img_path, img_status) " +
                                              "VALUES (" + gID + ", " + newGlyphID + ", '" + db.FixString(G["img_path"].ToString()) + "', '" + db.FixString(G["img_status"].ToString()) + "')");
                        }
                    }
                }

                this.DialogResult = System.Windows.Forms.DialogResult.OK;
                this.Close();
            }
        }