Esempio n. 1
0
            /// <summary>
            /// Gets an appropriate icon overlay to indicate the mouse button assigned to the associated tool.
            /// </summary>
            /// <param name="iconSize">The desired version of the icon overlay.</param>
            /// <returns>The icon overlay as an <see cref="Image"/>.</returns>
            public Image GetButtonOverlay(IconSize iconSize)
            {
                string[] resourceNames;
                switch (_assignedButton)
                {
                case XMouseButtons.Left:
                    resourceNames = new string[] { "BaseTools.LeftMouseButtonOverlaySmall.png", "BaseTools.LeftMouseButtonOverlayMedium.png", "BaseTools.LeftMouseButtonOverlayLarge.png" };
                    break;

                case XMouseButtons.Right:
                    resourceNames = new string[] { "BaseTools.RightMouseButtonOverlaySmall.png", "BaseTools.RightMouseButtonOverlayMedium.png", "BaseTools.RightMouseButtonOverlayLarge.png" };
                    break;

                case XMouseButtons.Middle:
                    resourceNames = new string[] { "BaseTools.MiddleMouseButtonOverlaySmall.png", "BaseTools.MiddleMouseButtonOverlayMedium.png", "BaseTools.MiddleMouseButtonOverlayLarge.png" };
                    break;

                case XMouseButtons.XButton1:
                    resourceNames = new string[] { "BaseTools.X1MouseButtonOverlaySmall.png", "BaseTools.X1MouseButtonOverlayMedium.png", "BaseTools.X1MouseButtonOverlayLarge.png" };
                    break;

                case XMouseButtons.XButton2:
                    resourceNames = new string[] { "BaseTools.X2MouseButtonOverlaySmall.png", "BaseTools.X2MouseButtonOverlayMedium.png", "BaseTools.X2MouseButtonOverlayLarge.png" };
                    break;

                case XMouseButtons.None:
                default:
                    return(null);
                }

                IResourceResolver resourceResolver = new ActionResourceResolver(GetType());

                switch (iconSize)
                {
                case IconSize.Small:
                    return(new Bitmap(resourceResolver.OpenResource(resourceNames[0])));

                case IconSize.Medium:
                    return(new Bitmap(resourceResolver.OpenResource(resourceNames[1])));

                case IconSize.Large:
                default:
                    return(new Bitmap(resourceResolver.OpenResource(resourceNames[2])));
                }
            }
        private static void InitializeImageList(ImageList imageList, string sizeString)
        {
            Type type             = typeof(LocalImageExplorerControl);
            var  resourceResolver = new ActionResourceResolver(type);

            string[] icons = { "Back", "Next", "Up", "Refresh", "Home", "ShowFolders", "View", "Go" };
            foreach (string iconName in icons)
            {
                var resourceName = string.Format("{0}.Icons.{1}Tool{2}.png", type.Namespace, iconName, sizeString);
                using (var ioStream = resourceResolver.OpenResource(resourceName))
                {
                    if (ioStream == null)
                    {
                        continue;
                    }
                    imageList.Images.Add(iconName, Image.FromStream(ioStream));
                }
            }
        }