Exemplo n.º 1
0
        private void FillFontControls(RasterFont font)
        {
            if (font == null)
            {
                return;
            }
            updateFont = true;

            // textbox
            txtFontName.Text = currentFont.Name;

            // combobox
            RefillSizesComboBox();

            if (cboSizes.Items.Count > 0)
            {
                updateSize             = true;
                cboSizes.SelectedIndex = 0;
                updateSize             = false;
            }

            updateFont = false;

            ShowSize((SizeInfo)cboSizes.SelectedItem);
        }
Exemplo n.º 2
0
        public static RasterFont LoadFont(string filenName)
        {
            string      text = File.ReadAllText(filenName);
            XmlDocument doc  = new XmlDocument();

            doc.Load(new StringReader(text));

            return(RasterFont.FromXML(doc.DocumentElement));
        }
Exemplo n.º 3
0
        private void RefillSizesComboBox()
        {
            RasterFont font = getCurrentFont();

            cboSizes.Items.Clear();
            cboCharacter.SelectedItems.Clear();
            foreach (SizeInfo s in font.SizeInfos)
            {
                cboSizes.Items.Add(s);
            }
        }
Exemplo n.º 4
0
        private void ShowFont(RasterFont font)
        {
            if (font == null)
            {
                ForbitEditingFont();
                return;
            }

            AllowEditingFont();
            FillFontControls(font);
        }
Exemplo n.º 5
0
        private void txtFontName_TextChanged(object sender, EventArgs e)
        {
            if (updateFont)
            {
                return;
            }

            RasterFont font = getCurrentFont();

            if (font == null)
            {
                return;
            }

            font.Name = txtFontName.Text;
        }
Exemplo n.º 6
0
        private void btnDeleteSize_Click(object sender, EventArgs e)
        {
            RasterFont font = getCurrentFont();

            if (font == null)
            {
                return;
            }

            SizeInfo size = (SizeInfo)cboSizes.SelectedItem;

            if (size == null)
            {
                return;
            }

            updateSize = true;

            // remove from list
            font.SizeInfos.Remove(size);

            // find combo entry
            int index = cboSizes.Items.IndexOf(size);

            // remove combo entry
            cboSizes.Items.Remove(size);

            // select next size
            if (index < cboSizes.Items.Count)
            {
                cboSizes.SelectedIndex = index;
            }
            else if (cboSizes.Items.Count > 0)
            {
                cboSizes.SelectedIndex = index - 1;
            }
            else
            {
                cboSizes.SelectedItem = null;// last cbo entry removed
            }

            updateSize = false;

            ShowSize((SizeInfo)cboSizes.SelectedItem);
        }
Exemplo n.º 7
0
        private void btnAddSize_Click(object sender, EventArgs e)
        {
            RasterFont font = getCurrentFont();

            if (font == null)
            {
                return;
            }

            SizeInfo size = new SizeInfo("new_Size", 10, 10);

            updateSize = true;
            font.SizeInfos.Add(size);
            cboSizes.Items.Add(size);
            cboSizes.SelectedItem = size;
            updateSize            = false;

            ShowSize(size);
        }
Exemplo n.º 8
0
        public static string SaveFont(RasterFont font, string filename)
        {
            XmlDocument doc     = new XmlDocument();
            XmlElement  xmlFont = font.ToXml(doc);

            doc.AppendChild(xmlFont);

            StringWriter  stringWriter  = new StringWriter();
            XmlTextWriter xmlTextWriter = new XmlTextWriter(stringWriter);

            xmlTextWriter.Formatting  = Formatting.Indented;
            xmlTextWriter.Indentation = 4;
            doc.WriteTo(xmlTextWriter);

            string text = stringWriter.ToString();

            File.WriteAllText(filename, text);

            return(text);
        }
Exemplo n.º 9
0
        public static RasterFont FromXML(XmlElement elem)
        {
            RasterFont font = new RasterFont();

            font.Name = elem.Attributes["Name"].Value;

            foreach (XmlNode elemSizes in elem.ChildNodes)
            {
                if (elemSizes.Name != "Sizes")
                {
                    continue;
                }

                foreach (XmlNode s in elemSizes.ChildNodes)
                {
                    SizeInfo size = SizeInfo.FromXML((XmlElement)s);
                    font.SizeInfos.Add(size);
                }
            }
            return(font);
        }
Exemplo n.º 10
0
 private void btnNewFont_Click(object sender, EventArgs e)
 {
     currentFont = new RasterFont();
     ShowFont(currentFont);
 }