Change system tabs to required operating systems tab in metadata dialog.

This commit is contained in:
2018-03-16 15:44:58 +00:00
parent 1d05a81d2d
commit 700814600c
3 changed files with 133 additions and 82 deletions

View File

@@ -160,4 +160,10 @@ namespace apprepodbmgr.Eto
public string path { get; set; }
public BlockMediaType disk { get; set; }
}
class TargetOsEntry
{
public string name { get; set; }
public string version { get; set; }
}
}

View File

@@ -80,6 +80,31 @@
</StackLayoutItem>
</StackLayout>
</TabPage>
<TabPage Text="Required operating systems" ID="tabTargetOs">
<StackLayout Orientation="Vertical">
<StackLayoutItem HorizontalAlignment="Stretch">
<StackLayout Orientation="Horizontal">
<Label>New operating system:</Label>
<StackLayoutItem Expand="True" HorizontalAlignment="Stretch">
<TextBox ID="txtNewOsName" />
</StackLayoutItem>
<Label>version:</Label>
<StackLayoutItem Expand="True" HorizontalAlignment="Stretch">
<TextBox ID="txtNewOsVersion" />
</StackLayoutItem>
<Button ID="btnAddNewOs" Click="OnBtnAddNewOsClicked">Add</Button>
</StackLayout>
</StackLayoutItem>
<StackLayoutItem HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Expand="True">
<GridView ID="treeOses">
</GridView>
</StackLayoutItem>
<StackLayout Orientation="Horizontal">
<Button ID="btnClearOses" Click="OnBtnClearOsesClicked">Clear</Button>
<Button ID="btnRemoveRemoveOs" Click="OnBtnRemoveOsClicked">Remove</Button>
</StackLayout>
</StackLayout>
</TabPage>
<TabPage Text="Keywords" ID="tabKeywords">
<StackLayout Orientation="Vertical">
<StackLayoutItem HorizontalAlignment="Stretch">
@@ -191,27 +216,6 @@
</StackLayout>
</StackLayout>
</TabPage>
<TabPage Text="Systems" ID="tabSystems">
<StackLayout Orientation="Vertical">
<StackLayoutItem HorizontalAlignment="Stretch">
<StackLayout Orientation="Horizontal">
<Label>New system:</Label>
<StackLayoutItem Expand="True" HorizontalAlignment="Stretch">
<TextBox ID="txtNewSystem" />
</StackLayoutItem>
<Button ID="btnAddSystem" Click="OnBtnAddSystemClicked">Add</Button>
</StackLayout>
</StackLayoutItem>
<StackLayoutItem HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Expand="True">
<GridView ID="treeSystems">
</GridView>
</StackLayoutItem>
<StackLayout Orientation="Horizontal">
<Button ID="btnClearSystems" Click="OnBtnClearSystemsClicked">Clear</Button>
<Button ID="btnRemoveSystem" Click="OnBtnRemoveSystemClicked">Remove</Button>
</StackLayout>
</StackLayout>
</TabPage>
<TabPage Text="Architectures" ID="tabArchitectures">
<StackLayout Orientation="Vertical">
<StackLayoutItem HorizontalAlignment="Stretch">

View File

