コード例 #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();
            }
        }
コード例 #2
0
 private void OnLoaded(object sender, RoutedEventArgs e)
 {
     videoPaths = PreferenceManager.ReadVideoSettings();
     if (videoPaths.Count == 0)
     {
         ShowError("This screensaver needs to be configured before any video is displayed.");
     }
     else
     {
         NextMediaItem();
     }
 }
コード例 #3
0
ファイル: MainWindow.xaml.cs プロジェクト: ricard0ff/winvid
        private void OnLoaded(object sender, RoutedEventArgs e)
        {
            videoPaths = PreferenceManager.ReadVideoSettings();
            videoPaths.ShufVideo(new Random());

            if (videoPaths.Count == 0)
            {
                ShowError("This screensaver needs to be configured before any video starts.");
            }
            else
            {
                PlayNext();
            }
        }
コード例 #4
0
ファイル: App.xaml.cs プロジェクト: ricard0ff/winvid
        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);
            }
        }
コード例 #5
0
        private void OnLoaded(object sender, RoutedEventArgs e)
        {
            List <String> videoPaths = PreferenceManager.ReadVideoSettings();

            if (videoPaths.Count == 0)
            {
                ShowError("This screensaver needs to be configured before any video is displayed.");
            }
            else
            {
                // Maximise the window
                this.WindowState = WindowState.Maximized;
                PlayNextVideo(sender, e);
            }
        }
コード例 #6
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();
     }
 }
コード例 #7
0
        private void OnLoaded(object sender, RoutedEventArgs e)
        {
            String videoPath = PreferenceManager.ReadVideoSettings();

            if (videoPath.Length == 0)
            {
                ShowError("This screensaver needs to be configured before any video is displayed.");
            }
            else
            {
                GetAllVideos(videoPath);
                videoList        = ShuffleStringArray(videoList);
                GeneralData.Text = "File count: " + videoList.Count;
                SetNewMedia((String)videoList[currentMediaIndex]);
            }
        }
コード例 #8
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);
            }
        }
コード例 #9
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();
     }
 }
コード例 #10
0
        /// <summary>
        /// Plays the next video in the series on the media object on the form
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void PlayNextVideo(object sender, RoutedEventArgs e)
        {
            List <String> videoPaths = PreferenceManager.ReadVideoSettings();

            FullScreenMedia.Source = new System.Uri(videoPaths[new Random().Next(videoPaths.Count)]);
        }
コード例 #11
0
        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();
        }