Example #1
0
        public WinDirStatViewModel()
        {
            model                            = new WinDirStatModel();
            settings                         = new WinDirStatSettings(this);
            extensions                       = new ExtensionRecordsViewModel(this);
            icons                            = new IconCache(this);
            fileComparer                     = new FileComparer();
            extensionComparer                = new ExtensionComparer();
            selectedFiles                    = new ObservableCollection <FileNodeViewModel>();
            selectedExtension                = null;
            model.PropertyChanged           += OnModelPropertyChanged;
            selectedFiles.CollectionChanged += OnSelectedFilesChanged;
            settings.PropertyChanged        += OnSettingsPropertyChanged;
            ramTimer                         = new DispatcherTimer(
                settings.RAMInterval,
                DispatcherPriority.Normal,
                OnRAMUsageTick,
                Application.Current.Dispatcher);
            statusTimer = new DispatcherTimer(
                settings.StatusInterval,
                DispatcherPriority.Normal,
                OnStatusTick,
                Application.Current.Dispatcher);
            statusTimer.Stop();
            validateTimer = new DispatcherTimer(
                settings.ValidateInterval,
                DispatcherPriority.Background,
                OnValidateTick,
                Application.Current.Dispatcher);
            validateTimer.Stop();

            ramUsage = GC.GetTotalMemory(false);
        }
        /// <summary>
        /// Initializes a new instance of the MainViewModel class.
        /// </summary>
        public MainViewModel(SettingsService settings,
                             ScanningService scanning,
                             IIconCacheService iconCache,
                             IUIService ui,
                             IBitmapFactory bitmapFactory,
                             ImagesServiceBase images,
                             IClipboardService clipboard,
                             IOSService os,
                             IWindowDialogService dialogs,
                             TreemapRendererFactory treemapFactory,
                             IShortcutsService shortcuts,
                             RelayCommandService relayFactory)
        {
            Settings      = settings;
            Scanning      = scanning;
            IconCache     = iconCache;
            UI            = ui;
            BitmapFactory = bitmapFactory;
            Images        = images;
            Clipboard     = clipboard;
            OS            = os;
            Dialogs       = dialogs;
            Shortcuts     = shortcuts;
            Treemap       = treemapFactory.Create();

            Settings.PropertyChanged += OnSettingsPropertyChanged;
            Scanning.PropertyChanged += OnScanningPropertyChanged;

            Extensions = new ExtensionItemViewModelCollection(this);

            SelectedFiles = new ObservableCollection <FileItemViewModel>();
            SelectedFiles.CollectionChanged += OnSelectedFilesChanged;

            FileComparer      = new FileComparer();
            ExtensionComparer = new ExtensionComparer();
            UpdateEmptyRecycleBin();

            GCRAMUsage = GC.GetTotalMemory(false);
            if (IsInDesignMode)
            {
                // Code runs in Blend --> create design time data.
            }
            else
            {
                // Code runs "for real"
                ramTimer    = UI.StartTimer(Settings.RAMInterval, true, OnRAMUsageTick);
                statusTimer = UI.CreateTimer(Settings.StatusInterval, true, OnStatusTick);
            }
        }