Beispiel #1
0
        public bool Load(string filename)
        {
            if (!File.Exists(filename)) return false;

            var setList = new List<EnvItemSet>();
            using (var reader = new StreamReader(filename))
            {
                while (!reader.EndOfStream)
                {
                    var listfile = reader.ReadLine().Trim();
                    if (!File.Exists(listfile)) continue;

                    var set = new EnvItemSet();
                    if (!set.Load(listfile)) continue;

                    setList.Add(set);
                }
            }

            FilePath = filename;
            SetList = new ObservableSynchronizedCollection<EnvItemSet>(setList);
            CurrentSetIndex = 0;

            return true;
        }
        public void ImportSet()
        {
            var form = new OpenFileDialog()
            {
                RestoreDirectory = true,
            };
            if (form.ShowDialog() == false) return;

            var found = EnvSetList.SetList.Where(set => set.FilePath == form.FileName);
            if (found.Count() > 0) return;

            var envSet = new EnvItemSet();
            if (!envSet.Load(form.FileName))
            {
                Console.WriteLine("cannot load envset: " + form.FileName);
                return;
            }

            EnvSetList.SetList.Add(envSet);
            CurrentSetIndex = EnvSetList.SetList.Count - 1;

            OneTimeMessenger.Send(typeof(EnvSetControlViewModel), "EnvSetList", EnvSetList);
        }