private void implFileIcon(FileInfo file, FileRecord rec) { if (rec.IconLoaded) { return; } FileType fileType = CommonTools.GetFileType(file.Name); if (fileType == FileType.eImage) { System.Drawing.Bitmap bitmap = FreeImageToBitmap.LoadImageFormFreeImage(file.FullName); rec.FileIcon = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(bitmap.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); } else if (fileType == FileType.eAudio) { rec.FileIcon = new BitmapImage(new Uri(CONST_STRING.Mp3Icon, UriKind.Relative)); } else if (fileType == FileType.eText) { rec.FileIcon = new BitmapImage(new Uri(CONST_STRING.TxtIcon, UriKind.Relative)); } else if (fileType == FileType.eScene) { rec.FileIcon = new BitmapImage(new Uri(CONST_STRING.SceneIcon, UriKind.Relative)); } else if (fileType == FileType.eParticle) { rec.FileIcon = new BitmapImage(new Uri(CONST_STRING.EffectIcon, UriKind.Relative)); } else if (fileType == FileType.eScript) { showScript(file, rec); } else if (fileType == FileType.eMaterial) { rec.FileIcon = new BitmapImage(new Uri(CONST_STRING.MaterialIcon, UriKind.Relative)); } else if (fileType == FileType.eShader) { rec.FileIcon = new BitmapImage(new Uri(CONST_STRING.ShaderIcon, UriKind.Relative)); } else if (fileType == FileType.ePrefab) { rec.FileIcon = new BitmapImage(new Uri(CONST_STRING.FrefabIcon, UriKind.Relative)); } else if (fileType == FileType.eModel) { rec.FileIcon = new BitmapImage(new Uri(CONST_STRING.ModelIcon, UriKind.Relative)); } }
private void createNewFileRow(PropertyInfo prop, int row, PropertyFieldAttribute attr) { if (!uiElementMap.ContainsKey(prop.Name)) { gridAddRowDef(); string text = prop.GetValue(_selectedObject) as string; if (text == "") { return; } FileType fileType = CommonTools.GetFileType(text); if (fileType == FileType.eImage) { System.Drawing.Bitmap bitmap = FreeImageToBitmap.LoadImageFormFreeImage(Config.GamePath + "\\" + text); System.Windows.Media.Imaging.BitmapSource bs = Imaging.CreateBitmapSourceFromHBitmap(bitmap.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, System.Windows.Media.Imaging.BitmapSizeOptions.FromEmptyOptions()); createImgeProperty(bs, _panelParent.RowDefinitions.Count - 1, prop.Name); } else if (fileType == FileType.eText || fileType == FileType.eScript) { showTxt(text, prop.Name); } else if (fileType == FileType.eVideo || fileType == FileType.eAudio) { showMusic(text, prop.Name); } else { _panelParent.RowDefinitions.RemoveAt(_panelParent.RowDefinitions.Count - 1); return; } gridAddEnd(); } }