Beispiel #1
0
        public EditGlyphForm( Glyph glyph, ReadOnlyCollection<string> existingNames )
        {
            InitializeComponent( );

            this.glyph = glyph;
            if ( glyph.UserData == null )
                glyph.UserData = new GlyphVisualizationData( Color.Red );
            visualizationData = (GlyphVisualizationData) glyph.UserData;

            forbiddenNames = existingNames;

            // show information about the glyph
            glyphEditor.GlyphData = (byte[,]) glyph.Data.Clone( );
            nameBox.Text = glyph.Name;
            colorButton.BackColor = visualizationData.Color;
            UpdateGlyphIcon( );
        }
Beispiel #2
0
        // Load information about databases and glyphs from XML reader
        public void Load( XmlTextReader xmlIn )
        {
            // read to the first node
            xmlIn.Read( );

            int startingDept = xmlIn.Depth;

            while ( ( xmlIn.Name == databaseTag ) && ( xmlIn.NodeType == XmlNodeType.Element ) && ( xmlIn.Depth >= startingDept ) )
            {
                string name = xmlIn.GetAttribute( nameAttr );
                int size = int.Parse( xmlIn.GetAttribute( sizeAttr ) );
                int count = int.Parse( xmlIn.GetAttribute( countAttr ) );

                // create new database and add it to collection
                GlyphDatabase db = new GlyphDatabase( size );
                AddGlyphDatabase( name, db );

                if ( count > 0 )
                {
                    // read all glyphs
                    for ( int i = 0; i < count; i++ )
                    {
                        // read to the next glyph node
                        xmlIn.Read( );

                        string glyphName = xmlIn.GetAttribute( nameAttr );
                        string glyphStrData = xmlIn.GetAttribute( dataAttr );

                        // create new glyph and add it database
                        Glyph glyph = new Glyph( glyphName, GlyphDataFromString( glyphStrData, size ) );
                        db.Add( glyph );

                        // read visualization params
                        GlyphVisualizationData visualization = new GlyphVisualizationData( Color.Red );

                        visualization.ImageName = xmlIn.GetAttribute( iconAttr );
                        visualization.ModelName = xmlIn.GetAttribute( modelAttr );

                        string colorStr = xmlIn.GetAttribute( colorAttr );

                        if ( colorStr != null )
                        {
                            string[] rgbStr = colorStr.Split( ',' );

                            visualization.Color = Color.FromArgb(
                                int.Parse( rgbStr[0] ), int.Parse( rgbStr[1] ), int.Parse( rgbStr[2] ) );
                        }

                        glyph.UserData = visualization;
                    }

                    // read to the end tag
                    xmlIn.Read( );
                }

                // read to the next node
                xmlIn.Read( );
            }
        }