Skip to content

Commit

Permalink
Add the ability to add Secure WIMs to the store
Browse files Browse the repository at this point in the history
  • Loading branch information
gus33000 committed Oct 12, 2024
1 parent 14bf607 commit d700ae5
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 18 deletions.
43 changes: 27 additions & 16 deletions WPinternals/ViewModels/DownloadsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ namespace WPinternals
internal class DownloadsViewModel : ContextViewModel
{
private readonly PhoneNotifierViewModel Notifier;
private readonly Timer SpeedTimer;
private bool IsSearching = false;

internal DownloadsViewModel(PhoneNotifierViewModel Notifier)
Expand All @@ -56,8 +55,6 @@ internal DownloadsViewModel(PhoneNotifierViewModel Notifier)
DownloadFolder = (string)Key.GetValue("DownloadFolder", @"C:\ProgramData\WPinternals\Repository");
Key.Close();

SpeedTimer = new Timer(TimerCallback, this, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(1));

AddFFUCommand = new DelegateCommand(() =>
{
string FFUPath = null;
Expand All @@ -77,20 +74,20 @@ internal DownloadsViewModel(PhoneNotifierViewModel Notifier)
{
App.Config.AddFfuToRepository(FFUPath);
App.Config.WriteConfig();
LastStatusText = $"File \"{FFUFile}\" was added to the repository.";
LastFFUStatusText = $"File \"{FFUFile}\" was added to the repository.";
}
catch (WPinternalsException Ex)
{
LastStatusText = $"Error: {Ex.Message}. File \"{FFUFile}\" was not added.";
LastFFUStatusText = $"Error: {Ex.Message}. File \"{FFUFile}\" was not added.";
}
catch
{
LastStatusText = $"Error: File \"{FFUFile}\" was not added.";
LastFFUStatusText = $"Error: File \"{FFUFile}\" was not added.";
}
}
else
{
LastStatusText = null;
LastFFUStatusText = null;
}
});

Expand All @@ -113,35 +110,49 @@ internal DownloadsViewModel(PhoneNotifierViewModel Notifier)
{
App.Config.AddSecWimToRepository(SecWIMPath, FirmwareVersion);
App.Config.WriteConfig();
LastStatusText = $"File \"{SecWIMFile}\" was added to the repository.";
LastSecWIMStatusText = $"File \"{SecWIMFile}\" was added to the repository.";
}
catch (WPinternalsException Ex)
{
LastStatusText = $"Error: {Ex.Message}. File \"{SecWIMFile}\" was not added.";
LastSecWIMStatusText = $"Error: {Ex.Message}. File \"{SecWIMFile}\" was not added.";
}
catch
{
LastStatusText = $"Error: File \"{SecWIMFile}\" was not added.";
LastSecWIMStatusText = $"Error: File \"{SecWIMFile}\" was not added.";
}
}
else
{
LastStatusText = null;
LastSecWIMStatusText = null;
}
});
}

private string _LastStatusText = null;
public string LastStatusText
private string _LastFFUStatusText = null;
public string LastFFUStatusText
{
get
{
return _LastFFUStatusText;
}
set
{
_LastFFUStatusText = value;
OnPropertyChanged(nameof(LastFFUStatusText));
}
}

private string _LastSecWIMStatusText = null;
public string LastSecWIMStatusText
{
get
{
return _LastStatusText;
return _LastSecWIMStatusText;
}
set
{
_LastStatusText = value;
OnPropertyChanged(nameof(LastStatusText));
_LastSecWIMStatusText = value;
OnPropertyChanged(nameof(LastSecWIMStatusText));
}
}

Expand Down
21 changes: 19 additions & 2 deletions WPinternals/Views/LumiaDownloadView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ DEALINGS IN THE SOFTWARE.
</helpers:Paragraph>
</FlowDocument>
</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.Resources>
<!-- This style is used to set the margins for all paragraphs in the FlowDocument to 0. -->
Expand All @@ -233,11 +233,28 @@ DEALINGS IN THE SOFTWARE.
</Style>
</FlowDocument.Resources>
<helpers:Paragraph>
<Run Text="{Binding Path=LastStatusText}" />
<Run Text="{Binding Path=LastFFUStatusText}" />
</helpers:Paragraph>
</FlowDocument>
</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}"/>
<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>
</Border>
</StackPanel>
Expand Down

0 comments on commit d700ae5

Please sign in to comment.