MonoDevelop Addins: hello world, disable if no active project
[CSharpForFun/.git] / MonoDevelop / addins / MonoDevelop.HelloWorld / MonoDevelop.HelloWorld / Commands.cs
index 9df0db6..9985036 100644 (file)
@@ -1,5 +1,4 @@
-using System;
-using System.Linq;
+using System.Linq;
 using MonoDevelop.Components.Commands;
 using MonoDevelop.Ide;
 using MonoDevelop.Projects;
@@ -23,6 +22,18 @@ namespace MonoDevelop.HelloWorld
                                MessageService.ShowCustomDialog (dlg);
                        }
                }
+
+               protected override void Update (CommandInfo info)
+               {
+                       var proj = IdeApp.Workspace.GetAllProjects ().FirstOrDefault ();
+                       if (proj != null) {
+                               info.Enabled = true;
+                               info.Visible = true;
+                       } else {
+                               info.Enabled = false;
+                               info.Visible = true;
+                       }
+               }
        }
 }