private Image GetSystemBitmap(SystemImageList sysImgList, int index) { System.Drawing.Icon ico = sysImgList.Icon(index); if (ico != null) { return(ico.ToBitmap( )); } else { return(null); } }
private static void SetImageListControl(Control ctrl, SystemImageList sysImageList, bool forStateImages) { if (ctrl.GetType( ) != typeof(ListView) && (ctrl.GetType( ) != typeof(TreeView) && !ctrl.GetType( ).IsSubclassOf(typeof(TreeView)))) { throw new ArgumentException("Invalid type of control"); } IntPtr wParam = IntPtr.Zero; if (ctrl.GetType( ) == typeof(ListView)) { wParam = (IntPtr)LVSIL_NORMAL; } else { wParam = (IntPtr)TVSIL_NORMAL; } if (sysImageList.ImageListSize == SystemImageListSize.SmallIcons) { if (ctrl.GetType( ) == typeof(ListView)) { wParam = (IntPtr)LVSIL_SMALL; } } if (forStateImages) { if (ctrl.GetType( ) == typeof(ListView)) { wParam = (IntPtr)LVSIL_STATE; } else { wParam = (IntPtr)TVSIL_STATE; } } if (ctrl.GetType( ) == typeof(ListView)) { SendMessage(ctrl.Handle, LVM_SETIMAGELIST, wParam, sysImageList.Handle); } else { SendMessage(ctrl.Handle, TVM_SETIMAGELIST, wParam, sysImageList.Handle); } }
public static void SetImageList(ListView listView, SystemImageList sysImageList, bool forStateImages) { SystemImageList.SetImageListControl(listView, sysImageList, forStateImages); }
public static void SetImageList(TreeView tree, SystemImageList sysImageList, bool forStateImages) { SystemImageList.SetImageListControl(tree, sysImageList, forStateImages); }
private SystemImageListHost() { SystemIcons = new Dictionary<string, int>(); SmallSystemImageList = new SystemImageList(SystemImageListSize.SmallIcons); LargeSystemImageList = new SystemImageList(SystemImageListSize.LargeIcons); }
private int GetSystemIconIndex(SystemImageList sysImgList, string file) { return(sysImgList.IconIndex(file, false)); }
private SystemImageListHost() { SystemIcons = new Dictionary <string, int>(); SmallSystemImageList = new SystemImageList(SystemImageListSize.SmallIcons); LargeSystemImageList = new SystemImageList(SystemImageListSize.LargeIcons); }
private static void SetImageListControl ( Control ctrl, SystemImageList sysImageList, bool forStateImages ) { if ( ctrl.GetType ( ) != typeof ( ListView ) && ( ctrl.GetType ( ) != typeof ( TreeView ) && !ctrl.GetType ( ).IsSubclassOf ( typeof ( TreeView ) ) ) ) throw new ArgumentException ( "Invalid type of control" ); IntPtr wParam = IntPtr.Zero; if ( ctrl.GetType ( ) == typeof ( ListView ) ) wParam = (IntPtr)LVSIL_NORMAL; else wParam = (IntPtr)TVSIL_NORMAL; if ( sysImageList.ImageListSize == SystemImageListSize.SmallIcons ) { if ( ctrl.GetType ( ) == typeof ( ListView ) ) wParam = (IntPtr)LVSIL_SMALL; } if ( forStateImages ) { if ( ctrl.GetType ( ) == typeof ( ListView ) ) wParam = (IntPtr)LVSIL_STATE; else wParam = (IntPtr)TVSIL_STATE; } if ( ctrl.GetType ( ) == typeof ( ListView ) ) SendMessage ( ctrl.Handle, LVM_SETIMAGELIST, wParam, sysImageList.Handle ); else SendMessage ( ctrl.Handle, TVM_SETIMAGELIST, wParam, sysImageList.Handle ); }
public static void SetImageList ( ListView listView, SystemImageList sysImageList, bool forStateImages ) { SystemImageList.SetImageListControl ( listView, sysImageList, forStateImages ); }
public static void SetImageList ( TreeView tree, SystemImageList sysImageList, bool forStateImages ) { SystemImageList.SetImageListControl ( tree, sysImageList, forStateImages ); }
/// <summary> /// Gets the index of the system icon. /// </summary> /// <param name="sysImgList">The sys img list.</param> /// <param name="file">The file.</param> /// <returns></returns> private int GetSystemIconIndex( SystemImageList sysImgList, string file ) { return sysImgList.IconIndex ( file, false ); }
/// <summary> /// Gets the system bitmap. /// </summary> /// <param name="sysImgList">The sys img list.</param> /// <param name="index">The index.</param> /// <returns></returns> private Image GetSystemBitmap( SystemImageList sysImgList, int index ) { System.Drawing.Icon ico = sysImgList.Icon ( index ); if ( ico != null ) { return ico.ToBitmap ( ); } else { return null; } }