private void LoadForm() { tbParentLocation.Text = _asset.Location; tbAssetName.Text = _asset.Name; tbSerialNumber.Text = _asset.SerialNumber; tbAssetTag.Text = _asset.AssetTag; cbOverwriteData.Checked = _asset.OverwriteData; _assetTypes.Populate(); // Recover the category of the current asset so that we can select it correctly in the combo AssetType assetType = _assetTypes.FindByName(_asset.TypeAsString); if (assetType == null) { assetType = _assetTypes[0]; } AssetType assetCategory = _assetTypes.GetParent(assetType); // We now need to add the Asset Type categories to the combo box cbAssetCategories.BeginUpdate(); cbAssetCategories.Items.Clear(); AssetTypeList categories = _assetTypes.EnumerateCategories(); foreach (AssetType category in categories) { cbAssetCategories.Items.Add(category); } int index = cbAssetCategories.Items.IndexOf(assetCategory); cbAssetCategories.SelectedIndex = (index != -1) ? index : 0; cbAssetCategories.EndUpdate(); FillAssetTypes(assetCategory); FillStockStatuses(_asset.StockStatus); // ...and select the asset type for the asset index = cbAssetTypes.Items.IndexOf(assetType); cbAssetTypes.SelectedIndex = (index != -1) ? index : 0; FillAssetMakes(assetType.AssetTypeID); FillAssetModels(assetType.AssetTypeID); InitializeNotesTab(); PopulateSuppliers(); InitializeDocumentsTab(); FillUserDefinedData(); //Added by Sojan E John KTS Infotech ClearControlsSupportContract(); FillControlsOnLoad(); FillSupportContractComboBox(); FillSuppliersComboBox(); InitialiseSupportContractTab(); }
private void FormAddAsset_Load(object sender, EventArgs e) { AuditWizardConfiguration configuration = new AuditWizardConfiguration(); this.labelLocation.Text = (configuration.ShowByDomain) ? "Parent Domain;" : "Parent Location:"; this.tbAssetName.Text = _asset.Name; this.tbParentLocation.Text = (configuration.ShowByDomain) ? _asset.Domain : _asset.Location; // Get Asset Types and load into the combo box _listAssetTypes.Populate(); // Load just the categories AssetTypeList categories = _listAssetTypes.EnumerateCategories(); // ...and add to the combo foreach (AssetType assetType in categories) { // Add categories only if they have children if (_listAssetTypes.EnumerateChildren(assetType.AssetTypeID).Count != 0) { this.cbAssetCategory.Items.Add(assetType); } } // Select the first asset type if (this.cbAssetCategory.Items.Count > 0) { this.cbAssetCategory.SelectedIndex = 0; } // Select the asset name as the user will need to change this this.tbAssetName.Focus(); this.tbAssetName.SelectAll(); }
/// <summary> /// Called as we try an exit from this form - we need to ensure that the category name is unique /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void bnOK_Click(object sender, EventArgs e) { // Update the asset type definition with any changes _assetType.Name = tbCategoryName.Text; _assetType.Icon = tbIconFile.Text; // AssetTypeList listAssetTypes = new AssetTypeList(); listAssetTypes.Populate(); // Does this name duplicate an existing item? AssetType existingAsset = listAssetTypes.FindByName(tbCategoryName.Text); if (existingAsset != null) { if (_assetType.AssetTypeID != existingAsset.AssetTypeID) { MessageBox.Show("An Asset Category of this name has already been created, please enter a different name for this category"); tbCategoryName.Focus(); this.DialogResult = DialogResult.None; return; } } // OK the name is fine so either create a new category or update an existing one _assetType.Add(); }
/// <summary> /// Called to refresh the information displayed on this tab /// </summary> protected void RefreshTab() { this.assettypesExplorerBar.Groups[0].Items.Clear(); _listAssetTypes = new AssetTypeList(); _listAssetTypes.Populate(); // We now need to display the Asset Type categories in the main ExplorerBar AssetTypeList categories = _listAssetTypes.EnumerateCategories(); foreach (AssetType category in categories) { UltraExplorerBarItem item = this.assettypesExplorerBar.Groups[0].Items.Add(category.Name, category.Name); item.Settings.AppearancesLarge.Appearance.Image = IconMapping.LoadIcon(category.Icon, IconMapping.Iconsize.Medium); item.Tag = category; } // If nothing is selected in the Explorer View then select the first entry if (this.assettypesExplorerBar.ActiveItem == null) { if ((_activeItem == null) || (!this.assettypesExplorerBar.Groups[0].Items.Contains(_activeItem))) { this.assettypesExplorerBar.ActiveItem = this.assettypesExplorerBar.Groups[0].Items[0]; _activeItem = this.assettypesExplorerBar.Groups[0].Items[0]; } else { this.assettypesExplorerBar.ActiveItem = _activeItem; } } }
private void DeleteCategory() { AssetType activeAssetType = _activeItem.Tag as AssetType; AssetTypeList listSubCategories = _listAssetTypes.EnumerateChildren(activeAssetType.AssetTypeID); if (listSubCategories.Count == 0) { if (MessageBox.Show("Are you sure that you want to delete this Asset Category?", "Confirm Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) != DialogResult.Yes) { return; } } else { if (MessageBox.Show("Are you sure that you want to delete this Asset Category? Deleting the category will also delete all child asset types.", "Confirm Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) != DialogResult.Yes) { return; } } // Delete this asset type and any sub-types if (activeAssetType.Delete() != 0) { MessageBox.Show("Failed to delete the selected Category - there may still be references to one of the child asset types which must be removed before the category may be deleted", "Delete Failed"); } _activeItem = null; // We should still refresh as we have partially deleted the category RefreshTab(); }
/// <summary> /// Refresh the list of Asset Types for the currently selected asset type category /// </summary> /// <param name="categoryID"></param> private void RefreshList(int categoryID) { // Call BeginUpdate and set the wait cursor while we refresh this.ulvAssetTypes.BeginUpdate(); this.Cursor = Cursors.WaitCursor; // Clear any existing items from the view ulvAssetTypes.Items.Clear(); // ...Get the children to display AssetTypeList listSubTypes = _listAssetTypes.EnumerateChildren(categoryID); // ...and add to the list view foreach (AssetType assettype in listSubTypes) { Bitmap icon = IconMapping.LoadIcon(assettype.Icon, IconMapping.Iconsize.Small); UltraListViewItem lvi = new UltraListViewItem(assettype, null); lvi.Appearance.Image = icon; lvi.Tag = assettype; ulvAssetTypes.Items.Add(lvi); } // Restore the cursor and end the update this.Cursor = Cursors.Default; this.ulvAssetTypes.EndUpdate(true); }
private void UpdateInteractiveComputers() { AssetTypeList listAssetTypes = new AssetTypeList(); listAssetTypes.Populate(); AssetType assetType = listAssetTypes.FindByName("Computers"); AssetTypeList computersList = listAssetTypes.EnumerateChildren(assetType.AssetTypeID); auditScannerDefinition.InteractiveCategories = computersList.ToString(); }
private void FormSelectAssetType_Load(object sender, EventArgs e) { tvAssetTypes.BeginUpdate(); this.Cursor = Cursors.WaitCursor; // get the currebnt list of asset types AssetTypeList listAssetTypes = new AssetTypeList(); listAssetTypes.Populate(); // We now need to display the Asset Type categories in the main ExplorerBar AssetTypeList categories = listAssetTypes.EnumerateCategories(); foreach (AssetType category in categories) { Bitmap icon = IconMapping.LoadIcon(category.Icon, IconMapping.Iconsize.Small); UltraTreeNode categoryNode = tvAssetTypes.Nodes.Add(category.Name, category.Name); categoryNode.LeftImages.Add(icon); categoryNode.Tag = category; // Is this the selected category? if (category.AssetTypeID == _selectedAssetTypeID) { this.tbSelectedType.Text = category.Name; this.tbSelectedType.Tag = category; } // Add the child asset types to the list also // ...Get the children to display AssetTypeList listSubTypes = listAssetTypes.EnumerateChildren(category.AssetTypeID); // ...and add to the list view foreach (AssetType assettype in listSubTypes) { UltraTreeNode itemNode = categoryNode.Nodes.Add(category.Name + "|" + assettype.Name, assettype.Name); Bitmap icon2 = IconMapping.LoadIcon(assettype.Icon, IconMapping.Iconsize.Small); itemNode.LeftImages.Add(icon2); itemNode.Tag = assettype; // Is this the selected category? if (assettype.AssetTypeID == _selectedAssetTypeID) { this.tbSelectedType.Text = assettype.Name; this.tbSelectedType.Tag = assettype; } } } this.Cursor = Cursors.Default; tvAssetTypes.EndUpdate(); }
/// <summary> /// Populate the asset types combo box for the selected asset category /// </summary> /// <param name="category"></param> private void FillAssetTypes(AssetType category) { cbAssetTypes.BeginUpdate(); cbAssetTypes.Items.Clear(); AssetTypeList subTypes = _assetTypes.EnumerateChildren(category.AssetTypeID); // foreach (AssetType subType in subTypes) { cbAssetTypes.Items.Add(subType); } // cbAssetTypes.EndUpdate(); }
private void UpdateInteractiveUserDataCategories() { auditAgentScannerDefinition.InteractiveUserDataCategories.Clear(); AssetTypeList listAssetTypes = new AssetTypeList(); listAssetTypes.Populate(); AssetTypeList computersList = listAssetTypes.EnumerateChildren(listAssetTypes.FindByName("Computers").AssetTypeID); UserDataCategoryList listCategories = new UserDataCategoryList(UserDataCategory.SCOPE.Asset); listCategories.Populate(); // Sort the list to put the categories in Tab Order listCategories.Sort(); // Iterate through the categories foreach (UserDataCategory category in listCategories) { if ((category.AppliesToName != "Computers") && (category.AppliesToName != String.Empty)) { // No - OK is it a type of computer? bool exclude = true; foreach (AssetType assetType in computersList) { if (assetType.Name == category.AppliesToName) { exclude = false; break; } } // If excluded, skip this category if (exclude) { continue; } } UserDataCategories lUserDataCategory = new UserDataCategories(); lUserDataCategory.Name = category.Name; lUserDataCategory.UserFields = category; auditAgentScannerDefinition.InteractiveUserDataCategories.Add(lUserDataCategory); } }
/// <summary> /// 生成BuildInfo信息 /// </summary> public bool GenBuildInfo() { //初始化数据 this.AssetTypeList = new List <string>(); this.BuildAssetsInfo = new BuildAssetsInfo(); this.RuntimeAssetsList = GetRuntimeAssetsInfo(); // var sw = new Stopwatch(); sw.Start(); BuildAssetsInfo.Time = DateTime.Now.ToShortDateString(); int id = 0; //搜集所有的依赖 foreach (var mainAsset in this.RuntimeAssetsList) { //这里会包含主资源 var dependAssetPathList = GetDependAssetList(mainAsset.importFrom); //获取依赖信息 并加入buildinfo foreach (var dependPath in dependAssetPathList) { //防止重复 if (BuildAssetsInfo.AssetDataMaps.ContainsKey(dependPath)) { continue; } //判断资源类型 var type = AssetBundleEditorToolsV2.GetMainAssetTypeAtPath(dependPath); if (type == null) { Debug.LogError("获取资源类型失败:" + dependPath); continue; } //构建资源类型 var assetData = new BuildAssetsInfo.BuildAssetData(); assetData.Id = id; assetData.Hash = this.GetHashFromAssets(dependPath); assetData.ABName = dependPath; var idx = AssetTypeList.FindIndex((a) => a == type.FullName); if (idx == -1) { AssetTypeList.Add(type.FullName); idx = AssetTypeList.Count - 1; } assetData.Type = idx; //获取依赖 var dependeAssetList = this.GetDependAssetList(dependPath); assetData.DependAssetList.AddRange(dependeAssetList); //添加 BuildAssetsInfo.AssetDataMaps[dependPath] = assetData; id++; } } //TODO AB依赖关系纠正 /// 已知Unity,bug/设计缺陷: /// 1.依赖接口,中会携带自己 /// 2.如若a.png、b.png 依赖 c.atlas,则abc依赖都会是:a.png 、b.png 、 a.atlas foreach (var asset in BuildAssetsInfo.AssetDataMaps) { //依赖中不包含自己 asset.Value.DependAssetList.Remove(asset.Value.ABName); } //获取依赖 this.DependAssetList = this.GetDependAssetsinfo(); //---------------------------------------end--------------------------------------------------------- //检查 foreach (var ar in this.RuntimeAssetsList) { if (!BuildAssetsInfo.AssetDataMaps.ContainsKey(ar.importFrom)) { Debug.LogError("AssetDataMaps遗漏资源:" + ar.importFrom); } } Debug.LogFormat("【GenBuildInfo】耗时:{0}ms.", sw.ElapsedMilliseconds); //检测构造的数据 var count = this.RuntimeAssetsList.Count + this.DependAssetList.Count; if (BuildAssetsInfo.AssetDataMaps.Count != count) { Debug.LogErrorFormat("【初始化框架资源环境】出错! buildinfo:{0} output:{1}", BuildAssetsInfo.AssetDataMaps.Count, count); var tmpBuildAssetsInfo = BuildAssetsInfo.Clone(); foreach (var ra in this.RuntimeAssetsList) { tmpBuildAssetsInfo.AssetDataMaps.Remove(ra.importFrom); } foreach (var drf in this.DependAssetList) { tmpBuildAssetsInfo.AssetDataMaps.Remove(drf.importFrom); } Debug.Log(JsonMapper.ToJson(tmpBuildAssetsInfo.AssetDataMaps, true)); return(false); } return(true); }