Smartmobili.Cocoa.NSColorList._ReadTextColorFile C# (CSharp) Method

_ReadTextColorFile() public method

public _ReadTextColorFile ( NSString filepath ) : bool
filepath NSString
return bool
        public virtual bool _ReadTextColorFile(NSString filepath)
        {
            int nColors = 0;
            int method = 0;
            float r = 0;
            float g = 0;
            float b = 0;
            float alpha = 0;
            NSString cname = null;
            int i = 0;
            bool st = false;
            NSColor color = null;
            NSCharacterSet newlineSet = NSCharacterSet.CharacterSetWithCharactersInString(@"\n");
            NSScanner scanner = (NSScanner)NSScanner.ScannerWithString(NSString.StringWithContentsOfFile(_fullFileName));

            if (scanner.ScanInt(ref nColors) == false)
            {
                //NSLog(@"Unable to read color file at \"%@\" -- unknown format.", _fullFileName);
                return false;
            }

            for (i = 0; i < nColors; i++)
            {
                if (scanner.ScanInt(ref method) == false)
                {
                    //NSLog(@"Unable to read color file at \"%@\" -- unknown format.", _fullFileName);
                    break;
                }
                //FIXME- replace this by switch on method to different
                //       NSColor initializers
                if (method != 0)
                {
                    //NSLog(@"Unable to read color file at \"%@\" -- only RGBA form " @"supported.", _fullFileName);
                    break;
                }
                st = scanner.ScanFloat(ref r);
                st = st && scanner.ScanFloat(ref g);
                st = st && scanner.ScanFloat(ref b);
                st = st && scanner.ScanFloat(ref alpha);
                st = st && scanner.ScanUpToCharactersFromSet(newlineSet, ref cname);
                if (st == false)
                {
                    //NSLog(@"Unable to read color file at \"%@\" -- unknown format.", _fullFileName);
                    break;
                }

                color = NSColor.ColorWithCalibratedRed(r, g, b, alpha);
                InsertColor(color, cname, (uint)i);
            }

            return (i == nColors);
        }