Skip to content

Commit

Permalink
Initial Release (v1.0)
Browse files Browse the repository at this point in the history
Final changes to the project for its initial release.
  • Loading branch information
Tornadocraver committed Oct 20, 2018
1 parent aa70087 commit a389821
Show file tree
Hide file tree
Showing 16 changed files with 57 additions and 60 deletions.
6 changes: 3 additions & 3 deletions GoPro Video Recovery/App.xaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Application x:Class="GoPro_Video_Recovery.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml">
StartupUri="Views/MainWindow.xaml">
<Application.Resources>

</Application.Resources>
</Application>
</Application>
10 changes: 2 additions & 8 deletions GoPro Video Recovery/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using System.Windows;

namespace GoPro_Video_Recovery
{
Expand All @@ -14,4 +8,4 @@ namespace GoPro_Video_Recovery
public partial class App : Application
{
}
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
26 changes: 13 additions & 13 deletions GoPro Video Recovery/GoPro Video Recovery.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>GoPro Icon.ico</ApplicationIcon>
<ApplicationIcon>Properties\GoPro Icon.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
Expand All @@ -58,29 +58,29 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="CommandSet.cs" />
<Compile Include="Error.cs" />
<Compile Include="ErrorDisplay.xaml.cs">
<Compile Include="Classes\CommandSet.cs" />
<Compile Include="Classes\Error.cs" />
<Compile Include="Views\ErrorDisplay.xaml.cs">
<DependentUpon>ErrorDisplay.xaml</DependentUpon>
</Compile>
<Compile Include="ErrorStage.cs" />
<Compile Include="ProcessResult.cs" />
<Compile Include="ViewModelBase.cs" />
<Page Include="ErrorDisplay.xaml">
<Compile Include="Classes\ErrorStage.cs" />
<Compile Include="Classes\ProcessResult.cs" />
<Compile Include="Classes\ViewModelBase.cs" />
<Page Include="Views\ErrorDisplay.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="MainWindow.xaml">
<Page Include="Views\MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="DelegateCommand.cs" />
<Compile Include="MainPageViewModel.cs" />
<Compile Include="MainWindow.xaml.cs">
<Compile Include="Classes\DelegateCommand.cs" />
<Compile Include="View Models\MainPageViewModel.cs" />
<Compile Include="Views\MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
Expand Down Expand Up @@ -112,7 +112,7 @@
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<Resource Include="GoPro Icon.ico" />
<Resource Include="Properties\GoPro Icon.ico" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
Expand Down
28 changes: 0 additions & 28 deletions GoPro Video Recovery/MainWindow.xaml.cs

This file was deleted.

File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;
using System.Windows.Input;
using System.Windows.Media;

Expand Down Expand Up @@ -44,7 +46,7 @@ private void Browse(object context)
Dialog.Multiselect = false;
Dialog.InitialDirectory = Path.GetDirectoryName(Dialog.FileName);
Dialog.FileName = string.Empty;
Dialog.Title = "Select Good Video";
Dialog.Title = "Select A Sample Video";
result = Dialog.ShowDialog();
if (!result.HasValue || !result.Value)
{
Expand Down Expand Up @@ -94,10 +96,11 @@ private void Recover(object context)
}
#endregion

#region Recovery
private async Task RecoverVideos(CancellationToken token)
{
token.ThrowIfCancellationRequested();
Application.Current.Dispatcher.Invoke(() => { Running = true; Progress = 25.0; Status = "Analyzing good file..."; });
Application.Current.Dispatcher.Invoke(() => { Running = true; Progress = 25.0; Status = "Analyzing sample video..."; });
int total = BadPaths.Count();
ProcessResult analyze = await AnalyzeVideo(GoodPath, token);
if (analyze.Success)
Expand Down Expand Up @@ -125,7 +128,7 @@ private async Task RecoverVideos(CancellationToken token)
else
Errors.Add(new Error(ErrorStage.Analysis, string.Join($":{Environment.NewLine}", (string[])analyze.Result), GoodPath));
int errors = total - Errors.Count;
Application.Current.Dispatcher.Invoke(() => { Progress = 100.0; Status = $"Finished: {errors} video{(total > 1 || errors == 0 ? "s" : string.Empty)} recovered."; Valid = false; });
Application.Current.Dispatcher.Invoke(() => { Progress = 100.0; Status = $"Finished: {errors} video{(total > 1 || errors == 0 ? "s" : string.Empty)} recovered."; Valid = false; });
}

private async Task<ProcessResult> AnalyzeVideo(string goodVideoPath, CancellationToken token)
Expand All @@ -151,7 +154,6 @@ private async Task<ProcessResult> AnalyzeVideo(string goodVideoPath, Cancellatio
catch (OperationCanceledException exception) { throw exception; }
catch (Exception exception) { return new ProcessResult(false, new string[] { "An error occurred while launching the analysis process", exception.ToString() }); }
}

private async Task<ProcessResult> RecoverVideo(string badVideoPath, string recoverCommand, CancellationToken token)
{
try
Expand All @@ -174,7 +176,6 @@ private async Task<ProcessResult> RecoverVideo(string badVideoPath, string recov
catch (OperationCanceledException exception) { throw exception; }
catch (Exception exception) { return new ProcessResult(false, new string[] { "An error occurred while launching the recovery process", exception.ToString() }); }
}

private async Task<ProcessResult> MuxVideo(string badVideoPath, string muxCommand, CancellationToken token)
{
try
Expand All @@ -197,6 +198,7 @@ private async Task<ProcessResult> MuxVideo(string badVideoPath, string muxComman
catch (OperationCanceledException exception) { throw exception; }
catch (Exception exception) { return new ProcessResult(false, new string[] { "An error occurred while launching the muxing process", exception.ToString() }); }
}
#endregion

#region Variables
private string[] BadPaths;
Expand Down Expand Up @@ -265,6 +267,19 @@ public bool Valid
#endregion
}

public class BooleanConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return !(bool)value;
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return !(bool)value;
}
}

