Example #1
0
        public MainViewModel(Window window)
        {
            windowInstance = window;

            // Listen out for the window resizing
            windowInstance.StateChanged += (sender, e) =>
            {
                OnPropertyChanged(nameof(ResizeBorderThickness));
                OnPropertyChanged(nameof(OuterMarginSize));
                OnPropertyChanged(nameof(OuterMarginSizeThickness));
                OnPropertyChanged(nameof(WindowRadius));
                OnPropertyChanged(nameof(WindowCornerRadius));
            };

            // Create commands for controls
            MinimizeCommand = new RelayCommand(() => windowInstance.WindowState = WindowState.Minimized);
            MaximizeCommand = new RelayCommand(() => windowInstance.WindowState ^= WindowState.Maximized);
            CloseCommand    = new RelayCommand(CloseWindow);

            List <ImageDownloaderViewModel> cotrols = new List <ImageDownloaderViewModel>();

            for (int i = 0; i < CountImageDownloaders; i++)
            {
                ImageDownloaderViewModel vm = new ImageDownloaderViewModel();
                vm.PropertyChanged += ImageDownloaders_PropertyChanged;
                cotrols.Add(vm);
            }

            ImageDownloaders = new ObservableCollection <ImageDownloaderViewModel>(cotrols);
            BindingOperations.EnableCollectionSynchronization(ImageDownloaders, new object());
            ImageDownloadersView = CollectionViewSource.GetDefaultView(ImageDownloaders);

            TotalDownloadingProgress = new TotalDownloadingProgress();
            TotalDownloadingProgress.PropertyChanged += TotalDownloadingProgress_PropertyChanged;
        }
Example #2
0
        public MainViewModel(params ImageDownloaderViewModel[] models)
        {
            for (int i = 0; i < models.Length; i++)
            {
                ImageDownloaders[i] = models[i];
            }

            TotalDownloadingProgress = new TotalDownloadingProgress();
        }