Skip to content

Commit

Permalink
Merged development into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Tichau committed Aug 19, 2016
2 parents ea52253 + b766aeb commit ce5efaf
Show file tree
Hide file tree
Showing 58 changed files with 4,378 additions and 676 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
build/
bld/
[Bb]in/
Expand Down
5 changes: 5 additions & 0 deletions Application/FileConverter/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,9 @@
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="Languages"/>
</assemblyBinding>
</runtime>
</configuration>
9 changes: 8 additions & 1 deletion Application/FileConverter/Application.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,18 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:xaml="clr-namespace:Markdown.Xaml;assembly=Markdown.Xaml"
xmlns:valueConverters="clr-namespace:FileConverter.ValueConverters"
xmlns:generic="clr-namespace:FileConverter.ValueConverters.Generic"
StartupUri="Windows/MainWindow.xaml" ShutdownMode="OnMainWindowClose">
<Application.Resources>
<!-- Converters -->
<valueConverters:ApplicationVersionToApplicationName x:Key="ApplicationVersionToApplicationName"/>

<generic:BoolToVisibility x:Key="BoolToVisibility"/>

<generic:ValueConverterGroup x:Key="InvBoolToVisibility">
<generic:BoolInverterConverter/>
<generic:BoolToVisibility/>
</generic:ValueConverterGroup>

<!-- Markdown style -->
<Style TargetType="FlowDocument" x:Key="DocumentStyle">
<Setter Property="FontFamily" Value="Segoe UI" />
Expand Down
61 changes: 36 additions & 25 deletions Application/FileConverter/Application.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public partial class Application : System.Windows.Application
private static readonly Version Version = new Version()
{
Major = 1,
Minor = 0,
Minor = 1,
Patch = 0,
};

Expand All @@ -42,8 +42,7 @@ public partial class Application : System.Windows.Application
private bool needToRunConversionThread;
private bool cancelAutoExit;
private bool isSessionEnding;
private UpgradeVersionDescription upgradeVersionDescription = null;


public Application()
{
this.ConvertionJobs = this.conversionJobs.AsReadOnly();
Expand Down Expand Up @@ -83,6 +82,12 @@ public bool HideMainWindow
set;
}

public UpgradeVersionDescription UpgradeVersionDescription
{
get;
private set;
}

public bool Verbose
{
get;
Expand All @@ -107,7 +112,7 @@ protected override void OnStartup(StartupEventArgs e)

if (this.needToRunConversionThread)
{
Thread fileConvertionThread = new Thread(this.ConvertFiles);
Thread fileConvertionThread = Helpers.InstantiateThread("ConversionQueueThread", this.ConvertFiles);
fileConvertionThread.Start();
}
}
Expand All @@ -118,31 +123,31 @@ protected override void OnExit(ExitEventArgs e)

Debug.Log("Exit application.");

