当前位置: 首页>>代码示例>>C#>>正文


C# IconSize类代码示例

本文整理汇总了C#中IconSize的典型用法代码示例。如果您正苦于以下问题:C# IconSize类的具体用法?C# IconSize怎么用?C# IconSize使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IconSize类属于命名空间,在下文中一共展示了IconSize类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DropDownToolbarItem

		public DropDownToolbarItem(IDropDownAction action, IconSize iconSize)
		{
			_action = action;

			_actionEnabledChangedHandler = new EventHandler(OnActionEnabledChanged);
			_actionVisibleChangedHandler = new EventHandler(OnActionVisibleChanged);
			_actionAvailableChangedHandler = new EventHandler(OnActionAvailableChanged);
			_actionLabelChangedHandler = new EventHandler(OnActionLabelChanged);
			_actionTooltipChangedHandler = new EventHandler(OnActionTooltipChanged);
			_actionIconSetChangedHandler = new EventHandler(OnActionIconSetChanged);

			_action.EnabledChanged += _actionEnabledChangedHandler;
			_action.VisibleChanged += _actionVisibleChangedHandler;
			_action.AvailableChanged += _actionAvailableChangedHandler;
			_action.LabelChanged += _actionLabelChangedHandler;
			_action.TooltipChanged += _actionTooltipChangedHandler;
			_action.IconSetChanged += _actionIconSetChangedHandler;

			_iconSize = iconSize;

			this.Text = _action.Label;
			this.Enabled = _action.Enabled;
			this.Visible = _action.Visible;
			this.ToolTipText = _action.Tooltip;

			UpdateVisibility();
			UpdateEnablement();
			UpdateIcon();

			this.ShowDropDownArrow = true;

			this.DropDown = new ContextMenuStrip();
			this.DropDown.ImageScalingSize = StandardIconSizes.Small;
			this.DropDownOpening += new EventHandler(OnDropDownOpening);
		}
开发者ID:nhannd,项目名称:Xian,代码行数:35,代码来源:DropDownToolbarItem.cs

示例2: ResolveIcon

        /// <summary>
        /// Resolves icon of the file.
        /// </summary>
        /// <param name="fileExtensionName">The file extension name.</param>
        /// <param name="iconSize">The icon size.</param>
        /// <returns></returns>
        public Stream ResolveIcon(string fileExtensionName, IconSize iconSize)
        {
            string iconManifestPath = string.Empty;
            switch (iconSize)
            {
                case IconSize.Pixel16x16:
                    iconManifestPath = string.Format(SmallIconManifestPathTemplate, fileExtensionName.ToLower());
                    break;
                case IconSize.Pixel50x50:
                    iconManifestPath = string.Format(LargeIconManifestPathTemplate, fileExtensionName.ToLower());
                    break;
            }

            Stream stream = typeof(FileIconApi).Assembly.GetManifestResourceStream(iconManifestPath);
            if (stream == null || stream.Length == 0)
            {
                switch (iconSize)
                {
                    case IconSize.Pixel16x16:
                        stream = typeof(FileIconApi).Assembly.GetManifestResourceStream(SmallMiscellaneousIconManifestPath);
                        break;
                    case IconSize.Pixel50x50:
                        stream = typeof(FileIconApi).Assembly.GetManifestResourceStream(LargeMiscellaneousIconManifestPath);
                        break;
                }
            }

            return stream;
        }
开发者ID:TatumAndBell,项目名称:RapidWebDev-Enterprise-CMS,代码行数:35,代码来源:FileIconApi.cs

示例3: GetIconData

        public static Bitmap GetIconData(string iconId, IconSize iconSize)
        {
            var hash = StockIconCodon.ComputeHashCode(iconId, iconSize);
            if (IconData.ContainsKey(hash))
                return IconData[hash];

            if (!IconStock.ContainsKey(hash))
               throw new Exception("Icon "+iconId+" not available!");

            var iconCodon = IconStock[hash];

            if (!string.IsNullOrEmpty (iconCodon.Resource) || !string.IsNullOrEmpty (iconCodon.File)) {
                Bitmap bitmap;
                Stream stream;
                if (iconCodon.Resource != null)
                    stream = iconCodon.Addin.GetResource (iconCodon.Resource);
                else
                    stream = File.OpenRead (iconCodon.Addin.GetFilePath (iconCodon.File));
                using (stream) {
                    if (stream == null || stream.Length < 0) {
                        throw new Exception(string.Format("Did not find resource '{0}' in addin '{1}' for icon '{2}'",
                                                    iconCodon.Resource, iconCodon.Addin.Id, iconCodon.StockId));
                    }
                    bitmap = (Bitmap) Image.FromStream(stream);
                }

                IconData[hash] = bitmap;
            }

            return IconData[hash];
        }
