Removed settings file
Save Icons to info.xml Fixed Bug
This commit is contained in:
parent
25153e6998
commit
4e654eebf6
|
@ -12,4 +12,5 @@
|
||||||
- __APPFILES
|
- __APPFILES
|
||||||
- info.xml
|
- info.xml
|
||||||
- Version
|
- Version
|
||||||
- Repo
|
- Repos
|
||||||
|
- Local Repo
|
2
ToDo.txt
2
ToDo.txt
|
@ -1,6 +1,6 @@
|
||||||
More Icons for Apps
|
More Icons for Apps
|
||||||
More apps: Laptop Sim (when done)
|
More apps: Laptop Sim (when done)
|
||||||
Use local info when building GUI (Except name/description)
|
|
||||||
Decent app Installer (Do not open CMD)
|
Decent app Installer (Do not open CMD)
|
||||||
Save Images on disk to allow offline usage
|
Save Images on disk to allow offline usage
|
||||||
Test Updates
|
Test Updates
|
||||||
|
Remove Settings.settings (move to main XML)
|
|
@ -11,6 +11,8 @@ using System.IO.Compression;
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Microsoft.VisualBasic;
|
using Microsoft.VisualBasic;
|
||||||
|
using System.Drawing.Drawing2D;
|
||||||
|
using System.Drawing.Imaging;
|
||||||
|
|
||||||
namespace UpTool2
|
namespace UpTool2
|
||||||
{
|
{
|
||||||
|
@ -194,9 +196,7 @@ namespace UpTool2
|
||||||
{
|
{
|
||||||
apps.Clear();
|
apps.Clear();
|
||||||
string xml = dir + @"\info.xml";
|
string xml = dir + @"\info.xml";
|
||||||
using (WebClient client = new WebClient())
|
XDocument.Load(xml).Element("meta").Element("LocalRepo").Elements().ToList().ForEach(app =>
|
||||||
{
|
|
||||||
XDocument.Load(xml).Element("meta").Element("Repo").Elements().ToList().ForEach(app =>
|
|
||||||
{
|
{
|
||||||
apps.Add(Guid.Parse(app.Element("ID").Value), new App(
|
apps.Add(Guid.Parse(app.Element("ID").Value), new App(
|
||||||
app.Element("Name").Value,
|
app.Element("Name").Value,
|
||||||
|
@ -207,12 +207,11 @@ namespace UpTool2
|
||||||
app.Element("Hash").Value,
|
app.Element("Hash").Value,
|
||||||
Guid.Parse(app.Element("ID").Value),
|
Guid.Parse(app.Element("ID").Value),
|
||||||
ColorTranslator.FromHtml(app.Element("Color").Value),
|
ColorTranslator.FromHtml(app.Element("Color").Value),
|
||||||
app.Element("Icon") == null ? Resources.C_64.ToBitmap() : Image.FromStream(client.OpenRead(app.Element("Icon").Value)),
|
app.Element("Icon") == null ? Resources.C_64.ToBitmap() : (Bitmap)new ImageConverter().ConvertFrom(Convert.FromBase64String(app.Element("Icon").Value)),
|
||||||
app.Element("MainFile") != null,
|
app.Element("MainFile") != null,
|
||||||
app.Element("MainFile") != null ? "" : app.Element("MainFile").Value
|
app.Element("MainFile") != null ? "" : app.Element("MainFile").Value
|
||||||
));
|
));
|
||||||
});
|
});
|
||||||
}
|
|
||||||
Directory.GetDirectories(dir + @"\Apps\").Where(s => !apps.ContainsKey(Guid.Parse(Path.GetFileName(s)))).ToList().ForEach(s =>
|
Directory.GetDirectories(dir + @"\Apps\").Where(s => !apps.ContainsKey(Guid.Parse(Path.GetFileName(s)))).ToList().ForEach(s =>
|
||||||
{
|
{
|
||||||
Guid tmp = Guid.Parse(Path.GetFileName(s));
|
Guid tmp = Guid.Parse(Path.GetFileName(s));
|
||||||
|
@ -223,24 +222,35 @@ namespace UpTool2
|
||||||
|
|
||||||
void fetchRepos()
|
void fetchRepos()
|
||||||
{
|
{
|
||||||
List<XElement> apps = new List<XElement>();
|
string xml = dir + @"\info.xml";
|
||||||
|
XElement meta = XDocument.Load(xml).Element("meta");
|
||||||
|
List<XElement> tmp_apps_list = new List<XElement>();
|
||||||
|
if (meta.Element("Repos") == null)
|
||||||
|
meta.Add(new XElement("Repos"));
|
||||||
|
if (meta.Element("Repos").Elements("Repo").Count() == 0)
|
||||||
|
meta.Element("Repos").Add(new XElement("Repo", "https://github.com/CreepyCrafter24/UpTool2/releases/download/Repo/Repo.xml"));
|
||||||
|
string[] repArr = meta.Element("Repos").Elements("Repo").Select(s => s.Value).ToArray();
|
||||||
using (WebClient client = new WebClient())
|
using (WebClient client = new WebClient())
|
||||||
{
|
{
|
||||||
for (int i = 0; i < Settings.Default.Repos.Count; i++)
|
for (int i = 0; i < repArr.Length; i++)
|
||||||
{
|
{
|
||||||
#if !DEBUG
|
#if !DEBUG
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
XDocument repo = XDocument.Load(Settings.Default.Repos[i]);
|
XDocument repo = XDocument.Load(repArr[i]);
|
||||||
foreach (XElement app in repo.Element("repo").Elements("app"))
|
foreach (XElement app in repo.Element("repo").Elements("app"))
|
||||||
|
{
|
||||||
|
if (tmp_apps_list.Where(a => a.Element("ID").Value == app.Element("ID").Value).Count() == 0 ||
|
||||||
|
tmp_apps_list.Where(a => a.Element("ID").Value == app.Element("ID").Value)
|
||||||
|
.Where(a => int.Parse(a.Element("Version").Value) >= int.Parse(app.Element("Version").Value)).Count() == 0)
|
||||||
{
|
{
|
||||||
//"Sanity check"
|
//"Sanity check"
|
||||||
int.Parse(app.Element("Version").Value);
|
int.Parse(app.Element("Version").Value);
|
||||||
Guid.Parse(app.Element("ID").Value);
|
Guid.Parse(app.Element("ID").Value);
|
||||||
ColorTranslator.FromHtml(app.Element("Color").Value);
|
ColorTranslator.FromHtml(app.Element("Color").Value);
|
||||||
//Create XElement
|
//Create XElement
|
||||||
apps.Add(new XElement("App",
|
tmp_apps_list.Add(new XElement("App",
|
||||||
new XElement("Name", app.Element("Name").Value),
|
new XElement("Name", app.Element("Name").Value),
|
||||||
new XElement("Description", app.Element("Description").Value),
|
new XElement("Description", app.Element("Description").Value),
|
||||||
new XElement("Version", app.Element("Version").Value),
|
new XElement("Version", app.Element("Version").Value),
|
||||||
|
@ -249,31 +259,63 @@ namespace UpTool2
|
||||||
new XElement("Hash", app.Element("Hash").Value)
|
new XElement("Hash", app.Element("Hash").Value)
|
||||||
));
|
));
|
||||||
if (app.Element("MainFile") != null)
|
if (app.Element("MainFile") != null)
|
||||||
apps.Last().Add(new XElement("MainFile", app.Element("MainFile").Value));
|
tmp_apps_list.Last().Add(new XElement("MainFile", app.Element("MainFile").Value));
|
||||||
if (app.Element("Icon") != null)
|
if (app.Element("Icon") != null)
|
||||||
apps.Last().Add(new XElement("Icon", app.Element("Icon").Value));
|
{
|
||||||
|
#if !DEBUG
|
||||||
|
try
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
//Scale Image and save as Base64
|
||||||
|
Image src = Image.FromStream(client.OpenRead(app.Element("Icon").Value));
|
||||||
|
Bitmap dest = new Bitmap(70, 70);
|
||||||
|
dest.SetResolution(src.HorizontalResolution, src.VerticalResolution);
|
||||||
|
using (Graphics g = Graphics.FromImage(dest))
|
||||||
|
{
|
||||||
|
g.CompositingMode = CompositingMode.SourceCopy;
|
||||||
|
g.CompositingQuality = CompositingQuality.HighQuality;
|
||||||
|
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
|
||||||
|
g.SmoothingMode = SmoothingMode.HighQuality;
|
||||||
|
g.PixelOffsetMode = PixelOffsetMode.HighQuality;
|
||||||
|
using (var wrapMode = new ImageAttributes())
|
||||||
|
{
|
||||||
|
wrapMode.SetWrapMode(WrapMode.TileFlipXY);
|
||||||
|
g.DrawImage(src, new Rectangle(0, 0, 70, 70), 0, 0, src.Width, src.Height, GraphicsUnit.Pixel, wrapMode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
using (var ms = new MemoryStream())
|
||||||
|
{
|
||||||
|
dest.Save(ms, ImageFormat.Png);
|
||||||
|
tmp_apps_list.Last().Add(new XElement("Icon", Convert.ToBase64String(ms.ToArray())));
|
||||||
|
}
|
||||||
|
#if !DEBUG
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
#endif
|
||||||
|
}
|
||||||
if (app.Element("Color") == null)
|
if (app.Element("Color") == null)
|
||||||
apps.Last().Add(new XElement("Color", "#FFFFFF"));
|
tmp_apps_list.Last().Add(new XElement("Color", "#FFFFFF"));
|
||||||
else
|
else
|
||||||
apps.Last().Add(new XElement("Color", app.Element("Color").Value));
|
tmp_apps_list.Last().Add(new XElement("Color", app.Element("Color").Value));
|
||||||
|
if (tmp_apps_list.Where(a => a.Element("ID").Value == app.Element("ID").Value).Count() > 1)
|
||||||
|
tmp_apps_list.Where(a => a.Element("ID").Value == app.Element("ID").Value).Reverse().Skip(1).ToList().ForEach(a => tmp_apps_list.Remove(a));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#if !DEBUG
|
#if !DEBUG
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
MessageBox.Show(e.ToString(), "Failed to load repo: " + Settings.Default.Repos[i]);
|
MessageBox.Show(e.ToString(), "Failed to load repo: " + repArr[i]);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
apps.Sort((x, y) => x.Element("Name").Value.CompareTo(y.Element("Name").Value));
|
tmp_apps_list.Sort((x, y) => x.Element("Name").Value.CompareTo(y.Element("Name").Value));
|
||||||
string xml = dir + @"\info.xml";
|
if (meta.Element("LocalRepo") == null)
|
||||||
XElement meta = XDocument.Load(xml).Element("meta");
|
meta.Add(new XElement("LocalRepo"));
|
||||||
if (meta.Element("Repo") == null)
|
XElement repos = meta.Element("LocalRepo");
|
||||||
meta.Add(new XElement("Repo"));
|
|
||||||
XElement repos = meta.Element("Repo");
|
|
||||||
repos.RemoveNodes();
|
repos.RemoveNodes();
|
||||||
apps.ForEach(app => repos.Add(app));
|
tmp_apps_list.ForEach(app => repos.Add(app));
|
||||||
meta.Save(xml);
|
meta.Save(xml);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
@ -80,7 +80,7 @@ namespace UpTool2
|
||||||
Directory.CreateDirectory(dir + @"\Apps");
|
Directory.CreateDirectory(dir + @"\Apps");
|
||||||
string xml = dir + @"\info.xml";
|
string xml = dir + @"\info.xml";
|
||||||
if (!File.Exists(xml))
|
if (!File.Exists(xml))
|
||||||
new XElement("meta", new XElement("Version", 0), new XElement("Repo")).Save(xml);
|
new XElement("meta", new XElement("Version", 0), new XElement("Repos", new XElement("Repo", "https://github.com/CreepyCrafter24/UpTool2/releases/download/Repo/Repo.xml")), new XElement("LocalRepo")).Save(xml);
|
||||||
XElement meta = XDocument.Load("https://github.com/CreepyCrafter24/UpTool2/releases/download/Repo/Meta.xml").Element("meta");
|
XElement meta = XDocument.Load("https://github.com/CreepyCrafter24/UpTool2/releases/download/Repo/Meta.xml").Element("meta");
|
||||||
int version = int.Parse(meta.Element("Version").Value);
|
int version = int.Parse(meta.Element("Version").Value);
|
||||||
if (int.Parse(XDocument.Load(xml).Element("meta").Element("Version").Value) < version)
|
if (int.Parse(XDocument.Load(xml).Element("meta").Element("Version").Value) < version)
|
||||||
|
|
41
UpTool2/Properties/Settings.Designer.cs
generated
41
UpTool2/Properties/Settings.Designer.cs
generated
|
@ -1,41 +0,0 @@
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// <auto-generated>
|
|
||||||
// This code was generated by a tool.
|
|
||||||
// Runtime Version:4.0.30319.42000
|
|
||||||
//
|
|
||||||
// Changes to this file may cause incorrect behavior and will be lost if
|
|
||||||
// the code is regenerated.
|
|
||||||
// </auto-generated>
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
namespace UpTool2.Properties {
|
|
||||||
|
|
||||||
|
|
||||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
|
||||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.3.0.0")]
|
|
||||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
|
||||||
|
|
||||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
|
||||||
|
|
||||||
public static Settings Default {
|
|
||||||
get {
|
|
||||||
return defaultInstance;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
|
||||||
[global::System.Configuration.DefaultSettingValueAttribute(@"<?xml version=""1.0"" encoding=""utf-16""?>
|
|
||||||
<ArrayOfString xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"">
|
|
||||||
<string>https://github.com/CreepyCrafter24/UpTool2/releases/download/Repo/Repo.xml</string>
|
|
||||||
</ArrayOfString>")]
|
|
||||||
public global::System.Collections.Specialized.StringCollection Repos {
|
|
||||||
get {
|
|
||||||
return ((global::System.Collections.Specialized.StringCollection)(this["Repos"]));
|
|
||||||
}
|
|
||||||
set {
|
|
||||||
this["Repos"] = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,12 +0,0 @@
|
||||||
<?xml version='1.0' encoding='utf-8'?>
|
|
||||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="UpTool2.Properties" GeneratedClassName="Settings">
|
|
||||||
<Profiles />
|
|
||||||
<Settings>
|
|
||||||
<Setting Name="Repos" Type="System.Collections.Specialized.StringCollection" Scope="User">
|
|
||||||
<Value Profile="(Default)"><?xml version="1.0" encoding="utf-16"?>
|
|
||||||
<ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
|
||||||
<string>https://github.com/CreepyCrafter24/UpTool2/releases/download/Repo/Repo.xml</string>
|
|
||||||
</ArrayOfString></Value>
|
|
||||||
</Setting>
|
|
||||||
</Settings>
|
|
||||||
</SettingsFile>
|
|
|
@ -91,15 +91,6 @@
|
||||||
<EmbeddedResource Include="SettingsForm.resx">
|
<EmbeddedResource Include="SettingsForm.resx">
|
||||||
<DependentUpon>SettingsForm.cs</DependentUpon>
|
<DependentUpon>SettingsForm.cs</DependentUpon>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
<None Include="Properties\Settings.settings">
|
|
||||||
<Generator>SettingsSingleFileGenerator</Generator>
|
|
||||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
|
||||||
</None>
|
|
||||||
<Compile Include="Properties\Settings.Designer.cs">
|
|
||||||
<AutoGen>True</AutoGen>
|
|
||||||
<DependentUpon>Settings.settings</DependentUpon>
|
|
||||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
|
||||||
</Compile>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="App.config" />
|
<None Include="App.config" />
|
||||||
|
|
Reference in New Issue
Block a user