Exemplo n.º 1
0
        public CroInfoViewModel(string name, CroInfo info)
        {
            mInfo = info;

            mOriginalKey = info.Key;
            if (string.IsNullOrWhiteSpace(mOriginalKey))
            {
                mOriginalKey = new FileInfo(info.Filepath).Directory.Name;
            }

            mTypes = new BindingList <CroInfoTypeItem>();
            mTypes.AddRange(CroInfoTypeItem.All);

            mPatterns = new BindingList <CroPatternViewModel>();
            LoadPatterns();

            mAddNewPatternCommand  = new DelegateCommand(DoAddNewPattern, CanAddNewPattern);
            mSetPatternTextCommand = new DelegateCommand(DoSetPatternText, CanSetPatternText);

            Name      = name;
            Key       = mOriginalKey;
            AddToPath = info.AddToPath;

            UpdateIsEditable();
        }
Exemplo n.º 2
0
        private void DoRead()
        {
            dcf.TryWrite(settings);

            using (mItems.DeferBinding())
            {
                mItems.Clear();

                var dir       = new DirectoryInfo(settings.RepositoryPath);
                var separator = Path.DirectorySeparatorChar.ToString();

                foreach (var cro in dir.EnumerateFiles("cro.xml", SearchOption.AllDirectories))
                {
                    var info = new CroInfo(cro.FullName);
                    info.Read();

                    var name = cro.Directory.FullName.Replace(dir.FullName, string.Empty);
                    if (name.StartsWith(separator))
                    {
                        name = name.Substring(1);
                    }

                    mItems.Add(new CroInfoViewModel(name, info));
                }
            }

            RefreshCommands();
        }