开发者ID:tritao,项目名称:flood,代码行数:31,代码来源:IconManager.cs

示例4: GetDirectoryIcon

        public static ImageSource GetDirectoryIcon(string path, int iconIndex, IconSize size = IconSize.Small)
        {
            ImageSource imageSource = null;

                if (IconsDictionary.TryGetValue(iconIndex, out imageSource))
                {
                    return imageSource;
                }
                Int32Rect sizeRect;
                WinAPI.SHGFI flags;
                if (IconSize.Small == size)
                {
                    flags = commonFlags | WinAPI.SHGFI.SHGFI_SMALLICON;
                    sizeRect = new Int32Rect(0, 0, 16, 16);
                }
                else
                {
                    flags = commonFlags | WinAPI.SHGFI.SHGFI_LARGEICON;
                    sizeRect = new Int32Rect(0, 0, 32, 32);
                }
                WinAPI.SHFILEINFO shfileinfo = new WinAPI.SHFILEINFO();
                WinAPI.SHGetFileInfo(path, 256, out shfileinfo, (uint) Marshal.SizeOf(shfileinfo), flags);
                if (shfileinfo.hIcon == IntPtr.Zero)
                {
                    return GetIcon(path);
                }
                imageSource = Imaging.CreateBitmapSourceFromHIcon(shfileinfo.hIcon, sizeRect,
                    BitmapSizeOptions.FromEmptyOptions());
                IconsDictionary.Add(iconIndex, imageSource);
                WinAPI.DestroyIcon(shfileinfo.hIcon);
                shfileinfo.hIcon = IntPtr.Zero;

                return imageSource;
        }
开发者ID:sagamors,项目名称:FileExplorer,代码行数:34,代码来源:IconExtractor.cs

示例5: GetFileIcon

        /// <summary>
        /// Returns an icon for a given file - indicated by the Name parameter.
        /// </summary>
        /// <param Name="Name">Pathname for file.</param>
        /// <param Name="size">Large or small</param>
        /// <param Name="linkOverlay">Whether to include the link icon</param>
        /// <returns>System.Drawing.Icon</returns>
        public static Icon GetFileIcon(string name, IconSize size, bool linkOverlay)
        {
            Shell32.SHFILEINFO shfi = new Shell32.SHFILEINFO();
            uint flags = Shell32.SHGFI_ICON | Shell32.SHGFI_USEFILEATTRIBUTES;

            if (linkOverlay) flags += Shell32.SHGFI_LINKOVERLAY;

            /* Check the size specified for return. */
            if (IconSize.Small == size)
            {
                flags += Shell32.SHGFI_SMALLICON;
            }
            else
            {
                flags += Shell32.SHGFI_LARGEICON;
            }

            Shell32.SHGetFileInfo(name,
                                  Shell32.FILE_ATTRIBUTE_NORMAL,
                                  ref shfi,
                                  (uint)Marshal.SizeOf(shfi),
                                  flags);

            Icon.FromHandle(shfi.hIcon); // Load the icon from an HICON handle

            // Now clone the icon, so that it can be successfully stored in an ImageList
            Icon icon = (Icon)Icon.FromHandle(shfi.hIcon).Clone();
            return icon;
        }
开发者ID:nullkuhl,项目名称:fsu-dev,代码行数:36,代码来源:IconHelper.cs

示例6: GetFileIcon

        /// <summary>
        /// Returns an icon for a given file - indicated by the name parameter.
        /// </summary>
        /// <param name="name">Pathname for file.</param>
        /// <param name="size">Large or small</param>
        /// <param name="linkOverlay">Whether to include the link icon</param>
        /// <returns>Icon</returns>
        public static Icon GetFileIcon(string name, IconSize size, bool linkOverlay)
        {
            var shfi = new Shell32.SHFILEINFO();
            var flags = Shell32.SHGFI_ICON | Shell32.SHGFI_USEFILEATTRIBUTES;

            if (linkOverlay) flags += Shell32.SHGFI_LINKOVERLAY;

            /* Check the size specified for return. */
            if (IconSize.Small == size) {
                flags += Shell32.SHGFI_SMALLICON;
            } else {
                flags += Shell32.SHGFI_LARGEICON;
            }

            //Shell32.SHGetFileInfo(name,
            //    Shell32.FILE_ATTRIBUTE_NORMAL,
            //    ref shfi,
            //    (uint)Marshal.SizeOf(shfi),
            //    flags);

            //// Copy (clone) the returned icon to a new object, thus allowing us to clean-up properly
            //var icon = (Icon)Icon.FromHandle(shfi.hIcon).Clone();
            //User32.DestroyIcon(shfi.hIcon);		// Cleanup
            //return icon;
            return GetIcon(flags, name, Shell32.FILE_ATTRIBUTE_NORMAL);
        }