@@ -58,8 +58,8 @@ namespace apprepodbmgr.Eto
ObservableCollection<StringEntry> lstKeywords;
ObservableCollection<StringEntry> lstLanguages;
ObservableCollection<string> lstLanguageTypes;
ObservableCollection<TargetOsEntry> lstOses;
ObservableCollection<StringEntry> lstSubcategories;
ObservableCollection<StringEntry> lstSystems;
// TODO: Add the options to edit these fields
MagazineType[] magazines;
@@ -67,7 +67,6 @@ namespace apprepodbmgr.Eto
public bool Modified;
PCIType[] pcis;
RequiredOperatingSystemType[] requiredOses;
bool stopped;
Thread thdDisc;
@@ -88,7 +87,7 @@ namespace apprepodbmgr.Eto
lstCategories = new ObservableCollection<StringEntry>();
lstSubcategories = new ObservableCollection<StringEntry>();
lstLanguages = new ObservableCollection<StringEntry>();
lstSystems = new ObservableCollection<StringEntry>();
lstOses = new ObservableCollection<TargetOsEntry>();
lstArchitectures = new ObservableCollection<StringEntry>();
lstDiscs = new ObservableCollection<DiscEntry>();
lstDisks = new ObservableCollection<DiskEntry>();
@@ -126,10 +125,15 @@ namespace apprepodbmgr.Eto
DataCell = new TextBoxCell {Binding = Binding.Property<StringEntry, string>(r => r.str)},
HeaderText = "Language"
});
treeSystems.Columns.Add(new GridColumn
treeOses.Columns.Add(new GridColumn
{
DataCell = new TextBoxCell {Binding = Binding.Property<StringEntry, string>(r => r.str)},
HeaderText = "System"
DataCell = new TextBoxCell {Binding = Binding.Property<TargetOsEntry, string>(r => r.name)},
HeaderText = "Name"
});
treeOses.Columns.Add(new GridColumn
{
DataCell = new TextBoxCell {Binding = Binding.Property<TargetOsEntry, string>(r => r.version)},
HeaderText = "Version"
});
treeArchitectures.Columns.Add(new GridColumn
{
@@ -152,7 +156,7 @@ namespace apprepodbmgr.Eto
treeCategories.DataStore = lstCategories;
treeSubcategories.DataStore = lstSubcategories;
treeLanguages.DataStore = lstLanguages;
treeSystems.DataStore = lstSystems;
treeOses.DataStore = lstOses;
treeArchitectures.DataStore = lstArchitectures;
treeDiscs.DataStore = lstDiscs;
treeDisks.DataStore = lstDisks;
@@ -162,7 +166,7 @@ namespace apprepodbmgr.Eto
treeCategories.AllowMultipleSelection = false;
treeSubcategories.AllowMultipleSelection = false;
treeLanguages.AllowMultipleSelection = false;
treeSystems.AllowMultipleSelection = false;
treeOses.AllowMultipleSelection = false;
treeArchitectures.AllowMultipleSelection = false;
treeDiscs.AllowMultipleSelection = false;
treeDisks.AllowMultipleSelection = false;
@@ -289,9 +293,10 @@ namespace apprepodbmgr.Eto
lstLanguageTypes.Remove(language.ToString());
}
if(Metadata.Systems != null)
foreach(string system in Metadata.Systems)
lstSystems.Add(new StringEntry {str = system});
if(Metadata.RequiredOperatingSystems != null)
foreach(RequiredOperatingSystemType reqos in Metadata.RequiredOperatingSystems)
foreach(string reqver in reqos.Version)
lstOses.Add(new TargetOsEntry {name = reqos.Name, version = reqver});
if(Metadata.Architectures != null)
foreach(ArchitecturesTypeArchitecture architecture in Metadata.Architectures)
@@ -372,7 +377,6 @@ namespace apprepodbmgr.Eto
magazines = Metadata.Magazine;
books = Metadata.Book;
requiredOses = Metadata.RequiredOperatingSystems;
usermanuals = Metadata.UserManual;
adverts = Metadata.Advertisement;
linearmedias = Metadata.LinearMedia;
@@ -483,20 +487,33 @@ namespace apprepodbmgr.Eto
FillLanguagesCombo();
}
protected void OnBtnAddSystemClicked(object sender, EventArgs e)
protected void OnBtnAddNewOsClicked(object sender, EventArgs e)
{
lstSystems.Add(new StringEntry {str = txtNewSystem.Text});
txtNewSystem.Text = "";
if(string.IsNullOrWhiteSpace(txtNewOsName.Text))
{
MessageBox.Show("Operating system name cannot be empty.", MessageBoxType.Error);
return;
}
protected void OnBtnClearSystemsClicked(object sender, EventArgs e)
if(string.IsNullOrWhiteSpace(txtNewOsVersion.Text))
{
lstSystems.Clear();
MessageBox.Show("Operating system version cannot be empty.", MessageBoxType.Error);
return;
}
protected void OnBtnRemoveSystemClicked(object sender, EventArgs e)
lstOses.Add(new TargetOsEntry {name = txtNewOsName.Text, version = txtNewOsVersion.Text});
txtNewOsName.Text = "";
txtNewOsVersion.Text = "";
}
protected void OnBtnClearOsesClicked(object sender, EventArgs e)
{
if(treeSystems.SelectedItem != null) lstSystems.Remove((StringEntry)treeSystems.SelectedItem);
lstOses.Clear();
}
protected void OnBtnRemoveOsClicked(object sender, EventArgs e)
{
if(treeOses.SelectedItem != null) lstOses.Remove((TargetOsEntry)treeOses.SelectedItem);
}
protected void OnBtnAddArchitectureClicked(object sender, EventArgs e)
@@ -529,7 +546,7 @@ namespace apprepodbmgr.Eto
tabBarcodes.Visible = false;
tabCategories.Visible = false;
tabLanguages.Visible = false;
tabSystems.Visible = false;
tabTargetOs.Visible = false;
tabArchitectures.Visible = false;
tabDisks.Visible = false;
prgAddDisc1.Visible = true;
@@ -616,7 +633,7 @@ namespace apprepodbmgr.Eto
tabBarcodes.Visible = true;
tabCategories.Visible = true;
tabLanguages.Visible = true;
tabSystems.Visible = true;
tabTargetOs.Visible = true;
tabArchitectures.Visible = true;
tabDisks.Visible = true;
prgAddDisc1.Visible = false;
@@ -678,7 +695,7 @@ namespace apprepodbmgr.Eto
tabBarcodes.Visible = true;
tabCategories.Visible = true;
tabLanguages.Visible = true;
tabSystems.Visible = true;
tabTargetOs.Visible = true;
tabArchitectures.Visible = true;
tabDisks.Visible = true;
prgAddDisc1.Visible = false;
@@ -724,7 +741,7 @@ namespace apprepodbmgr.Eto
tabBarcodes.Visible = false;
tabCategories.Visible = false;
tabLanguages.Visible = false;
tabSystems.Visible = false;
tabTargetOs.Visible = false;
tabArchitectures.Visible = false;
tabDiscs.Visible = false;
prgAddDisk1.Visible = true;
@@ -811,7 +828,7 @@ namespace apprepodbmgr.Eto
tabBarcodes.Visible = true;
tabCategories.Visible = true;
tabLanguages.Visible = true;
tabSystems.Visible = true;
tabTargetOs.Visible = true;
tabArchitectures.Visible = true;
tabDiscs.Visible = true;
prgAddDisk1.Visible = false;
@@ -877,7 +894,7 @@ namespace apprepodbmgr.Eto
tabBarcodes.Visible = true;
tabCategories.Visible = true;
tabLanguages.Visible = true;
tabSystems.Visible = true;
tabTargetOs.Visible = true;
tabArchitectures.Visible = true;
tabDiscs.Visible = true;
prgAddDisk1.Visible = false;
@@ -977,7 +994,31 @@ namespace apprepodbmgr.Eto
foreach(StringEntry entry in lstSubcategories) subcategories.Add(entry.str);
foreach(StringEntry entry in lstSystems) systems.Add(entry.str);
if(lstOses.Count > 0)
{
Dictionary<string, List<string>> osesDict = new Dictionary<string, List<string>>();
foreach(TargetOsEntry entry in lstOses.OrderBy(t => t.name).ThenBy(t => t.version))
{
osesDict.TryGetValue(entry.name, out List<string> versList);
if(versList == null) versList = new List<string>();
if(versList.Contains(entry.version)) continue;
versList.Add(entry.version);
versList.Sort();
osesDict.Remove(entry.name);
osesDict.Add(entry.name, versList);
}
Metadata.RequiredOperatingSystems = osesDict
.OrderBy(t => t.Key)
.Select(entry => new RequiredOperatingSystemType
{
Name = entry.Key,
Version = entry.Value.ToArray()
}).ToArray();
}
if(architectures.Count > 0) Metadata.Architectures = architectures.ToArray();
if(barcodes.Count > 0) Metadata.Barcodes = barcodes.ToArray();
@@ -991,7 +1032,6 @@ namespace apprepodbmgr.Eto
Metadata.Magazine = magazines;
Metadata.Book = books;
Metadata.RequiredOperatingSystems = requiredOses;
Metadata.UserManual = usermanuals;
Metadata.Advertisement = adverts;
Metadata.LinearMedia = linearmedias;
@@ -1069,9 +1109,10 @@ namespace apprepodbmgr.Eto
TabPage tabLanguages;
ComboBox cmbLanguages;
GridView treeLanguages;
TabPage tabSystems;
TextBox txtNewSystem;
GridView treeSystems;
TabPage tabTargetOs;
TextBox txtNewOsName;
TextBox txtNewOsVersion;
GridView treeOses;
TabPage tabArchitectures;
ComboBox cmbArchitectures;
GridView treeArchitectures;