Skip to content

Commit

Permalink
Merge pull request #3 from daredloco/subfolders-update
Browse files Browse the repository at this point in the history
Update to stable version 1.7
  • Loading branch information
daredloco authored Dec 3, 2020
2 parents f7750e9 + f8a9218 commit bf2c011
Show file tree
Hide file tree
Showing 10 changed files with 129 additions and 40 deletions.
7 changes: 7 additions & 0 deletions GitInstaller/GitInstaller/GitInstaller.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="ManualWindow.xaml.cs">
<DependentUpon>ManualWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Uninstaller.cs" />
<Compile Include="ZipSettings.cs" />
<Page Include="MainWindow.xaml">
Expand All @@ -89,6 +92,10 @@
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Page Include="ManualWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs">
Expand Down
24 changes: 1 addition & 23 deletions GitInstaller/GitInstaller/Installer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,21 +95,14 @@ async void GetVersions()
Releases.Add(robj);
}
}

//Old
//if(!Array.Exists(Settings.Ignored_Tags, x => x == robj.Tag))
//{
// idcount++;
// Releases.Add(robj);
//}
}

_window.cb_versions.SelectedIndex = 0;
}
_window.prog_loading.IsIndeterminate = false;
if(Releases.Count < 1)
{
MessageBox.Show("No releases found for this repository! Can't progress with the installation...");
MessageBox.Show("No releases found for this repository! Can't progress with the installation...", "Warning!", MessageBoxButton.OK, MessageBoxImage.Warning);
Environment.Exit(2);
return;
}
Expand Down Expand Up @@ -178,21 +171,6 @@ async void DownloadAssets()
assetcount++;
}
}

