Esempio n. 1
0
        private void OnLoaded(object sender, RoutedEventArgs e)
        {
            mediaPaths = PreferenceManager.ReadVideoSettings();
            mediaFiles = new List <string>();
            algorithm  = PreferenceManager.ReadAlgorithmSetting();
            foreach (string videoPath in mediaPaths)
            {
                AddMediaFilesFromDirRecursive(videoPath);
            }
            if (algorithm == PreferenceManager.ALGORITHM_RANDOM_NO_REPEAT)
            {
                // shuffle list
                mediaFiles = mediaFiles.OrderBy(i => Guid.NewGuid()).ToList();
            }
            if (algorithm == PreferenceManager.ALGORITHM_RANDOM)
            {
                lastMedia = new List <String>();
            }

            if (mediaPaths.Count == 0 || mediaFiles.Count == 0)
            {
                ShowError("This screensaver needs to be configured before any video is displayed.");
            }
            else
            {
                NextMediaItem();
            }
        }
Esempio n. 2
0
 private async void OnLoaded(object sender, RoutedEventArgs e)
 {
     mediaPaths     = PreferenceManager.ReadVideoSettings();
     mediaFiles     = new List <string>();
     algorithm      = PreferenceManager.ReadAlgorithmSetting();
     isLoadingFiles = true;
     Task.Factory.StartNew(() => LoadFiles()); // load files in another thread
     if ((mediaPaths.Count == 0 || mediaFiles.Count == 0) && !isLoadingFiles)
     {
         ShowError("This screensaver needs to be configured before any video is displayed.");
     }
     else
     {
         NextMediaItem();
     }
 }
Esempio n. 3
0
 private async void OnLoaded(object sender, RoutedEventArgs e)
 {
     mediaPaths = PreferenceManager.ReadVideoSettings();
     mediaFiles = new List <string>();
     algorithm  = PreferenceManager.ReadAlgorithmSetting();
     if (algorithm == PreferenceManager.ALGORITHM_RANDOM || algorithm == PreferenceManager.ALGORITHM_RANDOM_NO_REPEAT) // we need to create it before we start showing pictures. before it was after full load
     {
         lastMedia = new List <String>();
     }
     isLoadingFiles = true;
     Task.Factory.StartNew(() => LoadFiles()); // load files in another thread
     if ((mediaPaths.Count == 0 || mediaFiles.Count == 0) && !isLoadingFiles)
     {
         ShowError("This screensaver needs to be configured before any video is displayed.");
     }
     else
     {
         NextMediaItem();
     }
 }
        public SettingsViewModel()
        {
            // command that show folder selection dialog and add selected folder to list
            _addCommand = new CommandHandler(
                o =>
            {
                var dial = new FolderBrowserDialog();
                if (
                    dial.ShowDialog(null) == DialogResult.OK)
                {
                    _mediaPaths.Add(dial.SelectedPath);
                }
            },
                o => true);
            // command that delete selected folder from list
            _delCommand = new CommandHandler(o =>
            {
                if (!String.IsNullOrWhiteSpace(_selectedRow) && _mediaPaths.Contains(_selectedRow))
                {
                    _mediaPaths.Remove(_selectedRow);
                }
            }, o => !String.IsNullOrWhiteSpace(_selectedRow));

            // command that will remove all registry keys
            _removeSettingsCommand = new CommandHandler(o =>
            {
                if (System.Windows.MessageBox.Show("Are you sure you want to remove all settings from registry?", "Remove all settings", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
                {
                    PreferenceManager.RemoveRegistryKeys();
                    Application.Current.Shutdown();
                }
            }, o => true);

            // command that will save setting to registry
            _saveCommand = new CommandHandler(o =>
            {
                PreferenceManager.WriteVideoSettings(_mediaPaths.ToList());
                PreferenceManager.WriteVolumeSetting((float)Volume / 100F);
                PreferenceManager.WriteAlgorithmSetting(NextMediaAlgorithm);
                PreferenceManager.WriteIntervalSetting(Interval);
                PreferenceManager.WriteVolumeTimeoutSetting(VolumeTimeout);
                Application.Current.Shutdown();
            }, o => true);

            // command that will remove all registry keys
            _cancelCommand = new CommandHandler(o =>
            {
                if (System.Windows.MessageBox.Show("Are you sure you want to close settings and discard changes?", "Exit and discard", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
                {
                    Application.Current.Shutdown();
                }
            }, o => true);

            // list of folders
            var list = PreferenceManager.ReadVideoSettings();

            foreach (var item in list)
            {
                _mediaPaths.Add(item);
            }

            Volume             = (int)(PreferenceManager.ReadVolumeSetting() * 100);
            NextMediaAlgorithm = PreferenceManager.ReadAlgorithmSetting();
            Interval           = PreferenceManager.ReadIntervalSetting();
            VolumeTimeout      = PreferenceManager.ReadVolumeTimeoutSetting();
        }