static class ExtensionMethods
{
public static List<string> GetStrings(this string input, string delimeter, string searchPattern)
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
</Window.DataContext>
<Window.Resources>
<ResourceDictionary>
<local:BooleanConverter x:Key="BooleanConverter"/>
<Style x:Key="GoProButtonStyle" TargetType="Button">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Foreground" Value="#FFB2B2B2"/>
Expand All @@ -36,10 +37,10 @@
</ResourceDictionary>
</Window.Resources>
<Grid>
<Button Content="BROWSE" Command="{Binding BrowseCommand}" Style="{StaticResource GoProButtonStyle}" HorizontalAlignment="Left" VerticalAlignment="Top" Width="125" Margin="10,10,0,0" Height="33" FontFamily="Microsoft YaHei Light"/>
<Button Content="{Binding StartText}" Command="{Binding RecoverCommand}" Style="{StaticResource GoProButtonStyle}" Width="125" Height="33" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="150,10,0,0" FontFamily="Microsoft YaHei Light"/>
<Button Content="BROWSE" Command="{Binding BrowseCommand}" Style="{StaticResource GoProButtonStyle}" IsDefault="{Binding Valid, Converter={StaticResource BooleanConverter}}" HorizontalAlignment="Left" VerticalAlignment="Top" Width="125" Margin="10,10,0,0" Height="33" FontFamily="Microsoft YaHei Light"/>
<Button Content="{Binding StartText}" Command="{Binding RecoverCommand}" Style="{StaticResource GoProButtonStyle}" IsDefault="{Binding Valid}" Width="125" Height="33" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="150,10,0,0" FontFamily="Microsoft YaHei Light"/>
<TextBlock Text="{Binding Status}" Height="17" Margin="0,15.5,9,0" HorizontalAlignment="Center" Foreground="#FFAFAFAF" VerticalAlignment="Center"/>
<ProgressBar Value="{Binding Progress}" Panel.ZIndex="0" Width="265" Height="15" Margin="10,78,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Background="Transparent" Foreground="{Binding ProgressColor}"/>
<Border BorderBrush="#FF222222" Panel.ZIndex="1" BorderThickness="2" Width="265" Height="15" Margin="10,78,0,0" HorizontalAlignment="Left" VerticalAlignment="Top"/>
<Border BorderBrush="#FF222222" Panel.ZIndex="1" BorderThickness="1" Width="265" Height="15" Margin="10,78,0,0" HorizontalAlignment="Left" VerticalAlignment="Top"/>
</Grid>
</Window>
15 changes: 15 additions & 0 deletions GoPro Video Recovery/Views/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System.Windows;

namespace GoPro_Video_Recovery
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
}
}

0 comments on commit a389821

Please sign in to comment.