Use libexeinfo to retrieve strings and version from found executable files.
Find possible readme files. Present all of that information to the user as a way to fill fields when adding an application.
This commit is contained in:
@@ -48,6 +48,18 @@
|
||||
<DependentUpon>dlgOpticalDisc.xeto</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="WrappersForEto.cs" />
|
||||
<Compile Include="dlgImportMetadata.xeto.cs">
|
||||
<DependentUpon>dlgImportMetadata.xeto</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="pnlDescription.xeto.cs">
|
||||
<DependentUpon>pnlDescription.xeto</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="pnlStrings.xeto.cs">
|
||||
<DependentUpon>pnlStrings.xeto</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="pnlVersions.xeto.cs">
|
||||
<DependentUpon>pnlVersions.xeto</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Claunia.Encoding, Version=1.6.1.0, Culture=neutral, PublicKeyToken=null">
|
||||
@@ -109,6 +121,10 @@
|
||||
<EmbeddedResource Include="dlgFilesystem.xeto" />
|
||||
<EmbeddedResource Include="dlgBlockMedia.xeto" />
|
||||
<EmbeddedResource Include="dlgOpticalDisc.xeto" />
|
||||
<EmbeddedResource Include="dlgImportMetadata.xeto" />
|
||||
<EmbeddedResource Include="pnlDescription.xeto" />
|
||||
<EmbeddedResource Include="pnlStrings.xeto" />
|
||||
<EmbeddedResource Include="pnlVersions.xeto" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\apprepodbmgr.Core\apprepodbmgr.Core.csproj">
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Dialog xmlns="http://schema.picoe.ca/eto.forms" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Height="544" Width="857" Closing="OnDeleteEvent" Resizable="True" Title="Add operating system">
|
||||
<Dialog xmlns="http://schema.picoe.ca/eto.forms" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Height="544" Width="857" Closing="OnDeleteEvent" Resizable="True" Title="Add application">
|
||||
<StackLayout Orientation="Vertical">
|
||||
<StackLayoutItem HorizontalAlignment="Stretch">
|
||||
<StackLayout Orientation="Horizontal">
|
||||
|
||||
@@ -371,10 +371,59 @@ namespace apprepodbmgr.Eto
|
||||
|
||||
thdCheckFiles?.Abort();
|
||||
|
||||
thdHashFiles = null;
|
||||
lblProgress.Visible = false;
|
||||
prgProgress.Visible = false;
|
||||
btnStop.Visible = false;
|
||||
thdHashFiles = null;
|
||||
lblProgress.Visible = false;
|
||||
prgProgress.Visible = false;
|
||||
btnStop.Visible = false;
|
||||
|
||||
if(Context.Executables?.Count > 0 || Context.Readmes?.Count > 0)
|
||||
{
|
||||
dlgImportMetadata importMetadataDlg = new dlgImportMetadata();
|
||||
importMetadataDlg.ShowModal(this);
|
||||
|
||||
if(!importMetadataDlg.canceled && (importMetadataDlg.chosenArchitectures.Count > 0 ||
|
||||
importMetadataDlg.chosenOses.Count > 0 ||
|
||||
!string.IsNullOrWhiteSpace(importMetadataDlg.description) ||
|
||||
!string.IsNullOrWhiteSpace(importMetadataDlg.developer) ||
|
||||
!string.IsNullOrWhiteSpace(importMetadataDlg.product) ||
|
||||
!string.IsNullOrWhiteSpace(importMetadataDlg.publisher) ||
|
||||
!string.IsNullOrWhiteSpace(importMetadataDlg.version)))
|
||||
{
|
||||
if(Context.Metadata == null && (importMetadataDlg.chosenArchitectures.Count > 0 ||
|
||||
importMetadataDlg.chosenOses.Count > 0 ||
|
||||
!string.IsNullOrWhiteSpace(importMetadataDlg.developer) ||
|
||||
!string.IsNullOrWhiteSpace(importMetadataDlg.product) ||
|
||||
!string.IsNullOrWhiteSpace(importMetadataDlg.publisher) ||
|
||||
!string.IsNullOrWhiteSpace(importMetadataDlg.version)))
|
||||
Context.Metadata = new CICMMetadataType();
|
||||
|
||||
if(!string.IsNullOrWhiteSpace(importMetadataDlg.description))
|
||||
txtDescription.Text = importMetadataDlg.description;
|
||||
if(!string.IsNullOrWhiteSpace(importMetadataDlg.product))
|
||||
Context.Metadata.Name = importMetadataDlg.product;
|
||||
if(!string.IsNullOrWhiteSpace(importMetadataDlg.publisher))
|
||||
Context.Metadata.Publisher = new[] {importMetadataDlg.publisher};
|
||||
if(!string.IsNullOrWhiteSpace(importMetadataDlg.developer))
|
||||
Context.Metadata.Developer = new[] {importMetadataDlg.developer};
|
||||
|
||||
if(importMetadataDlg.chosenArchitectures.Count > 0)
|
||||
Context.Metadata.Architectures = importMetadataDlg.chosenArchitectures.ToArray();
|
||||
|
||||
if(importMetadataDlg.chosenOses.Count > 0)
|
||||
{
|
||||
List<RequiredOperatingSystemType> reqOs = new List<RequiredOperatingSystemType>();
|
||||
foreach(TargetOsEntry osEntry in importMetadataDlg.chosenOses)
|
||||
reqOs.Add(new RequiredOperatingSystemType
|
||||
{
|
||||
Name = osEntry.name,
|
||||
Version = new[] {osEntry.version}
|
||||
});
|
||||
|
||||
Context.Metadata.RequiredOperatingSystems = reqOs.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
btnClose.Visible = true;
|
||||
btnExit.Enabled = true;
|
||||
btnPack.Visible = true;
|
||||
@@ -470,6 +519,8 @@ namespace apprepodbmgr.Eto
|
||||
Context.Path = "";
|
||||
Context.Files = null;
|
||||
Context.Hashes = null;
|
||||
Context.Executables = null;
|
||||
Context.Readmes = null;
|
||||
btnStop.Visible = false;
|
||||
btnPack.Visible = false;
|
||||
btnClose.Visible = false;
|
||||
|
||||
27
dlgImportMetadata.xeto
Normal file
27
dlgImportMetadata.xeto
Normal file
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Dialog xmlns="http://schema.picoe.ca/eto.forms" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Height="544" Width="857" Resizable="True" Title="Import metadata">
|
||||
<StackLayout Orientation="Vertical">
|
||||
<StackLayoutItem HorizontalAlignment="Center">
|
||||
<Label ID="lblPanelName">Panel name goes here</Label>
|
||||
</StackLayoutItem>
|
||||
<StackLayoutItem Expand="True" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
|
||||
<Panel ID="pnlPanel" />
|
||||
</StackLayoutItem>
|
||||
<StackLayoutItem HorizontalAlignment="Stretch">
|
||||
<ProgressBar ID="prgProgress"/>
|
||||
</StackLayoutItem>
|
||||
<StackLayoutItem HorizontalAlignment="Right">
|
||||
<StackLayout Orientation="Horizontal">
|
||||
<StackLayoutItem HorizontalAlignment="Right">
|
||||
<Button ID="btnCancel" Click="OnBtnCancelClick">Cancel</Button>
|
||||
</StackLayoutItem>
|
||||
<StackLayoutItem HorizontalAlignment="Right">
|
||||
<Button ID="btnPrevious" Click="OnBtnPreviousClick">Previous</Button>
|
||||
</StackLayoutItem>
|
||||
<StackLayoutItem HorizontalAlignment="Right">
|
||||
<Button ID="btnNext" Click="OnBtnNextClick">Next</Button>
|
||||
</StackLayoutItem>
|
||||
</StackLayout>
|
||||
</StackLayoutItem>
|
||||
</StackLayout>
|
||||
</Dialog>
|
||||
421
dlgImportMetadata.xeto.cs
Normal file
421
dlgImportMetadata.xeto.cs
Normal file
@@ -0,0 +1,421 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using apprepodbmgr.Core;
|
||||
using Eto.Forms;
|
||||
using Eto.Serialization.Xaml;
|
||||
using libexeinfo;
|
||||
using Schemas;
|
||||
|
||||
namespace apprepodbmgr.Eto
|
||||
{
|
||||
public class dlgImportMetadata : Dialog
|
||||
{
|
||||
List<string> architectures;
|
||||
internal bool canceled;
|
||||
internal List<ArchitecturesTypeArchitecture> chosenArchitectures;
|
||||
internal List<TargetOsEntry> chosenOses;
|
||||
Panels currentPanel;
|
||||
internal string description;
|
||||
internal string developer;
|
||||
Panels maximumPanel;
|
||||
Panels minimumPanel;
|
||||
List<TargetOsEntry> operatingSystems;
|
||||
pnlDescription panelDescription;
|
||||
pnlStrings panelStrings;
|
||||
pnlVersions panelVersions;
|
||||
internal string product;
|
||||
internal string publisher;
|
||||
List<string> strings;
|
||||
internal string version;
|
||||
List<string> versions;
|
||||
|
||||
public dlgImportMetadata()
|
||||
{
|
||||
XamlReader.Load(this);
|
||||
|
||||
Topmost = true;
|
||||
canceled = true;
|
||||
AbortButton = btnCancel;
|
||||
DefaultButton = btnNext;
|
||||
DisplayMode = DialogDisplayMode.Attached;
|
||||
panelDescription = new pnlDescription();
|
||||
panelStrings = new pnlStrings();
|
||||
panelVersions = new pnlVersions();
|
||||
strings = new List<string>();
|
||||
architectures = new List<string>();
|
||||
operatingSystems = new List<TargetOsEntry>();
|
||||
versions = new List<string>();
|
||||
chosenArchitectures = new List<ArchitecturesTypeArchitecture>();
|
||||
chosenOses = new List<TargetOsEntry>();
|
||||
|
||||
LoadComplete += OnLoadComplete;
|
||||
|
||||
// TODO: Show relative path only
|
||||
panelDescription.treeFiles.DataStore = Context.Readmes;
|
||||
|
||||
//pnlPanel.Content = panelDescription;
|
||||
//pnlPanel.Content = panelStrings;
|
||||
//pnlPanel.Content = panelVersions;
|
||||
|
||||
minimumPanel = Context.Readmes?.Count > 0 ? Panels.Description : Panels.Strings;
|
||||
maximumPanel = Context.Readmes?.Count > 0 ? Panels.Description : Panels.Strings;
|
||||
}
|
||||
|
||||
// TODO: Icons
|
||||
void OnLoadComplete(object sender, EventArgs eventArgs)
|
||||
{
|
||||
if(Context.Executables?.Count > 0)
|
||||
{
|
||||
lblPanelName.Text = "Please wait while reading executables found";
|
||||
prgProgress.MaxValue = Context.Executables.Count;
|
||||
prgProgress.MinValue = 0;
|
||||
prgProgress.Value = 0;
|
||||
|
||||
foreach(string file in Context.Executables)
|
||||
{
|
||||
FileStream exeStream = new FileStream(file, FileMode.Open, FileAccess.Read);
|
||||
MZ mzExe = new MZ(exeStream);
|
||||
NE neExe = new NE(exeStream);
|
||||
AtariST stExe = new AtariST(exeStream);
|
||||
LX lxExe = new LX(exeStream);
|
||||
COFF coffExe = new COFF(exeStream);
|
||||
PE peExe = new PE(exeStream);
|
||||
Geos geosExe = new Geos(exeStream);
|
||||
ELF elfExe = new ELF(exeStream);
|
||||
IExecutable recognizedExe;
|
||||
|
||||
if(neExe.Recognized) recognizedExe = neExe;
|
||||
else if(lxExe.Recognized) recognizedExe = lxExe;
|
||||
else if(peExe.Recognized) recognizedExe = peExe;
|
||||
else if(mzExe.Recognized) recognizedExe = mzExe;
|
||||
else if(coffExe.Recognized) recognizedExe = coffExe;
|
||||
else if(stExe.Recognized) recognizedExe = stExe;
|
||||
else if(elfExe.Recognized) recognizedExe = elfExe;
|
||||
else if(geosExe.Recognized) recognizedExe = geosExe;
|
||||
else
|
||||
{
|
||||
exeStream.Close();
|
||||
continue;
|
||||
}
|
||||
|
||||
if(recognizedExe.Strings != null) strings.AddRange(recognizedExe.Strings);
|
||||
|
||||
foreach(Architecture exeArch in recognizedExe.Architectures)
|
||||
{
|
||||
ArchitecturesTypeArchitecture? arch = ExeArchToSchemaArch(exeArch);
|
||||
if(arch.HasValue && !architectures.Contains($"{arch.Value}"))
|
||||
architectures.Add($"{arch.Value}");
|
||||
}
|
||||
|
||||
operatingSystems.Add(new TargetOsEntry
|
||||
{
|
||||
name = recognizedExe.RequiredOperatingSystem.Name,
|
||||
version =
|
||||
$"{recognizedExe.RequiredOperatingSystem.MajorVersion}.{recognizedExe.RequiredOperatingSystem.MinorVersion}"
|
||||
});
|
||||
|
||||
switch(recognizedExe)
|
||||
{
|
||||
case NE _:
|
||||
if(neExe.Versions != null)
|
||||
foreach(NE.Version exeVersion in neExe.Versions)
|
||||
{
|
||||
versions.Add(exeVersion.FileVersion);
|
||||
versions.Add(exeVersion.ProductVersion);
|
||||
version = exeVersion.ProductVersion;
|
||||
foreach(KeyValuePair<string, Dictionary<string, string>> kvp in exeVersion
|
||||
.StringsByLanguage)
|
||||
{
|
||||
if(kvp.Value.TryGetValue("CompanyName", out string tmpValue))
|
||||
developer = tmpValue;
|
||||
if(kvp.Value.TryGetValue("ProductName", out string tmpValue2))
|
||||
product = tmpValue2;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case PE _:
|
||||
if(peExe.Versions != null)
|
||||
foreach(PE.Version exeVersion in peExe.Versions)
|
||||
{
|
||||
versions.Add(exeVersion.FileVersion);
|
||||
versions.Add(exeVersion.ProductVersion);
|
||||
version = exeVersion.ProductVersion;
|
||||
foreach(KeyValuePair<string, Dictionary<string, string>> kvp in exeVersion
|
||||
.StringsByLanguage)
|
||||
{
|
||||
if(kvp.Value.TryGetValue("CompanyName", out string tmpValue))
|
||||
developer = tmpValue;
|
||||
if(kvp.Value.TryGetValue("ProductName", out string tmpValue2))
|
||||
product = tmpValue2;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case LX _:
|
||||
if(lxExe.WinVersion != null)
|
||||
{
|
||||
versions.Add(lxExe.WinVersion.FileVersion);
|
||||
versions.Add(lxExe.WinVersion.ProductVersion);
|
||||
version = lxExe.WinVersion.ProductVersion;
|
||||
foreach(KeyValuePair<string, Dictionary<string, string>> kvp in lxExe
|
||||
.WinVersion
|
||||
.StringsByLanguage)
|
||||
{
|
||||
if(kvp.Value.TryGetValue("CompanyName", out string tmpValue)) developer = tmpValue;
|
||||
if(kvp.Value.TryGetValue("ProductName", out string tmpValue2)) product = tmpValue2;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
exeStream.Close();
|
||||
prgProgress.Value++;
|
||||
}
|
||||
|
||||
strings = strings.Distinct().ToList();
|
||||
strings.Sort();
|
||||
|
||||
if(strings.Count == 0 && minimumPanel == Panels.Strings) minimumPanel = Panels.Versions;
|
||||
else maximumPanel = Panels.Strings;
|
||||
|
||||
panelStrings.treeStrings.DataStore = strings;
|
||||
versions = versions.Distinct().ToList();
|
||||
versions.Sort();
|
||||
panelVersions.treeVersions.DataStore = versions;
|
||||
architectures = architectures.Distinct().ToList();
|
||||
architectures.Sort();
|
||||
panelVersions.treeArchs.DataStore = architectures;
|
||||
|
||||
Dictionary<string, List<string>> osEntriesDictionary = new Dictionary<string, List<string>>();
|
||||
|
||||
foreach(TargetOsEntry osEntry in operatingSystems)
|
||||
{
|
||||
if(string.IsNullOrEmpty(osEntry.name)) continue;
|
||||
|
||||
osEntriesDictionary.TryGetValue(osEntry.name, out List<string> osvers);
|
||||
|
||||
if(osvers == null) osvers = new List<string>();
|
||||
|
||||
osvers.Add(osEntry.version);
|
||||
osEntriesDictionary.Remove(osEntry.name);
|
||||
osEntriesDictionary.Add(osEntry.name, osvers);
|
||||
}
|
||||
|
||||
operatingSystems = new List<TargetOsEntry>();
|
||||
foreach(KeyValuePair<string, List<string>> kvp in osEntriesDictionary.OrderBy(t => t.Key))
|
||||
{
|
||||
kvp.Value.Sort();
|
||||
foreach(string s in kvp.Value.Distinct())
|
||||
operatingSystems.Add(new TargetOsEntry {name = kvp.Key, version = s});
|
||||
}
|
||||
|
||||
panelVersions.treeOs.DataStore = operatingSystems;
|
||||
|
||||
if(versions.Count > 0 || architectures.Count > 0 || operatingSystems.Count > 0)
|
||||
maximumPanel = Panels.Versions;
|
||||
}
|
||||
|
||||
prgProgress.Visible = false;
|
||||
btnPrevious.Enabled = false;
|
||||
switch(minimumPanel)
|
||||
{
|
||||
case Panels.Description:
|
||||
pnlPanel.Content = panelDescription;
|
||||
currentPanel = Panels.Description;
|
||||
break;
|
||||
case Panels.Strings:
|
||||
pnlPanel.Content = panelStrings;
|
||||
currentPanel = Panels.Strings;
|
||||
break;
|
||||
case Panels.Versions:
|
||||
pnlPanel.Content = panelVersions;
|
||||
currentPanel = Panels.Versions;
|
||||
break;
|
||||
}
|
||||
|
||||
if(currentPanel == maximumPanel) btnNext.Text = "Finish";
|
||||
lblPanelName.Visible = false;
|
||||
}
|
||||
|
||||
static ArchitecturesTypeArchitecture? ExeArchToSchemaArch(Architecture arch)
|
||||
{
|
||||
switch(arch)
|
||||
{
|
||||
case Architecture.Aarch64: return ArchitecturesTypeArchitecture.aarch64;
|
||||
case Architecture.Alpha: return ArchitecturesTypeArchitecture.axp;
|
||||
case Architecture.Amd64: return ArchitecturesTypeArchitecture.amd64;
|
||||
case Architecture.Arm: return ArchitecturesTypeArchitecture.arm;
|
||||
case Architecture.Avr: return ArchitecturesTypeArchitecture.avr;
|
||||
case Architecture.Avr32: return ArchitecturesTypeArchitecture.avr32;
|
||||
case Architecture.Clipper: return ArchitecturesTypeArchitecture.clipper;
|
||||
case Architecture.Hobbit: return ArchitecturesTypeArchitecture.hobbit;
|
||||
case Architecture.I286: return ArchitecturesTypeArchitecture.i86;
|
||||
case Architecture.I386: return ArchitecturesTypeArchitecture.ia32;
|
||||
case Architecture.I8051: return ArchitecturesTypeArchitecture.Item8051;
|
||||
case Architecture.I86: return ArchitecturesTypeArchitecture.i86;
|
||||
case Architecture.I860: return ArchitecturesTypeArchitecture.i860;
|
||||
case Architecture.I960: return ArchitecturesTypeArchitecture.i960;
|
||||
case Architecture.IA64: return ArchitecturesTypeArchitecture.ia64;
|
||||
case Architecture.M68HC05: return ArchitecturesTypeArchitecture.m6805;
|
||||
case Architecture.M68K: return ArchitecturesTypeArchitecture.m68k;
|
||||
case Architecture.M88K: return ArchitecturesTypeArchitecture.m88k;
|
||||
case Architecture.Mips: return ArchitecturesTypeArchitecture.mips32;
|
||||
case Architecture.Mips16: return ArchitecturesTypeArchitecture.mips32;
|
||||
case Architecture.Mips3: return ArchitecturesTypeArchitecture.mips64;
|
||||
case Architecture.NIOS2: return ArchitecturesTypeArchitecture.nios2;
|
||||
case Architecture.OpenRisc: return ArchitecturesTypeArchitecture.openrisc;
|
||||
case Architecture.PaRisc: return ArchitecturesTypeArchitecture.parisc;
|
||||
case Architecture.Pdp10: return ArchitecturesTypeArchitecture.pdp10;
|
||||
case Architecture.Pdp11: return ArchitecturesTypeArchitecture.pdp11;
|
||||
case Architecture.Power: return ArchitecturesTypeArchitecture.power;
|
||||
case Architecture.PowerPc: return ArchitecturesTypeArchitecture.ppc;
|
||||
case Architecture.PowerPc64: return ArchitecturesTypeArchitecture.ppc64;
|
||||
case Architecture.Prism: return ArchitecturesTypeArchitecture.prism;
|
||||
case Architecture.RiscV: return ArchitecturesTypeArchitecture.riscv;
|
||||
case Architecture.S370: return ArchitecturesTypeArchitecture.s360;
|
||||
case Architecture.S390: return ArchitecturesTypeArchitecture.esa390;
|
||||
case Architecture.Sh2: return ArchitecturesTypeArchitecture.sh2;
|
||||
case Architecture.Sh3: return ArchitecturesTypeArchitecture.sh3;
|
||||
case Architecture.Sh4: return ArchitecturesTypeArchitecture.sh4;
|
||||
case Architecture.Sh5: return ArchitecturesTypeArchitecture.sh5;
|
||||
case Architecture.Sparc: return ArchitecturesTypeArchitecture.sparc;
|
||||
case Architecture.Sparc64: return ArchitecturesTypeArchitecture.sparc64;
|
||||
case Architecture.Thumb: return ArchitecturesTypeArchitecture.arm;
|
||||
case Architecture.Thumb2: return ArchitecturesTypeArchitecture.arm;
|
||||
case Architecture.Vax: return ArchitecturesTypeArchitecture.vax;
|
||||
case Architecture.We32000: return ArchitecturesTypeArchitecture.we32000;
|
||||
case Architecture.Z80: return ArchitecturesTypeArchitecture.z80;
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
|
||||
void OnBtnCancelClick(object sender, EventArgs eventArgs)
|
||||
{
|
||||
canceled = true;
|
||||
Close();
|
||||
// throw new NotImplementedException();
|
||||
}
|
||||
|
||||
void OnBtnPreviousClick(object sender, EventArgs eventArgs)
|
||||
{
|
||||
switch(currentPanel)
|
||||
{
|
||||
case Panels.Description:
|
||||
// Ok...
|
||||
break;
|
||||
case Panels.Strings:
|
||||
if(minimumPanel == Panels.Strings) return;
|
||||
|
||||
pnlPanel.Content = panelDescription;
|
||||
currentPanel = Panels.Description;
|
||||
|
||||
btnPrevious.Enabled = currentPanel != minimumPanel;
|
||||
|
||||
break;
|
||||
case Panels.Versions:
|
||||
if(minimumPanel == Panels.Versions) return;
|
||||
|
||||
pnlPanel.Content = panelStrings;
|
||||
currentPanel = Panels.Strings;
|
||||
|
||||
btnPrevious.Enabled = currentPanel != minimumPanel;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if(currentPanel != maximumPanel) btnNext.Text = "Next";
|
||||
}
|
||||
|
||||
void OnBtnNextClick(object sender, EventArgs eventArgs)
|
||||
{
|
||||
if(currentPanel != maximumPanel)
|
||||
{
|
||||
switch(currentPanel)
|
||||
{
|
||||
case Panels.Description:
|
||||
if(maximumPanel == Panels.Description) return;
|
||||
|
||||
pnlPanel.Content = panelStrings;
|
||||
currentPanel = Panels.Strings;
|
||||
|
||||
btnPrevious.Enabled = currentPanel != minimumPanel;
|
||||
|
||||
break;
|
||||
case Panels.Strings:
|
||||
if(maximumPanel == Panels.Strings) return;
|
||||
|
||||
pnlPanel.Content = panelVersions;
|
||||
currentPanel = Panels.Versions;
|
||||
|
||||
btnPrevious.Enabled = currentPanel != minimumPanel;
|
||||
|
||||
break;
|
||||
case Panels.Versions:
|
||||
if(minimumPanel == Panels.Versions) return;
|
||||
|
||||
pnlPanel.Content = panelStrings;
|
||||
currentPanel = Panels.Strings;
|
||||
|
||||
btnPrevious.Enabled = currentPanel != minimumPanel;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if(currentPanel == maximumPanel) btnNext.Text = "Finish";
|
||||
return;
|
||||
}
|
||||
|
||||
if(Context.Readmes?.Count > 0 && !string.IsNullOrWhiteSpace(panelDescription.description))
|
||||
description = panelDescription.description;
|
||||
|
||||
if(!(Context.Executables?.Count > 0)) return;
|
||||
|
||||
if(!string.IsNullOrWhiteSpace(panelStrings.txtDeveloper.Text)) developer = panelStrings.txtDeveloper.Text;
|
||||
if(!string.IsNullOrWhiteSpace(panelStrings.txtPublisher.Text)) publisher = panelStrings.txtPublisher.Text;
|
||||
if(!string.IsNullOrWhiteSpace(panelStrings.txtProduct.Text)) product = panelStrings.txtProduct.Text;
|
||||
if(!string.IsNullOrWhiteSpace(panelStrings.txtVersion.Text)) version = panelStrings.txtVersion.Text;
|
||||
|
||||
foreach(object archsSelectedItem in panelVersions.treeArchs.SelectedItems)
|
||||
{
|
||||
if(!(archsSelectedItem is string arch)) continue;
|
||||
|
||||
if(Enum.TryParse(arch, true, out ArchitecturesTypeArchitecture realArch))
|
||||
chosenArchitectures.Add(realArch);
|
||||
}
|
||||
|
||||
foreach(object osesSelectedItem in panelVersions.treeOs.SelectedItems)
|
||||
{
|
||||
if(!(osesSelectedItem is TargetOsEntry os)) continue;
|
||||
|
||||
chosenOses.Add(os);
|
||||
}
|
||||
|
||||
if(panelVersions.treeVersions.SelectedItem is string chosenVersion) version = chosenVersion;
|
||||
|
||||
canceled = false;
|
||||
Close();
|
||||
}
|
||||
|
||||
enum Panels
|
||||
{
|
||||
Description,
|
||||
Strings,
|
||||
Versions
|
||||
}
|
||||
|
||||
#region XAML UI elements
|
||||
#pragma warning disable 0649
|
||||
Label lblPanelName;
|
||||
Panel pnlPanel;
|
||||
ProgressBar prgProgress;
|
||||
Button btnCancel;
|
||||
Button btnPrevious;
|
||||
Button btnNext;
|
||||
#pragma warning restore 0649
|
||||
#endregion XAML UI elements
|
||||
}
|
||||
}
|
||||
38
pnlDescription.xeto
Normal file
38
pnlDescription.xeto
Normal file
@@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Panel xmlns="http://schema.picoe.ca/eto.forms" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<StackLayout Orientation="Horizontal">
|
||||
<StackLayoutItem Expand="True" HorizontalAlignment="Left" VerticalAlignment="Stretch">
|
||||
<StackLayout Orientation="Vertical">
|
||||
<StackLayoutItem HorizontalAlignment="Center">
|
||||
<Label>Files with description</Label>
|
||||
</StackLayoutItem>
|
||||
<StackLayoutItem HorizontalAlignment="Stretch" Expand="True" VerticalAlignment="Stretch">
|
||||
<GridView ID="treeFiles"/>
|
||||
</StackLayoutItem>
|
||||
</StackLayout>
|
||||
</StackLayoutItem>
|
||||
<StackLayoutItem Expand="True" HorizontalAlignment="Right" VerticalAlignment="Stretch">
|
||||
<StackLayout>
|
||||
<StackLayoutItem HorizontalAlignment="Center">
|
||||
<Label>Description</Label>
|
||||
</StackLayoutItem>
|
||||
<StackLayoutItem Expand="True" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
|
||||
<TextArea ID="txtDescription" ReadOnly="True"/>
|
||||
</StackLayoutItem>
|
||||
<StackLayoutItem VerticalAlignment="Bottom">
|
||||
<StackLayout Orientation="Horizontal">
|
||||
<StackLayoutItem HorizontalAlignment="Left">
|
||||
<Label>Codepage:</Label>
|
||||
</StackLayoutItem>
|
||||
<StackLayoutItem Expand="True" HorizontalAlignment="Center">
|
||||
<DropDown ID="cmbCodepages"/>
|
||||
</StackLayoutItem>
|
||||
<StackLayoutItem HorizontalAlignment="Right">
|
||||
<Button ID="btnClear" Click="OnBtnClearClick">Clear</Button>
|
||||
</StackLayoutItem>
|
||||
</StackLayout>
|
||||
</StackLayoutItem>
|
||||
</StackLayout>
|
||||
</StackLayoutItem>
|
||||
</StackLayout>
|
||||
</Panel>
|
||||
86
pnlDescription.xeto.cs
Normal file
86
pnlDescription.xeto.cs
Normal file
@@ -0,0 +1,86 @@
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Eto.Forms;
|
||||
using Eto.Serialization.Xaml;
|
||||
using EncodingInfo = Claunia.Encoding.EncodingInfo;
|
||||
|
||||
namespace apprepodbmgr.Eto
|
||||
{
|
||||
public class pnlDescription : Panel
|
||||
{
|
||||
ObservableCollection<ListItem> cmbCodepagesItems;
|
||||
Encoding currentEncoding;
|
||||
public string description;
|
||||
|
||||
public pnlDescription()
|
||||
{
|
||||
XamlReader.Load(this);
|
||||
|
||||
treeFiles.Columns.Add(new GridColumn
|
||||
{
|
||||
DataCell = new TextBoxCell {Binding = Binding.Property<string, string>(r => r)},
|
||||
HeaderText = "File"
|
||||
});
|
||||
|
||||
treeFiles.AllowMultipleSelection = false;
|
||||
treeFiles.SelectionChanged += TreeFilesOnSelectionChanged;
|
||||
cmbCodepagesItems = new ObservableCollection<ListItem>();
|
||||
foreach(EncodingInfo enc in Claunia.Encoding.Encoding.GetEncodings())
|
||||
cmbCodepagesItems.Add(new ListItem {Key = enc.Name, Text = enc.DisplayName});
|
||||
foreach(System.Text.EncodingInfo enc in Encoding.GetEncodings())
|
||||
cmbCodepagesItems.Add(new ListItem {Key = enc.Name, Text = enc.GetEncoding().EncodingName});
|
||||
cmbCodepages.DataStore = cmbCodepagesItems.OrderBy(t => t.Text);
|
||||
try
|
||||
{
|
||||
currentEncoding = Claunia.Encoding.Encoding.GetEncoding("ibm437");
|
||||
cmbCodepages.SelectedKey = currentEncoding.BodyName;
|
||||
}
|
||||
catch { currentEncoding = Encoding.ASCII; }
|
||||
|
||||
cmbCodepages.SelectedIndexChanged += CmbCodepagesOnSelectedIndexChanged;
|
||||
}
|
||||
|
||||
void CmbCodepagesOnSelectedIndexChanged(object sender, EventArgs eventArgs)
|
||||
{
|
||||
try { currentEncoding = Claunia.Encoding.Encoding.GetEncoding(cmbCodepages.SelectedKey); }
|
||||
catch
|
||||
{
|
||||
currentEncoding = Encoding.ASCII;
|
||||
cmbCodepages.SelectedKey = currentEncoding.BodyName;
|
||||
}
|
||||
|
||||
TreeFilesOnSelectionChanged(sender, eventArgs);
|
||||
}
|
||||
|
||||
void TreeFilesOnSelectionChanged(object sender, EventArgs eventArgs)
|
||||
{
|
||||
txtDescription.Text = "";
|
||||
description = null;
|
||||
if(!(treeFiles.SelectedItem is string file)) return;
|
||||
|
||||
StreamReader sr = new StreamReader(file, currentEncoding);
|
||||
description = sr.ReadToEnd();
|
||||
txtDescription.Text = description;
|
||||
sr.Close();
|
||||
}
|
||||
|
||||
void OnBtnClearClick(object sender, EventArgs eventArgs)
|
||||
{
|
||||
txtDescription.Text = "";
|
||||
description = null;
|
||||
treeFiles.UnselectAll();
|
||||
}
|
||||
|
||||
#region XAML UI elements
|
||||
#pragma warning disable 0649
|
||||
public GridView treeFiles;
|
||||
TextArea txtDescription;
|
||||
DropDown cmbCodepages;
|
||||
Button btnClear;
|
||||
#pragma warning restore 0649
|
||||
#endregion XAML UI elements
|
||||
}
|
||||
}
|
||||
55
pnlStrings.xeto
Normal file
55
pnlStrings.xeto
Normal file
@@ -0,0 +1,55 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Panel xmlns="http://schema.picoe.ca/eto.forms" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<StackLayout Orientation="Horizontal">
|
||||
<StackLayoutItem VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Expand="True">
|
||||
<StackLayout Orientation="Vertical">
|
||||
<StackLayoutItem>
|
||||
<Label>Strings found in executables</Label>
|
||||
</StackLayoutItem>
|
||||
<StackLayoutItem Expand="True" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
|
||||
<GridView ID="treeStrings"/>
|
||||
</StackLayoutItem>
|
||||
</StackLayout>
|
||||
</StackLayoutItem>
|
||||
<StackLayoutItem>
|
||||
<StackLayout Orientation="Vertical">
|
||||
<StackLayoutItem>
|
||||
<Button Click="OnBtnDeveloperClick">Set as developer</Button>
|
||||
</StackLayoutItem>
|
||||
<StackLayoutItem>
|
||||
<Button Click="OnBtnPublisherClick">Set as publisher</Button>
|
||||
</StackLayoutItem>
|
||||
<StackLayoutItem>
|
||||
<Button Click="OnBtnProductClick">Set as product</Button>
|
||||
</StackLayoutItem>
|
||||
<StackLayoutItem>
|
||||
<Button Click="OnBtnVersionClick">Set as version</Button>
|
||||
</StackLayoutItem>
|
||||
<StackLayoutItem>
|
||||
<Label>Developer</Label>
|
||||
</StackLayoutItem>
|
||||
<StackLayoutItem HorizontalAlignment="Stretch" Expand="True">
|
||||
<TextBox ID="txtDeveloper" ReadOnly="True" />
|
||||
</StackLayoutItem>
|
||||
<StackLayoutItem>
|
||||
<Label>Publisher</Label>
|
||||
</StackLayoutItem>
|
||||
<StackLayoutItem HorizontalAlignment="Stretch" Expand="True">
|
||||
<TextBox ID="txtPublisher" ReadOnly="True" />
|
||||
</StackLayoutItem>
|
||||
<StackLayoutItem>
|
||||
<Label>Product</Label>
|
||||
</StackLayoutItem>
|
||||
<StackLayoutItem Expand="True" HorizontalAlignment="Stretch">
|
||||
<TextBox ID="txtProduct" ReadOnly="True" />
|
||||
</StackLayoutItem>
|
||||
<StackLayoutItem>
|
||||
<Label>Version</Label>
|
||||
</StackLayoutItem>
|
||||
<StackLayoutItem HorizontalAlignment="Stretch" Expand="True">
|
||||
<TextBox ID="txtVersion" ReadOnly="True" />
|
||||
</StackLayoutItem>
|
||||
</StackLayout>
|
||||
</StackLayoutItem>
|
||||
</StackLayout>
|
||||
</Panel>
|
||||
64
pnlStrings.xeto.cs
Normal file
64
pnlStrings.xeto.cs
Normal file
@@ -0,0 +1,64 @@
|
||||
using System;
|
||||
using Eto.Forms;
|
||||
using Eto.Serialization.Xaml;
|
||||
|
||||
namespace apprepodbmgr.Eto
|
||||
{
|
||||
public class pnlStrings : Panel
|
||||
{
|
||||
public pnlStrings()
|
||||
{
|
||||
XamlReader.Load(this);
|
||||
|
||||
treeStrings.AllowMultipleSelection = false;
|
||||
treeStrings.ShowHeader = false;
|
||||
treeStrings.Columns.Add(new GridColumn
|
||||
{
|
||||
DataCell = new TextBoxCell {Binding = Binding.Property<string, string>(r => r)},
|
||||
HeaderText = "String"
|
||||
});
|
||||
}
|
||||
|
||||
void OnBtnDeveloperClick(object sender, EventArgs eventArgs)
|
||||
{
|
||||
txtDeveloper.Text = "";
|
||||
if(!(treeStrings.SelectedItem is string str)) return;
|
||||
|
||||
txtDeveloper.Text = str;
|
||||
}
|
||||
|
||||
void OnBtnPublisherClick(object sender, EventArgs eventArgs)
|
||||
{
|
||||
txtPublisher.Text = "";
|
||||
if(!(treeStrings.SelectedItem is string str)) return;
|
||||
|
||||
txtPublisher.Text = str;
|
||||
}
|
||||
|
||||
void OnBtnProductClick(object sender, EventArgs eventArgs)
|
||||
{
|
||||
txtProduct.Text = "";
|
||||
if(!(treeStrings.SelectedItem is string str)) return;
|
||||
|
||||
txtProduct.Text = str;
|
||||
}
|
||||
|
||||
void OnBtnVersionClick(object sender, EventArgs eventArgs)
|
||||
{
|
||||
txtVersion.Text = "";
|
||||
if(!(treeStrings.SelectedItem is string str)) return;
|
||||
|
||||
txtVersion.Text = str;
|
||||
}
|
||||
|
||||
#region XAML UI elements
|
||||
#pragma warning disable 0649
|
||||
public TextBox txtDeveloper;
|
||||
public TextBox txtPublisher;
|
||||
public TextBox txtProduct;
|
||||
public TextBox txtVersion;
|
||||
public GridView treeStrings;
|
||||
#pragma warning restore 0649
|
||||
#endregion XAML UI elements
|
||||
}
|
||||
}
|
||||
44
pnlVersions.xeto
Normal file
44
pnlVersions.xeto
Normal file
@@ -0,0 +1,44 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Panel xmlns="http://schema.picoe.ca/eto.forms" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<StackLayout Orientation="Horizontal" VerticalContentAlignment="Stretch">
|
||||
<StackLayoutItem Expand="True" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
|
||||
<StackLayout>
|
||||
<StackLayoutItem HorizontalAlignment="Center">
|
||||
<Label>Select architectures</Label>
|
||||
</StackLayoutItem>
|
||||
<StackLayoutItem HorizontalAlignment="Center">
|
||||
<Label>(multiple selection)</Label>
|
||||
</StackLayoutItem>
|
||||
<StackLayoutItem Expand="True" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
|
||||
<GridView ID="treeArchs"/>
|
||||
</StackLayoutItem>
|
||||
</StackLayout>
|
||||
</StackLayoutItem>
|
||||
<StackLayoutItem Expand="True" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
|
||||
<StackLayout>
|
||||
<StackLayoutItem HorizontalAlignment="Center">
|
||||
<Label>Select OSes</Label>
|
||||
</StackLayoutItem>
|
||||
<StackLayoutItem HorizontalAlignment="Center">
|
||||
<Label>(multiple selection)</Label>
|
||||
</StackLayoutItem>
|
||||
<StackLayoutItem Expand="True" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
|
||||
<GridView ID="treeOs"/>
|
||||
</StackLayoutItem>
|
||||
</StackLayout>
|
||||
</StackLayoutItem>
|
||||
<StackLayoutItem Expand="True" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
|
||||
<StackLayout>
|
||||
<StackLayoutItem HorizontalAlignment="Center">
|
||||
<Label>Select version</Label>
|
||||
</StackLayoutItem>
|
||||
<StackLayoutItem HorizontalAlignment="Center">
|
||||
<Label>(single selection)</Label>
|
||||
</StackLayoutItem>
|
||||
<StackLayoutItem Expand="True" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
|
||||
<GridView ID="treeVersions"/>
|
||||
</StackLayoutItem>
|
||||
</StackLayout>
|
||||
</StackLayoutItem>
|
||||
</StackLayout>
|
||||
</Panel>
|
||||
50
pnlVersions.xeto.cs
Normal file
50
pnlVersions.xeto.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
using Eto.Forms;
|
||||
using Eto.Serialization.Xaml;
|
||||
|
||||
namespace apprepodbmgr.Eto
|
||||
{
|
||||
public class pnlVersions : Panel
|
||||
{
|
||||
public pnlVersions()
|
||||
{
|
||||
XamlReader.Load(this);
|
||||
|
||||
treeArchs.AllowMultipleSelection = true;
|
||||
treeOs.AllowMultipleSelection = true;
|
||||
treeVersions.AllowMultipleSelection = false;
|
||||
|
||||
treeArchs.ShowHeader = false;
|
||||
treeOs.ShowHeader = true;
|
||||
treeVersions.ShowHeader = false;
|
||||
|
||||
treeArchs.Columns.Add(new GridColumn
|
||||
{
|
||||
DataCell = new TextBoxCell {Binding = Binding.Property<string, string>(r => r)},
|
||||
HeaderText = "Arch"
|
||||
});
|
||||
treeOs.Columns.Add(new GridColumn
|
||||
{
|
||||
DataCell = new TextBoxCell {Binding = Binding.Property<TargetOsEntry, string>(r => r.name)},
|
||||
HeaderText = "Name"
|
||||
});
|
||||
treeOs.Columns.Add(new GridColumn
|
||||
{
|
||||
DataCell = new TextBoxCell {Binding = Binding.Property<TargetOsEntry, string>(r => r.version)},
|
||||
HeaderText = "Version"
|
||||
});
|
||||
treeVersions.Columns.Add(new GridColumn
|
||||
{
|
||||
DataCell = new TextBoxCell {Binding = Binding.Property<string, string>(r => r)},
|
||||
HeaderText = "Version"
|
||||
});
|
||||
}
|
||||
|
||||
#region XAML UI elements
|
||||
#pragma warning disable 0649
|
||||
public GridView treeArchs;
|
||||
public GridView treeOs;
|
||||
public GridView treeVersions;
|
||||
#pragma warning restore 0649
|
||||
#endregion XAML UI elements
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user