private void LoadDatabases() { if (!File.Exists(textBoxDatabasePath.Text)) { return; } XmlSerializer xs = new XmlSerializer(typeof(SmallBasicExtensionList)); StreamReader sr = new StreamReader(textBoxDatabasePath.Text); extensionList = (SmallBasicExtensionList)xs.Deserialize(sr); sr.Close(); databaseItems.Clear(); for (int i = 0; i < extensionList.numExtension; i++) { SmallBasicExtension extension = extensionList.Extensions[i].Extension; DatabaseItem rowItem = new DatabaseItem { Name = extension.Name, Description = extension.Description, Author = extension.Author, WebSite = extension.WebSite, API = extension.API, ChangeLog = extension.ChangeLog, SBVersion = extension.SBVersion, ExtVersion = extension.ExtVersion, ZipLocation = extension.ZipLocation, dllFiles = GetFiles(extension.dllFiles), xmlFiles = GetFiles(extension.xmlFiles), docFiles = GetFiles(extension.docFiles), sampleFiles = GetFiles(extension.sampleFiles) }; databaseItems.Add(rowItem); } }
private void SaveDatabases() { extensionList = new SmallBasicExtensionList(); extensionList.Version = DatabaseVersion; extensionList.numExtension = 0; for (int i = 0; i < databaseItems.Count; i++) { DatabaseItem item = databaseItems[i]; if (null == item.Name || item.Name == "") { continue; } extensionList.numExtension++; } extensionList.Extensions = new SmallBasicExtensionListExtensions[extensionList.numExtension]; int index = 0; for (int i = 0; i < databaseItems.Count; i++) { DatabaseItem item = databaseItems[i]; if (null == item.Name || item.Name == "") { continue; } extensionList.Extensions[index] = new SmallBasicExtensionListExtensions(); extensionList.Extensions[index].Extension = new SmallBasicExtension(); SmallBasicExtension extension = extensionList.Extensions[index].Extension; index++; extension.Name = item.Name; extension.Description = item.Description; extension.Author = item.Author; extension.WebSite = item.WebSite; extension.API = item.API; extension.ChangeLog = item.ChangeLog; extension.SBVersion = item.SBVersion; extension.ExtVersion = item.ExtVersion; extension.ZipLocation = item.ZipLocation; extension.dllFiles = SetFiles(item.dllFiles); extension.xmlFiles = SetFiles(item.xmlFiles); extension.docFiles = SetFiles(item.docFiles); extension.sampleFiles = SetFiles(item.sampleFiles); } XmlSerializer xs = new XmlSerializer(typeof(SmallBasicExtensionList)); StreamWriter sw = new StreamWriter(textBoxDatabasePath.Text, false); xs.Serialize(sw, extensionList); sw.Close(); LoadDatabases(); }
private void _CopyRows(object sender, RoutedEventArgs e) { foreach (DataGridCellInfo info in dataGridDatabases.SelectedCells) { DatabaseItem item = (DatabaseItem)info.Item; DatabaseItem rowItem = new DatabaseItem { Name = item.Name, Description = item.Description, Author = item.Author, WebSite = item.WebSite, API = item.API, ChangeLog = item.ChangeLog, SBVersion = item.SBVersion, ExtVersion = item.ExtVersion, ZipLocation = item.ZipLocation, dllFiles = item.dllFiles, xmlFiles = item.xmlFiles, docFiles = item.docFiles, sampleFiles = item.sampleFiles }; databaseItems.Add(rowItem); } }