예제 #1
0
        private void InitAreas(string arrkey, string prefix, ScanAreas scanArea, ScanAreaDictionary lookup, KeyValuePair <string, ScanArea> a)
        {
            var key = arrkey.Substring(prefix.Length);

            if (!lookup.ContainsKey(key))
            {
                // lookup[key] = new Tuple<ulong, IDictionary<int, Rectangle>>(a.Value.Hash, new Dictionary<int, Rectangle>());
                lookup[key] = new Dictionary <int, ScanArea>();
            }

            var tmp = lookup[key];

            if (!tmp.ContainsKey(scanArea.BaseResolution))
            {
                tmp[scanArea.BaseResolution] = a.Value;
            }
        }
예제 #2
0
        private void InitImageAreas(string arrkey, string prefix, ScanAreas scanArea, ScanAreaImageDictionary lookup, KeyValuePair <string, ScanArea> a)
        {
            var key = arrkey.Substring(prefix.Length);

            if (!lookup.ContainsKey(key))
            {
                // lookup[key] = new Tuple<ulong, IDictionary<int, Rectangle>>(a.Value.Hash, new Dictionary<int, Rectangle>());
                lookup[key] = new Dictionary <int, Tuple <Bitmap, ScanArea> >();
            }

            var tmp = lookup[key];

            if (!tmp.ContainsKey(scanArea.BaseResolution))
            {
                // var image = (Bitmap)Image.FromFile(Path.Combine(BasePath, a.Value.Image));
                var image = (Bitmap)scanAreaProvider.GetImage(a.Value.Image);
                tmp[scanArea.BaseResolution] = new Tuple <Bitmap, ScanArea>(image, a.Value);
            }
        }
        private void RefreshAreas()
        {
            areas.Clear();
            var models = new List<ScanAreaModel>();
            var area = scanAreas.FirstOrDefault(x => x.BaseResolution == BaseResolution);
            if (area == null)
            {
                area = new ScanAreas { BaseResolution = BaseResolution, Areas = new List<ScanArea>() };
                scanAreas.Add(area);
                return;
            }

            foreach (var scanArea in area.Areas)
            {
                var model = new ScanAreaModel(scanArea);
                models.Add(model);
            }

            areas.AddRange(models);
        }
        private ScanAreas CreateScanAreas()
        {
            var result = new ScanAreas
                {
                    BaseResolution = BaseResolution
                };

            foreach (var model in Areas)
            {
                result.Areas.Add(new ScanArea
                    {
                        Key = model.Key,
                        X = model.X,
                        Y = model.Y,
                        Width = model.Width,
                        Height = model.Height,
                        Hash = model.Hash,
                        BaseResolution = model.BaseResolution,
                        Image = model.ImageLocation,
                        Mostly = model.Mostly
                    });
            }

            return result;
        }