public RedditControl()
        {
            InitializeComponent();
            _vm = (Application.Current as App).Container.GetService <RedditControlViewModel>();

            //Radiobutton command
            _vm.PullCommand = new RelayCommand(o =>
            {
                if (_vm.PullParam == "top")
                {
                    RadioTopAll.IsEnabled   = true;
                    RadioTopYear.IsEnabled  = true;
                    RadioTopMonth.IsEnabled = true;
                    RadioTopWeek.IsEnabled  = true;
                    RadioTopDay.IsEnabled   = true;
                    RadioTopHour.IsEnabled  = true;
                }
                else
                {
                    RadioTopAll.IsEnabled   = false;
                    RadioTopYear.IsEnabled  = false;
                    RadioTopMonth.IsEnabled = false;
                    RadioTopWeek.IsEnabled  = false;
                    RadioTopDay.IsEnabled   = false;
                    RadioTopHour.IsEnabled  = false;
                }
            });

            //Checkboxes
            _vm.CustomQueryCommand = new RelayCommand(o =>
            {
                if (_vm.CustomQuery)
                {
                    RadioPullMain.IsEnabled          = false;
                    RadioPullTop.IsEnabled           = false;
                    RadioPullControversial.IsEnabled = false;
                    RadioPullRising.IsEnabled        = false;
                    RadioPullNew.IsEnabled           = false;

                    RadioTopAll.IsEnabled   = false;
                    RadioTopYear.IsEnabled  = false;
                    RadioTopMonth.IsEnabled = false;
                    RadioTopWeek.IsEnabled  = false;
                    RadioTopDay.IsEnabled   = false;
                    RadioTopHour.IsEnabled  = false;
                }
                else
                {
                    RadioPullMain.IsEnabled          = true;
                    RadioPullTop.IsEnabled           = true;
                    RadioPullControversial.IsEnabled = true;
                    RadioPullRising.IsEnabled        = true;
                    RadioPullNew.IsEnabled           = true;
                    _vm.PullCommand.Execute(null);
                }
            });
            //Disable the "save albums in nested folders" checkbox if we're skipping albums.
            _vm.SkipAlbumsCommand = new RelayCommand(o => { SaveAlbumsInFoldersCheckbox.IsEnabled = !_vm.SkipAlbums; });

            //Buttons
            _vm.Download     = SharedEventHandlingLogic.CreateDownloadCommand(_vm, ProgressIndicator);
            _vm.ShowLog      = SharedEventHandlingLogic.CreateLogCommand(_vm, this, "Reddit");
            _vm.SelectFolder = SharedEventHandlingLogic.CreateSelectFolderCommand(_vm);

            _vm.PullCommand.Execute(null);
            ProgressIndicator.Visibility = Visibility.Hidden;
            DataContext = _vm;
        }
Ejemplo n.º 2
0
        public RedditControl()
        {
            InitializeComponent();
            _vm = (Application.Current as App).Container.GetService <RedditControlViewModel>();

            //Radiobutton command
            _vm.PullCommand = new RelayCommand(o =>
            {
                if (_vm.PullParam == "top")
                {
                    RadioTopAll.IsEnabled   = true;
                    RadioTopYear.IsEnabled  = true;
                    RadioTopMonth.IsEnabled = true;
                    RadioTopWeek.IsEnabled  = true;
                    RadioTopDay.IsEnabled   = true;
                    RadioTopHour.IsEnabled  = true;
                }
                else
                {
                    RadioTopAll.IsEnabled   = false;
                    RadioTopYear.IsEnabled  = false;
                    RadioTopMonth.IsEnabled = false;
                    RadioTopWeek.IsEnabled  = false;
                    RadioTopDay.IsEnabled   = false;
                    RadioTopHour.IsEnabled  = false;
                }
            });

            //Checkboxes
            _vm.CustomQueryCommand = new RelayCommand(o =>
            {
                if (_vm.CustomQuery)
                {
                    RadioPullMain.IsEnabled          = false;
                    RadioPullTop.IsEnabled           = false;
                    RadioPullControversial.IsEnabled = false;
                    RadioPullRising.IsEnabled        = false;
                    RadioPullNew.IsEnabled           = false;

                    RadioTopAll.IsEnabled   = false;
                    RadioTopYear.IsEnabled  = false;
                    RadioTopMonth.IsEnabled = false;
                    RadioTopWeek.IsEnabled  = false;
                    RadioTopDay.IsEnabled   = false;
                    RadioTopHour.IsEnabled  = false;
                }
                else
                {
                    RadioPullMain.IsEnabled          = true;
                    RadioPullTop.IsEnabled           = true;
                    RadioPullControversial.IsEnabled = true;
                    RadioPullRising.IsEnabled        = true;
                    RadioPullNew.IsEnabled           = true;
                    _vm.PullCommand.Execute(null);
                }
            });

            //Buttons
            _vm.Download = new RelayCommand(o =>
            {
                _vm.StartDownload();
                Separator.Visibility = Visibility.Visible;
                Log.Visibility       = Visibility.Visible;
            },  //Download button is only enabled when both a source and target have been chosen.
                                            o => !string.IsNullOrWhiteSpace(_vm.Source) && !string.IsNullOrWhiteSpace(_vm.TargetFolder));

            _vm.SelectFolder = new RelayCommand(o =>
            {
                var dialog = new FolderBrowserDialog();
                var result = dialog.ShowDialog();
                if (result == DialogResult.OK)
                {
                    _vm.TargetFolder = dialog.SelectedPath;
                }
            });

            Separator.Visibility = Visibility.Collapsed;
            Log.Visibility       = Visibility.Collapsed;
            _vm.PullCommand.Execute(null);

            DataContext = _vm;
        }