if (!this.isSessionEnding && this.upgradeVersionDescription != null && this.upgradeVersionDescription.NeedToUpgrade)
if (!this.isSessionEnding && this.UpgradeVersionDescription != null && this.UpgradeVersionDescription.NeedToUpgrade)
{
Debug.Log("A new version of file converter has been found: {0}.", this.upgradeVersionDescription.LatestVersion);
Debug.Log("A new version of file converter has been found: {0}.", this.UpgradeVersionDescription.LatestVersion);

if (string.IsNullOrEmpty(this.upgradeVersionDescription.InstallerPath))
if (string.IsNullOrEmpty(this.UpgradeVersionDescription.InstallerPath))
{
Debug.LogError("Invalid installer path.");
}
else
{
Debug.Log("Wait for the end of the installer download.");
while (this.upgradeVersionDescription.InstallerDownloadInProgress)
while (this.UpgradeVersionDescription.InstallerDownloadInProgress)
{
Thread.Sleep(1000);
}

string installerPath = this.upgradeVersionDescription.InstallerPath;
string installerPath = this.UpgradeVersionDescription.InstallerPath;
if (!System.IO.File.Exists(installerPath))
{
Debug.LogError("Can't find upgrade installer ({0}). Try to restart the application.", installerPath);
return;
}

// Start process.
Debug.Log("Start file converter upgrade from version {0} to {1}.", ApplicationVersion, this.upgradeVersionDescription.LatestVersion);
Debug.Log("Start file converter upgrade from version {0} to {1}.", ApplicationVersion, this.UpgradeVersionDescription.LatestVersion);

System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo(installerPath)
{
Expand Down Expand Up @@ -172,10 +177,12 @@ protected override void OnSessionEnding(SessionEndingCancelEventArgs e)

private void Initialize()
{
Diagnostics.Debug.Log("File Converter v" + ApplicationVersion.ToString());
this.numberOfConversionThread = System.Math.Max(1, Environment.ProcessorCount / 2);
Diagnostics.Debug.Log("The number of processors on this computer is {0}. Set the default number of conversion threads to {0}", this.numberOfConversionThread);

#if BUILD32
Diagnostics.Debug.Log("File Converter v" + ApplicationVersion.ToString() + " (32 bits)");
#else
Diagnostics.Debug.Log("File Converter v" + ApplicationVersion.ToString() + " (64 bits)");
#endif

// Retrieve arguments.
Debug.Log("Retrieve arguments...");
string[] args = Environment.GetCommandLineArgs();
Expand Down Expand Up @@ -286,9 +293,21 @@ private void Initialize()
return;
}

if (this.Settings.MaximumNumberOfSimultaneousConversions <= 0)
{
this.Settings.MaximumNumberOfSimultaneousConversions = System.Math.Max(1, Environment.ProcessorCount / 2);
Diagnostics.Debug.Log("The number of processors on this computer is {0}. Set the default number of conversion threads to {0}", this.Settings.MaximumNumberOfSimultaneousConversions);
}

this.numberOfConversionThread = this.Settings.MaximumNumberOfSimultaneousConversions;
Diagnostics.Debug.Log("Maximum number of conversion threads: {0}", this.numberOfConversionThread);

// Check upgrade.
if (this.Settings.CheckUpgradeAtStartup)
{
#if DEBUG
Task<UpgradeVersionDescription> task = Upgrade.Helpers.GetLatestVersionDescriptionAsync(this.OnGetLatestVersionDescription);
#else
long fileTime = Registry.GetValue<long>(Registry.Keys.LastUpdateCheckDate);
DateTime lastUpdateDateTime = DateTime.FromFileTime(fileTime);

Expand All @@ -297,6 +316,7 @@ private void Initialize()
{
Task<UpgradeVersionDescription> task = Upgrade.Helpers.GetLatestVersionDescriptionAsync(this.OnGetLatestVersionDescription);
}
#endif
}

ConversionPreset conversionPreset = null;
Expand Down Expand Up @@ -376,7 +396,7 @@ private void ConvertFiles()
Thread thread = jobThreads[threadIndex];
if (thread == null || !thread.IsAlive)
{
jobThread = new Thread(this.ExecuteConversionJob);
jobThread = Helpers.InstantiateThread("ConversionThread", this.ExecuteConversionJob);
jobThreads[threadIndex] = jobThread;
break;
}
Expand Down Expand Up @@ -458,15 +478,6 @@ private void ExecuteConversionJob(object parameter)
{
Debug.LogError("Failure during conversion: {0}", exception.ToString());
}

if (conversionJob.State == ConversionJob.ConversionState.Done && !System.IO.File.Exists(conversionJob.OutputFilePath))
{
Debug.LogError("Can't find the output file.");
}
else if (conversionJob.State == ConversionJob.ConversionState.Failed && System.IO.File.Exists(conversionJob.OutputFilePath))
{
Debug.Log("The conversion job failed but there is an output file that does exists.");
}
}

private void OnGetLatestVersionDescription(UpgradeVersionDescription upgradeVersionDescription)
Expand All @@ -483,7 +494,7 @@ private void OnGetLatestVersionDescription(UpgradeVersionDescription upgradeVers
return;
}

this.upgradeVersionDescription = upgradeVersionDescription;
this.UpgradeVersionDescription = upgradeVersionDescription;
(this.MainWindow as MainWindow).OnNewVersionReleased(upgradeVersionDescription);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:valueConverters="clr-namespace:FileConverter.ValueConverters" x:Name="userControl"
xmlns:valueConverters="clr-namespace:FileConverter.ValueConverters"
xmlns:project="clr-namespace:FileConverter.Properties"
x:Name="userControl"
x:Class="FileConverter.Controls.EncodingQualitySliderControl"
mc:Ignorable="d" d:DesignWidth="300" Height="50">
<UserControl.Resources>
Expand All @@ -21,6 +23,6 @@

<Slider Grid.Column="0" x:Name="slider" Margin="0,2,0,0" VerticalAlignment="Top" Maximum="245" AutoToolTipPlacement="TopLeft" SmallChange="8" IsSnapToTickEnabled="True" IsSelectionRangeEnabled="True" SelectionStart="115" SelectionEnd="245" Minimum="65" TickPlacement="BottomRight" LargeChange="32" TickFrequency="8" Ticks="65 85 100 115 130 165 175 190 225 245" Foreground="#004B82" />
<Label Grid.Column="1" Content="{Binding Value, Converter={StaticResource BitrateToString}, ElementName=slider, Mode=OneWay}" Width="65" />
<Label Grid.Column="0" Grid.Row="1" Content="Recommended bitrate range in blue" Foreground="#E5004B82" FontSize="11" />
<Label Grid.Column="0" Grid.Row="1" Content="{x:Static project:Resources.RecommendeBitrateRangeInBlue}" Foreground="#E5004B82" FontSize="11" />
</Grid>
</UserControl>

0 comments on commit ce5efaf

Please sign in to comment.