Skip to content

Commit

Permalink
WinGui: (WPF) Further work hooking up the new main window.
Browse files Browse the repository at this point in the history
git-svn-id: svn://localhost/HandBrake/trunk@4372 b64f7644-9d1e-0410-96f1-a4d463321fa5
  • Loading branch information
sr55 committed Dec 3, 2011
1 parent 01cf816 commit db451de
Show file tree
Hide file tree
Showing 20 changed files with 208 additions and 64 deletions.
2 changes: 1 addition & 1 deletion win/CS/Controls/AudioPanel.cs
Expand Up @@ -155,7 +155,7 @@ public bool RequiresM4V()
/// Load an arraylist of AudioTrack items into the list.
/// </summary>
/// <param name="tracks">List of audio tracks</param>
public void LoadTracks(List<AudioTrack> tracks)
public void LoadTracks(ObservableCollection<AudioTrack> tracks)
{
ClearAudioList();

Expand Down
11 changes: 7 additions & 4 deletions win/CS/Functions/QueryGenerator.cs
Expand Up @@ -7,6 +7,7 @@ namespace Handbrake.Functions
{
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Globalization;
using System.IO;
using System.Linq;
Expand Down Expand Up @@ -707,17 +708,19 @@ private static EncodeTask CreateEncodeTaskObject(frmMain frmMain)
}

// Audio
task.AudioTracks = new List<AudioTrack>(frmMain.AudioSettings.AudioTracks);
task.AudioTracks = new ObservableCollection<AudioTrack>(frmMain.AudioSettings.AudioTracks);

// Subtitles
task.SubtitleTracks = new List<SubtitleTrack>(frmMain.Subtitles.SubtitlesList);
task.SubtitleTracks = new ObservableCollection<SubtitleTrack>(frmMain.Subtitles.SubtitlesList);

// Chapters
task.IncludeChapterMarkers = frmMain.Check_ChapterMarkers.Checked;
task.ChapterNames = new List<string>();
task.ChapterNames = new ObservableCollection<ChapterMarker>();
foreach (DataGridViewRow row in frmMain.data_chpt.Rows)
{
task.ChapterNames.Add(row.Cells[1].Value.ToString());
int number;
int.TryParse(row.Cells[0].Value.ToString(), out number);
task.ChapterNames.Add(new ChapterMarker(number, row.Cells[1].Value.ToString()));
}

// Advanced Options
Expand Down
Expand Up @@ -7,6 +7,7 @@ namespace HandBrake.ApplicationServices.Functions
{
using System;
using System.Collections.Generic;
using System.Linq;

using HandBrake.ApplicationServices.Model;
using HandBrake.ApplicationServices.Model.Encoding;
Expand Down Expand Up @@ -154,7 +155,7 @@ public static EncodeJob GetEncodeJob(QueueTask task)
job.FramesStart = work.StartPoint;
}

job.CustomChapterNames = work.ChapterNames;
job.CustomChapterNames = work.ChapterNames.Select(item => item.ChapterName).ToList();
job.UseDefaultChapterNames = work.IncludeChapterMarkers;

job.OutputPath = work.Destination;
Expand Down
Expand Up @@ -103,6 +103,7 @@
<Compile Include="Functions\Win7.cs" />
<Compile Include="Model\DriveInformation.cs" />
<Compile Include="Model\Encoding\AudioTrack.cs" />
<Compile Include="Model\Encoding\ChapterMarker.cs" />
<Compile Include="Model\Encoding\FramerateMode.cs" />
<Compile Include="Model\Encoding\PointToPointMode.cs" />
<Compile Include="Model\EncodeTask.cs" />
Expand Down
13 changes: 9 additions & 4 deletions win/CS/HandBrake.ApplicationServices/Model/EncodeTask.cs
Expand Up @@ -6,8 +6,10 @@
namespace HandBrake.ApplicationServices.Model
{
using System.Collections.Generic;
using System.Collections.ObjectModel;

using HandBrake.ApplicationServices.Model.Encoding;
using HandBrake.ApplicationServices.Parsing;
using HandBrake.Interop.Model;
using HandBrake.Interop.Model.Encoding;
using HandBrake.Interop.Model.Encoding.x264;
Expand All @@ -25,6 +27,9 @@ public class EncodeTask
public EncodeTask()
{
this.Cropping = new Cropping();
this.AudioTracks = new ObservableCollection<AudioTrack>();
this.SubtitleTracks = new ObservableCollection<SubtitleTrack>();
this.ChapterNames = new ObservableCollection<ChapterMarker>();
}

#region Source
Expand Down Expand Up @@ -257,15 +262,15 @@ public EncodeTask()
/// <summary>
/// Gets or sets AudioEncodings.
/// </summary>
public List<AudioTrack> AudioTracks { get; set; }
public ObservableCollection<AudioTrack> AudioTracks { get; set; }
#endregion

#region Subtitles

/// <summary>
/// Gets or sets SubtitleTracks.
/// </summary>
public List<SubtitleTrack> SubtitleTracks { get; set; }
public ObservableCollection<SubtitleTrack> SubtitleTracks { get; set; }
#endregion

#region Chapters
Expand All @@ -281,9 +286,9 @@ public EncodeTask()
public string ChapterMarkersFilePath { get; set; }

/// <summary>
/// Chapter Names
/// Gets or sets ChapterNames.
/// </summary>
public List<string> ChapterNames { get; set; }
public ObservableCollection<ChapterMarker> ChapterNames { get; set; }

#endregion

Expand Down
@@ -0,0 +1,45 @@
/* ChapterMarker.cs $
This file is part of the HandBrake source code.
Homepage: <http://handbrake.fr>.
It may be used under the terms of the GNU General Public License. */

namespace HandBrake.ApplicationServices.Model.Encoding
{
/// <summary>
/// A Movie Chapter
/// </summary>
public class ChapterMarker
{
/// <summary>
/// Initializes a new instance of the <see cref="ChapterMarker"/> class.
/// </summary>
public ChapterMarker()
{
}

/// <summary>
/// Initializes a new instance of the <see cref="ChapterMarker"/> class.
/// </summary>
/// <param name="number">
/// The number.
/// </param>
/// <param name="Name">
/// The name.
/// </param>
public ChapterMarker(int number, string Name)
{
this.ChapterName = Name;
this.ChapterNumber = number;
}

/// <summary>
/// Gets or sets The number of this Chapter, in regards to it's parent Title
/// </summary>
public int ChapterNumber { get; set; }

/// <summary>
/// Gets or sets ChapterName.
/// </summary>
public string ChapterName { get; set; }
}
}
Expand Up @@ -7,6 +7,7 @@ namespace HandBrake.ApplicationServices.Utilities
{
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Text;
using System.Windows.Forms;
Expand Down Expand Up @@ -42,7 +43,7 @@ public static EncodeTask Import(string filename)

#region Get a List of Audio Track Objects
XmlNode audioListDict = root.ChildNodes[2].ChildNodes[0].FirstChild.ChildNodes[1];
List<AudioTrack> audioTracks = new List<AudioTrack>();
ObservableCollection<AudioTrack> audioTracks = new ObservableCollection<AudioTrack>();

for (int i = 0; i < audioListDict.ChildNodes.Count; i++)
{
Expand Down
Expand Up @@ -7,6 +7,7 @@ namespace HandBrake.ApplicationServices.Utilities
{
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Globalization;
using System.IO;

Expand Down Expand Up @@ -463,7 +464,7 @@ private static string AudioSettingsQuery(EncodeTask task)
{
string query = string.Empty;

List<AudioTrack> audioTracks = task.AudioTracks;
ObservableCollection<AudioTrack> audioTracks = task.AudioTracks;

List<int> tracks = new List<int>();
List<AudioEncoder> codecs = new List<AudioEncoder>();
Expand Down Expand Up @@ -807,14 +808,14 @@ private static string ExtraSettings()
/// <param name="chapters">The List of chapters</param>
/// <param name="filePathName">Path to save the csv file</param>
/// <returns>True if successful </returns>
private static bool ChapterCsvSave(IEnumerable<string> chapters, string filePathName)
private static bool ChapterCsvSave(IEnumerable<ChapterMarker> chapters, string filePathName)
{
string csv = string.Empty;
int counter = 0;

foreach (string name in chapters)
foreach (ChapterMarker name in chapters)
{
csv += counter + "," + name.Replace(",", "\\,") + Environment.NewLine;
csv += counter + "," + name.ChapterName.Replace(",", "\\,") + Environment.NewLine;
counter++;
}

Expand Down
Expand Up @@ -7,6 +7,7 @@ namespace HandBrake.ApplicationServices.Utilities
{
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Globalization;
using System.Text.RegularExpressions;

Expand Down Expand Up @@ -361,7 +362,7 @@ public static EncodeTask Parse(string input)
trackGainValues = gainValues.ToString().Replace("--gain=", string.Empty).Split(',');

// Create new Audio Track Classes and store them in the ArrayList
List<AudioTrack> allAudioTrackInfo = new List<AudioTrack>();
ObservableCollection<AudioTrack> allAudioTrackInfo = new ObservableCollection<AudioTrack>();
for (int x = 0; x < encoderCount; x++)
{
AudioTrack track = new AudioTrack();
Expand Down
4 changes: 4 additions & 0 deletions win/CS/HandBrakeWPF/HandBrakeWPF.csproj
Expand Up @@ -266,6 +266,10 @@
<Project>{087A2BA8-BAC2-4577-A46F-07FF9D420016}</Project>
<Name>HandBrake.ApplicationServices</Name>
</ProjectReference>
<ProjectReference Include="..\HandBrake.Interop\HandBrakeInterop\HandBrakeInterop.csproj">
<Project>{F0A61F62-2C3B-4A87-AFF4-0C4256253DA1}</Project>
<Name>HandBrakeInterop</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Folder Include="Factories\" />
Expand Down
10 changes: 8 additions & 2 deletions win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
Expand Up @@ -588,9 +588,15 @@ public void ExitApplication()
/// </summary>
public void BrowseDestination()
{
VistaSaveFileDialog dialog = new VistaSaveFileDialog { Filter = "MP4 File (*.mp4)|Mkv File(*.mkv)" };
VistaSaveFileDialog dialog = new VistaSaveFileDialog
{
Filter = "mp4|*.mp4;*.m4v|mkv|*.mkv",
AddExtension = true,
OverwritePrompt = true,
DefaultExt = ".mp4"
};
dialog.ShowDialog();
dialog.AddExtension = true;

this.CurrentTask.Destination = dialog.FileName;
this.NotifyOfPropertyChange("CurrentTask");
}
Expand Down
8 changes: 4 additions & 4 deletions win/CS/HandBrakeWPF/Views/Controls/AdvancedView.xaml
Expand Up @@ -4,7 +4,8 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
d:DesignHeight="300" d:DesignWidth="300"
x:Name="advancedView">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
Expand All @@ -14,9 +15,8 @@

<TextBlock Text="Advanced" FontWeight="Bold" Margin="10,5,0,0" Grid.Row="0" ></TextBlock>

<TextBox Grid.Row="2" Margin="10" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">

</TextBox>
<TextBox Grid.Row="2" Margin="10" Text="{Binding Query, RelativeSource={RelativeSource AncestorType=UserControl}}"
VerticalAlignment="Stretch" HorizontalAlignment="Stretch" />

</Grid>
</UserControl>
13 changes: 10 additions & 3 deletions win/CS/HandBrakeWPF/Views/Controls/AdvancedView.xaml.cs
Expand Up @@ -28,15 +28,22 @@ public AdvancedView()
/// <summary>
/// The "Query" Dependancy Property
/// </summary>
public static readonly DependencyProperty QueryProperty = DependencyProperty.Register("Query", typeof(string), typeof(AdvancedView), new PropertyMetadata(null));
public static readonly DependencyProperty QueryProperty = DependencyProperty.Register("Query", typeof(string), typeof(AdvancedView));

/// <summary>
/// Gets or sets State.
/// </summary>
public string Query
{
get { return (string)this.GetValue(QueryProperty); }
set { this.SetValue(QueryProperty, value); }
get
{
return (string)this.GetValue(QueryProperty);
}

set
{
this.SetValue(QueryProperty, value);
}
}
}
}
6 changes: 3 additions & 3 deletions win/CS/HandBrakeWPF/Views/Controls/AudioView.xaml
Expand Up @@ -18,11 +18,11 @@
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Button Content="Add Track" Grid.Column="0" Width="75" Margin="0,0,10,0" />
<Button Content="Remove" Grid.Column="1" Width="75" />
<Button Content="Add Track" Click="Add" Grid.Column="0" Width="75" Margin="0,0,10,0" />
<Button Content="Remove" Click="Remove" Grid.Column="1" Width="75" />
</Grid>

<DataGrid Grid.Row="2" Margin="10" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
<DataGrid Grid.Row="2" Margin="10" ItemsSource="{Binding AudioTracks, RelativeSource={RelativeSource AncestorType=UserControl}}" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">

</DataGrid>

Expand Down
35 changes: 23 additions & 12 deletions win/CS/HandBrakeWPF/Views/Controls/AudioView.xaml.cs
Expand Up @@ -10,7 +10,7 @@
namespace HandBrakeWPF.Views.Controls
{
using System;
using System.ComponentModel;
using System.Collections.ObjectModel;
using System.Windows;
using System.Windows.Controls;

Expand All @@ -27,38 +27,49 @@ public partial class AudioView : UserControl
public AudioView()
{
InitializeComponent();
this.AudioTracks = new BindingList<AudioTrack>();
}

/// <summary>
/// The "Query" Dependancy Property
/// </summary>
public static readonly DependencyProperty QueryProperty = DependencyProperty.Register("AudioTracks", typeof(BindingList<AudioTrack>), typeof(AudioView), new PropertyMetadata(null));

public static readonly DependencyProperty AudioTracksProperty = DependencyProperty.Register("AudioTracks", typeof(ObservableCollection<AudioTrack>), typeof(AudioView));

/// <summary>
/// Gets or sets State.
/// </summary>
public BindingList<AudioTrack> AudioTracks
public ObservableCollection<AudioTrack> AudioTracks
{
get { return (BindingList<AudioTrack>)this.GetValue(QueryProperty); }
set { this.SetValue(QueryProperty, value); }
get { return (ObservableCollection<AudioTrack>)this.GetValue(AudioTracksProperty); }
set { this.SetValue(AudioTracksProperty, value); }
}


/// <summary>
/// Add an audio track.
/// Add a new Track
/// </summary>
public void Add()
/// <param name="sender">
/// The sender.
/// </param>
/// <param name="e">
/// The e.
/// </param>
public void Add(object sender, RoutedEventArgs e)
{
this.AudioTracks.Add(new AudioTrack());
}

/// <summary>
/// Remove an Audio Track
/// Remove a Track
/// </summary>
public void Remove()
/// <param name="sender">
/// The sender.
/// </param>
/// <param name="e">
/// The e.
/// </param>
public void Remove(object sender, RoutedEventArgs e)
{
throw new NotImplementedException("Not Done Yet!");
throw new NotImplementedException();
}
}
}

0 comments on commit db451de

Please sign in to comment.