开发者ID:davidbitton,项目名称:wpFolderPicker,代码行数:33,代码来源:IconHelper.cs

示例7: GetImage

        public Bitmap GetImage(IconSize imageSize)
        {
            if (!File.Exists(_imagePath))
                return null;

            if (PathEx.HasExtension(_imagePath, FileExtensions.Executable) ||
                PathEx.HasExtension(_imagePath, FileExtensions.Shortcut) ||
                PathEx.HasExtension(_imagePath, FileExtensions.Icon))
            {
                return GetIcon(imageSize);
            }

            try
            {
                return new Bitmap(_imagePath);
            }
            catch (ArgumentException ex)
            {
                // Unable to convert to an image, assume it's an exe/ico/lnk file even though the extension is wrong.
                if (Log.IsDebugEnabled)
                    Log.DebugFormat("Failed to convert {0} to a image, trying to convert to an icon instead: {1}", _imagePath, ex);

                return GetIcon(imageSize);
            }
            catch (IOException ex)
            {
                // Unable to convert to an image, assume it's an exe/ico/lnk file even though the extension is wrong.
                if (Log.IsDebugEnabled)
                    Log.DebugFormat("Failed to convert {0} to a image, trying to convert to an icon instead: {1}", _imagePath, ex);

                return GetIcon(imageSize);
            }
        }
开发者ID:notsonormal,项目名称:AstoundingDock,代码行数:33,代码来源:ApplicationIcon.cs

示例8: GetFileBasedFSBitmap

        protected Bitmap GetFileBasedFSBitmap(string ext, IconSize size)
        {
            string lookup = tempPath;
            Bitmap folderBitmap = KeyToBitmap(lookup, size);
            if (ext != "")
            {
                ext = ext.Substring(0, 1).ToUpper() + ext.Substring(1).ToLower();

                using (Graphics g = Graphics.FromImage(folderBitmap))
                {
                    g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;

                    Font font = new Font("Comic Sans MS", folderBitmap.Width / 5, System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic);
                    float height = g.MeasureString(ext, font).Height;
                    float rightOffset = folderBitmap.Width / 5;

                    if (size == IconSize.small)
                    {
                        font = new Font("Arial", 5, System.Drawing.FontStyle.Bold);
                        height = g.MeasureString(ext, font).Height;
                        rightOffset = 0;
                    }


                    g.DrawString(ext, font,
                                System.Drawing.Brushes.Black,
                                new RectangleF(0, folderBitmap.Height - height, folderBitmap.Width - rightOffset, height),
                                new StringFormat(StringFormatFlags.DirectionRightToLeft));

                }
            }

            return folderBitmap;
        }
开发者ID:kolan72,项目名称:QuickZip.IO.PIDL.UserControls,代码行数:34,代码来源:ExToIconConverter.cs

示例9: IconFromExtension

        /// <summary>
        /// Get Windows-Icon for the Extension of a file
        /// </summary>
        /// <param name="Extension">ext of tile</param>
        /// <param name="Size">IconSize</param>
        /// <returns>Icon for this extension</returns>
        public static Icon IconFromExtension(string Extension, IconSize Size)
        {
            Icon icon = null;
            try
            {
                //add '.' if necessary
                if (Extension[0] != '.') Extension = '.' + Extension;

                //search registry for the file extension
                RegistryKey Root = Registry.ClassesRoot;
                RegistryKey ExtensionKey = Root.OpenSubKey(Extension);
                ExtensionKey.GetValueNames();
                RegistryKey appKey = Root.OpenSubKey(ExtensionKey.GetValue("").ToString());

                //gets the name of the file that has the icon.
                string IconLocation = appKey.OpenSubKey("DefaultIcon").GetValue("").ToString();
                string[] IconPath = IconLocation.Split(',');

                if (IconPath[1] == null) IconPath[1] = "0";
                IntPtr[] Large = new IntPtr[1];
                IntPtr[] Small = new IntPtr[1];

                //extracts the icon from the file.
                ExtractIconEx(IconPath[0], Convert.ToInt16(IconPath[1]), Large, Small, 1);
                icon = Size == IconSize.Large ? Icon.FromHandle(Large[0]) : Icon.FromHandle(Small[0]);
            }
            catch (Exception e)
            {
                Util.Debug("Icon konnte nicht extrahiert werden!", e);
            }
            return icon;
        }
