public FManifest([NotNull] AssetInfoList manifest, [NotNull] ManifestOpening opening, [CanBeNull] DownloadConfig downloadConfig) { Manifest = manifest; _opening = opening; _downloadConfig = downloadConfig; _downloadPendingSet = new HashSet <TreeListItem>(); InitializeComponent(); RegisterEventHandlers(); InitializeControls(); }
private void MnuFileOpenLocal_Click(object sender, EventArgs e) { ofd.CheckFileExists = true; ofd.DereferenceLinks = true; ofd.Filter = "Asset Database (*.data)|*.data"; ofd.Multiselect = false; ofd.ReadOnlyChecked = false; ofd.ShowReadOnly = false; ofd.SupportMultiDottedExtensions = true; ofd.ValidateNames = true; var r = ofd.ShowDialog(this); if (r == DialogResult.Cancel) { return; } var filePath = ofd.FileName; var data = File.ReadAllBytes(filePath); var b = AssetInfoList.TryParse(data, out var assetInfoList); if (!b) { var message = $"'{filePath}' is not a valid asset database file."; MessageBox.Show(message, ApplicationHelper.GetApplicationTitle(), MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } Debug.Assert(assetInfoList != null); var opening = ManifestOpening.Local(filePath); var form = new FManifest(assetInfoList, opening, null); form.MdiParent = this; form.Show(); }
private async void MnuFileOpenRemote_Click(object sender, EventArgs e) { var(r, config) = FManifestDownload.ShowModal(this); if (r == DialogResult.Cancel) { return; } Debug.Assert(config != null); byte[] assetInfoListData; try { assetInfoListData = await TDDownloader.DownloadData(config.ResourceVersion, config.ManifestAssetName); } catch (Exception ex) { MessageBox.Show(ex.ToString(), ApplicationHelper.GetApplicationTitle(), MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } var b = AssetInfoList.TryParse(assetInfoListData, out var assetInfoList); if (!b) { const string message = "Received data is not a valid asset database file."; MessageBox.Show(message, ApplicationHelper.GetApplicationTitle(), MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } Debug.Assert(assetInfoList != null); var opening = ManifestOpening.Remote(config.ResourceVersion, config.IsLatest); var form = new FManifest(assetInfoList, opening, config); form.MdiParent = this; form.Show(); }