Ejemplo n.º 1
0
 public SpritesForm(LayoutProperties layout)
 {
     InitializeComponent();
     layoutProp = layout;
     textBoxInputDirectoryPath.Text = layoutProp.outputSpriteFilePath;
     textBoxCssFilePath.Text = layoutProp.cssFilePath;
 }
Ejemplo n.º 2
0
        public static void AddImage(string path)
        {
            if (string.IsNullOrEmpty(path)) throw new ArgumentNullException("path");

            string directory = Path.GetDirectoryName(path);
            string file = Path.GetFileName(path);
            string absoluteDir = HttpContext.Current.Server.MapPath(directory);
            string[] filePaths = Directory.GetFiles(absoluteDir, file);

            if (SpriteSettings == null)
            {
                SpriteSettings = new LayoutProperties
                {
                    distanceBetweenImages = 0,
                    inputFilePaths = filePaths,
                    outputCssFilePath = HttpContext.Current.Server.MapPath("~/autosprite.css"),
                    outputSpriteFilePath = HttpContext.Current.Server.MapPath("~/autosprite.png"),
                    layout = "Automatic"
                };
            }
            else
            {
                List<string> inputFilePaths = SpriteSettings.inputFilePaths.ToList();
                inputFilePaths.AddRange(filePaths);
                SpriteSettings.inputFilePaths = inputFilePaths.ToArray();
            }
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            LayoutProperties layoutProp = new LayoutProperties();
            if (args.Contains("-images"))
            {
                string spritePath = args.ElementAt(Array.IndexOf(args, "-images") + 1);
                layoutProp.outputSpriteFilePath = spritePath + @"\sprite.png";
                string[] filters = { ".png", ".jpg", ".jpeg", ".gif" };
                layoutProp.inputFilePaths = (from filter in filters
                                             from file in Directory.GetFiles(spritePath)
                                             where file.EndsWith(filter)
                                             select file).ToArray();
            }

            if (args.Contains("-css"))
            {
                layoutProp.cssFilePath = args.ElementAt(Array.IndexOf(args, "-css") + 1);
            }

            if (args.Contains("-gui"))
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new SpritesForm(layoutProp));
            }
            else
            {
                Sprite sprite = new Sprite(layoutProp);
                sprite.Create();
            }
        }
Ejemplo n.º 4
0
 public LayoutProperties GenerateLayoutProperties()
 {
     var layout = new LayoutProperties
     {
         inputFilePaths = GetInputFiles(),
         outputSpriteFilePath = GetOutputImageFile(),
         outputCssFilePath = GetOutputCssFile(),
         cssClassPrefix = GetStringValueOrDefault(CssClassPrefix, "sprite"),
         layout = GetStringValueOrDefault(Layout, "Automatic"),
         distanceBetweenImages = GetIntValueOrDefault(DistanceBetweenImages, 0),
         marginWidth = GetIntValueOrDefault(MarginWidth, 0),
         imagesInRow = GetIntValueOrDefault(ImagesInRow, 0),
         imagesInColumn = GetIntValueOrDefault(ImagesInColumn, 0)
     };
     return layout;
 }
Ejemplo n.º 5
0
 public Sprite(LayoutProperties _layoutProp)
 {
     images        = new Dictionary <int, Image>();
     cssClassNames = new Dictionary <int, string>();
     layoutProp    = _layoutProp;
 }
Ejemplo n.º 6
0
 public Sprite(LayoutProperties _layoutProp)
 {
     images = new Dictionary<int, Image>();
     cssClassNames = new Dictionary<int, string>();
     layoutProp = _layoutProp;
 }