开发者ID:BackupTheBerlios,项目名称:lyra2-svn,代码行数:38,代码来源:FileLauncher.cs

示例10: GetIcon

        /// <summary>
        ///		Get system icon for specified folder/file
        /// </summary>
        /// <param name="path"> Full path to a folder or file </param>
        /// <param name="type"> Type: folder or file </param>
        /// <param name="size"> Icon size: small or large</param>
        /// <param name="isOpen"> Is open icon (applicable for folders only) </param>
        /// <returns></returns>
        public static Icon GetIcon(string path, ItemType type, IconSize size, bool isOpen)
        {
            var flags = SHGFI_ICON | SHGFI_USEFILEATTRIBUTES;
            var attribute = (type == ItemType.Folder) ? FILE_ATTRIBUTE_DIRECTORY : FILE_ATTRIBUTE_FILE;
            if (isOpen)
                flags += SHGFI_OPENICON;

            if (size == IconSize.Small)
                flags += SHGFI_SMALLICON;
            else
                flags += SHGFI_LARGEICON;

            var shfi = new SHFileInfo();
            var res = SHGetFileInfo(path, attribute, out shfi, (uint)Marshal.SizeOf(shfi), flags);
            if (Equals(res, IntPtr.Zero))
                throw Marshal.GetExceptionForHR(Marshal.GetHRForLastWin32Error());
            try
            {
                Icon.FromHandle(shfi.hIcon);
                return (Icon)Icon.FromHandle(shfi.hIcon).Clone();
            }
            finally
            {
                DestroyIcon(shfi.hIcon);
            }
        }
开发者ID:AKlaus,项目名称:WPF,代码行数:34,代码来源:SystemIcon.cs

示例11: thumbnailInfo

 public thumbnailInfo(WriteableBitmap b, string path, IconSize size, int rol)
 {
     bitmap = b;
     fullPath = path;
     iconsize = size;
     roll = rol;
 }
开发者ID:kolan72,项目名称:QuickZip.IO.PIDL.UserControls,代码行数:7,代码来源:IconConverterBase.cs

示例12: TextBoxToolbarItem

		public TextBoxToolbarItem(ITextBoxAction action, IconSize iconSize)
		{
			_action = action;

			_actionEnabledChangedHandler = new EventHandler(OnActionEnabledChanged);
			_actionVisibleChangedHandler = new EventHandler(OnActionVisibleChanged);
			_actionAvailableChangedHandler = new EventHandler(OnActionAvailableChanged);
			_actionLabelChangedHandler = new EventHandler(OnActionLabelChanged);
			_actionTooltipChangedHandler = new EventHandler(OnActionTooltipChanged);
			_actionIconSetChangedHandler = new EventHandler(OnActionIconSetChanged);
			_actionTextBoxValueChangedHandler = new EventHandler(OnActionTextBoxValueChanged);
			_actionCueTextChangedHandler = new EventHandler(OnActionCueTextChanged);

			_action.EnabledChanged += _actionEnabledChangedHandler;
			_action.VisibleChanged += _actionVisibleChangedHandler;
			_action.AvailableChanged += _actionAvailableChangedHandler;
			_action.LabelChanged += _actionLabelChangedHandler;
			_action.TooltipChanged += _actionTooltipChangedHandler;
			_action.IconSetChanged += _actionIconSetChangedHandler;
			_action.TextValueChanged += _actionTextBoxValueChangedHandler;
			_action.CueTextChanged += _actionCueTextChangedHandler;

			_iconSize = iconSize;

			this.Text = _action.TextValue;
			this.Enabled = _action.Enabled;
			SetTooltipText();
			UpdateCueBanner();
			UpdateVisibility();
			UpdateEnablement();
			UpdateIcon();

		}
开发者ID:m-berkani,项目名称:ClearCanvas,代码行数:33,代码来源:TextBoxToolbarItem.cs