//Old
//if (!Array.Exists(Settings.Ignored_Files, x => x == asset.Filename))
//{
// string installfname = Path.Combine(_installdir, asset.Filename);
// await client.DownloadFileTaskAsync(new Uri(asset.DownloadUrl), installfname);
// downloadedfiles.Add(installfname);
// assetcount++;
// _window.WriteLog($"Asset downloaded... ({assetcount}/{maxcount})");
//}
//else
//{
// _window.WriteLog($"Asset \"{asset.Filename}\" will be ignored...");
// assetcount++;
//}
}
catch (Exception ex)
{
Expand Down
11 changes: 8 additions & 3 deletions GitInstaller/GitInstaller/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@ public MainWindow()
}
else
{
MessageBox.Show("The Installer can't progress because the settings file couldn't loaded!");
ManualWindow mwin = new ManualWindow();
if(mwin.ShowDialog() == true)
{
return;
}
MessageBox.Show("The Installer can't progress because the settings file couldn't loaded!", "Warning!", MessageBoxButton.OK, MessageBoxImage.Warning);
Environment.Exit(1);
}
}
Expand All @@ -66,7 +71,7 @@ private void UninstallClicked(object sender, RoutedEventArgs e)
if (result == System.Windows.Forms.DialogResult.OK)
{
if (!Uninstaller.DoUninstall(fbd.SelectedPath))
System.Windows.Forms.MessageBox.Show("Couldn't uninstall the software, read the log for more informations!");
MessageBox.Show("Couldn't uninstall the software, read the log for more informations!", "Warning!", MessageBoxButton.OK, MessageBoxImage.Warning);
else
WriteLog("Software was uninstalled successfuly!");
}
Expand Down Expand Up @@ -109,7 +114,7 @@ private void VersionChanged(object sender, SelectionChangedEventArgs e)
{
if (ex.HResult != -2146233086)
{
MessageBox.Show("There was an unexpected error while changing the version!");
MessageBox.Show("There was an unexpected error while changing the version!", "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
throw ex;
}
}
Expand Down
27 changes: 27 additions & 0 deletions GitInstaller/GitInstaller/ManualWindow.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<Window x:Class="GitInstaller.ManualWindow"
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="ManualWindow" Height="125" Width="400" ResizeMode="NoResize" WindowStartupLocation="CenterOwner">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="4*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="3*" />
<RowDefinition Height="*" />
<RowDefinition Height="3*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Label Content="Repository URL:" Grid.Column="1" Grid.Row="1"/>
<TextBox Margin="5,5,5,5" Name="tb_url" Grid.Column="2" Grid.Row="1"/>
<Button Name="bt_confirm" Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="3" Content="Load"/>
</Grid>
</Window>
57 changes: 57 additions & 0 deletions GitInstaller/GitInstaller/ManualWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
using Newtonsoft.Json;
using System;
using System.Diagnostics;
using System.IO;
using System.Windows;

namespace GitInstaller
{
/// <summary>
/// Interaktionslogik für ManualWindow.xaml
/// </summary>
public partial class ManualWindow : Window
{
public ManualWindow()
{
InitializeComponent();
bt_confirm.Click += ClickConfirm;
}

private void ClickConfirm(object sender, RoutedEventArgs e)
{
try
{

Uri url = new Uri(tb_url.Text);
if (url.Host != "github.com" && url.Host != "www.github.com")
{
MessageBox.Show("Invalid URL. Needs to be a github.com url!", "Warning!", MessageBoxButton.OK, MessageBoxImage.Warning);
return;
}

string ustr = url.AbsoluteUri;
ustr = ustr.Replace("://", "");

Settings.SettingsFile sfile = new Settings.SettingsFile() {
ignored_files = new string[]{ "" },
ignored_tags = new string[] { "" },
project = ustr.Split('/')[2],
uninstall = false,
unzip = true,
preview = true,
user = ustr.Split('/')[1],
repo = ustr.Split('/')[2]
};
string jsondata = JsonConvert.SerializeObject(sfile);
File.WriteAllText("config.json", jsondata);
Process.Start("GitInstaller.exe");
Environment.Exit(4);
}
catch(Exception ex)
{
MessageBox.Show("Error creating configuration file... => " + ex.Message, "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
return;
}
}
}
}
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.6.0.0")]
[assembly: AssemblyFileVersion("1.6.0.0")]
[assembly: AssemblyVersion("1.7.1.0")]
[assembly: AssemblyFileVersion("1.7.1.0")]
2 changes: 0 additions & 2 deletions GitInstaller/GitInstaller/Uninstaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GitInstaller
{
Expand Down
16 changes: 16 additions & 0 deletions GitInstaller/GitInstaller/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,27 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace GitInstaller
{
public static class Utils
{
public enum ZipType
{
File,
Directory,
None
}

public static ZipType FileOrDir(string path)
{
if (path.EndsWith("/"))
return ZipType.Directory;
else
return ZipType.File;
}

public static bool HasWildcard(string value, string wildcard, string wildcardchar = "*")
{

Expand Down
7 changes: 1 addition & 6 deletions GitInstaller/GitInstaller/ZipArchiveExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GitInstaller
{
Expand Down
14 changes: 10 additions & 4 deletions GitInstaller/GitInstaller/ZipSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;

Expand All @@ -17,7 +15,10 @@ public ZipSettings() { }

public string GetSubfolder(string fname, string sub = "")
{
SubFolder sf = Subfolders.Find(x => x.Files.Find(y => y == fname) != null);
SubFolder sf = null;
string ffolder = fname.Replace(fname.Split('/')[fname.Split('/').Length - 1], "").Replace(fname.Split('\\')[fname.Split('\\').Length - 1],"");
sf = Subfolders.Find(x => x.Directories.Find(y => y == ffolder) != null);
sf = Subfolders.Find(x => x.Files.Find(y => y == fname) != null);
if (sf == null)
return "";

Expand Down Expand Up @@ -52,7 +53,11 @@ public static ZipSettings FromStream(Stream stream)
sub.Name = dict.Key;
foreach (JToken token in dict.Value.Children<JToken>().ToList())
{
sub.Files.Add(token.Value<string>());
Utils.ZipType ztype = Utils.FileOrDir(token.Value<string>());
if (ztype == Utils.ZipType.File)
sub.Files.Add(token.Value<string>());
else if (ztype == Utils.ZipType.Directory)
sub.Directories.Add(token.Value<string>());
}
}
zs.Subfolders.Add(sub);
Expand All @@ -71,6 +76,7 @@ public class SubFolder
{
public string Name;
public List<string> Files = new List<string>();
public List<string> Directories = new List<string>();
}
}
}

0 comments on commit bf2c011

Please sign in to comment.