Esempio n. 1
0
            public byte[] Save(object instance)
            {
                CharPointCollection collection = instance as CharPointCollection;

                if (collection == null)
                {
                    return(new byte[0]);
                }
                Symbol.IO.Packing.TreePackage data = new Symbol.IO.Packing.TreePackage();
                data.Add("0", collection._list);
                return(data.Save());
            }
Esempio n. 2
0
            public object Load(byte[] buffer)
            {
                Symbol.IO.Packing.TreePackage data = Symbol.IO.Packing.TreePackage.Load(buffer);
                if (data == null)
                {
                    return(null);
                }
                CharPointCollection collection = new CharPointCollection();
                List <CharPoint>    list       = data["0"] as List <CharPoint>;

                if (list != null)
                {
                    collection._list.AddRange(list);
                }

                return(collection);
            }
Esempio n. 3
0
        void SaveBefore()
        {
            _data["preHandlers"] = _preHandlers.Count;
            string[] oriKeys = LinqHelper.ToArray(LinqHelper.Where(_data.Keys, p => p.StartsWith("pre_")));
            foreach (string key in oriKeys)
            {
                _data.Remove(key, false);
            }
            for (int i = 0; i < _preHandlers.Count; i++)
            {
                _data.Add("pre_" + i + "_" + _preHandlers[i].Name, _preHandlers[i].Save());
            }

            //_data["takeHandlers"] = _takeHandlers.Count;
            //string[] oriKeys2 = LinqHelper.ToArray(LinqHelper.Where(_data.Keys, p => p.StartsWith("take_")));
            //foreach (string key in oriKeys2) { _data.Remove(key,false); }
            //for (int i = 0; i < _takeHandlers.Count; i++) {
            //    _data.Add("take_" + i + "_" + _takeHandlers[i].Name, _takeHandlers[i].Save());
            //}

            string[] oriKeys3 = LinqHelper.ToArray(LinqHelper.Where(_data.Keys, p => p.StartsWith("char_")));
            foreach (string key in oriKeys3)
            {
                _data.Remove(key, false);
            }
            _data["chars"] = _chars.Count;
            for (int i = 0; i < _chars.Count; i++)
            {
                if (_chars[i].Value == null)
                {
                    continue;
                }
                Symbol.IO.Packing.TreePackage charData = new Symbol.IO.Packing.TreePackage()
                {
                    EncryptType = Symbol.IO.Packing.PackageEncryptTypes.BinaryWave_EmptyPassword
                };
                CharPointCollection collection = _chars[i].Points;
                charData.Add("count", collection.Count);
                for (int j = 0; j < collection.Count; j++)
                {
                    string keyBefore = j + "_";
                    charData.Add(keyBefore + "OriginalX", collection[j].OriginalX);
                    charData.Add(keyBefore + "OriginalY", collection[j].OriginalY);
                    charData.Add(keyBefore + "X", collection[j].X);
                    charData.Add(keyBefore + "Y", collection[j].Y);
                    charData.Add(keyBefore + "R", collection[j].R);
                    charData.Add(keyBefore + "G", collection[j].G);
                    charData.Add(keyBefore + "B", collection[j].B);
                }
                _data.Add("char_" + i + "_" + _chars[i].Value, charData);
            }
            string takeHandlerKeyBefore = "takeHandler_";
            string takeHandlerKeyOri    = LinqHelper.FirstOrDefault(_data.Keys, p => p.StartsWith(takeHandlerKeyBefore));

            if (!string.IsNullOrEmpty(takeHandlerKeyOri))
            {
                _data.Remove(takeHandlerKeyOri, false);
            }
            string takeHandlerKey = takeHandlerKeyBefore + _takeHandler.Name;

            _data.Add(takeHandlerKey, _takeHandler.Save());

            string charRecognizerKeyBefore = "charRecognizer_";
            string charRecognizerKeyOri    = LinqHelper.FirstOrDefault(_data.Keys, p => p.StartsWith(charRecognizerKeyBefore));

            if (!string.IsNullOrEmpty(charRecognizerKeyOri))
            {
                _data.Remove(charRecognizerKeyOri, false);
            }
            string charRecognizerKey = charRecognizerKeyBefore + _charRecognizer.Name;

            _data.Add(charRecognizerKey, _charRecognizer.Save());
        }