forked from SGCSam/XUIHelper
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GUI - finished implementation of mass conversion with MassConvertProg…
…ressPage. Core - reworked IXUIHelperProgressable to be more lightweight, with work count being implemented into mass conversion directly.
- Loading branch information
Showing
7 changed files
with
201 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
XUIHelper.GUI/ViewModels/HUD/MassConvertProgressPageViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
using NXEControls; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using XUIHelper.Core; | ||
|
||
namespace XUIHelper.GUI | ||
{ | ||
public class MassConvertProgressPageViewModel : NXEViewModelBase, IXUIHelperProgressable | ||
{ | ||
private float _Progress; | ||
private bool _IsIndeterminate; | ||
private string _Description = string.Empty; | ||
|
||
public float Progress | ||
{ | ||
get | ||
{ | ||
return _Progress; | ||
} | ||
set | ||
{ | ||
_Progress = value; | ||
NotifyPropertyChanged(); | ||
} | ||
} | ||
|
||
public bool IsIndeterminate | ||
{ | ||
get | ||
{ | ||
return _IsIndeterminate; | ||
} | ||
set | ||
{ | ||
_IsIndeterminate = value; | ||
NotifyPropertyChanged(); | ||
} | ||
} | ||
|
||
public string Description | ||
{ | ||
get | ||
{ | ||
return _Description; | ||
} | ||
set | ||
{ | ||
_Description = value; | ||
NotifyPropertyChanged(); | ||
} | ||
} | ||
|
||
private string _SourceDirectory; | ||
private XUIHelperAPI.XUIHelperSupportedFormats _Format; | ||
private string _DestinationDirectory; | ||
|
||
public async Task ConvertAsync() | ||
{ | ||
XUIHelperAPI.MassConversionResult result = await XUIHelperAPI.TryMassConvertDirectoryAsync(_SourceDirectory, _Format, _DestinationDirectory, this); | ||
if (!result.Successful) | ||
{ | ||
_ = Constants.HUDManager?.ShowMessageBox("The conversion has failed. Consider enabling logging and consult the log file for more information.", "Conversion Failed", System.Windows.MessageBoxButton.OK, NXEHUD.NXEHUDIconType.Error, true); | ||
} | ||
else | ||
{ | ||
_ = Constants.HUDManager?.ShowMessageBox(string.Format("The conversion has completed!\n\nSuccessful Conversions: {0}\nFailed Conversions: {1}\nSuccess Rate: {2}%", | ||
result.SuccessfulWorkCount, | ||
result.FailedWorkCount, | ||
Convert.ToInt32((result.SuccessfulWorkCount / (float)(result.SuccessfulWorkCount + result.FailedWorkCount)) * 100.0f) | ||
), | ||
"Conversion Completed", System.Windows.MessageBoxButton.OK, NXEHUD.NXEHUDIconType.Exclamation, true); | ||
} | ||
} | ||
|
||
public MassConvertProgressPageViewModel(string sourceDir, XUIHelperAPI.XUIHelperSupportedFormats format, string destDir) | ||
{ | ||
_SourceDirectory = sourceDir; | ||
_Format = format; | ||
_DestinationDirectory = destDir; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<nxe:NXEHUDUserControl x:Class="XUIHelper.GUI.MassConvertProgressPage" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
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:local="clr-namespace:XUIHelper.GUI" | ||
xmlns:nxe="clr-namespace:NXEControls;assembly=NXEControls" | ||
mc:Ignorable="d" | ||
d:DesignHeight="315" d:DesignWidth="550" PageSize="Half" Title="Conversion in Progress" IconType="Exclamation"> | ||
<Viewbox> | ||
<Grid Width="550" Height="315" Margin="15"> | ||
<TextBlock Style="{StaticResource NXEHUDMessageBoxPage.TextBlock.MessageText}" Text="Please wait while files are converted. This may take some time." /> | ||
<nxe:NXELoading Variant="HUDInline" Width="38" Height="38" HorizontalAlignment="Center" VerticalAlignment="Center" /> | ||
<TextBlock Style="{StaticResource NXEHUDMessageBoxPage.TextBlock.MessageText}" HorizontalAlignment="Stretch" VerticalAlignment="Center" Height="100" Margin="0, 150, 0, 0" | ||
Text="{Binding Description, Mode=OneWay, UpdateSourceTrigger=PropertyChanged, FallbackValue=Description Text}" /> | ||
<nxe:NXEHUDProgressBar HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="20, 0" | ||
IsIndeterminate="{Binding IsIndeterminate, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}" | ||
Value="{Binding Progress, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}" /> | ||
</Grid> | ||
</Viewbox> | ||
|
||
</nxe:NXEHUDUserControl> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using NXEControls; | ||
using XUIHelper.Core; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
using System.Windows.Data; | ||
using System.Windows.Documents; | ||
using System.Windows.Input; | ||
using System.Windows.Media; | ||
using System.Windows.Media.Imaging; | ||
using System.Windows.Navigation; | ||
using System.Windows.Shapes; | ||
|
||
namespace XUIHelper.GUI | ||
{ | ||
/// <summary> | ||
/// Interaction logic for MassConvertProgressPage.xaml | ||
/// </summary> | ||
public partial class MassConvertProgressPage : NXEHUDUserControl | ||
{ | ||
private MassConvertProgressPageViewModel _ViewModel; | ||
|
||
public MassConvertProgressPage(string sourceDir, XUIHelperAPI.XUIHelperSupportedFormats format, string destDir) | ||
{ | ||
_ViewModel = new MassConvertProgressPageViewModel(sourceDir, format, destDir); | ||
DataContext = _ViewModel; | ||
InitializeComponent(); | ||
Loaded += OnLoaded; | ||
} | ||
|
||
private void OnLoaded(object sender, RoutedEventArgs e) | ||
{ | ||
_ = _ViewModel.ConvertAsync(); | ||
} | ||
} | ||
} |