void LoadPackage(string path, bool skipFileAppend) { if (!string.IsNullOrWhiteSpace(SelectedPackage.UniqueID)) { txtNamespace.Text = SelectedPackage.UniqueID; } if (!string.IsNullOrWhiteSpace(SelectedPackage.Name)) { txtName.Text = SelectedPackage.Name; } if (!string.IsNullOrWhiteSpace(SelectedPackage.Version)) { txtVersion.Text = SelectedPackage.Version; } if (!string.IsNullOrWhiteSpace(SelectedPackage.Author)) { txtAuthor.Text = SelectedPackage.Author; } if (!string.IsNullOrWhiteSpace(SelectedPackage.URL)) { txtPackURL.Text = SelectedPackage.URL; } if (SelectedPackage.License != null) { License = SelectedPackage.License; if (License.LicenseSource == RMPackLic.Source.File && !string.IsNullOrWhiteSpace(License.Data)) { License.Data = path + "\\" + License.Data; } } if (!string.IsNullOrWhiteSpace(SelectedPackage.Description)) { txtDesc.Text = SelectedPackage.Description; } if (SelectedPackage.Implicit) { cboxImplicit.Checked = true; if (!string.IsNullOrWhiteSpace(path)) { txtAssetDir.Text = path; } ProcessLicenseAndImplicitDirCommonPath(); btnViewAssetDir.Enabled = true; } else { CustomAssetPack = SelectedPackage.Clone() as RMPackage; if (!skipFileAppend) { List <RMPackFile> listOfFiles = CustomAssetPack.RetrieveAllFiles(); if (listOfFiles != null) { foreach (RMPackFile file in listOfFiles) { file.Path = path + "\\" + file.Path; } } } ProcessCustomAssetsCommonPath(MethodBase.GetCurrentMethod().ToLogFormatFullName()); } }
void ProcessCustomAssetsCommonPath(string _namespace) { if (CustomAssetPack == null || CustomAssetPack.Collections == null || CustomAssetPack.Collections.Count == 0) { btnSaveXML.Enabled = true; FormattedCustomAssetPack = null; return; } FormattedCustomAssetPack = (RMPackage)CustomAssetPack.Clone(); if (License != null) { FormattedCustomAssetPack.License = License.Clone(); } List <RMPackFile> retrievedFiles = null; string commonPath = null; frmLoading loadingForm = new frmLoading(StringConst.frmLoading.FORMAT_PACK_META); Thread thread = new Thread(delegate() { commonPath = FormattedCustomAssetPack.TrimPrefixCommonPathOfFiles(out retrievedFiles, true); loadingForm.SafeClose(); }); thread.Start(); loadingForm.ShowDialog(); if (retrievedFiles == null || retrievedFiles.Count == 0 || ((FormattedCustomAssetPack.License == null || FormattedCustomAssetPack.License.LicenseSource != RMPackLic.Source.File) && retrievedFiles.Count == 1)) { btnSaveXML.Enabled = true; if (retrievedFiles != null && retrievedFiles.Count == 1) { CustomAssetsCommonPath = Path.GetDirectoryName(retrievedFiles[0].Path); } return; // User did not select any assets or has selected 1 asset but the license source is not a file. } if (string.IsNullOrWhiteSpace(commonPath)) { Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPropPack.NO_COMMON_PATH, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Warning); CustomAssetsCommonPath = null; btnSaveXML.Enabled = false; return; } bool allPathRelative = true; LogDataList warningLog = new LogDataList(); if (FormattedCustomAssetPack.License != null && FormattedCustomAssetPack.License.LicenseSource == RMPackLic.Source.File && !FormattedCustomAssetPack.License.NonRootedLicenseFile) { warningLog.WriteWarningLog(frmPropPackMessagse.Warning.NonCommonPathFile(License.Data, commonPath, true), _namespace); allPathRelative = false; } foreach (RMPackFile file in retrievedFiles) { if (!file.NonRootedPath) { warningLog.WriteWarningLog(frmPropPackMessagse.Warning.NonCommonPathFile(file.Path, commonPath), _namespace); allPathRelative = false; } } CustomAssetsCommonPath = commonPath; if (allPathRelative) { btnSaveXML.Enabled = true; return; } if (warningLog != null && warningLog.HasErrorsOrWarnings()) { Helper.ShowMessageBox(MessageBoxStrings.General.HAS_ERRORS_WARNINGS, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Warning); frmLogger loggerForm = new frmLogger(_logList: warningLog); loggerForm.StartPosition = FormStartPosition.CenterParent; loggerForm.ShowDialog(); } btnSaveXML.Enabled = false; }