Skip to content

Commit

Permalink
Merge pull request #11 from daredloco/update-net5
Browse files Browse the repository at this point in the history
Update to NET5
  • Loading branch information
daredloco authored Dec 31, 2020
2 parents aeb994a + 27ee472 commit 77df223
Show file tree
Hide file tree
Showing 28 changed files with 1,725 additions and 10 deletions.
6 changes: 6 additions & 0 deletions GitInstaller/GitInstaller.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ VisualStudioVersion = 16.0.30320.27
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitInstaller", "GitInstaller\GitInstaller.csproj", "{6B88A56A-98E2-450D-A059-65BD18919AE1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitInstallerNET5", "..\GitInstallerNET5\GitInstallerNET5\GitInstallerNET5.csproj", "{40E2DF0D-A017-4EBD-844A-92708E425293}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -15,6 +17,10 @@ Global
{6B88A56A-98E2-450D-A059-65BD18919AE1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6B88A56A-98E2-450D-A059-65BD18919AE1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6B88A56A-98E2-450D-A059-65BD18919AE1}.Release|Any CPU.Build.0 = Release|Any CPU
{40E2DF0D-A017-4EBD-844A-92708E425293}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{40E2DF0D-A017-4EBD-844A-92708E425293}.Debug|Any CPU.Build.0 = Debug|Any CPU
{40E2DF0D-A017-4EBD-844A-92708E425293}.Release|Any CPU.ActiveCfg = Release|Any CPU
{40E2DF0D-A017-4EBD-844A-92708E425293}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
7 changes: 7 additions & 0 deletions GitInstaller/GitInstaller/GitInstaller.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,18 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="LicenseWindow.xaml.cs">
<DependentUpon>LicenseWindow.xaml</DependentUpon>
</Compile>
<Compile Include="ManualWindow.xaml.cs">
<DependentUpon>ManualWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Uninstaller.cs" />
<Compile Include="ZipSettings.cs" />
<Page Include="LicenseWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
Expand Down
29 changes: 24 additions & 5 deletions GitInstaller/GitInstaller/Installer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,30 @@ async void GetVersions()
/// <param name="installdir">The installation directory</param>
internal void StartInstallation(int releaseindex, string installdir)
{
_window.bt_install.IsEnabled = false;
_installrelease = Releases[releaseindex];
_window.WriteLog("Starting installation of release \"" + _installrelease.Tag + "\" to \"" + installdir + "\"...");
_installdir = installdir;
DownloadAssets();
if(Settings.ShowLicense)
{
LicenseWindow licenseWindow = new LicenseWindow();
if (licenseWindow.ShowDialog() == true)
{
_window.bt_install.IsEnabled = false;
_installrelease = Releases[releaseindex];
_window.WriteLog("Starting installation of release \"" + _installrelease.Tag + "\" to \"" + installdir + "\"...");
_installdir = installdir;
DownloadAssets();
}
else
{
_window.WriteLog("You need to accept the license to proceed with the installation.");
}
}
else
{
_window.bt_install.IsEnabled = false;
_installrelease = Releases[releaseindex];
_window.WriteLog("Starting installation of release \"" + _installrelease.Tag + "\" to \"" + installdir + "\"...");
_installdir = installdir;
DownloadAssets();
}
}

/// <summary>
Expand Down
39 changes: 39 additions & 0 deletions GitInstaller/GitInstaller/LicenseWindow.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<Window x:Class="GitInstaller.LicenseWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:GitInstaller"
mc:Ignorable="d"
Title="LicenseWindow" Height="450" Width="800">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="0.05*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="0.05*"/>
<RowDefinition Height="0.15*"/>
<RowDefinition Height="0.05*"/>
</Grid.RowDefinitions>

<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.1*"/>
<ColumnDefinition Width="0.3*"/>
<ColumnDefinition Width="0.05*"/>
<ColumnDefinition Width="0.3*"/>
<ColumnDefinition Width="0.1*"/>
</Grid.ColumnDefinitions>
<RichTextBox Name="rtb_license" Grid.Row="1" Grid.ColumnSpan="5" Margin="5,0,5,0" VerticalScrollBarVisibility="Visible">
<RichTextBox.Resources>
<Style TargetType="{x:Type Paragraph}">
<Setter Property="Margin" Value="0" />
</Style>
</RichTextBox.Resources>
<FlowDocument>
<Paragraph>Loading License</Paragraph>
<Paragraph>Please wait...</Paragraph>
</FlowDocument>
</RichTextBox>
<Button Name="bt_accept" Content="Accept" Grid.Row="3" Grid.Column="3"/>
<Button Name="bt_decline" Content="Decline" Grid.Row="3" Grid.Column="1"/>
</Grid>
</Window>
70 changes: 70 additions & 0 deletions GitInstaller/GitInstaller/LicenseWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
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.Shapes;

namespace GitInstaller
{
/// <summary>
/// Interaktionslogik für LicenseWindow.xaml
/// </summary>
public partial class LicenseWindow : Window
{
public LicenseWindow()
{
InitializeComponent();
LoadLicense();
bt_accept.Click += AcceptClick;
bt_decline.Click += DeclineClick;

bt_accept.IsEnabled = false;
}

private void DeclineClick(object sender, RoutedEventArgs e)
{
DialogResult = false;
Close();
}

private void AcceptClick(object sender, RoutedEventArgs e)
{
DialogResult = true;
Close();
}

async void LoadLicense()
{
using (var client = new WebClient())
{
client.Headers.Add("user-agent", "GitInstaller");
string licenseJson = await client.DownloadStringTaskAsync(Settings.LicenseUrl.AbsoluteUri);
JObject job = JsonConvert.DeserializeObject<JObject>(licenseJson);
//License
JToken license = job.Value<JToken>("license");
client.Headers["user-agent"] = "gitinstaller";
client.Headers.Add("accept", "application/vnd.github.v3+json");
string licJson = await client.DownloadStringTaskAsync(new Uri(license.Value<string>("url")).AbsoluteUri);
JObject licobj = JsonConvert.DeserializeObject<JObject>(licJson);
string licenseBody = licobj.Value<string>("body");
rtb_license.Document.Blocks.Clear();
Paragraph para = new Paragraph();
para.Inlines.Add(licenseBody);
rtb_license.Document.Blocks.Add(para);
}

bt_accept.IsEnabled = true;
}
}
}
2 changes: 1 addition & 1 deletion GitInstaller/GitInstaller/ManualWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:GitInstaller"
mc:Ignorable="d"
Title="ManualWindow" Height="125" Width="400" ResizeMode="NoResize" WindowStartupLocation="CenterOwner">
Title="Select Repository:" Height="125" Width="400" ResizeMode="NoResize" WindowStartupLocation="CenterScreen">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
Expand Down
1 change: 1 addition & 0 deletions GitInstaller/GitInstaller/ManualWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public partial class ManualWindow : Window
public ManualWindow()
{
InitializeComponent();
Title = "Select a Repository:";
bt_confirm.Click += ClickConfirm;
}

Expand Down
4 changes: 2 additions & 2 deletions GitInstaller/GitInstaller/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
// indem Sie "*" wie unten gezeigt eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.8.4.0")]
[assembly: AssemblyFileVersion("1.8.4.0")]
[assembly: AssemblyVersion("1.9.1.0")]
[assembly: AssemblyFileVersion("1.9.1.0")]
7 changes: 7 additions & 0 deletions GitInstaller/GitInstaller/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ internal enum SettingsState
internal static bool Unzip { get { return file.unzip; } }
internal static bool Preview { get { return file.preview; } }
internal static bool Uninstall { get { return file.uninstall; } }
internal static bool ShowLicense { get { return file.showlicense; } }
internal static string[] Ignored_Tags { get { return file.ignored_tags; } }
internal static string[] Ignored_Files { get { return file.ignored_files; } }

Expand All @@ -42,6 +43,11 @@ internal static Uri ApiUrl
get { if (State == SettingsState.Loaded) { return new Uri($"https://api.github.com/repos/{file.user}/{file.repo}/releases"); } else { return null; } }
}

