Working Example
This is a working example using these methods to translate Skype chats in 57 different languages in real-time and also speaks your Skype chat messages and contact status changes in 10 different languages.
More here:
Click here for more information
Downloads
NOTE: You will need any copy, some copy, of Microsoft Visual C# installed for these Visual C# Project Templates to install properly. If you don't have Microsoft Visual C# installed already, you can install the latest version of Microsoft Visual C# 2008 Express Edition for FREE below:
Install Microsoft Visual C# 2008 Express Edition fo FREE - C# 3.0 .NET 3.5(SP1) latest versions
Click Here To Download the FREE Microsoft Visual C# - 2010 Express Edtition
Install TheNotifyIconExample
Click And choose Open or Run to Install TheNotifyIconExample Templates
You now should be able to Open Microsoft Visual C# Visual Studio and do the following:
File -> New Project -> My Templates ("Select TheNotifyIconExample with comments for now to play and read how the TheNotifyIconExample templates function and work, the without comments won't show you that information, because comments are removed.") Pick a Project name, click ok.
Now Build the project as is. To do this simply do this from Visual Studio C#:
Build -> Build Solution
To run the new project as is ("With the Default Visual Studio Project User Settings shown below") do this from Visual Studio C#:
Debug -> Start Debugging
To stop Debugging simply exit TheNotifyIconExample or from Visual Studio C# do:
Debug -> Stop Debugging
To change ANY of the Visual Studio Project User Settings and see just how easy they can be changed for All your projects, now and in the future, from Visual Studio C# do:
Projects -> TheNotifyIconExample -> Settings
User your mouse to expand/shrink columns.
Left Click on the Value ("On the rar right of each Setting and select true or false from the dropdown listbox") then from the Visual Studio Top Menu:
Debug -> Start Debugging No need to re-build the project to test or save setting changes.
In the Solutions Explorer Window in Visual Studio C#, righ click on Form1.cs and choose "View Code" to view the source code.
When you exit Visual Studio you can choose to save this project or discard it. It's that easy for all your future projects!
Facts - Not Fiction
1. There is nothing more redundant which uses more of your time, from one project to the next, than coding how your project is displayed at startup, what is shown during execution, NotifyIcon? Taskbar? When is a Taskbar displayed? During normal Display? When you are minimized? Your Context Menu logic, your exit logic, your deployment logic and your update logic.
Not Just An Example Use of NotifyIcon But The Golden Standard
2. This example will save you more time in all of your projects than any other single example you will find elsewhere, that's a promise, because Visual Studio Project Templates are included for you to use these techniques for all your future projects. Nothing comes close to ease-of-use as a total solution for all your future project needs. Nothing!
What Can TheNotifyIconExample Do For Me and Teach Me?
Everybody and their brother, sister and cousin has some kind of example of NotifyIcon, Taskbar, ContextMenuStrip, Mouse Click Logic, Startup and Exit logic.
Nobody has them all togther, and all changeable by Visual Studio Project Users settings, without even re-bulding a project required in Visual Studio C# Project Templates.
So, not only will you be able to create projects must faster, you can look at the source code produced the second your project is created, if you choose, to see how all the magic as done.
TheNotifyIconExample uses Visual C# Project Templates, one with and one without comments ("otherwise they are the same") to be used as base code for any of your projects, now or in the future, to control your Startup minimized, normal, with or without a Taskbar or NotifyIcon, Exit, MouseClicks on Form1 and NotifyIcon, Tasbar and NotifyIcon combinations including invisibility as well as only allowing only one single copy of your application or program to run at once on any system.
Both ClickOnce Install and Automatic-Updates technology is supported as well. All of these things are done using Visual Studio Project User Settings. No more need to write code each and everytime for each project for these functions. Have that already done, the second your project is created.
The rest of this article is for those that want to learn more about these C# Project Templates and Microsoft ClickOnce Deployment and Automatic Updates Technologies.
Save Hundreds Of Coding Hours On Future Projects Combined
Do all of this Using Visual Studio Project User Settings For All Your Projects.
Starting from the second your projects are created.
Create Programs and Applications Three and Four Times Faster
Never, ever, code 1 line of display, startup or exit logic, NotifiyIcon, Taskbar, NotifyIcon MouseClick or complicated Context Menu code from now on.
Never create or modify any setup project for any of your projects now or in the future or need to purchase any 3rd party deployment software to deploy your applications or programs.
Provide Instant Bug and Functionality Updates To Your Users
Never worry about how you will push updates for your applications and programs for bugs, or new functionality.
Automatically update them, anytime you wish, pushing them to your users, when you choose, so that they always have the latest versions of your software, always.
Never Waste Time Again On Redundant Code Now or In The Future
Never change or modify any of that type of this kinds of code again, never, ever, have any need to re-build any of your projects now, or any future projects, when or if, any of these settings below are changed or modified, as well.
Change Settings Without Even The Need to Re-Build The Project!
Instead, simply select a True or False setting from a drop down listbox, using Visual Studio Project User settings and the Visual Studio Project Templates provided in this example:
- Allow One Single Instance of Your Program to run per system
- Startup normal, with/without a NotifyIcon, with/without a Taskbar
- Startup minimized with/without a Notifyicon, with/without a Taskbar
- Every possible NotifyIcon and Taskbar display and MouseClick combination supported
- NotifyIcon no Taskbar when displayed normal or minimized
- NotifyIcon and Taskbar when displayed normal, no Taskbar minimized
- NotifyIcon and Taskbar when minimized, no Taskbar when displayed normal
- NotifyIcon and Taskbar when minimized and when normal
- Taskbar when normal and minimized no NotifyIcon
- NotifyIcon Single-Right MouseClick does nothing, makes program not stoppable by GUI
- NotifyIcon Single-Right MouseClick shows Context Menu
- NotifyIcon Single-Right MouseClick shows Form1
- NotifyIcon Single-Left MouseClick does nothing
- NotifyIcon Single-Left MouseClick shows Form1
- NotifyIcon Single-Left MouseClick shows Context Menu
- NotifyIcon Single-Left MouseClick shows Different Context Menu
- NotifyIcon Double-Right MouseClick does nothing
- NotifyIcon Double-Right MouseClick shows Context Menu
- NotifyIcon Double-Right MouseClick shows Form1
- NotifyIcon Double-Left MouseClick does nothing
- NotifyIcon Double-Left MouseClick shows Context Menu
- NotifyIcon Double-Left MouseClick shows Form1
- Form1 Single-Right MouseClick does nothing
- Form1 Single-Right MouseClick shows Context Menu
- Form1 Single-Right MouseClick shows Form1
- Form1 Single-Left MouseClick does nothing
- Form1 Single-Left MouseClick shows Form1
- Form1 Single-Left MouseClick shows Context Menu
- Form1 Single-Left MouseClick shows Different Context Menu
- Form1 Double-Right MouseClick does nothing
- Form1 Double-Right MouseClick shows Context Menu
- Form1 Double-Right MouseClick shows Form1
- Form1 Double-Left MouseClick does nothing
- Form1 Double-Left MouseClick shows Context Menu
- Form1 Double-Left MouseClick shows Form1
- Automatic NotifyIcon text matches your project names
- Automatic Context Menu display Form1 menu item matches your project names
- Automatic Restricted Exit Warning Message matches your project names
- Share Context Menus with both Form1 and NotifyIcon automatically
- Use more than one Context Menu Automatically with NotifyIcon
- All Context Menus have a built-in Close Context Menu item to be user friendly
- Total GUI invisibility option
- No accidental invisibility setting combinations, this code avoids these bad settings
- Restricted Exit, deny close from Form1 X, option, minimizes to System Tray instead
- Restricted Exit Warning message, option, inform user to Exit from Context Menu
- Any and All of these Visual Studio Project User Settings can be added to user GUI easily
- Microsoft ClickOnce Deployment Technology
- Never use another setup project or a 3rd party deployment package again
- Deploy and update your programs and applications via the Intranet or Internet
- Microsoft ClickOnce Automatic-Updates never worry about pushing updates again
- Visual Studio Project Templates provided with and without comments
- Visual Studio Project Templates automatically change items to your project names
- Create your own Visual Studio customized Project Templates from these Templates
- Built using .NET 3.5(SP1) and C# 3.0 Both the latest versions from Microsoft
- Backwards compatible from .NET 2.0 and C# 2.0 as well
- Can be used with the FREE Microsoft Visual C# 2008 Express edition
- NotifyIcon if displayed, goes away when your programs close, unlike other solutions
- None of the Form1 focus issues that can be caused by MouseClicks on NotifyIcon
- No other example saves you more, time, testing, or money, while giving so much flexability
- The ONLY known All-In-One re-useable for All future projects no-code no-rebuild solution
Stop Wasting Valuable Time and Money Coding and Testing Now!
Use your talents for the important stuff, like what the program or application is being created for.
Finish your projects faster and never modify code for Startup or Exit Logic or NotifyIcon or TaskBar logic or Context Menu or Mouse click assignment logic to NotifyIcon again, use Visual Studio Project User Settings instead.
Deploy and Auto-Update From The Intranet and Internet
Deploy your projects from a Web Site or Web Server, without ANY Startup Project or 3rd party Installer using Microsoft ClickOnce Technology.
Push Updates To Your Programs And Applications Anytime
Learn how to make your programs and applications automatically-update ANYTIME a bug is found, or new functionality is added, or a change is made, automatically, all by simply posting a new version of your program or application on a web site or web server>
Your users will auto-sense when new versions of your programs and applications are available, as frequently as each time your software is run, and you can pick that frequency that new versions are looked for as well using Microsoft ClickOnce Update Technology.
How Many Hours of Coding and Testing Will This Save You?
Now, how many hours did I just save you on every project you will create in the future?
Are You Ready To Save Both Time and Money?
There is a catch here. You need to read and play with the example here to learn ALL of the things above. It should take you no more than 1 hour to learn to do ALL the things above. That is why there is no code-snippets here, because you need to download and play.
How Fast Can You Learn?
Seasoned Visual Studio users can just jump right to using the Visual Studio Template Files. The Project Example and the ClickOnce Install Example are more to show working examples.
Are You Bold?
So if you feel bold, just install the Visual Studio Templates and forgo playing with the actual project. Create your own test projects from the Visual Studio Project Templates instead.
See Microsoft ClickOnce Deployment in Action
You may still however want to see how Microsoft ClickOnce deployment technology works from a web server or web site, so you may still wish to try clicking on the picture below or the ClickOnce install link below to see how that magic is done as well for the demo project that was created using the Visual Studio C# Project Template and was created in less than 10 minutes from creation to deployment. ClickOnce requires NO setup project, no MSI wrapper, no 3rd party installer, and it will also install any required files automatically if they are missing such as .NET versions required by your program, when ClickOnce senses those files are needed.
This Was All Done For FREE! - Yet It Saves So Much Time and Money
This entire project and all files including the Visual Studio Project Templates and Microsoft ClickOnce deployment files published to the web server for this example and article and Microsoft ClickOne automatic-update technology were created using the FREE Microsoft Visual C# 2008 Express Edition which can be downloaded by Clicking Here
Nothing used for this article, to create the files here, or the technology used and demonstrated here, had any cost, besides the Linux web server used to deploy and auto-update the Microsoft ClickOnce published files as needed.
While this Example is in C# the concepts in this example can be applied to many other Windows languages. The project was very heavily commented for this very reason, which is why a without comment project template was also offered for download as well.
Click The picture above, to Install TheNotifyIconExample Demo Project that was created in less than 10 Minutes using the TheNotifyIconExample Template With Comments from Project Creation to Deployment Using Microsoft ClickOnce Technology
NOTE: If you do not already have .NET 3.5 (SP1) installed, it will be installed, if needed. Another great feature TheNotifyIconExample will provide using CickOnce deployment technology for any an all your projects you choose.
TheNotifyIconExample Demo can be uninstalled using Add/Remove Programs from Control Panel
Background
I have seen many NotifyIcon examples in the past, however none of them have shown how to use Visual Studio Project User settings to support all possible combinations of NotifyIcon and Taskbar logic that are capable of being supported.
This example not only does these things, Visual Studio Project Templates are also provided as well ("two versions, one with and one without comments, otherwise both Visual Studio Project Templates are the same") that you can use to build all your projects with in the future, so that you no longer need to add ANY lines of code for your startup logic, in any project, ever.
This includes things like what Mouse single and double clicks do what, when or if your NotifyIcon is clicked ("If you use one, which is also a setting here as well to disable or enable a NotifyIcon").
Combine that with showing examples of sharing and using different Context Menus, as well as startup logic for minimized and normal form display, restrictive exit logic, GUI invisibility, dealing with all the focus issues involved in doing some of these things, that normally are not dealt with, shown, or explained in many cases.
This also means you can change your Startup logic, Taskbar Display logic, NotifyIcon Mouse click assignment logic of what Mouse clicks do what and exit Logic at anytime using Visual Studio Project User Settings without the need to add or modify any code or even re-build your project when you change any of these settings.
Add to ALL of the above, with showing how to use Microsoft ClickOnce Deployment and ClickOnce Automatic-Updates technology in your projects so that you can deploy your project from a web site, or web server and package that supports automatic updates to your programs and applications, roll all of that up, in a Visual Studio Project Template that you can use and evenh customize for your own Visual Studio Project Templates or for all your future projects, makes this example very unique indeed.
The above example ClickOnce Demo, simply shows a working program built from the Commented version of the TheNotifyIconExample Project Template.
The real magic of this article and example is after you have downloaded, installed, and used the Visual Studio Project Templates provided here, as templates when create your new projects.
This ClickOnce Demo Project example can be removed at anytime using the Add/Remove Programs Icon from your Control Panel.
The above example and defaults for the Visual Studio Project User settings in the download files above are using the following Visual Studio Project User Settings:
Click Here To Install a Demo Project created from NotifyIconExample Using ClickOnce Technology
So what you will see with these settings when running the example ClickOnce Demo project and the default settings for both templates are also the same.
These defaults were selected as defaults NOT because they are the best, but to show the diversity of what these settings can do.
1. We don't exit always, we deny Form1 Exits using the "X" but do exit from the ContextMenuStrip.
2. We show a Exit warning NotifyIcon BalloonTip informing the user that we will minimize to the System Tray and not Exit, but that they can click on Exit in our ContextMenuStrip and we will Exit then.
3. Double right MouseClicks on Blank Areas on Form1 toggle Form1 from normal display to minimized.
4. Single left MouseClicks on Form1 show a ContextMenuStrip that is Different from the normal one shown with NotifyIcon. This allows instant support of multiple ContextMenuStrips if needed.
5. Single right MouseClicks are disabled on Form1 blank areas to show a ContextMenuStrip. Meaning that a right single click on Form1 blank areas will not show a ContextMenuStrip as is would by default when a ContextMenuStrip is assigned to Form1.
6. Single left MouseClicks on NotifyIcon show the normal ContextMenuStrip that by default would normally show on single right MouseClicks on NotifyIcon when a ContextMenuStrip is assigned to NotifyIcon.
7. Single right MouseClicks on NotifyIcon are disabled, so the normal ContextMenuStrip will not display when NotifyIcon is single right clicked.
8. Single right MouseClicks on NotifyIcon Toggle Form1 from a minimized to normal to minimized display.
9. We show a Taskbar item when we are in a normal display state but not when we are minimized.
10. We display a NotifyIcon in the System Tray.
11. We do not startup minimized. We start up in a normal display state.
12. We only allow a single instance of this program to run at one time.
As you can see, any of these settings can be changed, at anytime, without the need to code anything or even re-build the project.
The instant you create any project using this Template, all this logic is present, the second the project is created, no coding, "Just set it and forget it!"
Finish projects 3,4 even 5 times faster, because all your focus is on why you created the program or application, and not how it launches or displays, testing NotifyIcon, Taskbar, exit logic, left/right single/double MouseClicks on Form1 or NotifyIcon and assigning and building and sharing ContextMenuStrips. All the logic and testing for that is already done now, before you even add a line of code to the project, that is all in place.
Any multitude of settings can be used for any project, since this is all done using Visual Studio Project C# Templates.
Now, imagine the time you will save by using these templates and not repeating the same display, startup, exit logic, MouseClick assignments for Form1 and NotifyIcon and TaskBar combinations as well as being able to have instant "Single Instance" abilities, Microsoft ClickOnce deployment and ClickOnce Automatic Update technology.
Now you can focus on the purpose of each project and changes Visual Studio Project settings quickly, instead of coding each and every project for special startup and display logic.
You can now download and install the Example Project Download NotifyIconExample.zip or extract it from Download AllNotifyIconExample.zip ("Read the Readme.txt file") to be able to change the settings and see how easy this is to do. There really is no need to even use the project, since the templates are really what this is all about, but, if you install the example project using the links here for a ClickOnce intsall, it shows you that the project template with comments was used to build the demo project.
The entire demo project from creation to deployment, took 10 minutes from the time it was created from the Visual C# project template to the time it was uploaded to the Web Server for ClickOnce deployment.
There is never a need to re-build the project when any settings are changed.
Using Microsoft ClickOnce Deployment - Auto-Update Technology
Deploying Your Visual Studio Project from a Linux Web Server
If you want to Deploy your applications using Microsoft ClickOnce Technology from a Linux Server or Web Site, you first need to make sure you have these MIME types defined on that server or Web Site:
For ClickOnce, you need to configure the MIME types correctly.
.application --> application/x-ms-application
.manifest --> application/x-ms-application
.deploy --> application/octet stream
If you are pushing .Net 3.5 as a prerequisite (and you should be pushing whatever version of the .Net Framework you are targeting), you need these as well:
.msp --> application/microsoftpatch
.msu --> application/microsoftupdate
If you have vsto apps, you need this one too:
.vsto --> application/x-ms-vsto
Having these MIME types defined, allows you to automatically push updates for your applications as well as install from the web using Microsoft ClickOnce Technology.
As new functionality or Bug Fixes are added to your programs and applications, you now can make sure the users of your programs and applications have access to the changes the Second they are available with no manual effort from the user and no effort on your part other than publishing the new version to the Web Server or Web Site, the rest is automatic and based on your Visual Studio Publish settings.
If a user did NOT run your program or application for one month, as an example, and you updated 3 times during that period, they would only be prompted to install the most current update, NOT all 3 updates. There are many advantages of using ClickOnce Deployment and ClickOnce Update Technology. More here about ClickOnce From Microsoft:
Click Here for ClickOnce and .NET Framework Resources from Microsoft
Setting Up Visual Studio Publish Settings for Your Projects Using These Templates
In Visual Studio with the NotifyIconExample Project provided or Projects created using the Example Visual Studio Project Templates do:
Project -> [Project Name] Properties -> Publish
Click Both The Updates And Options Buttons And notice how you can deploy your program or application ("Without") a startup project and without any other 3rd party tool even when using Visual Express Editions from a web site or web server.
Of course I changed the web site names to "YourWebSite.com" but you can still see how you can deploy your program or application from a web site or a web server using the Visual Studio Project templates provided in this example.
Updates Button
You can enable or disable auto-update checking.
You can require a minimum version to be installed.
You can define how often you check for updates as well.
You can have automatic updates done when your program or application starts or stops each time, or setting what frequency you want your program or appliation to check for udpates by using the Update Button and setting your preferences as well.
This example updates before the TheNotifyIconExample project starts. If there were any updates the user would be notified and prompted to install the new version automatically, when they ran your program or application prior to it actually starting.
Options Button
Check all the Menu Items when you select Options Button.
Description - Allows you to add links to support web pages and error pages.
Manifest - Allows a Desktop icon to be created automatically.
By Deploying using a Web Site, or Web Server, you will make your program or application available to your customer base or corporation for automatic updates. This feature alone is worth an article, but I thought I would try using this project as a real world example and use this article to also demonstrate what a powerful feature using Microsoft ClickOnce Technology is both for deployment to avoid setup projects or 3rd party installers and all the extra time that takes as well as the automatic-updates using auto-sense logic with ClickOnce. I don't think that feature is even available from other 3rd party providers with all the options available for FREE from Microsoft ClickOnce Technology.
Points of Interest
I have been a programmer for 39 years now, mostly MainFrame, Tandem based systems, but for the last 15 years I have also done Windows programming as well.
To Learn How Don Kennedy Obtained the Nick OverLord Click Here
I have found that sometimes it is very hard to get all the information about things like focus issues with Forms, NotifyIcon and Taskbar and Mouse clicks cobinations with NotifyIcon and Context Menu combinations and ClickOnce examples all in one place, is virtually impossible.
This example allows you to combine all of these in one project template that you can customize even more if you wish to do so.
If you are like me, you spend alot of time on each project working on how your program or application will be displayed at startup, what combination of Taskbar and/or NotifyIcon logic as well as Mouse click combinations your NotifyIcon will support, Context Menu logic, and Exit logic and ClickOnce deployment and Auto-Update Technology logic. I have done it all so many times, I could do it in my sleep, this allows me time to sleep.
So now you can stop manually adding or typing the same code, over and over, from project to project, and manually modifying code to support any changes, and instead, just use these Visual Studio project Templates ("Or create your own Visual Studio Project Templates from these") that require no code changes for your future projects, to make startup, running, Exit, Deployment and Auto-Upate Logic in your projects, by using Visual Studio Project User or Application Settings which do not even requiring a re-build of your projects when you change them.
My goals here for this article and example was to supply a working sample project to quickly demonstrate these settings and Microsoft ClickOnce Deployment in action in a working project, that you can install using the Microsoft ClickOnce Technology. To also provide Visual Studio Project Templates that let you quickly add this logic to any of your future projects so you have more time to work on the purpose of your programs and applications.
These settings could also be offered to your users as well easily, if you would like, so that your users could define what options they want defined for your programs and applications as well by simply adding CheckBoxes to your Application for Visual Studio Project User Setttings included here that you would want your users to be able to control, if any.
By using Visual Studio Project User settings the selected settings by your users could be by Windows user Id as well as by application, these examples are by Windows User Id.
Hopefully this will save you many hours in the future by using these reusable Visual Studio Project Templates or combining these or creating your own.
Please let me know here, if you found this example and article helpful by your vote and comments or questions here.
It would seem I have been slammed well ("So Far") with bad votes on this article and can't understand why really. Well such is life. LOL.
Suggestions on how to really see the power and time this example can save you:
1. Install The Example using the ClickOnce Link above and look at the settings used for it above.
2. Download the All Files zip file above and Build the Project, change the settings to see how easily they can be changed.
3. Place Both Templates in your Visual Studio Project Template Folder for C#, See "Example Of Using Visual Studio Project Templates" Above:
TheNotifyIconExamplewc.zip - Template with Comments
TheNotifyIconExamplewoc.zip - Template with Comments
4. Create a new Visual Studio project using just one these Templates, name it anything you want, build it. Play with the settings. As you can see, no more worry about NotifyIcon, Taskbar, Startup Display, Context Menus or Exit Logic in your projects, it can all be there when you create a project now with one of these templates.
Note: You may need to create a test key when building these examples, because they all use ClickOnce Technology Settings, which require your project to be signed with a Key to use ClickOnce Technologies, to do that from Visual Studio ("Only do this if you get an error building a project"):
Project -> [Project Name] Properties -> Signing -> Create Test Certificate ("If you do not have your own Certificate(s)")
Additional Notes
The Folder used to publish to when using Microsoft ClickOnce for Deployment, must already be created on the Web Server or Web Site prior to attempting to publish otherwise you will receive an error.
The project user settings names are self-explanatory, they do what they are named, when they are set to true, when they are set to false, the do not do what they are named.
Support for conflicting or overlapping project user setting logic is not included, other than not setting anything that would make you accidentally invisible is not provided in this example.
The Exit Warning Message text when Restricted Exit Logic is in place, will need to be changed manually, to reflect the actual Mouse Click(s) you eventually choose to support the display of the Context Menu, if any, to invoke the Context Menu from the NotifyIcon.
Enjoy.
TheUberOverLord AKA Don Kennedy
History
Original Release Version 1.0.0.0 - For a real world example where these methods are used in another article I wrote here at the CodeProject Click Here