public DefaultGraphicModule(Options options)
 {
     Width = options.Width;
     Height = options.Height;
     Bitmap = new Bitmap(Width, Height);
     Graphics = Graphics.FromImage(Bitmap);
     BrushColor = Color.FromName(options.BrushColorName);
     FontColor = Color.FromName(options.FontColorName);
     Graphics.Clear(FontColor);
 }
예제 #2
0
        private static IKernel CreateKernel(Options options)
        {
            var kernel = new StandardKernel();

            kernel.Bind<Options>().ToConstant(options);
            kernel.Bind<IDataReader>().To<TxtFileReader>();
            kernel.Bind<IPointGenerator>().ToConstant(options.Generator);
            kernel.Bind<IFontGenerator>().ToConstant(GetFontGenerator(options));
            kernel.Bind<ISaveModule>().ToConstant(new PngSaveModule(ImagePath));
            kernel.Bind<IGraphicModule>().To<DefaultGraphicModule>();
            kernel.Bind<ICloudBuilder>().To<GraphicCloudBuilder>();

            return kernel;
        }
예제 #3
0
        public static Options Parse(string[] args, Dictionary<String, IPointGenerator> pointGenerators)
        {
            var opt = new Options();
            opt.Generator = pointGenerators.First().Value;

            for (int i = 0; i < args.Length; i++)
            {
                switch (args[i])
                {
                    case "-f":
                    case "--file":
                        opt.InputFile = args[++i];
                        break;
                    case "-g":
                    case "--gen":
                        opt.Generator = pointGenerators[args[++i]];
                        break;
                    case "-w":
                    case "--width":
                        opt.Width = int.Parse(args[++i]);
                        break;
                    case "-h":
                    case "--height":
                        opt.Height = int.Parse(args[++i]);
                        break;
                    case "-l":
                    case "--log":
                        opt.Log = false;
                        break;
                    case "-s":
                    case "--multipleSize":
                        opt.MultipleSize = int.Parse(args[++i]);
                        break;
                    case "-i":
                    case "--ignoreCase":
                        opt.AddToPreLoad(s => s.ToLower());
                        break;
                    case "-c":
                    case "--clear":
                        opt.AddToPreLoad(x => new String(x.Where(char.IsLetter).ToArray()));
                        break;
                    case "-n":
                    case "--fontFamilyName":
                        opt.FontFamilyName = "";
                        for (; i < args.Length; i++)
                            if (args[i][0] != '-')
                                opt.AddToFontFamilyName(args[i]);
                            else
                                i--;
                                break;
                        break;
                    case "-b":
                    case "--brush":
                        opt.BrushColorName = args[++i];
                        break;
                    case "-o":
                    case "--font":
                        opt.FontColorName = args[++i];
                        break;
                }
            }
            return opt;
        }
예제 #4
0
 static FontGenerator GetFontGenerator(Options options)
 {
     return new FontGenerator(new FontFamily(options.FontFamilyName), options.Log, options.MultipleSize);
 }