Skip to content

Commit

Permalink
Simplify dialog settings
Browse files Browse the repository at this point in the history
  • Loading branch information
0x90d committed Jan 1, 2020
1 parent f4ce923 commit 1c55afc
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions YetAnotherLosslessCutter/MainWindowVM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ sealed class MainWindowVM : ViewModelBase
ProgressDialogController progressDialogController;
public string Title => $"YALC - {YALCConstants.ASSEMBLY_INFORMATIONAL_VERSION}";
MediaInfo SourceInfo;
readonly MetroDialogSettings dialogSettings = new MetroDialogSettings
{
AnimateShow = false,
AnimateHide = false,
};
public MainWindowVM(MainWindow mainWindow)
{
host = mainWindow;
Expand Down Expand Up @@ -219,13 +224,8 @@ void CloseProject()
ffmpeg.settings.CutFrom = LeftPosition;
ffmpeg.settings.CutTo = RightPosition < LeftPosition ? SourceInfo.Duration : RightPosition;
ffmpeg.settings.OutputFile = Path.ChangeExtension(SourceFile, $"-{LeftPosition:hh\\.mm\\.ss\\.fff}-{RightPosition:hh\\.mm\\.ss\\.fff}{Path.GetExtension(SourceFile)}");
var mySettings = new MetroDialogSettings()
{
AnimateShow = false,
AnimateHide = false,
};
host.TaskbarInfo.ProgressState = System.Windows.Shell.TaskbarItemProgressState.Normal;
progressDialogController = await host.ShowProgressAsync("Please wait...", "0%", settings: mySettings);
progressDialogController = await host.ShowProgressAsync("Please wait...", "0%", settings: dialogSettings);
try
{
await ffmpeg.Cut();
Expand All @@ -235,19 +235,14 @@ void CloseProject()
{
await progressDialogController.CloseAsync();
host.TaskbarInfo.ProgressState = System.Windows.Shell.TaskbarItemProgressState.Error;
await host.ShowMessageAsync("Error", ex.ToString(), settings: mySettings);
await host.ShowMessageAsync("Error", ex.ToString(), settings: dialogSettings);
}
host.TaskbarInfo.ProgressState = System.Windows.Shell.TaskbarItemProgressState.None;
});
public RelayCommand DeleteSource => new RelayCommand(async () =>
{
var mySettings = new MetroDialogSettings()
{
AnimateShow = false,
AnimateHide = false,
};
host.TaskbarInfo.ProgressState = System.Windows.Shell.TaskbarItemProgressState.Normal;
var result = await host.ShowMessageAsync("Confirmation", $"Delete {SourceFile}?", MessageDialogStyle.AffirmativeAndNegative, settings: mySettings);
var result = await host.ShowMessageAsync("Confirmation", $"Delete {SourceFile}?", MessageDialogStyle.AffirmativeAndNegative, settings: dialogSettings);
if (result != MessageDialogResult.Affirmative) return;
host.MediaElement1.Stop();
host.MediaElement1.Close();
Expand All @@ -267,7 +262,7 @@ void CloseProject()
catch (Exception ex)
{
host.MediaElement1.Source = new Uri(SourceFile);
await host.ShowMessageAsync("Failed to delete file", ex.ToString(), MessageDialogStyle.Affirmative, settings: mySettings);
await host.ShowMessageAsync("Failed to delete file", ex.ToString(), MessageDialogStyle.Affirmative, settings: dialogSettings);
}
});
static T Do<T>(Func<T> action, TimeSpan retryInterval, int maxAttemptCount = 3)
Expand Down

0 comments on commit 1c55afc

Please sign in to comment.