From d40d2fe37b2e9a61067f2f13fdabaf4ff4c2a69a Mon Sep 17 00:00:00 2001 From: sr55 Date: Mon, 28 Nov 2011 20:27:02 +0000 Subject: WinGui: (WPF) Further UI work on the new interface. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4366 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs | 202 +++++++++++++++++++++--- 1 file changed, 182 insertions(+), 20 deletions(-) (limited to 'win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs') diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs index 206eeba0c..6401f4c3a 100644 --- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs @@ -10,17 +10,23 @@ namespace HandBrakeWPF.ViewModels { using System; + using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel.Composition; using System.Diagnostics; using System.IO; + using System.Linq; using System.Windows; using Caliburn.Micro; + using Castle.Components.DictionaryAdapter; + using HandBrake.ApplicationServices; using HandBrake.ApplicationServices.Exceptions; + using HandBrake.ApplicationServices.Functions; using HandBrake.ApplicationServices.Model; + using HandBrake.ApplicationServices.Model.Encoding; using HandBrake.ApplicationServices.Parsing; using HandBrake.ApplicationServices.Services; using HandBrake.ApplicationServices.Services.Interfaces; @@ -88,6 +94,11 @@ namespace HandBrakeWPF.ViewModels /// private Title selectedTitle; + /// + /// Backing field for duration + /// + private string duration; + #endregion /// @@ -117,7 +128,7 @@ namespace HandBrakeWPF.ViewModels this.scanService = scanService; this.encodeService = encodeService; this.presetService = presetService; - this.queueProcessor = new QueueProcessor(Process.GetProcessesByName("HandBrake").Length); + this.queueProcessor = IoC.Get(); // TODO Instance ID! // Setup Properties this.WindowTitle = "HandBrake WPF Test Application"; @@ -181,6 +192,7 @@ namespace HandBrakeWPF.ViewModels { return this.scannedSource; } + set { this.scannedSource = value; @@ -188,6 +200,117 @@ namespace HandBrakeWPF.ViewModels } } + /// + /// Gets or sets the Source Label + /// This indicates the status of scans. + /// + public string SourceLabel + { + get + { + return string.IsNullOrEmpty(this.sourceLabel) ? "Select 'Source' to continue" : this.sourceLabel; + } + + set + { + if (!object.Equals(this.sourceLabel, value)) + { + this.sourceLabel = value; + this.NotifyOfPropertyChange("SourceLabel"); + } + } + } + + /// + /// Gets or sets the Program Status Toolbar Label + /// This indicates the status of HandBrake + /// + public string ProgramStatusLabel + { + get + { + return string.IsNullOrEmpty(this.programStatusLabel) ? "Ready" : this.sourceLabel; + } + + set + { + if (!object.Equals(this.programStatusLabel, value)) + { + this.programStatusLabel = value; + this.NotifyOfPropertyChange("ProgramStatusLabel"); + } + } + } + + /// + /// Gets RangeMode. + /// + public IEnumerable RangeMode + { + get + { + return new List + { + PointToPointMode.Chapters, PointToPointMode.Seconds, PointToPointMode.Frames + }; + } + } + + /// + /// Gets StartEndRangeItems. + /// + public IEnumerable StartEndRangeItems + { + get + { + if (this.SelectedTitle == null) + { + return null; + } + + return this.SelectedTitle.Chapters.Select(item => item.ChapterNumber).Select(dummy => (int)dummy).ToList(); + } + } + + /// + /// Gets Angles. + /// + public IEnumerable Angles + { + get + { + if (this.SelectedTitle == null) + { + return null; + } + + List items = new List(); + for (int i = 1; i <= this.selectedTitle.AngleCount + 1; i++) + { + items.Add(i); + } + return items; + } + } + + /// + /// Gets or sets Duration. + /// + public string Duration + { + get + { + return string.IsNullOrEmpty(duration) ? "--:--:--" : duration; + } + set + { + duration = value; + this.NotifyOfPropertyChange("Duration"); + } + } + + /* Properties for User Selections */ + /// /// Gets or sets SelectedTitle. /// @@ -202,52 +325,89 @@ namespace HandBrakeWPF.ViewModels if (!object.Equals(this.selectedTitle, value)) { this.selectedTitle = value; + + if (selectedTitle == null) + { + return; + } + // Use the Path on the Title, or the Source Scan path if one doesn't exist. this.CurrentTask.Source = !string.IsNullOrEmpty(this.selectedTitle.SourceName) ? this.selectedTitle.SourceName : this.ScannedSource.ScanPath; this.CurrentTask.Title = value.TitleNumber; + this.NotifyOfPropertyChange("StartEndRangeItems"); + this.NotifyOfPropertyChange("SelectedTitle"); + this.NotifyOfPropertyChange("Angles"); + + // Default the Start and End Point dropdowns + this.SelectedStartPoint = 1; + this.SelectedEndPoint = selectedTitle.Chapters.Last().ChapterNumber; + this.SelectedPointToPoint = PointToPointMode.Chapters; + this.SelectedAngle = 1; } } } /// - /// Gets or sets the Source Label - /// This indicates the status of scans. + /// Gets or sets SelectedAngle. /// - public string SourceLabel + public int SelectedAngle { get { - return string.IsNullOrEmpty(this.sourceLabel) ? "Select 'Source' to continue" : this.sourceLabel; + return this.CurrentTask.StartPoint; } + set + { + this.CurrentTask.EndPoint = value; + this.NotifyOfPropertyChange("SelectedAngle"); + } + } + /// + /// Gets or sets SelectedStartPoint. + /// + public int SelectedStartPoint + { + get + { + return this.CurrentTask.StartPoint; + } set { - if (!object.Equals(this.sourceLabel, value)) - { - this.sourceLabel = value; - this.NotifyOfPropertyChange("SourceLabel"); - } + this.CurrentTask.StartPoint = value; + this.NotifyOfPropertyChange("SelectedStartPoint"); } } /// - /// Gets or sets the Program Status Toolbar Label - /// This indicates the status of HandBrake + /// Gets or sets SelectedEndPoint. /// - public string ProgramStatusLabel + public int SelectedEndPoint { get { - return string.IsNullOrEmpty(this.programStatusLabel) ? "Ready" : this.sourceLabel; + return this.CurrentTask.EndPoint; + } + set + { + this.CurrentTask.EndPoint = value; + this.NotifyOfPropertyChange("SelectedEndPoint"); } + } + /// + /// Gets or sets SelectedPointToPoint. + /// + public PointToPointMode SelectedPointToPoint + { + get + { + return this.CurrentTask.PointToPointMode; + } set { - if (!object.Equals(this.programStatusLabel, value)) - { - this.programStatusLabel = value; - this.NotifyOfPropertyChange("ProgramStatusLabel"); - } + this.CurrentTask.PointToPointMode = value; + this.NotifyOfPropertyChange("SelectedPointToPoint"); } } @@ -421,7 +581,7 @@ namespace HandBrakeWPF.ViewModels #endregion - #region Main Window + #region Main Window Public Methods /// /// The Destination Path @@ -488,6 +648,8 @@ namespace HandBrakeWPF.ViewModels this.scanService.SouceData.CopyTo(this.ScannedSource); this.NotifyOfPropertyChange("ScannedSource"); this.NotifyOfPropertyChange("ScannedSource.Titles"); + this.NotifyOfPropertyChange("T"); + this.SelectedTitle = this.ScannedSource.Titles.Where(t => t.MainTitle).FirstOrDefault(); } this.SourceLabel = "Scan Completed"; -- cgit v1.2.3