Add the ability to add Secure WIMs to the store

This commit is contained in:
Gustave Monce
2024-10-12 17:19:47 +02:00
parent 14bf607111
commit d700ae5911
2 changed files with 46 additions and 18 deletions
+27 -16
View File
@@ -41,7 +41,6 @@ namespace WPinternals
internal class DownloadsViewModel : ContextViewModel internal class DownloadsViewModel : ContextViewModel
{ {
private readonly PhoneNotifierViewModel Notifier; private readonly PhoneNotifierViewModel Notifier;
private readonly Timer SpeedTimer;
private bool IsSearching = false; private bool IsSearching = false;
internal DownloadsViewModel(PhoneNotifierViewModel Notifier) internal DownloadsViewModel(PhoneNotifierViewModel Notifier)
@@ -56,8 +55,6 @@ namespace WPinternals
DownloadFolder = (string)Key.GetValue("DownloadFolder", @"C:\ProgramData\WPinternals\Repository"); DownloadFolder = (string)Key.GetValue("DownloadFolder", @"C:\ProgramData\WPinternals\Repository");
Key.Close(); Key.Close();
SpeedTimer = new Timer(TimerCallback, this, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(1));
AddFFUCommand = new DelegateCommand(() => AddFFUCommand = new DelegateCommand(() =>
{ {
string FFUPath = null; string FFUPath = null;
@@ -77,20 +74,20 @@ namespace WPinternals
{ {
App.Config.AddFfuToRepository(FFUPath); App.Config.AddFfuToRepository(FFUPath);
App.Config.WriteConfig(); App.Config.WriteConfig();
LastStatusText = $"File \"{FFUFile}\" was added to the repository."; LastFFUStatusText = $"File \"{FFUFile}\" was added to the repository.";
} }
catch (WPinternalsException Ex) catch (WPinternalsException Ex)
{ {
LastStatusText = $"Error: {Ex.Message}. File \"{FFUFile}\" was not added."; LastFFUStatusText = $"Error: {Ex.Message}. File \"{FFUFile}\" was not added.";
} }
catch catch
{ {
LastStatusText = $"Error: File \"{FFUFile}\" was not added."; LastFFUStatusText = $"Error: File \"{FFUFile}\" was not added.";
} }
} }
else else
{ {
LastStatusText = null; LastFFUStatusText = null;
} }
}); });
@@ -113,35 +110,49 @@ namespace WPinternals
{ {
App.Config.AddSecWimToRepository(SecWIMPath, FirmwareVersion); App.Config.AddSecWimToRepository(SecWIMPath, FirmwareVersion);
App.Config.WriteConfig(); App.Config.WriteConfig();
LastStatusText = $"File \"{SecWIMFile}\" was added to the repository."; LastSecWIMStatusText = $"File \"{SecWIMFile}\" was added to the repository.";
} }
catch (WPinternalsException Ex) catch (WPinternalsException Ex)
{ {
LastStatusText = $"Error: {Ex.Message}. File \"{SecWIMFile}\" was not added."; LastSecWIMStatusText = $"Error: {Ex.Message}. File \"{SecWIMFile}\" was not added.";
} }
catch catch
{ {
LastStatusText = $"Error: File \"{SecWIMFile}\" was not added."; LastSecWIMStatusText = $"Error: File \"{SecWIMFile}\" was not added.";
} }
} }
else else
{ {
LastStatusText = null; LastSecWIMStatusText = null;
} }
}); });
} }
private string _LastStatusText = null; private string _LastFFUStatusText = null;
public string LastStatusText public string LastFFUStatusText
{ {
get get
{ {
return _LastStatusText; return _LastFFUStatusText;
} }
set set
{ {
_LastStatusText = value; _LastFFUStatusText = value;
OnPropertyChanged(nameof(LastStatusText)); OnPropertyChanged(nameof(LastFFUStatusText));
}
}
private string _LastSecWIMStatusText = null;
public string LastSecWIMStatusText
{
get
{
return _LastSecWIMStatusText;
}
set
{
_LastSecWIMStatusText = value;
OnPropertyChanged(nameof(LastSecWIMStatusText));
} }
} }
+19 -2
View File
@@ -221,7 +221,7 @@ DEALINGS IN THE SOFTWARE.
</helpers:Paragraph> </helpers:Paragraph>
</FlowDocument> </FlowDocument>
</helpers:FlowDocumentScrollViewerNoMouseWheel> </helpers:FlowDocumentScrollViewerNoMouseWheel>
<helpers:FlowDocumentScrollViewerNoMouseWheel Grid.Column="1" Margin="20,-15,20,0" VerticalScrollBarVisibility="Auto" Visibility="{Binding Path=LastStatusText, Converter={StaticResource ObjectToVisibilityConverter}}"> <helpers:FlowDocumentScrollViewerNoMouseWheel Grid.Column="1" Margin="20,-15,20,0" VerticalScrollBarVisibility="Auto" Visibility="{Binding Path=LastFFUStatusText, Converter={StaticResource ObjectToVisibilityConverter}}">
<FlowDocument FontFamily="Segoe UI" FontSize="12" Loaded="Document_Loaded" TextAlignment="Left"> <FlowDocument FontFamily="Segoe UI" FontSize="12" Loaded="Document_Loaded" TextAlignment="Left">
<FlowDocument.Resources> <FlowDocument.Resources>
<!-- This style is used to set the margins for all paragraphs in the FlowDocument to 0. --> <!-- This style is used to set the margins for all paragraphs in the FlowDocument to 0. -->
@@ -233,11 +233,28 @@ DEALINGS IN THE SOFTWARE.
</Style> </Style>
</FlowDocument.Resources> </FlowDocument.Resources>
<helpers:Paragraph> <helpers:Paragraph>
<Run Text="{Binding Path=LastStatusText}" /> <Run Text="{Binding Path=LastFFUStatusText}" />
</helpers:Paragraph> </helpers:Paragraph>
</FlowDocument> </FlowDocument>
</helpers:FlowDocumentScrollViewerNoMouseWheel> </helpers:FlowDocumentScrollViewerNoMouseWheel>
<Button Height="30" Width="Auto" Content="Add existing FFU-file..." Padding="20,5,20,5" HorizontalAlignment="Right" Margin="0,0,36,20" Command="{Binding Path=AddFFUCommand}"/> <Button Height="30" Width="Auto" Content="Add existing FFU-file..." Padding="20,5,20,5" HorizontalAlignment="Right" Margin="0,0,36,20" Command="{Binding Path=AddFFUCommand}"/>
<helpers:FlowDocumentScrollViewerNoMouseWheel Grid.Column="1" Margin="20,-15,20,0" VerticalScrollBarVisibility="Auto" Visibility="{Binding Path=LastSecWIMStatusText, Converter={StaticResource ObjectToVisibilityConverter}}">
<FlowDocument FontFamily="Segoe UI" FontSize="12" Loaded="Document_Loaded" TextAlignment="Left">
<FlowDocument.Resources>
<!-- This style is used to set the margins for all paragraphs in the FlowDocument to 0. -->
<Style TargetType="{x:Type Paragraph}">
<Setter Property="Margin" Value="0"/>
</Style>
<Style TargetType="{x:Type Section}">
<Setter Property="Margin" Value="0"/>
</Style>
</FlowDocument.Resources>
<helpers:Paragraph>
<Run Text="{Binding Path=LastSecWIMStatusText}" />
</helpers:Paragraph>
</FlowDocument>
</helpers:FlowDocumentScrollViewerNoMouseWheel>
<Button Height="30" Width="Auto" Content="Add existing Secure WIM-file..." Padding="20,5,20,5" HorizontalAlignment="Right" Margin="0,0,36,20" Command="{Binding Path=AddSecWIMCommand}"/>
</StackPanel> </StackPanel>
</Border> </Border>
</StackPanel> </StackPanel>