Ejemplo n.º 1
0
        private void ConfigureScreensaver()
        {
            List <String> videoUri = PreferenceManager.ReadVideoSettings();

            Microsoft.Win32.OpenFileDialog openDialog = new Microsoft.Win32.OpenFileDialog();
            openDialog.Multiselect = true;
            openDialog.FileName    = (videoUri.Count > 0) ? videoUri[0] : "";
            openDialog.Title       = "Select video files to display...";
            if (openDialog.ShowDialog() == true)
            {
                List <String> videos = new List <String>();
                videos.AddRange(openDialog.FileNames);
                PreferenceManager.WriteVideoSettings(videos);
            }
        }
Ejemplo n.º 2
0
        private void ConfigureScreensaver()
        {
            String videoUri = PreferenceManager.ReadVideoSettings();

            System.Windows.Forms.FolderBrowserDialog folderDialog = new System.Windows.Forms.FolderBrowserDialog();
            //Microsoft.Win32.OpenFileDialog openDialog = new Microsoft.Win32.OpenFileDialog();
            //openDialog.Multiselect = true;
            //openDialog.FileName = (videoUri.Count > 0) ? videoUri[0] : "";
            //openDialog.Title = "Select root folder containing video files";
            folderDialog.SelectedPath = videoUri;

            if (folderDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                //List<String> videos = new List<String>();

                //videos.AddRange(openDialog.FileNames);
                PreferenceManager.WriteVideoSettings(folderDialog.SelectedPath);
            }
        }
        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();
        }