internal static Uri LicenseUrl
{
get { if (State == SettingsState.Loaded) { return new Uri($"https://api.github.com/repos/{file.user}/{file.repo}/license"); } else { return null; } }
}

/// <summary>
/// Loads the settings from the config.json inside the applications directory
/// </summary>
Expand Down Expand Up @@ -92,6 +98,7 @@ public class SettingsFile
public bool unzip;
public bool preview;
public bool uninstall;
public bool showlicense;
[JsonProperty("ignored-tags")]
public string[] ignored_tags;
[JsonProperty("ignored-files")]
Expand Down
5 changes: 3 additions & 2 deletions GitInstaller/GitInstaller/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"unzip": true,
"preview": true,
"uninstall": true,
"ignored-tags": ["v1.0"],
"ignored-files": ["somefiletoignore.zip"]
"showlicense": true,
"ignored-tags": [ "v1.0" ],
"ignored-files": [ "somefiletoignore.zip" ]
}
9 changes: 9 additions & 0 deletions GitInstallerNET5/GitInstallerNET5/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Application x:Class="GitInstallerNET5.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:GitInstallerNET5"
StartupUri="MainWindow.xaml">
<Application.Resources>

</Application.Resources>
</Application>
17 changes: 17 additions & 0 deletions GitInstallerNET5/GitInstallerNET5/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;

namespace GitInstallerNET5
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}
10 changes: 10 additions & 0 deletions GitInstallerNET5/GitInstallerNET5/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System.Windows;

[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]
50 changes: 50 additions & 0 deletions GitInstallerNET5/GitInstallerNET5/GitInstallerNET5.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net5.0-windows</TargetFramework>
<UseWPF>true</UseWPF>
<UseWindowsForms>true</UseWindowsForms>
<AssemblyName>GitInstaller</AssemblyName>
<RootNamespace>GitInstallerNET5</RootNamespace>
<Authors>Roman Wanner</Authors>
<Company>Roman Wanner</Company>
<Description>Simple Installer for Github</Description>
<Copyright>© Roman Wanner 2020</Copyright>
<PackageProjectUrl>https://github.com/daredloco/GitInstaller/</PackageProjectUrl>
<AssemblyVersion>1.9.0.0</AssemblyVersion>
<FileVersion>1.9.0.0</FileVersion>
<ApplicationIcon>icon.ico</ApplicationIcon>
</PropertyGroup>

<ItemGroup>
<None Remove="icon.ico" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="icon.ico" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
</ItemGroup>

<ItemGroup>
<Compile Update="LicenseWindow.xaml.cs">
<DependentUpon>LicenseWindow.xaml</DependentUpon>
</Compile>
</ItemGroup>

<ItemGroup>
<None Update="config.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>

<ItemGroup>
<Page Update="LicenseWindow.xaml">
<SubType>Designer</SubType>
</Page>
</ItemGroup>

</Project>
Loading

0 comments on commit 77df223

Please sign in to comment.