/// <summary> SetAssetIcon /// Searches through mAssetTypes to find the matching key with /// that of the filename. Then returns the index /// </summary> /// <param name="filename"></param> /// <returns>index of icon in the mAssetTypeImages list</returns> static public int GetClassIconIndex(string filename, MOG_Properties properties) { // Construct a filename MOG_Filename file = null; try { file = new MOG_Filename(filename); } catch (Exception e) { e.ToString(); return(0); } string classification; switch (file.GetFilenameType()) { case MOG_FILENAME_TYPE.MOG_FILENAME_Asset: classification = file.GetAssetClassification(); break; case MOG_FILENAME_TYPE.MOG_FILENAME_Group: classification = "group"; break; default: classification = filename; break; } try { TstDictionaryEntry node = mAssetTypes.Find(classification); if (node != null && node.IsKey) { return((int)node.Value); } else { if (properties == null) { // If we didn't get anything, we need to load this icon into our array properties = new MOG_Properties(classification); } return(MogUtil_AssetIcons.LoadIcon(properties.ClassIcon, classification)); } } catch { return(0); } } // end ()
/// <summary> /// Get all the files associated with this version and populate the info windows /// </summary> /// <param name="version"></param> public void GetFileList(VersionNode version) { try { mainForm.VersionFilesListView.Items.Clear(); mainForm.VersionFilesListView.BeginUpdate(); DirectoryInfo dir = new DirectoryInfo(version.SourceDirectory); foreach (FileInfo file in dir.GetFiles()) { ListViewItem item = new ListViewItem(file.Name); item.SubItems.Add(file.LastWriteTime.ToShortDateString() + " " + file.LastWriteTime.ToShortTimeString()); item.SubItems.Add(file.Length.ToString()); item.ImageIndex = MogUtil_AssetIcons.GetFileIconIndex(file.FullName); mainForm.VersionFilesListView.Items.Add(item); } mainForm.VersionFilesListView.EndUpdate(); } catch { } }
static public int GetLockedAssetIcon(MOG_Filename file) { try { // Check to see if we can find this loced icon in our cache TstDictionaryEntry assetLocked = mAssetTypes.Find(file.GetAssetClassification() + "ASSETICON_locked"); if (assetLocked != null) { // Yup, return the index return((int)assetLocked.Value); } else { // Nope, We are going to have to create it // Setup some new containers Bitmap myImage = null; Bitmap lockSource = null; Bitmap source = null; // Can we find the locked image TstDictionaryEntry nodeLocked = mAssetTypes.Find("locked"); if (nodeLocked != null && nodeLocked.IsKey) { // Great, get a copy of that lockSource = (Bitmap)mAssetTypeImages.Images[(int)nodeLocked.Value]; // Can we find the class icon for this asset TstDictionaryEntry nodeSource = mAssetTypes.Find(file.GetAssetClassification() + "_ASSETICON"); if (nodeSource != null && nodeSource.IsKey) { // Great get a copy of that source = (Bitmap)mAssetTypeImages.Images[(int)nodeSource.Value]; } else { // If we didn't get anything, we need to load this icon into our array MOG_Properties properties = new MOG_Properties(file.GetAssetClassification()); source = (Bitmap)mAssetTypeImages.Images[MogUtil_AssetIcons.LoadIcon(properties.AssetIcon, file.GetAssetClassification() + "_ASSETICON")]; } // Ok, if we got a lockSource and a class source icon, lets attempt to overlay them if (source != null && lockSource != null) { myImage = BitmapManipulator.OverlayBitmap(source, lockSource, 100, BitmapManipulator.ImageCornerEnum.BottomRight); } // Did the overlay work? if (myImage != null) { lock (mAssetTypes) { // Add the image and the type to the arrayLists mAssetTypeImages.Images.Add(myImage); mAssetTypes.Add(file.GetAssetClassification() + "ASSETICON_locked", mAssetTypeImages.Images.Count - 1); return(mAssetTypeImages.Images.Count - 1); } } } else { // Try to just turn the source icon red or something string message = "We could not locate the (FileLocked.png)lock icon! Make sure that it is located in one of your images directories within the MOG repository!"; MOG_Report.ReportMessage("Load Icon", message, "No StackTrace available", MOG_ALERT_LEVEL.ERROR); } } } catch (Exception e) { MOG_Report.ReportMessage("Get Locked Icon", e.Message, e.StackTrace, MOG_ALERT_LEVEL.CRITICAL); } return(0); }