diff options
author | sr55 <[email protected]> | 2011-11-28 20:27:02 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2011-11-28 20:27:02 +0000 |
commit | d40d2fe37b2e9a61067f2f13fdabaf4ff4c2a69a (patch) | |
tree | ff897b7664fc414aef2a4b8cb87713de671b0a27 /win/CS/HandBrakeWPF | |
parent | 044fa5acfdfba93e70f9ade5586f14aee0958532 (diff) |
WinGui: (WPF) Further UI work on the new interface.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4366 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/CS/HandBrakeWPF')
-rw-r--r-- | win/CS/HandBrakeWPF/Factories/ViewModelFactory.cs | 60 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/HandBrakeWPF.csproj | 4 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs | 202 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Views/AboutView.xaml | 55 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Views/MainView.xaml | 61 |
5 files changed, 262 insertions, 120 deletions
diff --git a/win/CS/HandBrakeWPF/Factories/ViewModelFactory.cs b/win/CS/HandBrakeWPF/Factories/ViewModelFactory.cs deleted file mode 100644 index 2c840f441..000000000 --- a/win/CS/HandBrakeWPF/Factories/ViewModelFactory.cs +++ /dev/null @@ -1,60 +0,0 @@ -// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="ViewModelFactory.cs" company="HandBrake Project (http://handbrake.fr)">
-// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
-// </copyright>
-// <summary>
-// The View Model Factory
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrakeWPF.Factories
-{
- using Caliburn.Micro;
-
- using HandBrake.ApplicationServices.Services.Interfaces;
-
- using HandBrakeWPF.ViewModels;
- using HandBrakeWPF.ViewModels.Interfaces;
-
- /// <summary>
- /// The View Model Factory
- /// </summary>
- public class ViewModelFactory
- {
- /// <summary>
- /// The Window Manager
- /// </summary>
- private readonly IWindowManager windowManager;
-
- /// <summary>
- /// The User Setting Service
- /// </summary>
- private readonly IUserSettingService userSettingsService;
-
- /// <summary>
- /// Initializes a new instance of the <see cref="ViewModelFactory"/> class.
- /// </summary>
- /// <param name="windowManager">
- /// The window Manager.
- /// </param>
- /// <param name="userSettingsService">
- /// The user Settings Service.
- /// </param>
- public ViewModelFactory(IWindowManager windowManager, IUserSettingService userSettingsService)
- {
- this.windowManager = windowManager;
- this.userSettingsService = userSettingsService;
- }
-
- /// <summary>
- /// Create an ErrorViewModel
- /// </summary>
- /// <returns>
- /// An Error ViewModel
- /// </returns>
- public IErrorViewModel CreateErrorViewModel()
- {
- return new ErrorViewModel();
- }
- }
-}
diff --git a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj index 1f9a1b1a8..3869f479d 100644 --- a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj +++ b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj @@ -78,7 +78,6 @@ <Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
- <Compile Include="Factories\ViewModelFactory.cs" />
<Compile Include="Helpers\ListBoxHelper.cs" />
<Compile Include="Startup\CastleBootstrapper.cs" />
<Compile Include="Startup\MefBootstrapper.cs" />
@@ -268,6 +267,9 @@ <Name>HandBrake.ApplicationServices</Name>
</ProjectReference>
</ItemGroup>
+ <ItemGroup>
+ <Folder Include="Factories\" />
+ </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(ProgramFiles)\MSBuild\StyleCop\v4.*\StyleCop.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
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 /// </summary>
private Title selectedTitle;
+ /// <summary>
+ /// Backing field for duration
+ /// </summary>
+ private string duration;
+
#endregion
/// <summary>
@@ -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<IQueueProcessor>(); // 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;
@@ -189,6 +201,117 @@ namespace HandBrakeWPF.ViewModels }
/// <summary>
+ /// Gets or sets the Source Label
+ /// This indicates the status of scans.
+ /// </summary>
+ 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");
+ }
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets the Program Status Toolbar Label
+ /// This indicates the status of HandBrake
+ /// </summary>
+ 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");
+ }
+ }
+ }
+
+ /// <summary>
+ /// Gets RangeMode.
+ /// </summary>
+ public IEnumerable<PointToPointMode> RangeMode
+ {
+ get
+ {
+ return new List<PointToPointMode>
+ {
+ PointToPointMode.Chapters, PointToPointMode.Seconds, PointToPointMode.Frames
+ };
+ }
+ }
+
+ /// <summary>
+ /// Gets StartEndRangeItems.
+ /// </summary>
+ public IEnumerable<int> StartEndRangeItems
+ {
+ get
+ {
+ if (this.SelectedTitle == null)
+ {
+ return null;
+ }
+
+ return this.SelectedTitle.Chapters.Select(item => item.ChapterNumber).Select(dummy => (int)dummy).ToList();
+ }
+ }
+
+ /// <summary>
+ /// Gets Angles.
+ /// </summary>
+ public IEnumerable<int> Angles
+ {
+ get
+ {
+ if (this.SelectedTitle == null)
+ {
+ return null;
+ }
+
+ List<int> items = new List<int>();
+ for (int i = 1; i <= this.selectedTitle.AngleCount + 1; i++)
+ {
+ items.Add(i);
+ }
+ return items;
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets Duration.
+ /// </summary>
+ public string Duration
+ {
+ get
+ {
+ return string.IsNullOrEmpty(duration) ? "--:--:--" : duration;
+ }
+ set
+ {
+ duration = value;
+ this.NotifyOfPropertyChange("Duration");
+ }
+ }
+
+ /* Properties for User Selections */
+
+ /// <summary>
/// Gets or sets SelectedTitle.
/// </summary>
public Title 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;
}
}
}
/// <summary>
- /// Gets or sets the Source Label
- /// This indicates the status of scans.
+ /// Gets or sets SelectedAngle.
/// </summary>
- 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");
+ }
+ }
+ /// <summary>
+ /// Gets or sets SelectedStartPoint.
+ /// </summary>
+ 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");
}
}
/// <summary>
- /// Gets or sets the Program Status Toolbar Label
- /// This indicates the status of HandBrake
+ /// Gets or sets SelectedEndPoint.
/// </summary>
- 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");
}
+ }
+ /// <summary>
+ /// Gets or sets SelectedPointToPoint.
+ /// </summary>
+ 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
/// <summary>
/// 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";
diff --git a/win/CS/HandBrakeWPF/Views/AboutView.xaml b/win/CS/HandBrakeWPF/Views/AboutView.xaml index 0c8bf0ecb..1a86c7a76 100644 --- a/win/CS/HandBrakeWPF/Views/AboutView.xaml +++ b/win/CS/HandBrakeWPF/Views/AboutView.xaml @@ -1,30 +1,53 @@ <Window x:Class="HandBrakeWPF.Views.AboutView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:Micro="clr-namespace:Caliburn.Micro;assembly=Caliburn.Micro" Title="AboutView"
- Height="270" Width="500">
+ Height="320" Width="600">
- <StackPanel Orientation="Horizontal">
- <Image Source="Images/logo64.png" Width="64" Height="64" SnapsToDevicePixels="True" Margin="10,10,10,10" HorizontalAlignment="Left" VerticalAlignment="Top" />
+ <Grid>
+ <Grid.RowDefinitions>
+ <RowDefinition Height="*"/>
+ <RowDefinition Height="Auto"/>
+ </Grid.RowDefinitions>
- <StackPanel Orientation="Vertical">
- <StackPanel Orientation="Horizontal" Margin="0,10,0,0">
- <TextBlock Text="HandBrake" FontWeight="Bold" FontSize="14" Margin="0,0,5,0" />
- <TextBlock Text="{Binding Version}" Margin="0,0,0,1" VerticalAlignment="Bottom" />
- </StackPanel>
- <TextBlock Text="Copyright 2003-2011 HandBrake Team" />
+ <Grid Grid.Row="0">
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width="Auto" />
+ <ColumnDefinition Width="*" />
+ </Grid.ColumnDefinitions>
+
+ <Image Source="Images/logo64.png" Width="64" Height="64" Grid.Column="0" SnapsToDevicePixels="True" Margin="10,10,10,10" HorizontalAlignment="Left" VerticalAlignment="Top" />
- <Label Content="License:" />
- <TextBox Width="380" Height="125" IsReadOnly="True" TextWrapping="Wrap" VerticalScrollBarVisibility="Auto" Margin="10,0,10,10">
- This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
+ <Grid Grid.Column="1">
+ <Grid.RowDefinitions>
+ <RowDefinition Height="Auto" />
+ <RowDefinition Height="Auto" />
+ <RowDefinition Height="Auto" />
+ <RowDefinition Height="*" />
+ </Grid.RowDefinitions>
+
+ <StackPanel Orientation="Horizontal" Margin="5,10,0,0" Grid.Row="0">
+ <TextBlock Text="HandBrake" FontWeight="Bold" FontSize="14" Margin="0,0,5,0" />
+ <TextBlock Text="{Binding Version}" Margin="0,0,0,1" VerticalAlignment="Bottom" />
+ </StackPanel>
+
+ <TextBlock Text="Copyright 2003-2011 HandBrake Team" Margin="5,0,0,0 " Grid.Row="1" />
+
+ <TextBlock Text="License:" Margin="5,10,0,5" Grid.Row="2" />
+ <TextBox VerticalAlignment="Stretch" HorizontalAlignment="Stretch" IsReadOnly="True" TextWrapping="Wrap"
+ VerticalScrollBarVisibility="Auto" Margin="10,0,10,10" Grid.Row="3">
+ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- </TextBox>
+ </TextBox>
- <Button Content="Close" Micro:Message.Attach="[Event Click] = [Action Close]"
- HorizontalAlignment="Right" Padding="12,2" Margin="0,0,10,10" />
+ </Grid>
+ </Grid>
+ <StackPanel HorizontalAlignment="Stretch" Background="LightGray" Grid.Row="1">
+ <Button Content="Close" Micro:Message.Attach="[Event Click] = [Action Close]"
+ HorizontalAlignment="Right" Padding="12,2" Margin="0,5,10,5" VerticalAlignment="Center" />
</StackPanel>
- </StackPanel>
+ </Grid>
</Window>
diff --git a/win/CS/HandBrakeWPF/Views/MainView.xaml b/win/CS/HandBrakeWPF/Views/MainView.xaml index d959c18d8..07f880ae5 100644 --- a/win/CS/HandBrakeWPF/Views/MainView.xaml +++ b/win/CS/HandBrakeWPF/Views/MainView.xaml @@ -45,18 +45,33 @@ <!-- ToolBar -->
<ToolBar Name="mainToolBar" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" SnapsToDevicePixels="False">
- <Button Name="Source">
- <StackPanel Orientation="Horizontal">
- <Image Source="Images/Movies.png" Height="32" Width="32" />
- <Label Content="Source" Margin="8,0,0,0" VerticalAlignment="Center" />
- </StackPanel>
- <Button.ContextMenu>
- <ContextMenu >
- <MenuItem Header="Open Folder" Micro:Message.Attach="[Event Click] = [Action FolderScan]"/>
- <MenuItem Header="Open File" Micro:Message.Attach="[Event Click] = [Action FileScan]"/>
- </ContextMenu>
- </Button.ContextMenu>
- </Button>
+ <Menu Background="Transparent" >
+ <MenuItem>
+ <MenuItem.Header>
+ <StackPanel Orientation="Horizontal">
+ <Image Source="Images/Movies.png" Height="32" Width="32" />
+ <Label Content="Source" Margin="8,0,0,0" VerticalAlignment="Center" />
+ </StackPanel>
+ </MenuItem.Header>
+
+ <MenuItem Micro:Message.Attach="[Event Click] = [Action FolderScan]">
+ <MenuItem.Header>
+ <StackPanel Orientation="Horizontal">
+ <Image Source="Images/folder.png" Height="20" Width="20" />
+ <Label Content="Open Folder" Margin="8,0,0,0" VerticalAlignment="Center" />
+ </StackPanel>
+ </MenuItem.Header>
+ </MenuItem>
+ <MenuItem Micro:Message.Attach="[Event Click] = [Action FileScan]">
+ <MenuItem.Header>
+ <StackPanel Orientation="Horizontal">
+ <Image Source="Images/Movies.png" Height="20" Width="20" />
+ <Label Content="Open File" Margin="8,0,0,0" VerticalAlignment="Center" />
+ </StackPanel>
+ </MenuItem.Header>
+ </MenuItem>
+ </MenuItem>
+ </Menu>
<Separator />
@@ -115,14 +130,14 @@ <ComboBox Name="Titles" Margin="8,0,0,0" MinWidth="100" ItemsSource="{Binding ScannedSource.Titles}" SelectedItem="{Binding Path=SelectedTitle}" />
<Label Content="Angle" Margin="8,0,0,0" />
- <ComboBox Name="Angles" Margin="8,0,0,0" MinWidth="60" SelectedItem="{Binding Path=CurrentTask.Angle}"/>
+ <ComboBox Name="Angles" Margin="8,0,0,0" MinWidth="60" ItemsSource="{Binding Angles}" SelectedItem="{Binding SelectedAngle}"/>
- <ComboBox Name="PointToPointMode" Margin="8,0,0,0" MinWidth="80" SelectedItem="{Binding Path=CurrentTask.PointToPointMode}" />
- <ComboBox Name="StartPoint" Margin="8,0,0,0" MinWidth="60" SelectedItem="{Binding Path=CurrentTask.StartPoint}" />
+ <ComboBox Name="PointToPointMode" Margin="8,0,0,0" MinWidth="80" ItemsSource="{Binding RangeMode}" SelectedItem="{Binding SelectedPointToPoint}" />
+ <ComboBox Name="StartPoint" Margin="8,0,0,0" MinWidth="60" ItemsSource="{Binding StartEndRangeItems}" SelectedItem="{Binding SelectedStartPoint}" />
<Label Content="through" Margin="8,0,0,0" />
- <ComboBox Name="EndPoint" Margin="8,0,0,0" MinWidth="60" SelectedItem="{Binding Path=CurrentTask.EndPoint}" />
+ <ComboBox Name="EndPoint" Margin="8,0,0,0" MinWidth="60" ItemsSource="{Binding StartEndRangeItems}" SelectedItem="{Binding SelectedEndPoint}" />
<Label Content="Duration" Margin="8,0,0,0" />
- <Label Content="--:--:--" Margin="8,0,0,0" />
+ <Label Content="{Binding Duration}" Margin="8,0,0,0" />
</StackPanel>
</StackPanel>
@@ -207,7 +222,7 @@ </Grid>
</TabItem>
-
+
<TabItem Header="Video" Name="videoTab">
<Grid Margin="10,5,0,0">
<Grid.RowDefinitions>
@@ -225,12 +240,12 @@ <StackPanel Orientation="Vertical" Grid.Column="0" >
<TextBlock Text="Video" FontWeight="Bold" Margin="0,0,0,10"/>
-
+
<StackPanel Orientation="Horizontal" Margin="0,0,0,10" >
<TextBlock Text="Video Codec:" Width="100" />
<ComboBox Width="120"/>
</StackPanel>
-
+
<StackPanel Orientation="Horizontal">
<TextBlock Text="Franerate (FPS):" Width="100"/>
<StackPanel Orientation="Vertical">
@@ -245,15 +260,15 @@ <StackPanel Orientation="Vertical" Grid.Column="1" >
<TextBlock Text="Quality" FontWeight="Bold" Margin="0,0,0,10"/>
-
+
<StackPanel Orientation="Horizontal" Margin="0,0,0,10" >
<RadioButton Content="Constant Quality:" Margin="0,0,10,0"/>
<TextBlock Text="0" Width="25" />
<TextBlock Text="RF" FontWeight="Bold" />
</StackPanel>
-
+
<Slider Width="240" Margin="0,0,0,20" />
-
+
<StackPanel Orientation="Horizontal" Margin="0,0,0,10">
<RadioButton Content="Avg Bitrate (kbps):" Margin="0,0,10,0"/>
<TextBox Width="75" />
|