Пример #1
0
        private void SelectGlyph(char glyph)
        {
            var glyphData = this.glyphsList.GetGlyphData(glyph);

            if (glyphData == null)
            {
                MessageBox.Show("Glyph '" + glyph + "' do not exist in glyph list.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                this.currentGlyph = new GlyphData
                {
                    Glyph     = glyph,
                    XPosition = glyphData.XPosition,
                    YPosition = glyphData.YPosition,
                    Width     = glyphData.Width,
                    Height    = glyphData.Height
                };

                this.selectionManager.SelectionRect = glyphData.GetGlyphRect(this.zoom);

                this.ShowGlyphData();
                pictureBoxImagem.Invalidate();
            }
        }
Пример #2
0
        private void CreateDividedGlyph(ref int glyphCode, int x, int y)
        {
            var glyphArea = new Rectangle(x, y, this.formQuickDivide.GlyphsWidth, this.formQuickDivide.GlyphsHeight);
            var img       = this.DrawImageCopy(glyphArea, pictureBoxPedacoImg);

            var glyphData = new GlyphData();

            if (this.formQuickDivide.CharEnumerator.MoveNext())
            {
                glyphData.Glyph = this.formQuickDivide.CharEnumerator.Current;
            }

            if (this.glyphsList.GetGlyphData(glyphData.Glyph) != null)
            {
                glyphData.Glyph = '\0';
            }

            if (glyphData.Glyph == '\0')
            {
                do
                {
                    glyphCode++;
                    glyphData.Glyph = (char)glyphCode;
                }while (this.glyphsList.GetGlyphData(glyphData.Glyph) != null);
            }

            glyphData.SetGlyphRect(glyphArea, 100);

            this.glyphsList.SaveGlyph(glyphData, img);
        }
Пример #3
0
 private void ClearSelection()
 {
     this.selectionManager.ResetSelection();
     this.currentGlyph = null;
     this.ShowGlyphData();
     pictureBoxImagem.Invalidate();
 }
Пример #4
0
        public void EditSelectedGlyph(GlyphData newData, Image newImg)
        {
            var selectedGlyphData = GetSelectedGlyphData();

            selectedGlyphData.SetGlyphRect(newData.GetGlyphRect(), 100);

            var key = selectedGlyphData.Glyph + "";

            listViewGlyphs.LargeImageList.Images.RemoveByKey(key);
            listViewGlyphs.LargeImageList.Images.Add(key, newImg);

            this.listViewGlyphs.Invalidate();
        }
Пример #5
0
        public void SaveGlyph(GlyphData glyphData, Image image)
        {
            var glyph = glyphData.Glyph;

            if (glyphs.ContainsKey(glyph))
            {
                throw new Exception("Glyph '" + glyph + "' already exists in glyphs list.");
            }
            else
            {
                this.AddGlyphToListView(glyph, image);
                this.glyphs.Add(glyph, glyphData);
            }
        }
Пример #6
0
        private void UpdateCurrentGlyph()
        {
            if (this.selectionManager.SelectionRectHasArea())
            {
                var selectedArea = this.selectionManager.SelectionRect;

                if (this.currentGlyph == null)
                {
                    this.currentGlyph = new GlyphData();
                }

                this.currentGlyph.SetGlyphRect(selectedArea, this.zoom);
            }
            else
            {
                this.currentGlyph = null;
                listViewGlyphs.SelectedItems.Clear();
            }

            this.ShowGlyphData();

            pictureBoxImagem.Invalidate();
        }
Пример #7
0
        private void ImportGlyphsData()
        {
            var imgSize = new Bitmap(this.ImagePath).Size;

            this.GlyphDataList = new List <GlyphData>();

            using (var reader = new StreamReader(this.FontsettingsPath))
            {
                var indexIdentifier = "    index: ";
                var xIdentifier     = "      x: ";
                var yIdentifier     = "      y: ";
                var wIdentifier     = "      width: ";
                var hIdentifier     = "      height: ";
                var vertSession     = false;

                GlyphData currentGlyphData = null;
                double    uvX   = Double.NaN;
                double    uvY   = Double.NaN;
                double    uvW   = Double.NaN;
                double    uvH   = Double.NaN;
                double    vertW = Double.NaN;
                double    vertH = Double.NaN;

                string line = "";
                do
                {
                    Console.WriteLine(line);
                    if (line.Contains(indexIdentifier))
                    {
                        //create glyph data
                        currentGlyphData = new GlyphData();
                        var indexStr = line.Replace(indexIdentifier, "");
                        var index    = Convert.ToInt32(indexStr);
                        currentGlyphData.Glyph = (char)index;
                        this.GlyphDataList.Add(currentGlyphData);

                        uvX   = Double.NaN;
                        uvY   = Double.NaN;
                        uvW   = Double.NaN;
                        uvH   = Double.NaN;
                        vertW = Double.NaN;
                        vertH = Double.NaN;
                    }
                    else if (!vertSession && line.Contains(xIdentifier))
                    {
                        var str = line.Replace(xIdentifier, "");
                        uvX = Convert.ToDouble(str, CultureInfo.GetCultureInfo("en-US"));
                    }
                    else if (!vertSession && line.Contains(yIdentifier))
                    {
                        var str = line.Replace(yIdentifier, "");
                        uvY = Convert.ToDouble(str, CultureInfo.GetCultureInfo("en-US"));
                    }
                    else if (line.Contains(wIdentifier))
                    {
                        var str = line.Replace(wIdentifier, "");
                        var dbl = Convert.ToDouble(str, CultureInfo.GetCultureInfo("en-US"));

                        if (vertSession)
                        {
                            vertW = dbl;
                        }
                        else
                        {
                            uvW = dbl;
                        }
                    }
                    else if (line.Contains(hIdentifier))
                    {
                        var str = line.Replace(hIdentifier, "");
                        var dbl = Convert.ToDouble(str, CultureInfo.GetCultureInfo("en-US"));

                        if (vertSession)
                        {
                            vertH = dbl;

                            //insert glyph data
                            currentGlyphData.SetGlyphRect(this.ImportGlyphRect(uvX, uvY, uvW, uvH, vertW, vertH, imgSize), 100);
                        }
                        else
                        {
                            uvH = dbl;
                        }

                        vertSession = !vertSession;
                    }

                    line = reader.ReadLine();
                }while (line != null);
            }
        }