Multiple Image Sizes for ToolStrip Items



IconToolStrip_demo

Introduction

Tool strips are a fantastic asset because they provide a tidy and user-friendly interface for the user. It is possible to add images to many of the different tool strip items. It is even possible to force such items to appear larger by adjusting the property ImageScalingSize, however at the cost of pixelisation.
Usually it is desirable to make our applications as accessible as possible. Larger tool strip items are fantastic for those with poorer sight, or even those who just simply enjoy the quality of larger icons. Unfortunately, the standard ToolStrip class does not provide Icon support. When an icon is specified, it is converted into an Image instance. Thus the benefits of using an icon are lost.
So I decided that it would be a nice idea to add multi-image support to the ToolStrip control. Whilst my primary focus was on adding some support for Icon, I thought it more desirable to generalize this by using the two interfaces IImageProvider and IMultipleImageProvider.

Design

When MultipleImageToolStrip is being updated, it calls upon available IImageProvider‘s to acquire images of the required size.
An IImageProvider exposes the two methods IsImageSupported and GetImage. When multiple icon providers are available, it is possible to access the required icon using a key. In the code supplied with this article, the key represents a ToolStripItem. The following illustration provides an overview of the design using a UML class diagram.
multi_image_tooltips/uml-overview.png
When no IImageProvider is available, the original ToolStripItem is maintained and stretched where necessary to match the overall tool strip size.
For my extension, I decided that four discreet sizes would ease the implementation of custom image providers. The available sizes are: Small (16 x 16), Medium (24 x 24), Large (32 x 32), and ExtraLarge (48 x 48). When the requested image size is not available, a default icon can be automatically substituted if the MultipleImageToolStrip.UseUnknownImageSizeIcon is set to true.
Images are selected as follows:

  • If an image provider is available from within the tool strip:
    • If the required image size is supported, that image is acquired.
    • If the required image size was not supported and UseUnknownImageSizeIcon is set, the default image provider is utilized.
    • When no image can be acquired using those criteria, the original image is simply stretched to match that of the scaled buttons.
  • If the above fails and the item is itself an IImageProvider then it is used to acquire the required image.
  • Finally if the items ToolStripItem.Tag is an IImageProvider then it is used to acquire the required image.

Using the Code

It is always a good idea to backup your project before trying something new!
To use the attached code simply:

  • Add the source files to your project.
  • Recompile your project.
  • Drag MultipleImageToolStrip onto your Form or UserControl from the tool box.
  • Add some buttons.
  • You should now have a ToolStrip which behaves much the same as before.

If you want to convert an existing ToolStrip into a MultipleImageToolStrip:

  • Find the “.designer.cs” file which is associated with your form or control.
  • Open it up and replace instances of ToolStrip with MultipleImageToolStrip.

To make items automatically resizable, add a handler for your form’s (or control’s) Load event. Take a look below for an example of how to do this:

private void Form1_Load(object sender, EventArgs e)
{
    // Begin updating tool strip images. This is important because it prevents
    // the tool strip from refreshing after each image assignment.
    this.iconToolStrip.BeginUpdateImages();
    // Here it is possible to provide an 'IImageProvider' instance.
    this.iconToolStrip.AssignImage(toolStripBack, new IconImageProvider(
        Resources.arrow_left));
    // Or just provide icons themselves.
    this.iconToolStrip.AssignImage(toolStripForward, Resources.arrow_right);
    this.iconToolStrip.AssignImage(toolStripHome, Resources.home);
    this.iconToolStrip.AssignImage(toolStripStop, Resources.stop);
    // Finalize updating.
    this.iconToolStrip.EndUpdateImages();
    // Then to select an initial icon size.
    this.iconToolStrip.ImageSize = ImageSize.Medium;
}

When a tool strip item is permanently removed, the associated IImageProvider must also be manually removed. This decision was made because often an item is only removed temporarily and then reinserted.
If you always want to remove an associated IImageProvider when a tool item is removed, add a handler for the MultipleImageToolStrip.ItemRemove event:

private void iconToolStrip_ItemRemoved(object sender, ToolStripItemEventArgs e)
{
    // Automatically remove associated image provider.
    this.iconToolStrip.RemoveImage(e.Item);
}

