示例#1
0
 public ResizerDialoge2(Bitmap srcimage, string dstpath, ResizingProfile profile, Rectangle crop)
 {
     _sourceimage   = srcimage;
     _dstpath       = dstpath;
     _profile       = profile;
     _cropRectangle = crop;
     InitializeComponent();
 }
示例#2
0
 private static ResizingJob decode2(IEnumerable <string> lines, string sourcePath)
 {
     using (var tor = lines.GetEnumerator())
     {
         int done   = 0;
         var dests  = new Dictionary <string, Tuple <int, ResizingProfile> >();
         var images = new Dictionary <string, DialogResult?[]>();
         if (!tor.MoveNext() || !tor.Current.StartsWith("<<"))
         {
             throw new Exception("bad initial line");
         }
         var raw = tor.Current.Substring("<<2".Length);
         int ind = 0;
         while (true)
         {
             if (!tor.MoveNext())
             {
                 return(new ResizingJob(raw, dests, sourcePath, 0, images));
             }
             if (!tor.Current.StartsWith(">"))
             {
                 break;
             }
             var reldestpath = tor.Current.Substring(1);
             var destpath    = Path.GetFullPath(Path.Combine(raw, reldestpath));
             var propath     = Path.Combine(destpath, "preset.txt");
             var profile     = ResizingProfile.fromFile(propath);
             dests.Add(destpath, new Tuple <int, ResizingProfile>(ind++, profile));
         }
         while (true)
         {
             var split = tor.Current.Split(':');
             if (split.Length != dests.Count + 1)
             {
                 throw new Exception("argument mismatch:" + tor.Current);
             }
             var args = split.Skip(1).Select(a =>
             {
                 if (a == "-")
                 {
                     return(null);
                 }
                 done++;
                 return((DialogResult?)(DialogResult)int.Parse(a));
             }).ToArray();
             images.Add(split[0], args);
             if (!tor.MoveNext())
             {
                 return(new ResizingJob(raw, dests, sourcePath, done, images));
             }
         }
     }
 }
示例#3
0
        public static ResizingJob Create(string[] destinations, string rawdir, string sourcePath)
        {
            var dests = new Dictionary <string, Tuple <int, ResizingProfile> >(destinations.Length);
            int i     = 0;

            foreach (var destination in destinations)
            {
                var propath = Path.Combine(destination, "preset.txt");
                dests[destination] = Tuple.Create(i++, ResizingProfile.fromFile(propath));
            }
            return(new ResizingJob(rawdir, dests, sourcePath, 0));
        }
示例#4
0
        public void rePoolDests()
        {
            var ndpath = Path.Combine(rawdir, "destinations.txt");

            string[] newdests;
            using (var reader = new StreamReader(ndpath))
            {
                newdests = reader.Loop().ToArray();
            }
            var transform = adjustDestMap(_dests.Select(x => x.Item1), newdests);

            foreach (var image in _images.Keys.ToArray())
            {
                _images[image] = ResizingJob.transform(_images[image], transform, newdests.Length);
            }
            _dests = newdests.Select((a, i) =>
            {
                var propath = Path.Combine(a, "preset.txt");
                return(new KeyValuePair <string, Tuple <int, ResizingProfile> >(a, Tuple.Create(i, ResizingProfile.fromFile(propath))));
            }).ToDictionary();
        }
示例#5
0
 public ResizerDialoge2(Bitmap scrimage, string dstpath, ResizingProfile profile) : this(scrimage, dstpath, profile, Rectangle.Empty)
 {
 }