public int CompareTo(DetailsListSampleFileItem other, string columnSortingKey) { if (other == null) { throw new ArgumentException(nameof(other)); } if (columnSortingKey.Equals(nameof(FileIcon))) { return(FileIcon.CompareTo(other.FileIcon)); } if (columnSortingKey.Equals(nameof(FileName))) { return(string.Compare(FileName, other.FileName, StringComparison.Ordinal)); } if (columnSortingKey.Equals(nameof(DateModified))) { return(DateModified.CompareTo(other.DateModified)); } if (columnSortingKey.Equals(nameof(ModifiedBy))) { return(string.Compare(FileName, other.FileName, StringComparison.Ordinal)); } if (columnSortingKey.Equals(nameof(FileSize))) { return(FileSize.CompareTo(other.FileSize)); } throw new InvalidOperationException($"Can not match {columnSortingKey} to current list item"); }
private ListViewItem GetItem(int index) { //information needed for parsing var fileName = _filesArray[index].Name; var fileType = Methods.GetLegoFileType(fileName); //icon assignation (default is the 'Unknown File' icon) var imageIndex = FileIcon.FileIconIndex(fileName); //item to add to the list view var newItem = new ListViewItem(@"", imageIndex); //construct sub-items var items = new[] { new ListViewItem.ListViewSubItem(newItem, index.ToString()), new ListViewItem.ListViewSubItem(newItem, fileName), new ListViewItem.ListViewSubItem(newItem, fileType), new ListViewItem.ListViewSubItem(newItem, $"0x{_filesArray[index].Crc:X8}"), new ListViewItem.ListViewSubItem(newItem, $"0x{_filesArray[index].Offset:X8}"), new ListViewItem.ListViewSubItem(newItem, _filesArray[index].SizeUnComp.ToString()), new ListViewItem.ListViewSubItem(newItem, _filesArray[index].Size.ToString()), new ListViewItem.ListViewSubItem(newItem, $"0x{_filesArray[index].Pack:X3}") }; //add sub-items newItem.SubItems.AddRange(items); //return the final item return(newItem); }
/// <summary> /// Gets the TreeNodes representing the entries /// </summary> /// <param name="img">The image list that will hold the icons</param> /// <returns>An array list of treenodes</returns> public TreeNode[] GetTreeNodes(ImageList img) { if (m_Entries.Count == 0) { return new TreeNode[0]; } if (img == null) img = new ImageList(); var nodes = new TreeNode[m_Entries.Count]; img.Images.Clear(); for (var i = 0; i < nodes.Length; i++) { // Issue 10 - Update the code to Net Framework 3.5 - http://code.google.com/p/pandorasbox3/issues/detail?id=10 - Smjert var entry = m_Entries[i]; // Issue 10 - End nodes[i] = entry.TreeNode; if (entry.Valid) { var icon = FileIcon.GetSmallIcon(entry.Path); if (icon != null) { img.Images.Add(icon); nodes[i].ImageIndex = img.Images.Count - 1; nodes[i].SelectedImageIndex = img.Images.Count - 1; } } } return nodes; }
public File(DirectoryInfo file, DriveMapping mapping, User user) { Extension = file.Extension; Type = "Directory"; Name = file.Name + (file.Name.Contains(file.Extension) ? "" : file.Extension); try { Permissions = UserFileAccessRights.Get(file.FullName).ToPerms(); } catch { } FileIcon fi; if (FileIcon.TryGet(Extension, out fi)) { Type = fi.Type; Name = Name.Remove(Name.LastIndexOf(file.Extension)); } Icon = "../images/icons/" + ParseForImage(file); if (Icon.EndsWith(".ico")) { Icon = "../api/mycomputer/" + ParseForImage(file); } if (file.Extension.ToLower().Equals(".png") || file.Extension.ToLower().Equals(".jpg") || file.Extension.ToLower().Equals(".jpeg") || file.Extension.ToLower().Equals(".gif") || file.Extension.ToLower().Equals(".bmp") || file.Extension.ToLower().Equals(".wmf")) { Icon = "../api/mycomputer/thumb/" + HttpUtility.UrlEncode(Converter.UNCtoDrive(file.FullName, mapping, user).Replace(":", "")).Replace('+', ' ').Replace("%", "|").Replace("|2f", "/"); } CreationTime = file.CreationTime.ToShortDateString() + " " + file.CreationTime.ToString("hh:mm"); UnderlyingCreation = file.CreationTime; ModifiedTime = file.LastWriteTime.ToShortDateString() + " " + file.LastWriteTime.ToString("hh:mm"); UnderlyingModified = file.LastWriteTime; UnderlyingSize = 0; Size = ""; Path = HttpUtility.UrlEncode(Converter.UNCtoDrive(file.FullName, mapping, user).Replace(":", "")).Replace('+', ' ').Replace("%", "|").Replace("|5c", "\\"); Permissions = UserFileAccessRights.Get(file.FullName).ToPerms(); }
private void Wrap_Drop(object sender, DragEventArgs e) { Array dropObject = (System.Array)e.Data.GetData(DataFormats.FileDrop); if (dropObject == null) { return; } string path = (string)dropObject.GetValue(0); if (File.Exists(path)) { // 文件 BitmapImage bi = FileIcon.GetBitmapImage(path); DataInfos infos = new DataInfos(); infos.Path = path; infos.BitmapImage = bi; infos.Name = Path.GetFileNameWithoutExtension(path); data.Items.Add(infos); data.Items.Refresh(); } else if (Directory.Exists(path)) { //文件夹 } }
public void GetFileIcon() { try { if (System.IO.File.Exists(_fullFileName)) { using (Icon CurrentIcon = Icon.ExtractAssociatedIcon(_fullFileName)) { FileIcon = Imaging.CreateBitmapSourceFromHIcon(CurrentIcon.Handle, System.Windows.Int32Rect.Empty, System.Windows.Media.Imaging.BitmapSizeOptions.FromEmptyOptions()); FileIcon.Freeze(); } } else if ((System.IO.Directory.Exists(_fullFileName))) { BitmapImage Bi = null; Bi = new BitmapImage(new Uri(@"pack://application:,,,/NavigatorRV;component/Images/folder.png", UriKind.Absolute)); FileIcon = Bi; FileIcon.Freeze(); //FileIcon = new BitmapImage(new Uri(PngFolderPath + "\\img\\folder.png")); //FileIcon.Freeze(); } else { FileIcon = null; } } catch (Exception) { } }
private void DisplayIcon(FileData fileData) { FileIcon icon = Instantiate(IconPrefab, IconHolder); icon.Setup(GetIcon(fileData.Extension), String.Concat(RemoveFileNamePrefix(fileData.FileName), ".", fileData.Extension.ToString("F"))); icon.fileData = fileData; }
public FileItemView(string fullFilename, FileIconType fileType) { InitializeComponent(); this.FullFilename = fullFilename; this.Filename = Path.GetFileName(fullFilename); UserControl icon = null; switch (fileType) { case FileIconType.Directory: icon = new DirectoryIcon(); break; case FileIconType.File: icon = new FileIcon(); break; } if (icon != null) { IconContext.Children.Add(icon); } RegisterEvents(); SetSelected(false); }
protected override void Dispose(bool disposing) { if (disposing) { FileIcon?.Dispose(); PreviewImage?.Dispose(); } base.Dispose(disposing); }
/// <summary> /// Create an instance of the class and reads the main icon of the given file. /// The icon is then converted into a bitmap so it is available both as icon object /// and as bitmap object. /// </summary> /// <param name="file">file to read icon from</param> public IconHandler(string file) { if (System.IO.File.Exists(file)) { SHFILEINFO shinfo = new SHFILEINFO(); SHGetFileInfo(file, 0, ref shinfo, (uint)Marshal.SizeOf(shinfo), SHGFI_ICON | SHGFI_SMALLICON); FileIcon = Icon.FromHandle(shinfo.hIcon); FileBitmap = FileIcon.ToBitmap(); } }
public override ImageSource Convert(string value) { if (Path.HasExtension(value)) { return(FileIcon.FromExtension(Path.GetExtension(value))?.Icon16ImageSource ?? SpecialFileIcons.Unknown.Icon16ImageSource); } else { return(null); } }
private void WindowLoaded(object sender, RoutedEventArgs e) { //System.Drawing.Icon icon = FileIcon.GetJumboIcon('*' + File.FileFormat); //BitmapImage img = GetBitmapImage(icon); //fileIcon_Image.Source = img; fileIcon_Image.Source = GetBitmapImage(FileIcon.GetJumboIcon(File.FileFormat)); fileName_Textblock.Text = "Name: " + File.Name; fileSize_Textblock.Text = "File Size: " + File.FileSize.ToString(); fileFormat_Textblock.Text = "Format: " + File.FileFormat; creationDate_Textblock.Text = "Date: " + File.CreationDate.ToShortDateString(); description_Textblock.Text = File.Description; }
public File(FileInfo file, DriveMapping mapping, User user) { Extension = file.Extension; Type = "File"; Name = file.Name + (file.Name.Contains(file.Extension) ? "" : file.Extension); CreationTime = file.CreationTime.ToShortDateString() + " " + file.CreationTime.ToString("hh:mm"); UnderlyingCreation = file.CreationTime; ModifiedTime = file.LastWriteTime.ToShortDateString() + " " + file.LastWriteTime.ToString("hh:mm"); UnderlyingModified = file.LastWriteTime; Size = parseLength(file.Length); UnderlyingSize = file.Length; FileIcon fi; if (FileIcon.TryGet(Extension, out fi)) { Type = fi.Type; Name = Name.Remove(Name.LastIndexOf(file.Extension)); } if (Type == "File") { try { RegistryKey rkRoot = Registry.ClassesRoot; string keyref = rkRoot.OpenSubKey(file.Extension).GetValue("").ToString(); Type = rkRoot.OpenSubKey(keyref).GetValue("").ToString(); Name = Name.Remove(Name.LastIndexOf(file.Extension)); } catch { Type = "File"; } } if (Type != "File") { Icon = "../images/icons/" + ParseForImage(file); if (Icon.EndsWith(".ico")) { Icon = "../api/mycomputer/" + ParseForImage(file); } } else { Icon = "../images/icons/file.png"; } string m = Converter.UNCtoDrive2(file.FullName, mapping, user); Path = "../Download/" + HttpUtility.UrlEncode(m.Replace(":", "")).Replace('+', ' ').Replace("%", "|").Replace("|2f", "/"); if (file.Extension.ToLower().Equals(".png") || file.Extension.ToLower().Equals(".jpg") || file.Extension.ToLower().Equals(".jpeg") || file.Extension.ToLower().Equals(".gif") || file.Extension.ToLower().Equals(".bmp") || file.Extension.ToLower().Equals(".wmf")) { Icon = "../api/mycomputer/thumb/" + HttpUtility.UrlEncode(m.Replace(":", "")).Replace('+', ' ').Replace("%", "|").Replace("|2f", "/"); } Permissions = UserFileAccessRights.Get(file.FullName).ToPerms(); }
public override void PreLoadContent() { antivirus = new FileIcon(graphicsDevice, this); taskBar = new TaskBar(graphicsDevice, this); startMenu = new StartMenu(graphicsDevice, this); warning = new Warning(graphicsDevice, this); hacking = new Hacking(graphicsDevice, this); readme = new Readme(graphicsDevice, this); message = new Label(graphicsDevice, this); message.TextSize = 24f; message.Text = "Startボタンでスキャン\r\nBackボタンでシャットダウン\r\nAボタンで確認\r\nBボタンでキャンセル"; message.Location = new Point(Size.Width - message.Size.Width, 0); new WarningMessage(graphicsDevice, this, antivirus); EventRegist(); base.PreLoadContent(); }
//private string getSuffix(ExportFileType type) { //} private DibMd loadFile(string srcPath, int icoSize) { string srcSuffix = Path.GetExtension(srcPath).ToLower(); FIBITMAP dib; try { switch (srcSuffix) { case ".ico": { dib = FreeImage.Load(FREE_IMAGE_FORMAT.FIF_ICO, srcPath, FREE_IMAGE_LOAD_FLAGS.DEFAULT); break; } case ".bmp": { dib = FreeImage.Load(FREE_IMAGE_FORMAT.FIF_BMP, srcPath, FREE_IMAGE_LOAD_FLAGS.DEFAULT); break; } case ".jpg": { dib = FreeImage.Load(FREE_IMAGE_FORMAT.FIF_JPEG, srcPath, FREE_IMAGE_LOAD_FLAGS.DEFAULT); break; } case ".png": { dib = FreeImage.Load(FREE_IMAGE_FORMAT.FIF_PNG, srcPath, FREE_IMAGE_LOAD_FLAGS.DEFAULT); break; } default: { Bitmap img = FileIcon.getIcon(srcPath, icoSize); if (img == null) { return(null); } dib = FreeImage.CreateFromBitmap(img); break; //return; } } return(new DibMd(dib)); } catch (Exception) { } return(null); }
private void FilesCtx_Opening(object sender, System.ComponentModel.CancelEventArgs e) { var hasItems = Files.SelectedItems.Count != 0; CtxOpenDirectory.Enabled = hasItems; if (!hasItems) { return; } var item = Files.SelectedItems[0] as ArchiveItem; if (item == null) { CtxOpenDirectory.Enabled = false; return; } CtxOpenDirectory.Image = FileIcon.GetIcon(item.BaseDirectory.FullName, FileIconSize.Small); }
public ArchiveItem(string aFileName, Guid aFormat, bool aNested) { format = aFormat; nested = aNested; SubItems.Add(string.Empty); SubItems.Add("Ready..."); file = new FileInfo(aFileName); parts.Add(aFileName, file); if (!Icons.Images.ContainsKey(file.Extension)) { Icons.Images.Add(file.Extension, FileIcon.GetIcon(file.FullName, FileIconSize.Small)); } ImageKey = file.Extension; StateImageIndex = 0; Invalidate(); }
public UploadWindow(FileStream selectedFile) { this.uploadFile = selectedFile; this.connection = new Connection(); InitializeComponent(); string fullFileName = selectedFile.Name; fullName = fullFileName; fileName = fullFileName.Split('\\')[fullFileName.Split('\\').Length - 1]; fileType = "." + fileName.Split('.')[fileName.Split('.').Length - 1]; fileSize = ExtensionMethods.ConvertFileSize(selectedFile.Length, ExtensionMethods.SizeUnit.kB); fileIcon_Image.Source = GetBitmapImage(FileIcon.GetJumboIcon(fileType)); lblName.Content += fileName; lblSize.Content += fileSize; lblFormat.Content += fileType; lblCreationDate.Content += String.Format("{0}-{1}-{2}", DateTime.Now.Day, DateTime.Now.Month, DateTime.Now.Year); }
public Properties(FileInfo file, DriveMapping mapping, User user) { Actions = isWriteAuth(mapping) ? HAP.MyFiles.AccessControlActions.Change : HAP.MyFiles.AccessControlActions.View; Name = file.Name + (file.Name.Contains(file.Extension) ? "" : file.Extension); Extension = file.Extension; DateCreated = file.CreationTime.ToString(); DateModified = file.LastWriteTime.ToString(); DateAccessed = file.LastAccessTime.ToString(); Location = HttpUtility.UrlEncode(Converter.UNCtoDrive(file.Directory.FullName, mapping, user).Replace(":", "")).Replace('+', ' ').Replace("%", "|").Replace("|5c", "\\"); Size = File.parseLength(file.Length); FileIcon fi; if (FileIcon.TryGet(Extension, out fi)) { Type = fi.Type; } if (Type == "File") { try { RegistryKey rkRoot = Registry.ClassesRoot; string keyref = rkRoot.OpenSubKey(file.Extension).GetValue("").ToString(); Type = rkRoot.OpenSubKey(keyref).GetValue("").ToString(); } catch { Type = "File"; } } if (Type != "File") { Icon = "../images/icons/" + File.ParseForImage(file); if (Icon.EndsWith(".ico")) { Icon = "../api/mycomputer/" + File.ParseForImage(file); } } else { Icon = "../images/icons/file.png"; } }
public Main(bool autoProcess, string dir, string[] args) { auto = autoProcess; InitializeComponent(); Files.SmallImageList = Files.LargeImageList = ArchiveItem.Icons; StateIcons.Images.Add(Properties.Resources.idle); StateIcons.Images.Add(Properties.Resources.done); StateIcons.Images.Add(Properties.Resources.error); StateIcons.Images.Add(Properties.Resources.run); StateIcons.Images.Add(Properties.Resources.warning); Text = String.Format(CultureInfo.CurrentCulture, "{0} - {1}bit", Text, CpuInfo.IsX64 ? 64 : 32); About.Image = Icon.ToBitmap(); RefreshPasswordCount(); BrowseDestDialog.SelectedPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal); CtxOpenDirectory.Image = FileIcon.GetIcon(BrowseDestDialog.SelectedPath, FileIconSize.Small); Dests.AddRange(Config.Destinations.ToArray()); DestinationsChanged(); if (!string.IsNullOrEmpty(dir)) { Dests.Add(dir); } if (args != null && args.Length != 0) { AddFiles(args); } else { AdjustHeaders(); } }
/// <summary> /// Returns the string name of the supplied icon. /// </summary> /// <param name="icon"> /// A <see cref="GLib.Icon"/> /// </param> /// <returns> /// A <see cref="System.String"/> /// </returns> public string IconFromGIcon(GLib.Icon icon) { string name = ""; if (icon is ThemedIcon) { ThemedIcon themeIcon = new ThemedIcon(icon.Handle); // if the icon exists in the theme, this will return the relevent icon if (themeIcon.Names.Any()) { name = themeIcon.Names.FirstOrDefault(n => IconTheme.Default.HasIcon(n)); } themeIcon.Dispose(); } else if (icon is FileIcon) { // in some cases, devices provide their own icon. This will use the device icon. FileIcon iconFile = new FileIcon(icon.Handle); name = iconFile.File.Path; iconFile.Dispose(); } return(name); }
public void LoadImageName() { // open folder, get all filenames string path = AppDomain.CurrentDomain.BaseDirectory + foldername; string[] filenames = Directory.GetFiles(path); // check filename to assign to variables foreach (var fullname in filenames) { string filename = Path.GetFileName(fullname); string[] tokens = filename.Split(new string[] { "_" }, StringSplitOptions.RemoveEmptyEntries); if (tokens[0].ToLower() == "Application".ToLower()) { ApplicationIcon.Add ( path + filename ); } else if (tokens[0].ToLower() == "Option".ToLower()) { OptionIcon.Add ( path + filename ); } else if (tokens[0].ToLower() == "Remove".ToLower()) { RemoveIcon.Add ( path + filename ); } else if (tokens[0].ToLower() == "RemoveAll".ToLower()) { RemoveAllIcon.Add ( path + filename ); } else if (tokens[0].ToLower() == "Add".ToLower()) { AddIcon.Add ( path + filename ); } else if (tokens[0].ToLower() == "Preview".ToLower()) { PreviewIcon.Add ( path + filename ); } else if (tokens[0].ToLower() == "Start".ToLower()) { StartIcon.Add ( path + filename ); } else if (tokens[0].ToLower() == "Refresh".ToLower()) { RefreshIcon.Add ( path + filename ); } else if (tokens[0].ToLower() == "Help".ToLower()) { HelpIcon.Add ( path + filename ); } else if (tokens[0].ToLower() == "Open".ToLower()) { OpenIcon.Add ( path + filename ); } else if (tokens[0].ToLower() == "Save".ToLower()) { SaveIcon.Add ( path + filename ); } else if (tokens[0].ToLower() == "Information".ToLower()) { InformationIcon.Add ( path + filename ); } else if (tokens[0].ToLower() == "File".ToLower()) { FileIcon.Add ( path + filename ); } else if (tokens[0].ToLower() == "Folder".ToLower()) { FolderIcon.Add ( path + filename ); } else if (tokens[0].ToLower() == "Action".ToLower()) { ActionIcon.Add ( path + filename ); } else if (tokens[0].ToLower() == "List".ToLower()) { ListIcon.Add ( path + filename ); } else if (tokens[0].ToLower() == "UpDirection".ToLower()) { UpDirectionIcon.Add ( path + filename ); } else if (tokens[0].ToLower() == "RightDirection".ToLower()) { RightDirectionIcon.Add ( path + filename ); } else if (tokens[0].ToLower() == "DownDirection".ToLower()) { DownDirectionIcon.Add ( path + filename ); } else if (tokens[0].ToLower() == "LeftDirection".ToLower()) { LeftDirectionIcon.Add ( path + filename ); } else { Images.Add ( path + filename ); } } }
private static DataTable BuildDataSource(DataTable data, List <GridColumnAttrib> columns, bool forceRawData) { var needsRebuilt = ColumnsRequireRebuild(columns); if (needsRebuilt & !forceRawData) { DataTable newTable = new DataTable(); // Add columns to the new table. foreach (GridColumnAttrib col in columns) { if (col.ColumnType != null) { newTable.Columns.Add(col.ColumnName, col.ColumnType); } else { if (data.Columns.Contains(col.ColumnName)) { newTable.Columns.Add(col.ColumnName, data.Columns[col.ColumnName].DataType); } } } foreach (DataRow row in data.Rows) { DataRow newRow = newTable.NewRow(); foreach (GridColumnAttrib col in columns) { if (!data.Columns.Contains(col.ColumnName)) { continue; } switch (col.ColumnFormatType) { case ColumnFormatType.DefaultFormat: case ColumnFormatType.AttributeCombo: newRow[col.ColumnName] = row[col.ColumnName]; break; case ColumnFormatType.AttributeDisplayMemberOnly: newRow[col.ColumnName] = col.Attributes[row[col.ColumnName].ToString()].DisplayValue; break; case ColumnFormatType.NotePreview: var noteText = OtherFunctions.RTFToPlainText(row[col.ColumnName].ToString()); newRow[col.ColumnName] = OtherFunctions.NotePreview(noteText); break; case ColumnFormatType.FileSize: newRow[col.ColumnName] = Math.Round((Convert.ToInt32(row[col.ColumnName]) / 1024d), 1); break; case ColumnFormatType.Image: newRow[col.ColumnName] = FileIcon.GetFileIcon(row[col.ColumnName].ToString()); break; } } newTable.Rows.Add(newRow); } return(newTable); } else { return(data); } }
private void convert(string srcPath, string dstPath, int icoSize, int bpp) { string srcSuffix = Path.GetExtension(srcPath).ToLower(); string dstSuffix = Path.GetExtension(dstPath).ToLower(); //bool isDir = Directory.Exists(srcPath); // save try { FIBITMAP dib; switch (srcSuffix) { case ".ico": { dib = FreeImage.Load(FREE_IMAGE_FORMAT.FIF_ICO, srcPath, FREE_IMAGE_LOAD_FLAGS.DEFAULT); break; } case ".bmp": { dib = FreeImage.Load(FREE_IMAGE_FORMAT.FIF_BMP, srcPath, FREE_IMAGE_LOAD_FLAGS.DEFAULT); break; } case ".jpg": { dib = FreeImage.Load(FREE_IMAGE_FORMAT.FIF_JPEG, srcPath, FREE_IMAGE_LOAD_FLAGS.DEFAULT); break; } case ".png": { dib = FreeImage.Load(FREE_IMAGE_FORMAT.FIF_PNG, srcPath, FREE_IMAGE_LOAD_FLAGS.DEFAULT); break; } default: { Bitmap img = FileIcon.getIcon(srcPath, icoSize); if (img == null) { return; } dib = FreeImage.CreateFromBitmap(img); break; //return; } } //FIBITMAP dib = FreeImage.Load(FREE_IMAGE_FORMAT.FIF_PNG, srcPath, FREE_IMAGE_LOAD_FLAGS.DEFAULT); uint width = FreeImage.GetWidth(dib); uint height = FreeImage.GetHeight(dib); //FIBITMAP dibTmp = FreeImage.Rescale(dib, icoSize, icoSize, FREE_IMAGE_FILTER.FILTER_BICUBIC); FIBITMAP dibOut = formatImage(dib, icoSize, bpp); FREE_IMAGE_FORMAT format = FREE_IMAGE_FORMAT.FIF_ICO; FREE_IMAGE_SAVE_FLAGS flag = FREE_IMAGE_SAVE_FLAGS.BMP_SAVE_RLE; switch (dstSuffix) { case ".png": format = FREE_IMAGE_FORMAT.FIF_PNG; flag = FREE_IMAGE_SAVE_FLAGS.PNG_Z_DEFAULT_COMPRESSION; break; case ".jpg": format = FREE_IMAGE_FORMAT.FIF_JPEG; flag = FREE_IMAGE_SAVE_FLAGS.JPEG_QUALITYGOOD; break; case ".bmp": format = FREE_IMAGE_FORMAT.FIF_BMP; flag = FREE_IMAGE_SAVE_FLAGS.BMP_SAVE_RLE; break; case ".ico": default: break; } FreeImage.Save(format, dibOut, dstPath, flag); //bool isOk = FreeImage.Save(FREE_IMAGE_FORMAT.FIF_PNG, dibOut, dstPath + ".png", FREE_IMAGE_SAVE_FLAGS.PNG_INTERLACED); FreeImage.Unload(dibOut); FreeImage.Unload(dib); } catch (Exception ex) { Debug.WriteLine(ex.ToString()); } }
public static Image GetImageForFile(string fileName) { return(FileIcon.GetBitmap(fileName, true)); }
private void PopulateListView() { //clear the list of any items then disable it to prevent user input while working lstMain.Invoke((MethodInvoker) delegate { lstMain.Items.Clear(); lstMain.Enabled = false; }); var nodeDirInfo = (DirectoryInfo)_newSelected.Tag; ListViewItem item; //reset progress bar lstMain.Invoke((MethodInvoker) delegate { if (pbMain.ProgressBar == null) { return; } pbMain.ProgressBar.Maximum = nodeDirInfo.GetFiles().Length; pbMain.ProgressBar.Value = 0; }); foreach (var file in nodeDirInfo.GetFiles()) { //index 1 is the 'Unknown File' icon var imageIndex = FileIcon.FileIconIndex(file.Name); //the new item to add item = new ListViewItem(file.Name, imageIndex); //the cells that belong to the new item var items = new[] { new ListViewItem.ListViewSubItem(item, Methods.GetLegoFileType(file.Extension)), new ListViewItem.ListViewSubItem(item, Methods.FormatSize(file.Length, true)), new ListViewItem.ListViewSubItem(item, file.LastAccessTime.ToShortDateString()) }; //add the new sub items item.SubItems.AddRange(items); //invoke and begin adding lstMain.Invoke((MethodInvoker) delegate { //new entry is added lstMain.Items.Add(item); //the method is exited if the progress bar is undefined if (pbMain.ProgressBar == null) { return; } //the progress bar is incremented ++pbMain.ProgressBar.Value; //percentage completion calculation var percComplete = (int)(pbMain.ProgressBar.Value / (double)pbMain.ProgressBar.Maximum * 100.0); //draws the % completion inside of the progressbar (on-the-fly) pbMain.ProgressBar.CreateGraphics().DrawString($"{percComplete}%", new Font("Arial", 8.25f, FontStyle.Regular), Brushes.Gray, new PointF(pbMain.ProgressBar.Width / 2 - 10, pbMain.ProgressBar.Height / 2 - 7)); }); } //resize the columns to fit the window lstMain.Invoke((MethodInvoker) delegate { lstMain.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent); lstMain.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize); lstMain.Enabled = true; }); }
/// <summary> /// Constructs a new instance of the FileIcon class /// and retrieves the information specified in the /// flags. /// </summary> /// <param name="fileName">The filename to get information /// for</param> /// <param name="flags">The flags to use when extracting the /// icon and other shell information.</param> public FileIcon(string fileName, FileIcon.SHGetFileInfoConstants flags) { this.fileName = fileName; this.flags = flags; GetInfo(); }
private Icon getIcon(bool large) { // Get icon index and path: int iconIndex = 0; StringBuilder iconPath = new StringBuilder(260, 260); if (linkA == null) { linkW.GetIconLocation(iconPath, iconPath.Capacity, out iconIndex); } else { linkA.GetIconLocation(iconPath, iconPath.Capacity, out iconIndex); } string iconFile = iconPath.ToString(); // If there are no details set for the icon, then we must use // the shell to get the icon for the target: if (iconFile.Length == 0) { // Use the FileIcon object to get the icon: FileIcon.SHGetFileInfoConstants flags = FileIcon.SHGetFileInfoConstants.SHGFI_ICON | FileIcon.SHGetFileInfoConstants.SHGFI_ATTRIBUTES; if (large) { flags = flags | FileIcon.SHGetFileInfoConstants.SHGFI_LARGEICON; } else { flags = flags | FileIcon.SHGetFileInfoConstants.SHGFI_SMALLICON; } FileIcon fileIcon = new FileIcon(Target, flags); return fileIcon.ShellIcon; } else { // Use ExtractIconEx to get the icon: IntPtr[] hIconEx = new IntPtr[1] {IntPtr.Zero}; int iconCount = 0; if (large) { iconCount = UnManagedMethods.ExtractIconEx( iconFile, iconIndex, hIconEx, null, 1); } else { iconCount = UnManagedMethods.ExtractIconEx( iconFile, iconIndex, null, hIconEx, 1); } // If success then return as a GDI+ object Icon icon = null; if (hIconEx[0] != IntPtr.Zero) { icon = Icon.FromHandle(hIconEx[0]); //UnManagedMethods.DestroyIcon(hIconEx[0]); } return icon; } }
/// <summary> /// Shows a native Gtk notification. For best results, you shows initialize a /// <seealso cref="GLib.Application"/> /// with the correct application id. Also, gnome-shell requires a desktop file /// whose base name matches the application id for the notification to show. /// </summary> /// <param name="toast">ToastNotification as created in the native library.</param> /// <returns></returns> public static async Task Show(this ToastNotification toast) { var notification = new Notification(toast.Title); notification.Body = toast.Message; string path = null; if (toast.AppLogoOverride != null) { var stream = await toast.AppLogoOverride.GetStreamAsync().ConfigureAwait(false); path = Path.GetTempFileName(); var fileStream = File.OpenWrite(path); stream.CopyTo(fileStream); stream.Dispose(); fileStream.Dispose(); var fileInfo = FileFactory.NewForPath(path); FileIcon icon = new FileIcon(fileInfo); notification.Icon = icon; icon.Dispose(); } Guid id; if (ids.ContainsKey(toast)) { id = ids[toast]; } else { id = Guid.NewGuid(); ids.Add(toast, id); notifications.Add(id, toast); } await InvokeAsync(() => { if (Application.Default == null) { var application = new Application(Windows.ApplicationModel.Package.Current.DisplayName + ".Skia.Gtk", ApplicationFlags.None); application.Register(null); } Application.Default.SendNotification(id.ToString(), notification); notification.Dispose(); // Gtk notifications do not automatically close, so we can decide the time here. var waitTime = toast.ToastDuration == ToastDuration.Short ? 7000 : 25000; Thread.Sleep(waitTime); Application.Default.WithdrawNotification(id.ToString()); // Gnome uses this temporary file to display the icon. We must not delete this file // before the notification withdraws. if (path != null) { File.Delete(path); } }).ConfigureAwait(false); }
/// <summary> /// Initializes a new instance of the <see cref="FileAttachmentAnnotation" /> class. /// </summary> /// <param name="Links">Link to the document.</param> /// <param name="Color">Color of the annotation.</param> /// <param name="Contents">Get the annotation content.</param> /// <param name="Modified">The date and time when the annotation was last modified.</param> /// <param name="Id">Gets ID of the annotation.</param> /// <param name="Flags">Gets Flags of the annotation.</param> /// <param name="Name">Gets Name of the annotation.</param> /// <param name="Rect">Gets Rect of the annotation. (required)</param> /// <param name="PageIndex">Gets PageIndex of the annotation.</param> /// <param name="ZIndex">Gets ZIndex of the annotation.</param> /// <param name="HorizontalAlignment">Gets HorizontalAlignment of the annotation.</param> /// <param name="VerticalAlignment">Gets VerticalAlignment of the annotation.</param> /// <param name="CreationDate">The date and time when the annotation was created.</param> /// <param name="Subject">Get the annotation subject.</param> /// <param name="Title">Get the annotation title.</param> /// <param name="RichText">Get the annotation RichText.</param> /// <param name="Icon">Gets or sets icon that shall be used in displaying annotation.</param> /// <param name="Opacity">Gets or sets icon's opacity from 0 to 1: 0 - completely transparant, 1 - completely opaque.</param> /// <param name="FileDescription">Gets or sets text associated with the file specification. </param> /// <param name="FileName">Gets or sets file specification name. </param> /// <param name="FilePath">Sets content file path. </param> public FileAttachmentAnnotation(List <Link> Links = default(List <Link>), Color Color = default(Color), string Contents = default(string), string Modified = default(string), string Id = default(string), List <AnnotationFlags> Flags = default(List <AnnotationFlags>), string Name = default(string), Rectangle Rect = default(Rectangle), int?PageIndex = default(int?), int?ZIndex = default(int?), HorizontalAlignment HorizontalAlignment = default(HorizontalAlignment), VerticalAlignment VerticalAlignment = default(VerticalAlignment), string CreationDate = default(string), string Subject = default(string), string Title = default(string), string RichText = default(string), FileIcon Icon = default(FileIcon), double?Opacity = default(double?), string FileDescription = default(string), string FileName = default(string), string FilePath = default(string)) { // to ensure "Rect" is required (not null) if (Rect == null) { throw new InvalidDataException("Rect is a required property for FileAttachmentAnnotation and cannot be null"); } else { this.Rect = Rect; } this.Links = Links; this.Color = Color; this.Contents = Contents; this.Modified = Modified; this.Id = Id; this.Flags = Flags; this.Name = Name; this.PageIndex = PageIndex; this.ZIndex = ZIndex; this.HorizontalAlignment = HorizontalAlignment; this.VerticalAlignment = VerticalAlignment; this.CreationDate = CreationDate; this.Subject = Subject; this.Title = Title; this.RichText = RichText; this.Icon = Icon; this.Opacity = Opacity; this.FileDescription = FileDescription; this.FileName = FileName; this.FilePath = FilePath; }
public void LoadImageName() { // open folder, get all filenames //AppDomain.CurrentDomain.BaseDirectory string path = AppDomain.CurrentDomain.BaseDirectory + foldername; string[] filenames = Directory.GetFiles(path); // check filename to assign to variables foreach (var fullname in filenames) { string filename = Path.GetFileName(fullname); string[] tokens = StringProcess.SplitString(filename, new string[] { "_" }); if (tokens[0].ToLower() == "Application".ToLower()) { ApplicationIcon.Add ( new MyString() { Value = path + filename } ); } else if (tokens[0].ToLower() == "Option".ToLower()) { OptionIcon.Add ( new MyString() { Value = path + filename } ); } else if (tokens[0].ToLower() == "Remove".ToLower()) { RemoveIcon.Add ( new MyString() { Value = path + filename } ); } else if (tokens[0].ToLower() == "RemoveAll".ToLower()) { RemoveAllIcon.Add ( new MyString() { Value = path + filename } ); } else if (tokens[0].ToLower() == "Add".ToLower()) { AddIcon.Add ( new MyString() { Value = path + filename } ); } else if (tokens[0].ToLower() == "Preview".ToLower()) { PreviewIcon.Add ( new MyString() { Value = path + filename } ); } else if (tokens[0].ToLower() == "Start".ToLower()) { StartIcon.Add ( new MyString() { Value = path + filename } ); } else if (tokens[0].ToLower() == "Refresh".ToLower()) { RefreshIcon.Add ( new MyString() { Value = path + filename } ); } else if (tokens[0].ToLower() == "Help".ToLower()) { HelpIcon.Add ( new MyString() { Value = path + filename } ); } else if (tokens[0].ToLower() == "Open".ToLower()) { OpenIcon.Add ( new MyString() { Value = path + filename } ); } else if (tokens[0].ToLower() == "Save".ToLower()) { SaveIcon.Add ( new MyString() { Value = path + filename } ); } else if (tokens[0].ToLower() == "Information".ToLower()) { InformationIcon.Add ( new MyString() { Value = path + filename } ); } else if (tokens[0].ToLower() == "File".ToLower()) { FileIcon.Add ( new MyString() { Value = path + filename } ); } else if (tokens[0].ToLower() == "Folder".ToLower()) { FolderIcon.Add ( new MyString() { Value = path + filename } ); } else if (tokens[0].ToLower() == "Action".ToLower()) { ActionIcon.Add ( new MyString() { Value = path + filename } ); } else if (tokens[0].ToLower() == "List".ToLower()) { ListIcon.Add ( new MyString() { Value = path + filename } ); } } }
/// <summary> /// Initializes a new instance of the <see cref="FileAttachmentAnnotation" /> class. /// </summary> /// <param name="Links">Link to the document..</param> /// <param name="Color">Color of the annotation..</param> /// <param name="Contents">Get the annotation content..</param> /// <param name="Modified">The date and time when the annotation was last modified..</param> /// <param name="Id">Gets ID of the annotation..</param> /// <param name="Flags">Gets Flags of the annotation..</param> /// <param name="Name">Gets Name of the annotation..</param> /// <param name="Rect">Gets Rect of the annotation..</param> /// <param name="PageIndex">Gets PageIndex of the annotation..</param> /// <param name="ZIndex">Gets ZIndex of the annotation..</param> /// <param name="HorizontalAlignment">Gets HorizontalAlignment of the annotation..</param> /// <param name="VerticalAlignment">Gets VerticalAlignment of the annotation..</param> /// <param name="CreationDate">The date and time when the annotation was created..</param> /// <param name="Subject">Get the annotation subject..</param> /// <param name="Title">Get the annotation title..</param> /// <param name="RichText">Get the annotation RichText..</param> /// <param name="Icon">Gets or sets icon that shall be used in displaying annotation..</param> /// <param name="Opacity">Gets or sets icon's opacity from 0 to 1: 0 - completely transparant, 1 - completely opaque..</param> /// <param name="FileDescription">Gets or sets text associated with the file specification. .</param> /// <param name="FileName">Gets or sets file specification name. .</param> /// <param name="FilePath">Sets content file path. .</param> public FileAttachmentAnnotation(List <Link> Links = default(List <Link>), Color Color = default(Color), string Contents = default(string), string Modified = default(string), string Id = default(string), List <AnnotationFlags> Flags = default(List <AnnotationFlags>), string Name = default(string), Rectangle Rect = default(Rectangle), int?PageIndex = default(int?), int?ZIndex = default(int?), HorizontalAlignment HorizontalAlignment = default(HorizontalAlignment), VerticalAlignment VerticalAlignment = default(VerticalAlignment), string CreationDate = default(string), string Subject = default(string), string Title = default(string), string RichText = default(string), FileIcon Icon = default(FileIcon), double?Opacity = default(double?), string FileDescription = default(string), string FileName = default(string), string FilePath = default(string)) { this.Links = Links; this.Color = Color; this.Contents = Contents; this.Modified = Modified; this.Id = Id; this.Flags = Flags; this.Name = Name; this.Rect = Rect; this.PageIndex = PageIndex; this.ZIndex = ZIndex; this.HorizontalAlignment = HorizontalAlignment; this.VerticalAlignment = VerticalAlignment; this.CreationDate = CreationDate; this.Subject = Subject; this.Title = Title; this.RichText = RichText; this.Icon = Icon; this.Opacity = Opacity; this.FileDescription = FileDescription; this.FileName = FileName; this.FilePath = FilePath; }