mirror of
https://github.com/Tichau/FileConverter.git
synced 2026-11-21 10:01:58 +01:00
Add conversion jobs to progress indicators converters
This commit is contained in:
1 parent
ed23984f4c
commit
ca6e2c8919
3 files changed
+90
No files matched your search
@@ -165,8 +165,10 @@
|
||||
<Compile Include="Settings.Settings.cs" />
|
||||
<Compile Include="Upgrade\Helpers.cs" />
|
||||
<Compile Include="Upgrade\UpgradeVersionDescription.cs" />
|
||||
<Compile Include="ValueConverters\ConversionJobsToProgressState.cs" />
|
||||
<Compile Include="ValueConverters\ApplicationVersionToApplicationName.cs" />
|
||||
<Compile Include="ConversionPreset\ConversionPreset.cs" />
|
||||
<Compile Include="ValueConverters\ConversionJobsToProgressValue.cs" />
|
||||
<Compile Include="ValueConverters\OutputTypeEnumToViewModel.cs" />
|
||||
<Compile Include="ValueConverters\BitrateToString.cs" />
|
||||
<Compile Include="ValueConverters\FileNameConverter.cs" />
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
// <copyright file="ConversionJobsToProgressState.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
|
||||
|
||||
namespace FileConverter.ValueConverters
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Shell;
|
||||
|
||||
using FileConverter.ConversionJobs;
|
||||
|
||||
public class ConversionJobsToProgressState : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (!(value is IEnumerable<ConversionJob>))
|
||||
{
|
||||
return TaskbarItemProgressState.None;
|
||||
}
|
||||
|
||||
IEnumerable<ConversionJob> jobs = (IEnumerable<ConversionJob>)value;
|
||||
|
||||
TaskbarItemProgressState progressState = TaskbarItemProgressState.None;
|
||||
foreach (ConversionJob job in jobs)
|
||||
{
|
||||
if (job.State == ConversionJob.ConversionState.Failed)
|
||||
{
|
||||
progressState = TaskbarItemProgressState.Error;
|
||||
break;
|
||||
}
|
||||
|
||||
if (job.State == ConversionJob.ConversionState.InProgress)
|
||||
{
|
||||
progressState = TaskbarItemProgressState.Normal;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return progressState;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
// <copyright file="ConversionJobsToProgressValue.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
|
||||
|
||||
namespace FileConverter.ValueConverters
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Shell;
|
||||
|
||||
using FileConverter.ConversionJobs;
|
||||
|
||||
public class ConversionJobsToProgressValue : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (!(value is IEnumerable<ConversionJob>))
|
||||
{
|
||||
return TaskbarItemProgressState.None;
|
||||
}
|
||||
|
||||
IEnumerable<ConversionJob> jobs = (IEnumerable<ConversionJob>)value;
|
||||
|
||||
int jobCount = 0;
|
||||
float progressValue = 0f;
|
||||
foreach (ConversionJob job in jobs)
|
||||
{
|
||||
progressValue += job.Progress;
|
||||
jobCount++;
|
||||
}
|
||||
|
||||
return jobCount > 0 ? progressValue / jobCount : 0f;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user