Alternatively the associated provider can be removed along with the item:

public void RemoveToolStripItem(ToolStripItem item)
{
    // Remove item itself.
    this.iconToolStrip.Items.Remove(item);
    // Remove any associated provider.
    this.iconToolStrip.RemoveImage(item);
}

“Multiple Image Sizes for ToolStrip Items”의 3,187개의 댓글

  1. Right here is the perfect web site for anyone who wants to understand this topic.
    You realize a whole lot its almost hard to argue with you
    (not that I really would want to…HaHa). You definitely put a new spin on a subject that has been written about for many years.

    Great stuff, just great!

  2. Thanks for ones marvelous posting! I quite enjoyed reading it, you happen to be a great author.
    I will make certain to bookmark your blog and will often come back later in life.
    I want to encourage one to continue your great posts, have a nice afternoon!

  3. Please let me know if you’re looking for a article writer for your site.
    You have some really good posts and I believe I
    would be a good asset. If you ever want to
    take some of the load off, I’d love to write some articles for your blog in exchange for a link back
    to mine. Please send me an e-mail if interested. Cheers!

  4. I just want to tell you that I am just all new to blogging and really savored this blog. Almost certainly I’m going to bookmark your site . You amazingly have perfect well written articles. Thanks a lot for sharing with us your blog site.

  5. This is the right web site for anyone who wants to understand
    this topic. You realize so much its almost hard to argue with you (not that I personally will need to…HaHa).

    You certainly put a brand new spin on a topic that has been written about for many years.
    Great stuff, just great!

  6. 핑백: https://bitcoineraonline.com

  7. 핑백: mơ thấy ao nước đánh con gì

  8. 핑백: Bichon Puppies for Sale

  9. 핑백: labradoodle puppies for sale near me

  10. 핑백: Dank Vapes flavors

  11. 핑백: ไปที่หน้านี้

  12. 핑백: mơ thấy nhà bị sập

  13. 핑백: male sex dolls for sale

  14. 핑백: nằm mơ thấy gãy răng

  15. I simply want to say I am just new to blogs and absolutely savored your blog site. Very likely I’m want to bookmark your blog . You absolutely come with beneficial writings. Regards for sharing your web page.

  16. Along with every thing that appears to be building inside this specific subject material, all your opinions are actually very refreshing. However, I am sorry, but I do not subscribe to your entire idea, all be it exciting none the less. It appears to us that your opinions are not entirely validated and in fact you are generally yourself not even totally convinced of your argument. In any event I did appreciate looking at it.

  17. I found your blog web site on google and verify a number of of your early posts. Continue to keep up the superb operate. I just extra up your RSS feed to my MSN Information Reader. Seeking ahead to reading extra from you afterward!…

  18. I happen to be commenting to let you know of the notable experience my princess undergone viewing your blog. She picked up such a lot of issues, most notably what it’s like to have a great giving style to let many people easily grasp specified advanced subject matter. You really did more than people’s expectations. I appreciate you for distributing the great, healthy, revealing and also easy guidance on your topic to Sandra.

  19. One more thing to say is that an online business administration study course is designed for learners to be able to efficiently proceed to bachelors degree programs. The Ninety credit education meets the lower bachelor diploma requirements when you earn your own associate of arts in BA online, you may have access to the newest technologies in this field. Some reasons why students would like to get their associate degree in business is because they’re interested in the field and want to obtain the general schooling necessary prior to jumping right into a bachelor diploma program. Many thanks for the tips you provide inside your blog.

  20. Having read this I believed it was very enlightening. I appreciate you taking the time and energy to put this information together. I once again find myself spending way too much time both reading and leaving comments. But so what, it was still worthwhile.

  21. Howdy! This post could not be written any better! Reading this post reminds me of my good old room mate! He always kept talking about this. I will forward this article to him. Fairly certain he will have a good read. Thanks for sharing!

  22. Anytime I research a topic I have no idea what i will discover. I am so very happy to have discovered your complete blogging as it properly covers the questions I have under consideration and also the unmentioned questions which i might have checked for in the future.

  23. After looking over a number of the blog posts on your web site, I seriously like your way of blogging. I bookmarked it to my bookmark site list and will be checking back in the near future. Please visit my website as well and tell me your opinion.

  24. I discovered your site website on google and check a couple of your early posts. Preserve the really good operate. I merely extra encourage Feed to my MSN News Reader. Looking for forward to reading far more within you later on!…

  25. I like what you guys are creating here. Such smart work and writing! Carry on with the superb works guys. I have incorporated your site into my blogroll and my website about HCG. I think it will improve the value of my websiteand the traffic too.

  26. You have made some really good points there. I checked on the web to learn more about the issue and found most individuals will go along with your views on this web site.

  27. 핑백: mơ thấy chuối xanh

  28. I wanted to send you this very small remark to finally thank you the moment again relating to the great basics you’ve shared in this article. This is pretty open-handed of people like you to allow publicly precisely what a lot of people could have offered for sale for an electronic book to help with making some bucks for themselves, certainly since you could possibly have tried it in the event you decided. Those advice as well worked as the great way to know that some people have the identical keenness much like my personal own to realize a great deal more in respect of this condition. I’m sure there are some more pleasurable sessions up front for individuals who check out your blog post.

  29. Just desire to say your article is as surprising. The clarity in your post is simply great and that i could assume you are knowledgeable on this subject. Well with your permission allow me to take hold of your feed to stay up to date with imminent post. Thank you one million and please carry on the enjoyable work.

  30. When I originally commented I clicked the “Notify me when new comments are added” checkbox and now each time a comment is added I get four emails with the same comment. Is there any way you can remove me from that service? Cheers!

  31. A person essentially lend a hand to make severely articles I would state. This is the first time I frequented your web page and up to now? I surprised with the analysis you made to create this particular publish extraordinary. Great job!

  32. Thanks for your post. I also feel that laptop computers have gotten more and more popular these days, and now tend to be the only form of computer utilized in a household. The reason is that at the same time that they are becoming more and more reasonably priced, their working power is growing to the point where they can be as strong as desktop computers coming from just a few years back.

  33. Hello There. I found your blog using msn. This is an extremely well written article. I’ll make sure to bookmark it and return to read more of your useful information. Thanks for the post. I will certainly return.

  34. Can I simply say what a comfort to discover someone that genuinely knows what they’re discussing online. You certainly realize how to bring a problem to light and make it important. More people ought to check this out and understand this side of the story. I was surprised you aren’t more popular because you surely have the gift.

  35. If your real friends know you as your nickname, use that nickname as your first name online. When you first friend someone, focus on making a personal comment that weaves connection.

  36. Thanks for discussing your ideas. I’d personally also like to mention that video games have been at any time evolving. Today’s technology and improvements have aided create practical and enjoyable games. These kinds of entertainment video games were not actually sensible when the actual concept was first of all being attempted. Just like other kinds of technological know-how, video games way too have had to advance through many years. This is testimony towards the fast progression of video games.

  37. Aw, this was an exceptionally good post. Taking the time and actual effort to produce a top notch article… but what can I say… I put things off a whole lot and don’t seem to get anything done.

  38. You could definitely see your enthusiasm in the work you write. The world hopes for even more passionate writers like you who aren’t afraid to say how they believe. Always follow your heart.

  39. Wow! This can be one particular of the most helpful blogs We have ever arrive across on this subject. Actually Excellent. I am also an expert in this topic therefore I can understand your effort.

  40. Throughout the great pattern of things you’ll receive an A for hard work. Where you actually lost me ended up being in your facts. As it is said, the devil is in the details… And that could not be much more accurate here. Having said that, let me tell you exactly what did work. Your writing is definitely pretty engaging which is possibly why I am taking an effort to opine. I do not really make it a regular habit of doing that. Next, while I can easily notice a leaps in logic you come up with, I am not confident of just how you appear to unite your ideas which in turn produce the conclusion. For right now I shall yield to your position however trust in the near future you actually connect your dots better.

  41. Howdy would you mind letting me know which hosting company you’re utilizing? I’ve loaded your blog in 3 different web browsers and I must say this blog loads a lot quicker then most. Can you recommend a good hosting provider at a honest price? Thanks, I appreciate it!

  42. of course like your website however you need to check the spelling on quite a few of your posts. Many of them are rife with spelling issues and I in finding it very troublesome to inform the truth nevertheless I will certainly come back again.

  43. I would like to thnkx for the efforts you have put in writing this site. I’m hoping the same high-grade website post from you in the upcoming as well. In fact your creative writing abilities has encouraged me to get my own site now. Actually the blogging is spreading its wings fast. Your write up is a good example of it.

  44. My coder is trying to convince me to move to .net from PHP. I have always disliked the idea because of the expenses. But he’s tryiong none the less. I’ve been using Movable-type on several websites for about a year and am worried about switching to another platform. I have heard good things about blogengine.net. Is there a way I can transfer all my wordpress posts into it? Any help would be really appreciated!

  45. Its such as you learn my mind! You seem to grasp a lot approximately this, like you wrote the ebook in it or something. I think that you simply could do with some percent to pressure the message house a bit, however instead of that, this is great blog. An excellent read. I will definitely be back.

  46. I must say, as a lot as I enjoyed reading what you had to say, I couldnt help but lose interest after a while. Its as if you had a wonderful grasp on the subject matter, but you forgot to include your readers. Perhaps you should think about this from far more than one angle. Or maybe you shouldnt generalise so considerably. Its better if you think about what others may have to say instead of just going for a gut reaction to the subject. Think about adjusting your own believed process and giving others who may read this the benefit of the doubt.Jobs offered

  47. Greetings! Quick question that’s totally off topic. Do you know how to make your site mobile friendly? My site looks weird when viewing from my apple iphone. I’m trying to find a theme or plugin that might be able to resolve this issue. If you have any recommendations, please share. With thanks!

  48. Have you ever considered about including a little bit more than just your articles? I mean, what you say is important and all. Nevertheless imagine if you added some great graphics or videos to give your posts more, “pop”! Your content is excellent but with pics and video clips, this website could undeniably be one of the best in its niche. Amazing blog!

  49. Today, while I was at work, my sister stole my apple ipad and tested to see if it can survive a 30 foot drop, just so she can be a youtube sensation. My iPad is now broken and she has 83 views. I know this is totally off topic but I had to share it with someone!

  50. Undeniably consider that that you stated. Your favourite reason seemed to be at the internet the easiest factor to understand of. I say to you, I certainly get annoyed even as other people think about concerns that they plainly don’t understand about. You managed to hit the nail upon the highest and defined out the entire thing without having side effect , folks could take a signal. Will likely be back to get more. Thank you

  51. Woah! I’m really loving the template/theme of this site. It’s simple, yet effective. A lot of times it’s difficult to get that “perfect balance” between superb usability and visual appearance. I must say that you’ve done a awesome job with this. In addition, the blog loads super fast for me on Internet explorer. Outstanding Blog!

  52. What i do not understood is actually how you are not really much more well-liked than you may be now. You’re so intelligent. You realize thus considerably relating to this subject, produced me personally consider it from numerous varied angles. Its like men and women aren’t fascinated unless it is one thing to accomplish with Lady gaga! Your own stuffs outstanding. Always maintain it up!

  53. Having read this I thought it was extremely informative. I appreciate you finding the time and energy to put this information together. I once again find myself spending way too much time both reading and commenting. But so what, it was still worth it!

  54. I’m amazed, I have to admit. Seldom do I come across a blog that’s both equally educative and engaging, and without a doubt, you have hit the nail on the head. The issue is something that too few men and women are speaking intelligently about. Now i’m very happy I stumbled across this in my search for something relating to this.

  55. Attractive section of content. I just stumbled upon your website and in accession capital to assert that I acquire actually enjoyed account your blog posts. Any way I’ll be subscribing to your feeds and even I achievement you access consistently quickly.

  56. I have been exploring for a little bit for any high quality articles or weblog posts in this kind of house . Exploring in Yahoo I eventually stumbled upon this website. Reading this information So i am happy to exhibit that I have a very excellent uncanny feeling I found out just what I needed. I most without a doubt will make sure to don’t overlook this web site and provides it a look on a relentless basis.

  57. A large percentage of of what you assert is astonishingly accurate and it makes me wonder the reason why I hadn’t looked at this in this light before. Your piece really did turn the light on for me personally as far as this issue goes. Nonetheless there is actually just one factor I am not necessarily too comfy with so whilst I try to reconcile that with the actual central theme of the issue, allow me observe exactly what the rest of your readers have to say.Very well done.

  58. I discovered your weblog website on google and verify just a few of your early posts. Continue to maintain up the very good operate. I simply additional up your RSS feed to my MSN News Reader. Searching for ahead to reading extra from you afterward!…

  59. Have you ever thought about creating an ebook or guest authoring on other websites? I have a blog based on the same subjects you discuss and would really like to have you share some stories/information. I know my subscribers would appreciate your work. If you’re even remotely interested, feel free to send me an e-mail.

  60. I needed to draft you a very little word to help give many thanks the moment again for these precious suggestions you have contributed on this page. It has been simply shockingly open-handed of people like you to present extensively just what a few people might have offered for an ebook to get some profit for themselves, mostly now that you could have tried it if you ever decided. Those points likewise served to be the easy way to be aware that other people have similar fervor much like mine to see great deal more when it comes to this matter. I am sure there are thousands of more fun moments in the future for many who see your site.

  61. I in addition to my guys happened to be checking the nice pointers on your site while the sudden came up with a horrible suspicion I had not expressed respect to the web site owner for those secrets. These people are actually passionate to see them and have definitely been taking pleasure in these things. Thank you for actually being very accommodating and also for figuring out this form of perfect useful guides millions of individuals are really eager to understand about. Our honest apologies for not expressing gratitude to earlier.

  62. naturally like your web-site but you have to check the spelling on several of your posts. A number of them are rife with spelling problems and I find it very bothersome to tell the truth nevertheless I’ll certainly come back again.

  63. Fantastic blog you have here but I was curious about if you knew of any community forums that cover the same topics talked about in this article? I’d really love to be a part of community where I can get responses from other knowledgeable individuals that share the same interest. If you have any suggestions, please let me know. Cheers!

  64. certainly like your web-site but you need to check the spelling on quite a few of your posts. Many of them are rife with spelling issues and I find it very troublesome to tell the truth nevertheless I’ll certainly come back again.

  65. Today, I went to the beachfront with my kids. I found a sea shell and gave it to my 4 year old daughter and said “You can hear the ocean if you put this to your ear.” She placed the shell to her ear and screamed. There was a hermit crab inside and it pinched her ear. She never wants to go back! LoL I know this is completely off topic but I had to tell someone!

  66. What i don’t understood is actually how you’re not actually much more well-liked than you might be right now. You’re very intelligent. You realize therefore significantly relating to this subject, made me personally consider it from numerous varied angles. Its like men and women aren’t fascinated unless it is one thing to accomplish with Lady gaga! Your own stuffs nice. Always maintain it up!

  67. Simply want to say your article is as amazing. The clarity in your post is just nice and i could assume you’re an expert on this subject. Fine with your permission allow me to grab your RSS feed to keep up to date with forthcoming post. Thanks a million and please continue the gratifying work.

  68. Together with the whole thing which appears to be developing inside this specific subject material, many of your points of view are quite exciting. Nonetheless, I am sorry, but I do not subscribe to your entire suggestion, all be it exhilarating none the less. It appears to everyone that your comments are actually not entirely justified and in actuality you are your self not even completely confident of the point. In any event I did appreciate reading it.

  69. Please let me know if you’re looking for a author for your blog. You have some really good articles and I feel I would be a good asset. If you ever want to take some of the load off, I’d absolutely love to write some articles for your blog in exchange for a link back to mine. Please blast me an e-mail if interested. Cheers!

  70. You really make it seem so easy with your presentation but I find this topic to be actually something which I think I would never understand. It seems too complicated and very broad for me. I’m looking forward for your next post, I will try to get the hang of it!

  71. Have you ever considered writing an ebook or guest authoring on other sites? I have a blog based upon on the same topics you discuss and would really like to have you share some stories/information. I know my audience would appreciate your work. If you’re even remotely interested, feel free to send me an e-mail.

  72. Thanks for some other informative web site. The place else could I am getting that kind of info written in such a perfect manner? I’ve a project that I am just now running on, and I’ve been at the look out for such info.

  73. Howdy just wanted to give you a quick heads up. The text in your article seem to be running off the screen in Internet explorer. I’m not sure if this is a formatting issue or something to do with internet browser compatibility but I figured I’d post to let you know. The design look great though! Hope you get the issue solved soon. Many thanks

  74. A powerful share, I just given this onto a colleague who was doing somewhat evaluation on this. And he actually bought me breakfast as a result of I found it for him.. smile. So let me reword that: Thnx for the deal with! However yeah Thnkx for spending the time to debate this, I really feel strongly about it and love reading more on this topic. If potential, as you turn into expertise, would you thoughts updating your weblog with more particulars? It’s highly useful for me. Huge thumb up for this blog publish!

  75. Hi there would you mind letting me know which hosting company you’re utilizing? I’ve loaded your blog in 3 different web browsers and I must say this blog loads a lot faster then most. Can you suggest a good internet hosting provider at a fair price? Thank you, I appreciate it!

  76. Hello! I know this is kinda off topic however I’d figured I’d ask. Would you be interested in exchanging links or maybe guest authoring a blog post or vice-versa? My site addresses a lot of the same topics as yours and I think we could greatly benefit from each other. If you happen to be interested feel free to shoot me an email. I look forward to hearing from you! Terrific blog by the way!

  77. Have you ever considered about adding a little bit more than just your articles? I mean, what you say is valuable and everything. Nevertheless think about if you added some great photos or videos to give your posts more, “pop”! Your content is excellent but with pics and clips, this site could undeniably be one of the best in its field. Excellent blog!

  78. The very next time I read a blog, Hopefully it doesn’t disappoint me just as much as this one. I mean, Yes, it was my choice to read, however I actually believed you would probably have something helpful to talk about. All I hear is a bunch of crying about something that you can fix if you were not too busy searching for attention.

  79. Hello! I could have sworn I’ve been to this website before but after going through many of the posts I realized it’s new to me. Nonetheless, I’m certainly happy I discovered it and I’ll be bookmarking it and checking back regularly!

  80. Hello, There’s no doubt that your blog could possibly be having browser compatibility issues. When I take a look at your blog in Safari, it looks fine however when opening in Internet Explorer, it has some overlapping issues. I merely wanted to give you a quick heads up! Besides that, great website.

  81. I have learn a few excellent stuff here. Definitely worth bookmarking for revisiting. I wonder how a lot attempt you place to create this kind of fantastic informative web site.

  82. Go to Pure CBD Selection for the best pure cbd oil. You can buy pure cbd oil that is full spectrum or broad spectrum. Make sure to sign up for there newsletter to receive a free coupon code.

  83. I’m extremely impressed with your writing skills and also with the layout on your weblog. Is this a paid theme or did you customize it yourself? Anyway keep up the nice quality writing, it is rare to see a nice blog like this one these days..

  84. I absolutely love your website.. Great colors & theme. Did you create this web site yourself? Please reply back as I’m attempting to create my own site and want to learn where you got this from or just what the theme is called. Appreciate it!

  85. May I simply say what a comfort to discover an individual who really understands what they’re discussing on the internet. You certainly understand how to bring a problem to light and make it important. A lot more people have to check this out and understand this side of your story. I was surprised that you aren’t more popular since you surely possess the gift.

  86. Have you ever thought about adding a little bit more than just your articles? I mean, what you say is fundamental and all. Nevertheless just imagine if you added some great visuals or videos to give your posts more, “pop”! Your content is excellent but with images and videos, this blog could definitely be one of the greatest in its field. Amazing blog!

  87. Good day! I could have sworn I’ve been to this site before but after going through some of the articles I realized it’s new to me. Regardless, I’m certainly happy I came across it and I’ll be book-marking it and checking back regularly!

  88. Howdy! This article couldn’t be written any better! Going through this article reminds me of my previous roommate! He always kept preaching about this. I most certainly will send this post to him. Fairly certain he’s going to have a good read. I appreciate you for sharing!