예제 #1
0
        public void SavePreset(string inName, bool inOverWrite)
        {
            KeyValuePreset preset = GetPreset(inName);

            if (preset != null)
            {
                DirectoryInfo dir = new DirectoryInfo(mPath + "\\" + Name);

                if (!dir.Exists)
                {
                    dir.Create();
                }

                FileInfo curInfo = new FileInfo(dir.FullName + "\\" + inName + ".xml");
                if (!curInfo.Exists || inOverWrite)
                {
                    FileStream stream = null;
                    try
                    {
                        stream = curInfo.Open(FileMode.Create);
                        serializer.Serialize(stream, preset);
                        stream.Close();
                    }
                    catch (Exception) { if (stream != null)
                                        {
                                            stream.Close();
                                        }
                    }
                }
            }
        }
예제 #2
0
        public void LoadPresets()
        {
            Clear();
            DirectoryInfo dir = new DirectoryInfo(mPath + "\\" + Name);

            if (dir.Exists)
            {
                foreach (FileInfo file in dir.GetFiles())
                {
                    if (file.Extension == ".xml")
                    {
                        FileStream stream = null;
                        try
                        {
                            stream = file.OpenRead();
                            KeyValuePreset preset = (KeyValuePreset)serializer.Deserialize(stream);
                            preset.SyncDic();
                            PushPreset(preset.Name, preset);
                            stream.Close();
                        }
                        catch (Exception) { if (stream != null)
                                            {
                                                stream.Close();
                                            }
                        }
                    }
                }
            }
        }
예제 #3
0
        public void DeletePreset(KeyValuePreset preset)
        {
            if (Presets.Contains(preset))
            {
                Presets.Remove(preset);
                Keys.Remove(preset.Name);
                presets.Remove(preset.Name);
            }

            FileInfo curInfo = new FileInfo(mPath + "\\" + Name + "\\" + preset.Name + ".xml");

            if (curInfo.Exists)
            {
                curInfo.Delete();
            }
        }
예제 #4
0
        public void PushPreset(string inKey, KeyValuePreset inValue)
        {
            inValue.Name = inKey;

            if (presets.ContainsKey(inKey))
            {
                presets[inKey] = inValue;
            }
            else
            {
                Keys.Add(inKey);
                Presets.Add(inValue);
                presets.Add(inKey, inValue);
            }

            presets[inKey].Collection = this;
        }