示例13: GetDefaultDirectoryIcon

 /// <summary>
 ///     The current Windows default Folder Icon in the given Size (Large/Small) as System.Drawing.Icon.
 /// </summary>
 /// <param name="size">The Size of the Icon (Small or Large).</param>
 /// <param name="folderType">The folderTypeIcon (closed or Open).</param>
 /// <returns>The Folder Icon as System.Drawing.Icon.</returns>
 public static Icon GetDefaultDirectoryIcon(IconSize size, FolderType folderType)
 {
     var flags = ShgfiIcon | ShgfiUsefileattributes;
     if (FolderType.Open == folderType)
     {
         flags += ShgfiOpenicon;
     }
     if (IconSize.Small == size)
     {
         flags += ShgfiSmallicon;
     }
     else
     {
         flags += ShgfiLargeicon;
     }
     var shfi = new Structs.Shfileinfo();
     var res = DllImports.SHGetFileInfo(@"C:\Windows", FileAttributeDirectory, out shfi, (uint) Marshal.SizeOf(shfi), flags);
     if (res == IntPtr.Zero)
     {
         throw Marshal.GetExceptionForHR(Marshal.GetHRForLastWin32Error());
     }
     Icon.FromHandle(shfi.hIcon);
     var icon = (Icon) Icon.FromHandle(shfi.hIcon).Clone();
     DllImports.DestroyIcon(shfi.hIcon);
     return icon;
 }
开发者ID:Belial09,项目名称:Fesslersoft-WindowsAPI,代码行数:32,代码来源:SHGetFileInfo.cs

示例14: GetFileIcon

        /// <summary>
        /// Returns an icon for a given file - indicated by the name parameter</summary>
        /// <param name="name">Pathname for file</param>
        /// <param name="size">Large or small icon</param>
        /// <param name="linkOverlay">Whether to include the link icon</param>
        /// <returns>Icon</returns>
        public static Icon GetFileIcon(string name, IconSize size, bool linkOverlay)
        {
            Shell32.SHFILEINFO shfi = new Shell32.SHFILEINFO();
            uint flags = Shell32.SHGFI_ICON | Shell32.SHGFI_USEFILEATTRIBUTES;

            if (linkOverlay) flags += Shell32.SHGFI_LINKOVERLAY;

            // Check the size specified for return.
            if (IconSize.Small == size)
            {
                flags += Shell32.SHGFI_SMALLICON;
            }
            else
            {
                flags += Shell32.SHGFI_LARGEICON;
            }

            Shell32.SHGetFileInfo(name,
                Shell32.FILE_ATTRIBUTE_NORMAL,
                ref shfi,
                (uint)System.Runtime.InteropServices.Marshal.SizeOf(shfi),
                flags);

            // Copy (clone) the returned icon to a new object, thus allowing us to clean-up properly
            Icon icon = (Icon)Icon.FromHandle(shfi.hIcon).Clone();
            User32.DestroyIcon(shfi.hIcon);        // Cleanup
            return icon;
        }
开发者ID:sbambach,项目名称:ATF,代码行数:34,代码来源:FileIconUtil.cs

示例15: GetFolderIcon

        public static System.Drawing.Icon GetFolderIcon(string name, IconSize size, FolderType folderType)
        {
            Shell32.SHFILEINFO shfi = new Shell32.SHFILEINFO();
            uint flags = Shell32.SHGFI_ICON | Shell32.SHGFI_USEFILEATTRIBUTES;

            if (FolderType.Open == folderType)
            {
                flags += Shell32.SHGFI_OPENICON;
            }

            //if (true == linkOverlay) flags += Shell32.SHGFI_LINKOVERLAY;

            /* Check the size specified for return. */
            if (IconSize.Small == size)
            {
                flags += Shell32.SHGFI_SMALLICON;
            }
            else
            {
                flags += Shell32.SHGFI_LARGEICON;
            }

            Shell32.SHGetFileInfo(name,
                Shell32.FILE_ATTRIBUTE_DIRECTORY,
                ref shfi,
                (uint)System.Runtime.InteropServices.Marshal.SizeOf(shfi),
                flags);

            // Copy (clone) the returned icon to a new object, thus allowing us to clean-up properly
            System.Drawing.Icon icon = (System.Drawing.Icon)System.Drawing.Icon.FromHandle(shfi.hIcon).Clone();
            User32.DestroyIcon(shfi.hIcon);		// Cleanup
            return icon;
        }
开发者ID:JoeyEremondi,项目名称:tikzedt,代码行数:33,代码来源:IconHelper.cs


注:本文中的IconSize类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。