Nohal.RleEditor.RleParser.BitmapPattern.IsValid C# (CSharp) Method

IsValid() public method

public IsValid ( ) : bool
return bool
        public override bool IsValid()
        {
            //TODO - implement more validation
            if (BitmapData.Length < 1) //Not enough...
            {
                _isvalid = false;
            }
            if (this.Code.Length != 8)
            {
                _isvalid = false;
            }
            if (this.Colors.Count < 1)
            {
                _isvalid = false;
            }
            if (this.Height < 1 || this.Width < 1)
            {
                _isvalid = false;
            }
            return _isvalid;
        }

Usage Example

Ejemplo n.º 1
0
        public void MergeBitmaps(string bitmapText)
        {
            foreach (string singleBitmap in bitmapText.Split(new string[] { "00001" + Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries))
            {
                if (IsBitmapSymbol(singleBitmap))
                {
                    BitmapSymbol bs = new BitmapSymbol(singleBitmap, ColorTables["DAY_BRIGHT"]);
                        //TODO: not nice to assume this ColorTable
                    try
                    {
                        if (bs.IsValid())
                        {
                            SymbolBitmaps.Add(bs.Code, bs);
                        }
                        else
                        {
                            Debug.Print("Bitmap symbol {0} is not valid and can't be merged.", bs.Code);
                        }
                    }
                    catch (Exception ex)
                    {
                        Debug.Print(
                            "Bitmap symbol {0} can't be loaded with following message: '{1}', if not invalid, assuming already exists and replacing",
                            bs.Code, ex.Message);
                        if (bs.Code != null)
                        {
                            this.SymbolBitmaps[bs.Code] = bs;
                        }
                    }
                    if (bs.ObjectId >= NextId)
                    {
                        NextId = bs.ObjectId + 1;
                    }
                }

                if (IsBitmapPattern(singleBitmap))
                {
                    BitmapPattern bp = new BitmapPattern(singleBitmap, ColorTables["DAY_BRIGHT"]);
                        //TODO: not nice to assume this ColorTable
                    try
                    {
                        if (bp.IsValid())
                        {
                            PatternBitmaps.Add(bp.Code, bp);
                        }
                        else
                        {
                            Debug.Print("Bitmap symbol {0} is not valid and can't be merged.", bp.Code);
                        }
                    }
                    catch (Exception ex)
                    {
                        Debug.Print(
                            "Bitmap symbol {0} can't be loaded with following message: '{1}', if not invalid, assuming already exists and replacing",
                            bp.Code, ex.Message);
                        if (bp.Code != null)
                        {
                            this.PatternBitmaps[bp.Code] = bp;
                        }
                    }
                    if (bp.ObjectId >= NextId)
                    {
                        NextId = bp.ObjectId + 1;
                    }
                }
            }
        }