Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the FolderViewModel class
        /// </summary>
        /// <param name="mainViewModel">main view model</param>
        /// <param name="folder">folder</param>
        public FolderViewModel(MainViewModel mainViewModel, Folder folder)
            : base(mainViewModel, folder)
        {
            var children = new TreeViewItemViewModelCollection(this);

            Children = children;
            ITreeViewItemViewModel       itemViewModel;
            TreeViewItemViewModelFactory factory = null;

            foreach (var child in folder.Children)
            {
                if (factory == null)
                {
                    factory = new TreeViewItemViewModelFactory();
                }
                itemViewModel = factory.CreateTreeViewItemViewModel(mainViewModel, child);
                children.Add(itemViewModel);
            }
        }
Ejemplo n.º 2
0
        private void Init()
        {
            var entries = new TreeViewItemViewModelCollection(null);
            var factory = new TreeViewItemViewModelFactory();

            foreach (var entry in Settings.Default.Entries)
            {
                entries.Add(factory.CreateTreeViewItemViewModel(this, entry));
            }
            var treeViewItemViewModel = entries.FirstOrDefault();

            if (treeViewItemViewModel != null)
            {
                treeViewItemViewModel.IsSelected = true;
            }
            Entries = entries;

            if (RunAtWindowsStartupVisible && !Application.IsMono)
            {
                try
                {
                    var rkApp = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run", false);
                    try
                    {
                        object value = rkApp.GetValue(Application.ProductName, false);
                        RunAtWindowsStartup = (value is string && (string)value == Application.ExecutablePath);
                    }
                    finally
                    {
                        rkApp.Close();
                    }
                }
                catch (Exception)
                {
                }
            }
        }