2017-05-17 05:12:57 +01:00
//
2017-05-15 07:30:27 +01:00
// Author:
// Natalia Portillo claunia@claunia.com
//
// Copyright (c) 2017, © Claunia.com
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in
// the documentation and/or other materials provided with the distribution.
// * Neither the name of the [ORGANIZATION] nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
2017-12-30 00:32:21 +00:00
2017-05-15 07:30:27 +01:00
using System ;
using System.Collections.Generic ;
2017-05-15 07:33:13 +01:00
using System.Collections.ObjectModel ;
2017-12-30 00:32:21 +00:00
using System.Linq ;
2017-05-15 07:33:13 +01:00
using System.Threading ;
2018-02-23 02:14:58 +00:00
using apprepodbmgr.Core ;
2017-05-15 07:30:27 +01:00
using Eto.Forms ;
using Eto.Serialization.Xaml ;
2017-05-15 07:33:13 +01:00
using Schemas ;
2017-12-30 00:32:21 +00:00
using BorderType = Schemas . BorderType ;
2017-05-15 07:30:27 +01:00
2018-02-23 02:14:58 +00:00
namespace apprepodbmgr.Eto
2017-05-15 07:30:27 +01:00
{
2017-05-15 07:33:13 +01:00
public class dlgMetadata : Dialog
2017-05-15 07:30:27 +01:00
{
2020-08-22 21:37:02 +01:00
AdvertisementType [ ] adverts ;
AudioMediaType [ ] audiomedias ;
BookType [ ] books ;
LinearMediaType [ ] linearmedias ;
readonly ObservableCollection < StringEntry > lstArchitectures ;
readonly ObservableCollection < string > lstArchitecturesTypes ;
readonly ObservableCollection < BarcodeEntry > lstBarcodes ;
readonly ObservableCollection < string > lstBarcodeTypes ;
readonly ObservableCollection < StringEntry > lstCategories ;
readonly ObservableCollection < DiscEntry > lstDiscs ;
readonly ObservableCollection < DiskEntry > lstDisks ;
readonly ObservableCollection < string > lstFilesForMedia ;
readonly ObservableCollection < StringEntry > lstKeywords ;
readonly ObservableCollection < StringEntry > lstLanguages ;
readonly ObservableCollection < string > lstLanguageTypes ;
readonly ObservableCollection < TargetOsEntry > lstOses ;
readonly ObservableCollection < StringEntry > lstSubcategories ;
2017-05-15 07:33:13 +01:00
2017-09-30 17:47:54 +01:00
// TODO: Add the options to edit these fields
2017-12-30 00:32:21 +00:00
MagazineType [ ] magazines ;
public CICMMetadataType Metadata ;
2017-09-30 17:47:54 +01:00
2018-03-16 15:44:58 +00:00
public bool Modified ;
PCIType [ ] pcis ;
bool stopped ;
2017-05-15 07:33:13 +01:00
2017-12-30 00:32:21 +00:00
Thread thdDisc ;
Thread thdDisk ;
UserManualType [ ] usermanuals ;
2017-05-15 07:33:13 +01:00
2017-05-15 07:30:27 +01:00
public dlgMetadata ( )
{
XamlReader . Load ( this ) ;
2017-05-15 07:33:13 +01:00
Modified = false ;
2018-03-16 15:44:58 +00:00
cmbReleaseType = new EnumDropDown < CICMMetadataTypeReleaseType > ( ) ;
2020-08-22 21:37:02 +01:00
stkReleaseType . Items . Add ( new StackLayoutItem
{
Control = cmbReleaseType ,
Expand = true
} ) ;
2017-05-15 07:33:13 +01:00
2017-12-30 00:32:21 +00:00
lstKeywords = new ObservableCollection < StringEntry > ( ) ;
lstBarcodes = new ObservableCollection < BarcodeEntry > ( ) ;
lstCategories = new ObservableCollection < StringEntry > ( ) ;
2017-05-15 07:33:13 +01:00
lstSubcategories = new ObservableCollection < StringEntry > ( ) ;
2017-12-30 00:32:21 +00:00
lstLanguages = new ObservableCollection < StringEntry > ( ) ;
2018-03-16 15:44:58 +00:00
lstOses = new ObservableCollection < TargetOsEntry > ( ) ;
2017-05-15 07:33:13 +01:00
lstArchitectures = new ObservableCollection < StringEntry > ( ) ;
2017-12-30 00:32:21 +00:00
lstDiscs = new ObservableCollection < DiscEntry > ( ) ;
lstDisks = new ObservableCollection < DiskEntry > ( ) ;
2017-05-15 07:33:13 +01:00
treeKeywords . Columns . Add ( new GridColumn
{
2020-08-22 21:37:02 +01:00
DataCell = new TextBoxCell
{
Binding = Binding . Property < StringEntry , string > ( r = > r . str )
} ,
2017-05-15 07:33:13 +01:00
HeaderText = "Keyword"
} ) ;
2020-08-22 21:37:02 +01:00
2017-05-15 07:33:13 +01:00
treeBarcodes . Columns . Add ( new GridColumn
{
2020-08-22 21:37:02 +01:00
DataCell = new TextBoxCell
{
Binding = Binding . Property < BarcodeEntry , string > ( r = > r . code )
} ,
2017-05-15 07:33:13 +01:00
HeaderText = "Barcode"
} ) ;
2020-08-22 21:37:02 +01:00
2017-05-15 07:33:13 +01:00
treeBarcodes . Columns . Add ( new GridColumn
{
2017-12-30 00:32:21 +00:00
DataCell = new TextBoxCell
{
Binding = Binding . Property < BarcodeEntry , BarcodeTypeType > ( r = > r . type ) . Convert ( v = > v . ToString ( ) )
} ,
2017-05-15 07:33:13 +01:00
HeaderText = "Type"
} ) ;
2020-08-22 21:37:02 +01:00
2017-05-15 07:33:13 +01:00
treeCategories . Columns . Add ( new GridColumn
{
2020-08-22 21:37:02 +01:00
DataCell = new TextBoxCell
{
Binding = Binding . Property < StringEntry , string > ( r = > r . str )
} ,
2017-05-15 07:33:13 +01:00
HeaderText = "Category"
} ) ;
2020-08-22 21:37:02 +01:00
2017-05-15 07:33:13 +01:00
treeSubcategories . Columns . Add ( new GridColumn
{
2020-08-22 21:37:02 +01:00
DataCell = new TextBoxCell
{
Binding = Binding . Property < StringEntry , string > ( r = > r . str )
} ,
2017-05-15 07:33:13 +01:00
HeaderText = "Subcategory"
} ) ;
2020-08-22 21:37:02 +01:00
2017-05-15 07:33:13 +01:00
treeLanguages . Columns . Add ( new GridColumn
{
2020-08-22 21:37:02 +01:00
DataCell = new TextBoxCell
{
Binding = Binding . Property < StringEntry , string > ( r = > r . str )
} ,
2017-05-15 07:33:13 +01:00
HeaderText = "Language"
} ) ;
2020-08-22 21:37:02 +01:00
2018-03-16 15:44:58 +00:00
treeOses . Columns . Add ( new GridColumn
2017-05-15 07:33:13 +01:00
{
2020-08-22 21:37:02 +01:00
DataCell = new TextBoxCell
{
Binding = Binding . Property < TargetOsEntry , string > ( r = > r . name )
} ,
2018-03-16 15:44:58 +00:00
HeaderText = "Name"
} ) ;
2020-08-22 21:37:02 +01:00
2018-03-16 15:44:58 +00:00
treeOses . Columns . Add ( new GridColumn
{
2020-08-22 21:37:02 +01:00
DataCell = new TextBoxCell
{
Binding = Binding . Property < TargetOsEntry , string > ( r = > r . version )
} ,
2018-03-16 15:44:58 +00:00
HeaderText = "Version"
2017-05-15 07:33:13 +01:00
} ) ;
2020-08-22 21:37:02 +01:00
2017-05-15 07:33:13 +01:00
treeArchitectures . Columns . Add ( new GridColumn
{
2020-08-22 21:37:02 +01:00
DataCell = new TextBoxCell
{
Binding = Binding . Property < StringEntry , string > ( r = > r . str )
} ,
2017-05-15 07:33:13 +01:00
HeaderText = "Architecture"
} ) ;
2020-08-22 21:37:02 +01:00
2017-05-15 07:33:13 +01:00
treeDiscs . Columns . Add ( new GridColumn
{
2020-08-22 21:37:02 +01:00
DataCell = new TextBoxCell
{
Binding = Binding . Property < DiscEntry , string > ( r = > r . path )
} ,
2017-05-15 07:33:13 +01:00
HeaderText = "File"
} ) ;
2020-08-22 21:37:02 +01:00
2017-05-15 07:33:13 +01:00
treeDisks . Columns . Add ( new GridColumn
{
2020-08-22 21:37:02 +01:00
DataCell = new TextBoxCell
{
Binding = Binding . Property < DiskEntry , string > ( r = > r . path )
} ,
2017-05-15 07:33:13 +01:00
HeaderText = "File"
} ) ;
2017-12-30 00:32:21 +00:00
treeKeywords . DataStore = lstKeywords ;
treeBarcodes . DataStore = lstBarcodes ;
treeCategories . DataStore = lstCategories ;
2017-05-15 07:33:13 +01:00
treeSubcategories . DataStore = lstSubcategories ;
2017-12-30 00:32:21 +00:00
treeLanguages . DataStore = lstLanguages ;
2018-03-16 15:44:58 +00:00
treeOses . DataStore = lstOses ;
2017-05-15 07:33:13 +01:00
treeArchitectures . DataStore = lstArchitectures ;
2017-12-30 00:32:21 +00:00
treeDiscs . DataStore = lstDiscs ;
treeDisks . DataStore = lstDisks ;
2017-05-15 07:33:13 +01:00
2017-12-30 00:32:21 +00:00
treeKeywords . AllowMultipleSelection = false ;
treeBarcodes . AllowMultipleSelection = false ;
treeCategories . AllowMultipleSelection = false ;
2017-05-15 07:33:13 +01:00
treeSubcategories . AllowMultipleSelection = false ;
2017-12-30 00:32:21 +00:00
treeLanguages . AllowMultipleSelection = false ;
2018-03-16 15:44:58 +00:00
treeOses . AllowMultipleSelection = false ;
2017-05-15 07:33:13 +01:00
treeArchitectures . AllowMultipleSelection = false ;
2017-12-30 00:32:21 +00:00
treeDiscs . AllowMultipleSelection = false ;
treeDisks . AllowMultipleSelection = false ;
2017-05-15 07:33:13 +01:00
2017-12-30 00:32:21 +00:00
lstBarcodeTypes = new ObservableCollection < string > ( ) ;
lstLanguageTypes = new ObservableCollection < string > ( ) ;
2017-05-15 07:33:13 +01:00
lstArchitecturesTypes = new ObservableCollection < string > ( ) ;
2017-12-30 00:32:21 +00:00
lstFilesForMedia = new ObservableCollection < string > ( ) ;
2017-05-15 07:33:13 +01:00
//cmbBarcodes.ItemTextBinding = Binding.Property<StringEntry, string>(r => r.str);
2017-12-30 00:32:21 +00:00
cmbBarcodes . DataStore = lstBarcodeTypes ;
cmbLanguages . DataStore = lstLanguageTypes ;
cmbArchitectures . DataStore = lstArchitecturesTypes ;
2017-05-15 07:33:13 +01:00
cmbFilesForNewDisc . DataStore = lstFilesForMedia ;
cmbFilesForNewDisk . DataStore = lstFilesForMedia ;
FillBarcodeCombo ( ) ;
FillLanguagesCombo ( ) ;
FillArchitecturesCombo ( ) ;
FillFilesCombos ( ) ;
2018-03-15 17:30:13 +00:00
txtDeveloper . ToolTip = "Who developed the application." ;
txtPublisher . ToolTip = "Who published the application." ;
txtAuthor . ToolTip = "Author of the audiovisual media." ;
txtPerformer . ToolTip = "Performer of the audiovisual media." ;
txtName . ToolTip = "Application name." ;
txtVersion . ToolTip = "Application version." ;
txtPartNumber . ToolTip = "Part number of the application distribution." ;
2020-08-22 21:37:02 +01:00
2018-03-15 17:30:13 +00:00
txtSerialNumber . ToolTip =
"Serial number of the application distribution. Not to be confused with serial number required to install." ;
2017-05-15 07:33:13 +01:00
}
void FillBarcodeCombo ( )
{
lstBarcodeTypes . Clear ( ) ;
2020-08-22 21:37:02 +01:00
2017-05-15 07:33:13 +01:00
foreach ( BarcodeTypeType type in Enum . GetValues ( typeof ( BarcodeTypeType ) ) )
lstBarcodeTypes . Add ( type . ToString ( ) ) ;
}
void FillLanguagesCombo ( )
{
lstLanguageTypes . Clear ( ) ;
2020-08-22 21:37:02 +01:00
2017-05-15 07:33:13 +01:00
foreach ( LanguagesTypeLanguage type in Enum . GetValues ( typeof ( LanguagesTypeLanguage ) ) )
lstLanguageTypes . Add ( type . ToString ( ) ) ;
}
void FillArchitecturesCombo ( )
{
lstArchitecturesTypes . Clear ( ) ;
2020-08-22 21:37:02 +01:00
2017-05-15 07:33:13 +01:00
foreach ( ArchitecturesTypeArchitecture type in Enum . GetValues ( typeof ( ArchitecturesTypeArchitecture ) ) )
lstArchitecturesTypes . Add ( type . ToString ( ) ) ;
}
void FillFilesCombos ( )
{
2020-08-22 21:37:02 +01:00
foreach ( KeyValuePair < string , DbAppFile > files in Context . Hashes )
lstFilesForMedia . Add ( files . Key ) ;
2017-05-15 07:33:13 +01:00
}
public void FillFields ( )
{
2020-08-22 21:37:02 +01:00
if ( Metadata = = null )
return ;
2017-05-15 07:33:13 +01:00
if ( Metadata . Developer ! = null )
foreach ( string developer in Metadata . Developer )
{
2020-08-22 21:37:02 +01:00
if ( ! string . IsNullOrWhiteSpace ( txtDeveloper . Text ) )
txtDeveloper . Text + = "," ;
2018-03-16 15:44:58 +00:00
txtDeveloper . Text + = developer ;
2017-05-15 07:33:13 +01:00
}
if ( Metadata . Publisher ! = null )
foreach ( string publisher in Metadata . Publisher )
{
2020-08-22 21:37:02 +01:00
if ( ! string . IsNullOrWhiteSpace ( txtPublisher . Text ) )
txtPublisher . Text + = "," ;
2018-03-16 15:44:58 +00:00
txtPublisher . Text + = publisher ;
2017-05-15 07:33:13 +01:00
}
if ( Metadata . Author ! = null )
foreach ( string author in Metadata . Author )
{
2020-08-22 21:37:02 +01:00
if ( ! string . IsNullOrWhiteSpace ( txtPublisher . Text ) )
txtPublisher . Text + = "," ;
2018-03-16 15:44:58 +00:00
txtPublisher . Text + = author ;
2017-05-15 07:33:13 +01:00
}
if ( Metadata . Performer ! = null )
foreach ( string performer in Metadata . Performer )
{
2020-08-22 21:37:02 +01:00
if ( ! string . IsNullOrWhiteSpace ( txtPublisher . Text ) )
txtPublisher . Text + = "," ;
2018-03-16 15:44:58 +00:00
txtPublisher . Text + = performer ;
2017-05-15 07:33:13 +01:00
}
2017-12-30 00:32:21 +00:00
txtName . Text = Metadata . Name ;
txtVersion . Text = Metadata . Version ;
txtPartNumber . Text = Metadata . PartNumber ;
2017-05-15 07:33:13 +01:00
txtSerialNumber . Text = Metadata . SerialNumber ;
if ( Metadata . ReleaseTypeSpecified )
{
2017-12-30 00:32:21 +00:00
chkKnownReleaseType . Checked = true ;
cmbReleaseType . Enabled = true ;
2017-05-15 07:33:13 +01:00
cmbReleaseType . SelectedValue = Metadata . ReleaseType ;
}
if ( Metadata . ReleaseDateSpecified )
{
chkReleaseDate . Checked = false ;
cldReleaseDate . Enabled = true ;
2017-12-30 00:32:21 +00:00
cldReleaseDate . Value = Metadata . ReleaseDate ;
2017-05-15 07:33:13 +01:00
}
if ( Metadata . Keywords ! = null )
foreach ( string keyword in Metadata . Keywords )
2020-08-22 21:37:02 +01:00
lstKeywords . Add ( new StringEntry
{
str = keyword
} ) ;
2017-05-15 07:33:13 +01:00
if ( Metadata . Categories ! = null )
foreach ( string category in Metadata . Categories )
2020-08-22 21:37:02 +01:00
lstCategories . Add ( new StringEntry
{
str = category
} ) ;
2017-05-15 07:33:13 +01:00
if ( Metadata . Subcategories ! = null )
foreach ( string subcategory in Metadata . Subcategories )
2020-08-22 21:37:02 +01:00
lstSubcategories . Add ( new StringEntry
{
str = subcategory
} ) ;
2017-05-15 07:33:13 +01:00
if ( Metadata . Languages ! = null )
foreach ( LanguagesTypeLanguage language in Metadata . Languages )
{
2020-08-22 21:37:02 +01:00
lstLanguages . Add ( new StringEntry
{
str = language . ToString ( )
} ) ;
2017-05-15 07:33:13 +01:00
lstLanguageTypes . Remove ( language . ToString ( ) ) ;
}
2018-03-16 15:44:58 +00:00
if ( Metadata . RequiredOperatingSystems ! = null )
foreach ( RequiredOperatingSystemType reqos in Metadata . RequiredOperatingSystems )
foreach ( string reqver in reqos . Version )
2020-08-22 21:37:02 +01:00
lstOses . Add ( new TargetOsEntry
{
name = reqos . Name ,
version = reqver
} ) ;
2017-05-15 07:33:13 +01:00
if ( Metadata . Architectures ! = null )
foreach ( ArchitecturesTypeArchitecture architecture in Metadata . Architectures )
{
2020-08-22 21:37:02 +01:00
lstArchitectures . Add ( new StringEntry
{
str = architecture . ToString ( )
} ) ;
2017-05-15 07:33:13 +01:00
lstArchitecturesTypes . Remove ( architecture . ToString ( ) ) ;
}
if ( Metadata . OpticalDisc ! = null )
foreach ( OpticalDiscType disc in Metadata . OpticalDisc )
{
2020-08-22 21:37:02 +01:00
lstDiscs . Add ( new DiscEntry
{
path = disc . Image . Value ,
disc = disc
} ) ;
List < string > files = new List < string >
{
disc . Image . Value
} ;
if ( disc . ADIP ! = null )
files . Add ( disc . ADIP . Image ) ;
if ( disc . ATIP ! = null )
files . Add ( disc . ATIP . Image ) ;
if ( disc . BCA ! = null )
files . Add ( disc . BCA . Image ) ;
if ( disc . CMI ! = null )
files . Add ( disc . CMI . Image ) ;
if ( disc . DCB ! = null )
files . Add ( disc . DCB . Image ) ;
if ( disc . DDS ! = null )
files . Add ( disc . DDS . Image ) ;
if ( disc . DMI ! = null )
files . Add ( disc . DMI . Image ) ;
if ( disc . LastRMD ! = null )
files . Add ( disc . LastRMD . Image ) ;
2018-03-16 15:44:58 +00:00
if ( disc . LeadIn ! = null )
2017-12-30 00:32:21 +00:00
foreach ( BorderType border in disc . LeadIn )
2017-05-15 07:33:13 +01:00
files . Add ( border . Image ) ;
2020-08-22 21:37:02 +01:00
if ( disc . LeadInCdText ! = null )
files . Add ( disc . LeadInCdText . Image ) ;
2018-03-16 15:44:58 +00:00
if ( disc . LeadOut ! = null )
2017-12-30 00:32:21 +00:00
foreach ( BorderType border in disc . LeadOut )
2017-05-15 07:33:13 +01:00
files . Add ( border . Image ) ;
2020-08-22 21:37:02 +01:00
if ( disc . MediaID ! = null )
files . Add ( disc . MediaID . Image ) ;
if ( disc . PAC ! = null )
files . Add ( disc . PAC . Image ) ;
if ( disc . PFI ! = null )
files . Add ( disc . PFI . Image ) ;
if ( disc . PFIR ! = null )
files . Add ( disc . PFIR . Image ) ;
if ( disc . PMA ! = null )
files . Add ( disc . PMA . Image ) ;
if ( disc . PRI ! = null )
files . Add ( disc . PRI . Image ) ;
if ( disc . SAI ! = null )
files . Add ( disc . SAI . Image ) ;
if ( disc . TOC ! = null )
files . Add ( disc . TOC . Image ) ;
if ( disc . Track ! = null )
files . AddRange ( disc . Track . Select ( track = > track . Image . Value ) ) ;
2017-05-15 07:33:13 +01:00
foreach ( string file in files )
if ( lstFilesForMedia . Contains ( file ) )
lstFilesForMedia . Remove ( file ) ;
}
if ( Metadata . BlockMedia ! = null )
foreach ( BlockMediaType disk in Metadata . BlockMedia )
{
2020-08-22 21:37:02 +01:00
lstDisks . Add ( new DiskEntry
{
path = disk . Image . Value ,
disk = disk
} ) ;
List < string > files = new List < string >
{
disk . Image . Value
} ;
if ( disk . ATA ? . Identify ! = null )
files . Add ( disk . ATA . Identify . Image ) ;
if ( disk . MAM ! = null )
files . Add ( disk . MAM . Image ) ;
if ( disk . PCI ? . ExpansionROM ! = null )
files . Add ( disk . PCI . ExpansionROM . Image . Value ) ;
if ( disk . PCMCIA ? . CIS ! = null )
files . Add ( disk . PCMCIA . CIS . Image ) ;
2018-03-16 15:44:58 +00:00
if ( disk . SCSI ! = null )
2017-05-15 07:33:13 +01:00
{
2020-08-22 21:37:02 +01:00
if ( disk . SCSI . Inquiry ! = null )
files . Add ( disk . SCSI . Inquiry . Image ) ;
if ( disk . SCSI . LogSense ! = null )
files . Add ( disk . SCSI . LogSense . Image ) ;
if ( disk . SCSI . ModeSense ! = null )
files . Add ( disk . SCSI . ModeSense . Image ) ;
if ( disk . SCSI . ModeSense10 ! = null )
files . Add ( disk . SCSI . ModeSense10 . Image ) ;
if ( disk . SCSI . EVPD ! = null )
files . AddRange ( disk . SCSI . EVPD . Select ( evpd = > evpd . Image ) ) ;
2017-05-15 07:33:13 +01:00
}
2017-12-30 00:32:21 +00:00
2017-05-15 07:33:13 +01:00
if ( disk . SecureDigital ! = null )
{
2020-08-22 21:37:02 +01:00
if ( disk . SecureDigital . CID ! = null )
files . Add ( disk . SecureDigital . CID . Image ) ;
if ( disk . SecureDigital . CSD ! = null )
files . Add ( disk . SecureDigital . CSD . Image ) ;
if ( disk . MultiMediaCard . ExtendedCSD ! = null )
files . Add ( disk . MultiMediaCard . ExtendedCSD . Image ) ;
2017-05-15 07:33:13 +01:00
}
2017-12-30 00:32:21 +00:00
2017-05-15 07:33:13 +01:00
if ( disk . TapeInformation ! = null )
2017-12-30 00:32:21 +00:00
files . AddRange ( disk . TapeInformation . Select ( tapePart = > tapePart . Image . Value ) ) ;
2020-08-22 21:37:02 +01:00
if ( disk . Track ! = null )
files . AddRange ( disk . Track . Select ( track = > track . Image . Value ) ) ;
if ( disk . USB ? . Descriptors ! = null )
files . Add ( disk . USB . Descriptors . Image ) ;
2017-05-15 07:33:13 +01:00
foreach ( string file in files )
if ( lstFilesForMedia . Contains ( file ) )
lstFilesForMedia . Remove ( file ) ;
}
2017-09-30 17:47:54 +01:00
2017-12-30 00:32:21 +00:00
magazines = Metadata . Magazine ;
books = Metadata . Book ;
usermanuals = Metadata . UserManual ;
adverts = Metadata . Advertisement ;
2017-09-30 17:47:54 +01:00
linearmedias = Metadata . LinearMedia ;
2017-12-30 00:32:21 +00:00
pcis = Metadata . PCICard ;
audiomedias = Metadata . AudioMedia ;
2017-05-15 07:33:13 +01:00
}
2020-08-22 21:37:02 +01:00
protected void OnChkKnownReleaseTypeToggled ( object sender , EventArgs e ) = >
2017-05-15 07:33:13 +01:00
cmbReleaseType . Enabled = chkKnownReleaseType . Checked . Value ;
2020-08-22 21:37:02 +01:00
protected void OnChkReleaseDateToggled ( object sender , EventArgs e ) = >
2017-05-15 07:33:13 +01:00
cldReleaseDate . Enabled = ! chkReleaseDate . Checked . Value ;
protected void OnBtnAddKeywordClicked ( object sender , EventArgs e )
{
2020-08-22 21:37:02 +01:00
lstKeywords . Add ( new StringEntry
{
str = txtNewKeyword . Text
} ) ;
2018-03-16 15:44:58 +00:00
txtNewKeyword . Text = "" ;
2017-05-15 07:33:13 +01:00
}
protected void OnBtnRemoveKeywordClicked ( object sender , EventArgs e )
{
2020-08-22 21:37:02 +01:00
if ( treeKeywords . SelectedItem ! = null )
lstKeywords . Remove ( ( StringEntry ) treeKeywords . SelectedItem ) ;
2017-05-15 07:33:13 +01:00
}
2020-08-22 21:37:02 +01:00
protected void OnBtnClearKeywordsClicked ( object sender , EventArgs e ) = > lstKeywords . Clear ( ) ;
2017-05-15 07:33:13 +01:00
protected void OnBtnAddBarcodeClicked ( object sender , EventArgs e )
{
2020-08-22 21:37:02 +01:00
if ( string . IsNullOrEmpty ( cmbBarcodes . Text ) )
return ;
2017-12-30 00:32:21 +00:00
lstBarcodes . Add ( new BarcodeEntry
2017-05-15 07:33:13 +01:00
{
2017-12-30 00:32:21 +00:00
code = txtNewBarcode . Text ,
type = ( BarcodeTypeType ) Enum . Parse ( typeof ( BarcodeTypeType ) , cmbBarcodes . Text )
} ) ;
2020-08-22 21:37:02 +01:00
2017-12-30 00:32:21 +00:00
txtNewBarcode . Text = "" ;
2017-05-15 07:33:13 +01:00
}
2020-08-22 21:37:02 +01:00
protected void OnBtnClearBarcodesClicked ( object sender , EventArgs e ) = > lstBarcodes . Clear ( ) ;
2017-05-15 07:33:13 +01:00
protected void OnBtnRemoveBarcodeClicked ( object sender , EventArgs e )
{
2020-08-22 21:37:02 +01:00
if ( treeBarcodes . SelectedItem ! = null )
lstBarcodes . Remove ( ( BarcodeEntry ) treeBarcodes . SelectedItem ) ;
2017-05-15 07:33:13 +01:00
}
protected void OnBtnAddCategoryClicked ( object sender , EventArgs e )
{
2020-08-22 21:37:02 +01:00
lstCategories . Add ( new StringEntry
{
str = txtNewCategory . Text
} ) ;
2018-03-16 15:44:58 +00:00
txtNewCategory . Text = "" ;
2017-05-15 07:33:13 +01:00
}
protected void OnBtnAddSubcategoryClicked ( object sender , EventArgs e )
{
2020-08-22 21:37:02 +01:00
lstSubcategories . Add ( new StringEntry
{
str = txtNewSubcategory . Text
} ) ;
2018-03-16 15:44:58 +00:00
txtNewSubcategory . Text = "" ;
2017-05-15 07:33:13 +01:00
}
protected void OnBtnRemoveSubcategoryClicked ( object sender , EventArgs e )
{
if ( treeSubcategories . SelectedItem ! = null )
lstSubcategories . Remove ( ( StringEntry ) treeSubcategories . SelectedItem ) ;
}
2020-08-22 21:37:02 +01:00
protected void OnBtnClearSubcategoriesClicked ( object sender , EventArgs e ) = > lstSubcategories . Clear ( ) ;
2017-05-15 07:33:13 +01:00
protected void OnBtnRemoveCategoryClicked ( object sender , EventArgs e )
{
2020-08-22 21:37:02 +01:00
if ( treeCategories . SelectedItem ! = null )
lstCategories . Remove ( ( StringEntry ) treeCategories . SelectedItem ) ;
2017-05-15 07:33:13 +01:00
}
2020-08-22 21:37:02 +01:00
protected void OnBtnClearCategoriesClicked ( object sender , EventArgs e ) = > lstCategories . Clear ( ) ;
2017-05-15 07:33:13 +01:00
protected void OnBtnAddLanguageClicked ( object sender , EventArgs e )
{
2020-08-22 21:37:02 +01:00
if ( string . IsNullOrWhiteSpace ( cmbLanguages . Text ) )
return ;
lstLanguages . Add ( new StringEntry
{
str = cmbLanguages . Text
} ) ;
2017-12-30 00:32:21 +00:00
lstLanguageTypes . Remove ( cmbLanguages . Text ) ;
2017-05-15 07:33:13 +01:00
}
protected void OnBtnRemoveLanguageClicked ( object sender , EventArgs e )
{
2020-08-22 21:37:02 +01:00
if ( treeLanguages . SelectedItem = = null )
return ;
2017-12-30 00:32:21 +00:00
lstLanguageTypes . Add ( ( ( StringEntry ) treeLanguages . SelectedItem ) . str ) ;
lstLanguages . Remove ( ( StringEntry ) treeLanguages . SelectedItem ) ;
2017-05-15 07:33:13 +01:00
}
protected void OnBtnClearLanguagesClicked ( object sender , EventArgs e )
{
lstLanguages . Clear ( ) ;
FillLanguagesCombo ( ) ;
}
2018-03-16 15:44:58 +00:00
protected void OnBtnAddNewOsClicked ( object sender , EventArgs e )
2017-05-15 07:33:13 +01:00
{
2018-03-16 15:44:58 +00:00
if ( string . IsNullOrWhiteSpace ( txtNewOsName . Text ) )
{
MessageBox . Show ( "Operating system name cannot be empty." , MessageBoxType . Error ) ;
2020-08-22 21:37:02 +01:00
2018-03-16 15:44:58 +00:00
return ;
}
if ( string . IsNullOrWhiteSpace ( txtNewOsVersion . Text ) )
{
MessageBox . Show ( "Operating system version cannot be empty." , MessageBoxType . Error ) ;
2020-08-22 21:37:02 +01:00
2018-03-16 15:44:58 +00:00
return ;
}
2020-08-22 21:37:02 +01:00
lstOses . Add ( new TargetOsEntry
{
name = txtNewOsName . Text ,
version = txtNewOsVersion . Text
} ) ;
2018-03-16 15:44:58 +00:00
txtNewOsName . Text = "" ;
txtNewOsVersion . Text = "" ;
2017-05-15 07:33:13 +01:00
}
2020-08-22 21:37:02 +01:00
protected void OnBtnClearOsesClicked ( object sender , EventArgs e ) = > lstOses . Clear ( ) ;
2017-05-15 07:33:13 +01:00
2018-03-16 15:44:58 +00:00
protected void OnBtnRemoveOsClicked ( object sender , EventArgs e )
2017-05-15 07:33:13 +01:00
{
2020-08-22 21:37:02 +01:00
if ( treeOses . SelectedItem ! = null )
lstOses . Remove ( ( TargetOsEntry ) treeOses . SelectedItem ) ;
2017-05-15 07:33:13 +01:00
}
protected void OnBtnAddArchitectureClicked ( object sender , EventArgs e )
{
2020-08-22 21:37:02 +01:00
if ( string . IsNullOrWhiteSpace ( cmbArchitectures . Text ) )
return ;
lstArchitectures . Add ( new StringEntry
{
str = cmbArchitectures . Text
} ) ;
2017-12-30 00:32:21 +00:00
lstArchitecturesTypes . Remove ( cmbArchitectures . Text ) ;
2017-05-15 07:33:13 +01:00
}
protected void OnBtnClearArchitecturesClicked ( object sender , EventArgs e )
{
lstArchitectures . Clear ( ) ;
FillArchitecturesCombo ( ) ;
}
protected void OnBtnRemoveArchitectureClicked ( object sender , EventArgs e )
{
2020-08-22 21:37:02 +01:00
if ( treeArchitectures . SelectedItem = = null )
return ;
2017-12-30 00:32:21 +00:00
lstArchitecturesTypes . Add ( ( ( StringEntry ) treeArchitectures . SelectedItem ) . str ) ;
lstArchitectures . Remove ( ( StringEntry ) treeArchitectures . SelectedItem ) ;
2017-05-15 07:33:13 +01:00
}
protected void OnBtnAddDiscClicked ( object sender , EventArgs e )
{
2017-12-30 00:32:21 +00:00
Context . SelectedFile = cmbFilesForNewDisc . Text ;
tabGeneral . Visible = false ;
tabKeywords . Visible = false ;
tabBarcodes . Visible = false ;
tabCategories . Visible = false ;
tabLanguages . Visible = false ;
2018-03-16 15:44:58 +00:00
tabTargetOs . Visible = false ;
2017-12-30 00:32:21 +00:00
tabArchitectures . Visible = false ;
tabDisks . Visible = false ;
prgAddDisc1 . Visible = true ;
prgAddDisc2 . Visible = true ;
lblAddDisc1 . Visible = true ;
lblAddDisc2 . Visible = true ;
btnCancel . Visible = false ;
btnOK . Visible = false ;
btnEditDisc . Visible = false ;
btnClearDiscs . Visible = false ;
Workers . Failed + = OnDiscAddFailed ;
Workers . Finished + = OnDiscAddFinished ;
Workers . UpdateProgress + = UpdateDiscProgress1 ;
Workers . UpdateProgress2 + = UpdateDiscProgress2 ;
Context . WorkingDisc = null ;
btnStopAddDisc . Visible = true ;
btnAddDisc . Visible = false ;
btnRemoveDisc . Visible = false ;
thdDisc = new Thread ( Workers . AddMedia ) ;
2017-05-15 07:33:13 +01:00
thdDisc . Start ( ) ;
}
protected void OnBtnStopAddDiscClicked ( object sender , EventArgs e )
{
2017-12-30 00:32:21 +00:00
thdDisc ? . Abort ( ) ;
2017-05-15 07:33:13 +01:00
stopped = true ;
OnDiscAddFailed ( null ) ;
}
2020-08-22 21:37:02 +01:00
void UpdateDiscProgress1 ( string text , string inner , long current , long maximum ) = >
2017-05-15 07:33:13 +01:00
Application . Instance . Invoke ( delegate
{
2017-12-30 00:32:21 +00:00
lblAddDisc1 . Text = ! string . IsNullOrWhiteSpace ( inner ) ? inner : text ;
2020-08-22 21:37:02 +01:00
2017-05-15 07:33:13 +01:00
if ( maximum > 0 )
{
2020-08-22 21:37:02 +01:00
if ( current < int . MinValue | |
current > int . MaxValue | |
maximum < int . MinValue | |
2017-12-30 00:32:21 +00:00
maximum > int . MaxValue )
2017-06-20 07:28:16 +01:00
{
current / = 100 ;
maximum / = 100 ;
}
2017-05-15 07:33:13 +01:00
prgAddDisc1 . Indeterminate = false ;
2017-12-30 00:32:21 +00:00
prgAddDisc1 . MinValue = 0 ;
prgAddDisc1 . MaxValue = ( int ) maximum ;
prgAddDisc1 . Value = ( int ) current ;
2017-05-15 07:33:13 +01:00
}
2020-08-22 21:37:02 +01:00
else
prgAddDisc1 . Indeterminate = true ;
2017-05-15 07:33:13 +01:00
} ) ;
2020-08-22 21:37:02 +01:00
void UpdateDiscProgress2 ( string text , string inner , long current , long maximum ) = >
2017-05-15 07:33:13 +01:00
Application . Instance . Invoke ( delegate
{
2017-12-30 00:32:21 +00:00
lblAddDisc2 . Text = ! string . IsNullOrWhiteSpace ( inner ) ? inner : text ;
2020-08-22 21:37:02 +01:00
2017-05-15 07:33:13 +01:00
if ( maximum > 0 )
{
2020-08-22 21:37:02 +01:00
if ( current < int . MinValue | |
current > int . MaxValue | |
maximum < int . MinValue | |
2017-12-30 00:32:21 +00:00
maximum > int . MaxValue )
2017-06-20 07:28:16 +01:00
{
current / = 100 ;
maximum / = 100 ;
}
2017-05-15 07:33:13 +01:00
prgAddDisc2 . Indeterminate = false ;
2017-12-30 00:32:21 +00:00
prgAddDisc2 . MinValue = 0 ;
prgAddDisc2 . MaxValue = ( int ) maximum ;
prgAddDisc2 . Value = ( int ) current ;
2017-05-15 07:33:13 +01:00
}
2020-08-22 21:37:02 +01:00
else
prgAddDisc2 . Indeterminate = true ;
2017-05-15 07:33:13 +01:00
} ) ;
2020-08-22 21:37:02 +01:00
void OnDiscAddFailed ( string text ) = > Application . Instance . Invoke ( delegate
2017-05-15 07:33:13 +01:00
{
2020-08-22 21:37:02 +01:00
if ( ! stopped )
MessageBox . Show ( text , MessageBoxType . Error ) ;
Context . SelectedFile = "" ;
tabGeneral . Visible = true ;
tabKeywords . Visible = true ;
tabBarcodes . Visible = true ;
tabCategories . Visible = true ;
tabLanguages . Visible = true ;
tabTargetOs . Visible = true ;
tabArchitectures . Visible = true ;
tabDisks . Visible = true ;
prgAddDisc1 . Visible = false ;
prgAddDisc2 . Visible = false ;
lblAddDisc1 . Visible = false ;
lblAddDisc2 . Visible = false ;
btnCancel . Visible = true ;
btnOK . Visible = true ;
btnEditDisc . Visible = true ;
btnClearDiscs . Visible = true ;
Workers . Failed - = OnDiscAddFailed ;
Workers . Finished - = OnDiscAddFinished ;
Workers . UpdateProgress - = UpdateDiscProgress1 ;
Workers . UpdateProgress2 - = UpdateDiscProgress2 ;
Context . WorkingDisc = null ;
btnStopAddDisc . Visible = false ;
btnAddDisc . Visible = true ;
btnRemoveDisc . Visible = true ;
thdDisc = null ;
} ) ;
2017-05-15 07:33:13 +01:00
2020-08-22 21:37:02 +01:00
void OnDiscAddFinished ( ) = > Application . Instance . Invoke ( delegate
2017-05-15 07:33:13 +01:00
{
2020-08-22 21:37:02 +01:00
if ( Context . WorkingDisc = = null )
return ;
OpticalDiscType disc = Context . WorkingDisc ;
lstDiscs . Add ( new DiscEntry
2017-05-15 07:33:13 +01:00
{
2020-08-22 21:37:02 +01:00
path = Context . SelectedFile ,
disc = disc
2017-05-15 07:33:13 +01:00
} ) ;
2020-08-22 21:37:02 +01:00
List < string > files = new List < string >
{
disc . Image . Value
} ;
if ( disc . ADIP ! = null )
files . Add ( disc . ADIP . Image ) ;
if ( disc . ATIP ! = null )
files . Add ( disc . ATIP . Image ) ;
if ( disc . BCA ! = null )
files . Add ( disc . BCA . Image ) ;
if ( disc . CMI ! = null )
files . Add ( disc . CMI . Image ) ;
if ( disc . DCB ! = null )
files . Add ( disc . DCB . Image ) ;
if ( disc . DDS ! = null )
files . Add ( disc . DDS . Image ) ;
if ( disc . DMI ! = null )
files . Add ( disc . DMI . Image ) ;
if ( disc . LastRMD ! = null )
files . Add ( disc . LastRMD . Image ) ;
if ( disc . LeadIn ! = null )
files . AddRange ( disc . LeadIn . Select ( border = > border . Image ) ) ;
if ( disc . LeadInCdText ! = null )
files . Add ( disc . LeadInCdText . Image ) ;
if ( disc . LeadOut ! = null )
files . AddRange ( disc . LeadOut . Select ( border = > border . Image ) ) ;
if ( disc . MediaID ! = null )
files . Add ( disc . MediaID . Image ) ;
if ( disc . PAC ! = null )
files . Add ( disc . PAC . Image ) ;
if ( disc . PFI ! = null )
files . Add ( disc . PFI . Image ) ;
if ( disc . PFIR ! = null )
files . Add ( disc . PFIR . Image ) ;
if ( disc . PMA ! = null )
files . Add ( disc . PMA . Image ) ;
if ( disc . PRI ! = null )
files . Add ( disc . PRI . Image ) ;
if ( disc . SAI ! = null )
files . Add ( disc . SAI . Image ) ;
if ( disc . TOC ! = null )
files . Add ( disc . TOC . Image ) ;
if ( disc . Track ! = null )
files . AddRange ( disc . Track . Select ( track = > track . Image . Value ) ) ;
foreach ( string file in files )
lstFilesForMedia . Remove ( file ) ;
Context . SelectedFile = "" ;
tabGeneral . Visible = true ;
tabKeywords . Visible = true ;
tabBarcodes . Visible = true ;
tabCategories . Visible = true ;
tabLanguages . Visible = true ;
tabTargetOs . Visible = true ;
tabArchitectures . Visible = true ;
tabDisks . Visible = true ;
prgAddDisc1 . Visible = false ;
prgAddDisc2 . Visible = false ;
lblAddDisc1 . Visible = false ;
lblAddDisc2 . Visible = false ;
btnCancel . Visible = true ;
btnOK . Visible = true ;
btnEditDisc . Visible = true ;
btnClearDiscs . Visible = true ;
Workers . Failed - = OnDiscAddFailed ;
Workers . Finished - = OnDiscAddFinished ;
Workers . UpdateProgress - = UpdateDiscProgress1 ;
Workers . UpdateProgress2 - = UpdateDiscProgress2 ;
Context . WorkingDisc = null ;
btnStopAddDisc . Visible = false ;
btnAddDisc . Visible = true ;
btnRemoveDisc . Visible = true ;
thdDisc = null ;
} ) ;
2017-05-15 07:33:13 +01:00
protected void OnBtnClearDiscsClicked ( object sender , EventArgs e )
{
lstDiscs . Clear ( ) ;
2020-08-22 21:37:02 +01:00
2017-05-15 07:33:13 +01:00
// TODO: Don't add files that are in disks
FillFilesCombos ( ) ;
}
protected void OnBtnRemoveDiscClicked ( object sender , EventArgs e )
{
2020-08-22 21:37:02 +01:00
if ( treeDiscs . SelectedItem = = null )
return ;
2017-12-30 00:32:21 +00:00
lstFilesForMedia . Add ( ( ( DiscEntry ) treeDiscs . SelectedItem ) . path ) ;
lstDiscs . Remove ( ( DiscEntry ) treeDiscs . SelectedItem ) ;
2017-05-15 07:33:13 +01:00
}
protected void OnBtnAddDiskClicked ( object sender , EventArgs e )
{
2017-12-30 00:32:21 +00:00
Context . SelectedFile = cmbFilesForNewDisk . Text ;
tabGeneral . Visible = false ;
tabKeywords . Visible = false ;
tabBarcodes . Visible = false ;
tabCategories . Visible = false ;
tabLanguages . Visible = false ;
2018-03-16 15:44:58 +00:00
tabTargetOs . Visible = false ;
2017-12-30 00:32:21 +00:00
tabArchitectures . Visible = false ;
tabDiscs . Visible = false ;
prgAddDisk1 . Visible = true ;
prgAddDisk2 . Visible = true ;
lblAddDisk1 . Visible = true ;
lblAddDisk2 . Visible = true ;
btnCancel . Visible = false ;
btnOK . Visible = false ;
btnEditDisk . Visible = false ;
btnClearDisks . Visible = false ;
Workers . Failed + = OnDiskAddFailed ;
Workers . Finished + = OnDiskAddFinished ;
Workers . UpdateProgress + = UpdateDiskProgress1 ;
Workers . UpdateProgress2 + = UpdateDiskProgress2 ;
Context . WorkingDisk = null ;
btnStopAddDisk . Visible = true ;
btnAddDisk . Visible = false ;
btnRemoveDisk . Visible = false ;
thdDisk = new Thread ( Workers . AddMedia ) ;
2017-05-15 07:33:13 +01:00
thdDisk . Start ( ) ;
}
protected void OnBtnStopAddDiskClicked ( object sender , EventArgs e )
{
2017-12-30 00:32:21 +00:00
thdDisk ? . Abort ( ) ;
2017-05-15 07:33:13 +01:00
stopped = true ;
OnDiskAddFailed ( null ) ;
}
2020-08-22 21:37:02 +01:00
void UpdateDiskProgress1 ( string text , string inner , long current , long maximum ) = >
2017-05-15 07:33:13 +01:00
Application . Instance . Invoke ( delegate
{
2017-12-30 00:32:21 +00:00
lblAddDisk1 . Text = ! string . IsNullOrWhiteSpace ( inner ) ? inner : text ;
2020-08-22 21:37:02 +01:00
2017-05-15 07:33:13 +01:00
if ( maximum > 0 )
{
2020-08-22 21:37:02 +01:00
if ( current < int . MinValue | |
current > int . MaxValue | |
maximum < int . MinValue | |
2017-12-30 00:32:21 +00:00
maximum > int . MaxValue )
2017-06-20 07:28:16 +01:00
{
current / = 100 ;
maximum / = 100 ;
}
2017-05-15 07:33:13 +01:00
prgAddDisk1 . Indeterminate = false ;
2017-12-30 00:32:21 +00:00
prgAddDisk1 . MinValue = 0 ;
prgAddDisk1 . MaxValue = ( int ) maximum ;
prgAddDisk1 . Value = ( int ) current ;
2017-05-15 07:33:13 +01:00
}
2020-08-22 21:37:02 +01:00
else
prgAddDisk1 . Indeterminate = true ;
2017-05-15 07:33:13 +01:00
} ) ;
2020-08-22 21:37:02 +01:00
void UpdateDiskProgress2 ( string text , string inner , long current , long maximum ) = >
2017-05-15 07:33:13 +01:00
Application . Instance . Invoke ( delegate
{
2017-12-30 00:32:21 +00:00
lblAddDisk2 . Text = ! string . IsNullOrWhiteSpace ( inner ) ? inner : text ;
2020-08-22 21:37:02 +01:00
2017-05-15 07:33:13 +01:00
if ( maximum > 0 )
{
2020-08-22 21:37:02 +01:00
if ( current < int . MinValue | |
current > int . MaxValue | |
maximum < int . MinValue | |
2017-12-30 00:32:21 +00:00
maximum > int . MaxValue )
2017-06-20 07:28:16 +01:00
{
current / = 100 ;
maximum / = 100 ;
}
2017-05-15 07:33:13 +01:00
prgAddDisk2 . Indeterminate = false ;
2017-12-30 00:32:21 +00:00
prgAddDisk2 . MinValue = 0 ;
prgAddDisk2 . MaxValue = ( int ) maximum ;
prgAddDisk2 . Value = ( int ) current ;
2017-05-15 07:33:13 +01:00
}
2020-08-22 21:37:02 +01:00
else
prgAddDisk2 . Indeterminate = true ;
2017-05-15 07:33:13 +01:00
} ) ;
2020-08-22 21:37:02 +01:00
void OnDiskAddFailed ( string text ) = > Application . Instance . Invoke ( delegate
2017-05-15 07:33:13 +01:00
{
2020-08-22 21:37:02 +01:00
if ( ! stopped )
MessageBox . Show ( text , MessageBoxType . Error ) ;
Context . SelectedFile = "" ;
tabGeneral . Visible = true ;
tabKeywords . Visible = true ;
tabBarcodes . Visible = true ;
tabCategories . Visible = true ;
tabLanguages . Visible = true ;
tabTargetOs . Visible = true ;
tabArchitectures . Visible = true ;
tabDiscs . Visible = true ;
prgAddDisk1 . Visible = false ;
prgAddDisk2 . Visible = false ;
lblAddDisk1 . Visible = false ;
lblAddDisk2 . Visible = false ;
btnCancel . Visible = true ;
btnOK . Visible = true ;
btnEditDisk . Visible = true ;
btnClearDisks . Visible = true ;
Workers . Failed - = OnDiskAddFailed ;
Workers . Finished - = OnDiskAddFinished ;
Workers . UpdateProgress - = UpdateDiskProgress1 ;
Workers . UpdateProgress2 - = UpdateDiskProgress2 ;
Context . WorkingDisk = null ;
btnStopAddDisk . Visible = false ;
btnAddDisk . Visible = true ;
btnRemoveDisk . Visible = true ;
thdDisk = null ;
} ) ;
void OnDiskAddFinished ( ) = > Application . Instance . Invoke ( delegate
{
if ( Context . WorkingDisk = = null )
return ;
BlockMediaType disk = Context . WorkingDisk ;
lstDisks . Add ( new DiskEntry
2017-05-15 07:33:13 +01:00
{
2020-08-22 21:37:02 +01:00
path = disk . Image . Value ,
disk = disk
2017-05-15 07:33:13 +01:00
} ) ;
2020-08-22 21:37:02 +01:00
List < string > files = new List < string >
2017-05-15 07:33:13 +01:00
{
2020-08-22 21:37:02 +01:00
disk . Image . Value
} ;
2017-12-30 00:32:21 +00:00
2020-08-22 21:37:02 +01:00
if ( disk . ATA ? . Identify ! = null )
files . Add ( disk . ATA . Identify . Image ) ;
2017-12-30 00:32:21 +00:00
2020-08-22 21:37:02 +01:00
if ( disk . MAM ! = null )
files . Add ( disk . MAM . Image ) ;
2017-12-30 00:32:21 +00:00
2020-08-22 21:37:02 +01:00
if ( disk . PCI ? . ExpansionROM ! = null )
files . Add ( disk . PCI . ExpansionROM . Image . Value ) ;
2017-12-30 00:32:21 +00:00
2020-08-22 21:37:02 +01:00
if ( disk . PCMCIA ? . CIS ! = null )
files . Add ( disk . PCMCIA . CIS . Image ) ;
if ( disk . SCSI ! = null )
{
if ( disk . SCSI . Inquiry ! = null )
files . Add ( disk . SCSI . Inquiry . Image ) ;
if ( disk . SCSI . LogSense ! = null )
files . Add ( disk . SCSI . LogSense . Image ) ;
if ( disk . SCSI . ModeSense ! = null )
files . Add ( disk . SCSI . ModeSense . Image ) ;
if ( disk . SCSI . ModeSense10 ! = null )
files . Add ( disk . SCSI . ModeSense10 . Image ) ;
if ( disk . SCSI . EVPD ! = null )
files . AddRange ( disk . SCSI . EVPD . Select ( evpd = > evpd . Image ) ) ;
}
if ( disk . SecureDigital ! = null )
{
if ( disk . SecureDigital . CID ! = null )
files . Add ( disk . SecureDigital . CID . Image ) ;
if ( disk . SecureDigital . CSD ! = null )
files . Add ( disk . SecureDigital . CSD . Image ) ;
if ( disk . MultiMediaCard . ExtendedCSD ! = null )
files . Add ( disk . MultiMediaCard . ExtendedCSD . Image ) ;
}
if ( disk . TapeInformation ! = null )
files . AddRange ( disk . TapeInformation . Select ( tapePart = > tapePart . Image . Value ) ) ;
if ( disk . Track ! = null )
files . AddRange ( disk . Track . Select ( track = > track . Image . Value ) ) ;
if ( disk . USB ? . Descriptors ! = null )
files . Add ( disk . USB . Descriptors . Image ) ;
foreach ( string file in files )
lstFilesForMedia . Remove ( file ) ;
Context . SelectedFile = "" ;
tabGeneral . Visible = true ;
tabKeywords . Visible = true ;
tabBarcodes . Visible = true ;
tabCategories . Visible = true ;
tabLanguages . Visible = true ;
tabTargetOs . Visible = true ;
tabArchitectures . Visible = true ;
tabDiscs . Visible = true ;
prgAddDisk1 . Visible = false ;
prgAddDisk2 . Visible = false ;
lblAddDisk1 . Visible = false ;
lblAddDisk2 . Visible = false ;
btnCancel . Visible = true ;
btnOK . Visible = true ;
btnEditDisk . Visible = true ;
btnClearDisks . Visible = true ;
Workers . Failed - = OnDiskAddFailed ;
Workers . Finished - = OnDiskAddFinished ;
Workers . UpdateProgress - = UpdateDiskProgress1 ;
Workers . UpdateProgress2 - = UpdateDiskProgress2 ;
Context . WorkingDisk = null ;
btnStopAddDisk . Visible = false ;
btnAddDisk . Visible = true ;
btnRemoveDisk . Visible = true ;
thdDisk = null ;
} ) ;
2017-05-15 07:33:13 +01:00
protected void OnBtnClearDisksClicked ( object sender , EventArgs e )
{
lstDisks . Clear ( ) ;
2020-08-22 21:37:02 +01:00
2017-05-15 07:33:13 +01:00
// TODO: Don't add files that are discs
FillFilesCombos ( ) ;
}
protected void OnBtnRemoveDiskClicked ( object sender , EventArgs e )
{
2020-08-22 21:37:02 +01:00
if ( treeDisks . SelectedItem = = null )
return ;
2017-12-30 00:32:21 +00:00
lstFilesForMedia . Add ( ( ( DiskEntry ) treeDisks . SelectedItem ) . path ) ;
lstDisks . Remove ( ( DiskEntry ) treeDisks . SelectedItem ) ;
2017-05-15 07:33:13 +01:00
}
protected void OnBtnCancelClicked ( object sender , EventArgs e )
{
Modified = false ;
Close ( ) ;
}
protected void OnBtnOKClicked ( object sender , EventArgs e )
{
2018-03-16 15:44:58 +00:00
Metadata = new CICMMetadataType ( ) ;
2017-05-15 07:33:13 +01:00
List < ArchitecturesTypeArchitecture > architectures = new List < ArchitecturesTypeArchitecture > ( ) ;
2017-12-30 00:32:21 +00:00
List < BarcodeType > barcodes = new List < BarcodeType > ( ) ;
List < BlockMediaType > disks = new List < BlockMediaType > ( ) ;
List < string > categories = new List < string > ( ) ;
List < string > keywords = new List < string > ( ) ;
List < LanguagesTypeLanguage > languages = new List < LanguagesTypeLanguage > ( ) ;
List < OpticalDiscType > discs = new List < OpticalDiscType > ( ) ;
List < string > subcategories = new List < string > ( ) ;
List < string > systems = new List < string > ( ) ;
2020-08-22 21:37:02 +01:00
if ( ! string . IsNullOrEmpty ( txtAuthor . Text ) )
Metadata . Author = txtAuthor . Text . Split ( ',' ) ;
if ( ! string . IsNullOrEmpty ( txtDeveloper . Text ) )
Metadata . Developer = txtDeveloper . Text . Split ( ',' ) ;
if ( ! string . IsNullOrEmpty ( txtName . Text ) )
Metadata . Name = txtName . Text ;
if ( ! string . IsNullOrEmpty ( txtPartNumber . Text ) )
Metadata . PartNumber = txtPartNumber . Text ;
if ( ! string . IsNullOrEmpty ( txtPerformer . Text ) )
Metadata . Performer = txtPerformer . Text . Split ( ',' ) ;
if ( ! string . IsNullOrEmpty ( txtPublisher . Text ) )
Metadata . Publisher = txtPublisher . Text . Split ( ',' ) ;
if ( ! string . IsNullOrEmpty ( txtSerialNumber . Text ) )
Metadata . SerialNumber = txtSerialNumber . Text ;
if ( ! string . IsNullOrEmpty ( txtVersion . Text ) )
Metadata . Version = txtVersion . Text ;
2017-05-15 07:33:13 +01:00
if ( ! chkReleaseDate . Checked . Value )
{
2017-12-30 00:32:21 +00:00
Metadata . ReleaseDate = cldReleaseDate . Value . Value ;
2017-05-15 07:33:13 +01:00
Metadata . ReleaseDateSpecified = true ;
}
2017-12-30 00:32:21 +00:00
2017-05-15 07:33:13 +01:00
if ( chkKnownReleaseType . Checked . Value )
{
2017-12-30 00:32:21 +00:00
Metadata . ReleaseType = cmbReleaseType . SelectedValue ;
2017-05-15 07:33:13 +01:00
Metadata . ReleaseTypeSpecified = true ;
}
foreach ( StringEntry entry in lstArchitectures )
2017-12-30 00:32:21 +00:00
architectures . Add ( ( ArchitecturesTypeArchitecture ) Enum . Parse ( typeof ( ArchitecturesTypeArchitecture ) ,
entry . str ) ) ;
2017-05-15 07:33:13 +01:00
foreach ( BarcodeEntry entry in lstBarcodes )
{
2020-08-22 21:37:02 +01:00
var barcode = new BarcodeType
{
type = entry . type ,
Value = entry . code
} ;
2017-05-15 07:33:13 +01:00
barcodes . Add ( barcode ) ;
}
2020-08-22 21:37:02 +01:00
foreach ( DiskEntry entry in lstDisks )
disks . Add ( entry . disk ) ;
2017-05-15 07:33:13 +01:00
2020-08-22 21:37:02 +01:00
foreach ( StringEntry entry in lstCategories )
categories . Add ( entry . str ) ;
2017-05-15 07:33:13 +01:00
2020-08-22 21:37:02 +01:00
foreach ( StringEntry entry in lstKeywords )
keywords . Add ( entry . str ) ;
2017-05-15 07:33:13 +01:00
foreach ( StringEntry entry in lstLanguages )
languages . Add ( ( LanguagesTypeLanguage ) Enum . Parse ( typeof ( LanguagesTypeLanguage ) , entry . str ) ) ;
2020-08-22 21:37:02 +01:00
foreach ( DiscEntry entry in lstDiscs )
discs . Add ( entry . disc ) ;
2017-12-30 00:32:21 +00:00
2020-08-22 21:37:02 +01:00
foreach ( StringEntry entry in lstSubcategories )
subcategories . Add ( entry . str ) ;
2017-12-30 00:32:21 +00:00
2018-03-16 15:44:58 +00:00
if ( lstOses . Count > 0 )
{
Dictionary < string , List < string > > osesDict = new Dictionary < string , List < string > > ( ) ;
2020-08-22 21:37:02 +01:00
2018-03-16 15:44:58 +00:00
foreach ( TargetOsEntry entry in lstOses . OrderBy ( t = > t . name ) . ThenBy ( t = > t . version ) )
{
osesDict . TryGetValue ( entry . name , out List < string > versList ) ;
2020-08-22 21:37:02 +01:00
if ( versList = = null )
versList = new List < string > ( ) ;
2018-03-16 15:44:58 +00:00
2020-08-22 21:37:02 +01:00
if ( versList . Contains ( entry . version ) )
continue ;
2018-03-16 15:44:58 +00:00
versList . Add ( entry . version ) ;
versList . Sort ( ) ;
osesDict . Remove ( entry . name ) ;
osesDict . Add ( entry . name , versList ) ;
}
2020-08-22 21:37:02 +01:00
Metadata . RequiredOperatingSystems = osesDict . OrderBy ( t = > t . Key ) .
Select ( entry = > new RequiredOperatingSystemType
{
Name = entry . Key ,
Version = entry . Value . ToArray ( )
} ) . ToArray ( ) ;
2018-03-16 15:44:58 +00:00
}
2017-12-30 00:32:21 +00:00
2020-08-22 21:37:02 +01:00
if ( architectures . Count > 0 )
Metadata . Architectures = architectures . ToArray ( ) ;
if ( barcodes . Count > 0 )
Metadata . Barcodes = barcodes . ToArray ( ) ;
if ( disks . Count > 0 )
Metadata . BlockMedia = disks . ToArray ( ) ;
if ( categories . Count > 0 )
Metadata . Categories = categories . ToArray ( ) ;
if ( keywords . Count > 0 )
Metadata . Keywords = keywords . ToArray ( ) ;
if ( languages . Count > 0 )
Metadata . Languages = languages . ToArray ( ) ;
if ( discs . Count > 0 )
Metadata . OpticalDisc = discs . ToArray ( ) ;
if ( subcategories . Count > 0 )
Metadata . Subcategories = subcategories . ToArray ( ) ;
if ( systems . Count > 0 )
Metadata . Systems = systems . ToArray ( ) ;
2017-12-30 00:32:21 +00:00
2018-03-16 15:44:58 +00:00
Metadata . Magazine = magazines ;
Metadata . Book = books ;
Metadata . UserManual = usermanuals ;
Metadata . Advertisement = adverts ;
Metadata . LinearMedia = linearmedias ;
Metadata . PCICard = pcis ;
Metadata . AudioMedia = audiomedias ;
2017-09-30 17:47:54 +01:00
2017-05-15 07:33:13 +01:00
Modified = true ;
Close ( ) ;
}
protected void OnBtnEditDiscClicked ( object sender , EventArgs e )
{
2020-08-22 21:37:02 +01:00
if ( treeDiscs . SelectedItem = = null )
return ;
2017-05-15 07:33:13 +01:00
2020-08-22 21:37:02 +01:00
var _dlgOpticalDisc = new dlgOpticalDisc
2017-12-30 00:32:21 +00:00
{
Title = $"Editing disc metadata for {((DiscEntry)treeDiscs.SelectedItem).path}" ,
Metadata = ( ( DiscEntry ) treeDiscs . SelectedItem ) . disc
} ;
2020-08-22 21:37:02 +01:00
2017-05-15 07:33:13 +01:00
_dlgOpticalDisc . FillFields ( ) ;
_dlgOpticalDisc . ShowModal ( this ) ;
2020-08-22 21:37:02 +01:00
if ( ! _dlgOpticalDisc . Modified )
return ;
2017-12-30 00:32:21 +00:00
lstDiscs . Remove ( ( DiscEntry ) treeDiscs . SelectedItem ) ;
2020-08-22 21:37:02 +01:00
lstDiscs . Add ( new DiscEntry
{
path = _dlgOpticalDisc . Metadata . Image . Value ,
disc = _dlgOpticalDisc . Metadata
} ) ;
2017-05-15 07:33:13 +01:00
}
protected void OnBtnEditDiskClicked ( object sender , EventArgs e )
{
2020-08-22 21:37:02 +01:00
if ( treeDisks . SelectedItem = = null )
return ;
2017-05-15 07:33:13 +01:00
2020-08-22 21:37:02 +01:00
var _dlgBlockMedia = new dlgBlockMedia
2017-12-30 00:32:21 +00:00
{
Title = $"Editing disk metadata for {((DiskEntry)treeDisks.SelectedItem).path}" ,
Metadata = ( ( DiskEntry ) treeDisks . SelectedItem ) . disk
} ;
2020-08-22 21:37:02 +01:00
2017-05-15 07:33:13 +01:00
_dlgBlockMedia . FillFields ( ) ;
_dlgBlockMedia . ShowModal ( this ) ;
2020-08-22 21:37:02 +01:00
if ( ! _dlgBlockMedia . Modified )
return ;
2017-05-15 07:33:13 +01:00
2017-12-30 00:32:21 +00:00
lstDisks . Remove ( ( DiskEntry ) treeDisks . SelectedItem ) ;
2020-08-22 21:37:02 +01:00
lstDisks . Add ( new DiskEntry
{
path = _dlgBlockMedia . Metadata . Image . Value ,
disk = _dlgBlockMedia . Metadata
} ) ;
2017-05-15 07:30:27 +01:00
}
2017-12-30 00:32:21 +00:00
#region XAML UI elements
#pragma warning disable 0649
2020-08-22 21:37:02 +01:00
TabPage tabGeneral ;
TextBox txtDeveloper ;
TextBox txtPublisher ;
TextBox txtAuthor ;
TextBox txtPerformer ;
TextBox txtName ;
TextBox txtVersion ;
StackLayout stkReleaseType ;
CheckBox chkKnownReleaseType ;
readonly EnumDropDown < CICMMetadataTypeReleaseType > cmbReleaseType ;
DateTimePicker cldReleaseDate ;
CheckBox chkReleaseDate ;
TextBox txtPartNumber ;
TextBox txtSerialNumber ;
TabPage tabKeywords ;
TextBox txtNewKeyword ;
GridView treeKeywords ;
TabPage tabBarcodes ;
TextBox txtNewBarcode ;
ComboBox cmbBarcodes ;
GridView treeBarcodes ;
TabPage tabCategories ;
TextBox txtNewCategory ;
GridView treeCategories ;
TextBox txtNewSubcategory ;
GridView treeSubcategories ;
TabPage tabLanguages ;
ComboBox cmbLanguages ;
GridView treeLanguages ;
TabPage tabTargetOs ;
TextBox txtNewOsName ;
TextBox txtNewOsVersion ;
GridView treeOses ;
TabPage tabArchitectures ;
ComboBox cmbArchitectures ;
GridView treeArchitectures ;
TabPage tabDiscs ;
ComboBox cmbFilesForNewDisc ;
Button btnAddDisc ;
GridView treeDiscs ;
Button btnStopAddDisc ;
Button btnEditDisc ;
Button btnClearDiscs ;
Button btnRemoveDisc ;
Label lblAddDisc1 ;
ProgressBar prgAddDisc1 ;
Label lblAddDisc2 ;
ProgressBar prgAddDisc2 ;
TabPage tabDisks ;
ComboBox cmbFilesForNewDisk ;
Button btnAddDisk ;
GridView treeDisks ;
Button btnStopAddDisk ;
Button btnEditDisk ;
Button btnClearDisks ;
Button btnRemoveDisk ;
Label lblAddDisk1 ;
ProgressBar prgAddDisk1 ;
Label lblAddDisk2 ;
ProgressBar prgAddDisk2 ;
Button btnCancel ;
Button btnOK ;
2017-12-30 00:32:21 +00:00
#pragma warning restore 0649
#endregion XAML UI elements
2017-05-15 07:30:27 +01:00
}
2017-05-15 07:33:13 +01:00
}