{"action":"created","comment":{"url":"https://api.github.com/repos/DynamoDS/DynamoRevit/pulls/comments/42583453","id":42583453,"diff_hunk":"@@ -109,104 +95,125 @@ public Result OnStartup(UIControlledApplication application)\n             return Result.Succeeded;\n         }\n \n-        public static bool LaunchDynamoCommand(int index, ExternalCommandData commandData)\n+        void executed(object sender, ExecutedEventArgs e)\n         {\n-            if (index >= Products.Count)\n-                return false; //Index out of range\n-\n-            try\n-            {\n-                var revitVersion = commandData.Application.Application.VersionNumber;\n-                var p = Products[index];\n-                var path = GetDynamoRevitPath(p, revitVersion);\n-                var data = new VersionSelectorData() { RevitVersion = revitVersion, SelectedVersion = p.VersionInfo };\n-                data.WriteToRegistry();\n-\n-                splitButton.Enabled = false; //Disable the split button, no more needed.\n-                splitButton.Visible = false; //Hide it from the UI\n-                //For older than 0.8.2, hide the Dynamo Versions ribbon panel\n-                //Otherwise rename it to \"Visual Programming\", so that DynamoRevit\n-                //will add it's button to this panel.\n-                if (p.VersionInfo < new Version(0, 8, 2))\n-                {\n-                    ribbonPanel.Visible = false; //Hide the panel\n-                }\n-                else\n-                {\n-                    ribbonPanel.Name = Resources.VisualProgramming;//Same as used in App Description for DynamoRevitApp\n-                    ribbonPanel.Title = Resources.VisualProgramming;\n-                }\n-\n-                //Initialize application\n-                var ass = Assembly.LoadFrom(path);\n-                var revitApp = ass.CreateInstance(\"Dynamo.Applications.DynamoRevitApp\");\n-                revitApp.GetType()\n-                    .GetMethod(\"OnStartup\")\n-                    .Invoke(revitApp, new object[] { uiApplication });\n-\n-                //Invoke command\n-                string message = string.Empty;\n-                var revitCmd = ass.CreateInstance(\"Dynamo.Applications.DynamoRevit\");\n-                revitCmd.GetType()\n-                    .GetMethod(\"Execute\")\n-                    .Invoke(revitCmd, new object[] { commandData, message, null });\n-\n-                uiApplication = null; //release application, no more needed.\n-                return true;\n-            }\n-            catch (Exception)\n-            {\n-                splitButton.Enabled = true; //Ensure that the split button is enabled.\n-                splitButton.Visible = true; //Also the split button is visible\n-                ribbonPanel.Visible = true; //As well as the panel is visible\n-                throw;\n-            }\n+            var product = PromptVersionSelectorDialog(Products);\n+            if(product.HasValue)\n+                LaunchDynamoCommand(product.Value, e);\n         }\n \n-        private SplitButton AddSplitButtonGroup(RibbonPanel panel)\n+        void beforeExecuted(object sender, BeforeExecutedEventArgs e)\n         {\n-            var versionData = new SplitButtonData(\"versions\", Resources.DynamoVersions);\n-            var button = panel.AddItem(versionData) as SplitButton;\n-\n-            Bitmap dynamoIcon = Resources.dynamo_32x32;\n+            e.UsingCommandData = true;\n+        }\n \n-            BitmapSource bitmapSource =\n-                Imaging.CreateBitmapSourceFromHBitmap(\n-                    dynamoIcon.GetHbitmap(),\n-                    IntPtr.Zero,\n-                    Int32Rect.Empty,\n-                    BitmapSizeOptions.FromEmptyOptions());\n+        void canExecute(object sender, CanExecuteEventArgs e)\n+        {\n+            e.CanExecute = e.ActiveDocument != null;","path":"src/Legacy/DynamoRevitVersionSelector/VersionSelectorApp.cs","position":171,"original_position":171,"commit_id":"16d865bc219f7c5b558156d5162e0565dca781ea","original_commit_id":"16d865bc219f7c5b558156d5162e0565dca781ea","user":{"login":"Randy-Ma","id":5584246,"avatar_url":"https://avatars.githubusercontent.com/u/5584246?v=3","gravatar_id":"","url":"https://api.github.com/users/Randy-Ma","html_url":"https://github.com/Randy-Ma","followers_url":"https://api.github.com/users/Randy-Ma/followers","following_url":"https://api.github.com/users/Randy-Ma/following{/other_user}","gists_url":"https://api.github.com/users/Randy-Ma/gists{/gist_id}","starred_url":"https://api.github.com/users/Randy-Ma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Randy-Ma/subscriptions","organizations_url":"https://api.github.com/users/Randy-Ma/orgs","repos_url":"https://api.github.com/users/Randy-Ma/repos","events_url":"https://api.github.com/users/Randy-Ma/events{/privacy}","received_events_url":"https://api.github.com/users/Randy-Ma/received_events","type":"User","site_admin":false},"body":"So I agree that the logic here may not be the same with SetRunEnabledBasedOnContext depending on the workflow.","created_at":"2015-10-21T04:58:49Z","updated_at":"2015-10-21T04:58:49Z","html_url":"https://github.com/DynamoDS/DynamoRevit/pull/732#discussion_r42583453","pull_request_url":"https://api.github.com/repos/DynamoDS/DynamoRevit/pulls/732","_links":{"self":{"href":"https://api.github.com/repos/DynamoDS/DynamoRevit/pulls/comments/42583453"},"html":{"href":"https://github.com/DynamoDS/DynamoRevit/pull/732#discussion_r42583453"},"pull_request":{"href":"https://api.github.com/repos/DynamoDS/DynamoRevit/pulls/732"}}},"pull_request":{"url":"https://api.github.com/repos/DynamoDS/DynamoRevit/pulls/732","id":47847788,"html_url":"https://github.com/DynamoDS/DynamoRevit/pull/732","diff_url":"https://github.com/DynamoDS/DynamoRevit/pull/732.diff","patch_url":"https://github.com/DynamoDS/DynamoRevit/pull/732.patch","issue_url":"https://api.github.com/repos/DynamoDS/DynamoRevit/issues/732","number":732,"state":"open","locked":false,"title":"Use command binding for Dynamo command","user":{"login":"sharadkjaiswal","id":1754137,"avatar_url":"https://avatars.githubusercontent.com/u/1754137?v=3","gravatar_id":"","url":"https://api.github.com/users/sharadkjaiswal","html_url":"https://github.com/sharadkjaiswal","followers_url":"https://api.github.com/users/sharadkjaiswal/followers","following_url":"https://api.github.com/users/sharadkjaiswal/following{/other_user}","gists_url":"https://api.github.com/users/sharadkjaiswal/gists{/gist_id}","starred_url":"https://api.github.com/users/sharadkjaiswal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sharadkjaiswal/subscriptions","organizations_url":"https://api.github.com/users/sharadkjaiswal/orgs","repos_url":"https://api.github.com/users/sharadkjaiswal/repos","events_url":"https://api.github.com/users/sharadkjaiswal/events{/privacy}","received_events_url":"https://api.github.com/users/sharadkjaiswal/received_events","type":"User","site_admin":false},"body":"### Purpose\r\n\r\nThis submission makes use of command binding to register Dynamo, so that Dynamo button will appear in manage tab in Revit 2017. \r\n\r\nIf there are multiple version of Dynamo installed on the system then a version selection dialog will be shown as follows for users to choose a specific version. Once a version is selected, the VersionLoader extension application unregisters the command binding and DynamoRevitApp will do the command binding for the actual DynamoRevit command.\r\n\r\n![image](https://cloud.githubusercontent.com/assets/1754137/10627531/4e798142-77ed-11e5-982d-bb1076912de8.png)\r\n\r\nThis also includes the refactoring done in #730 \r\n\r\n### Declarations\r\n\r\nCheck these if you believe they are true\r\n\r\n- [X] The code base is in a better state after this PR\r\n- [X] Is documented according to the [standards](https://github.com/DynamoDS/Dynamo/wiki/Coding-Standards)\r\n- [ ] The level of testing this PR includes is appropriate\r\n- [X] User facing strings, if any, are extracted into `*.resx` files\r\n\r\n### Reviewer\r\n- [ ] @ikeough \r\n- [ ] @Randy-Ma  \r\n\r\n### UX Reviewer\r\n\r\nPlease review the Task Dialog content as well as UX.\r\n- [ ] @Racel \r\n- [ ] @lillismith \r\n\r\n### FYI\r\n- [ ] @riteshchandawar \r\n- [ ] @kronz ","created_at":"2015-10-15T22:01:05Z","updated_at":"2015-10-21T04:58:49Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d8126caeabf2b637efdbee0aebefffbcebc18937","assignee":{"login":"ikeough","id":1139788,"avatar_url":"https://avatars.githubusercontent.com/u/1139788?v=3","gravatar_id":"","url":"https://api.github.com/users/ikeough","html_url":"https://github.com/ikeough","followers_url":"https://api.github.com/users/ikeough/followers","following_url":"https://api.github.com/users/ikeough/following{/other_user}","gists_url":"https://api.github.com/users/ikeough/gists{/gist_id}","starred_url":"https://api.github.com/users/ikeough/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ikeough/subscriptions","organizations_url":"https://api.github.com/users/ikeough/orgs","repos_url":"https://api.github.com/users/ikeough/repos","events_url":"https://api.github.com/users/ikeough/events{/privacy}","received_events_url":"https://api.github.com/users/ikeough/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/DynamoDS/DynamoRevit/pulls/732/commits","review_comments_url":"https://api.github.com/repos/DynamoDS/DynamoRevit/pulls/732/comments","review_comment_url":"https://api.github.com/repos/DynamoDS/DynamoRevit/pulls/comments{/number}","comments_url":"https://api.github.com/repos/DynamoDS/DynamoRevit/issues/732/comments","statuses_url":"https://api.github.com/repos/DynamoDS/DynamoRevit/statuses/16d865bc219f7c5b558156d5162e0565dca781ea","head":{"label":"Conceptual-Design:manageTab","ref":"manageTab","sha":"16d865bc219f7c5b558156d5162e0565dca781ea","user":{"login":"Conceptual-Design","id":1738955,"avatar_url":"https://avatars.githubusercontent.com/u/1738955?v=3","gravatar_id":"","url":"https://api.github.com/users/Conceptual-Design","html_url":"https://github.com/Conceptual-Design","followers_url":"https://api.github.com/users/Conceptual-Design/followers","following_url":"https://api.github.com/users/Conceptual-Design/following{/other_user}","gists_url":"https://api.github.com/users/Conceptual-Design/gists{/gist_id}","starred_url":"https://api.github.com/users/Conceptual-Design/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Conceptual-Design/subscriptions","organizations_url":"https://api.github.com/users/Conceptual-Design/orgs","repos_url":"https://api.github.com/users/Conceptual-Design/repos","events_url":"https://api.github.com/users/Conceptual-Design/events{/privacy}","received_events_url":"https://api.github.com/users/Conceptual-Design/received_events","type":"Organization","site_admin":false},"repo":{"id":25964048,"name":"DynamoRevit","full_name":"Conceptual-Design/DynamoRevit","owner":{"login":"Conceptual-Design","id":1738955,"avatar_url":"https://avatars.githubusercontent.com/u/1738955?v=3","gravatar_id":"","url":"https://api.github.com/users/Conceptual-Design","html_url":"https://github.com/Conceptual-Design","followers_url":"https://api.github.com/users/Conceptual-Design/followers","following_url":"https://api.github.com/users/Conceptual-Design/following{/other_user}","gists_url":"https://api.github.com/users/Conceptual-Design/gists{/gist_id}","starred_url":"https://api.github.com/users/Conceptual-Design/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Conceptual-Design/subscriptions","organizations_url":"https://api.github.com/users/Conceptual-Design/orgs","repos_url":"https://api.github.com/users/Conceptual-Design/repos","events_url":"https://api.github.com/users/Conceptual-Design/events{/privacy}","received_events_url":"https://api.github.com/users/Conceptual-Design/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Conceptual-Design/DynamoRevit","description":"Dynamo libaries and ExternalApplication implementation for Revit.","fork":true,"url":"https://api.github.com/repos/Conceptual-Design/DynamoRevit","forks_url":"https://api.github.com/repos/Conceptual-Design/DynamoRevit/forks","keys_url":"https://api.github.com/repos/Conceptual-Design/DynamoRevit/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Conceptual-Design/DynamoRevit/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Conceptual-Design/DynamoRevit/teams","hooks_url":"https://api.github.com/repos/Conceptual-Design/DynamoRevit/hooks","issue_events_url":"https://api.github.com/repos/Conceptual-Design/DynamoRevit/issues/events{/number}","events_url":"https://api.github.com/repos/Conceptual-Design/DynamoRevit/events","assignees_url":"https://api.github.com/repos/Conceptual-Design/DynamoRevit/assignees{/user}","branches_url":"https://api.github.com/repos/Conceptual-Design/DynamoRevit/branches{/branch}","tags_url":"https://api.github.com/repos/Conceptual-Design/DynamoRevit/tags","blobs_url":"https://api.github.com/repos/Conceptual-Design/DynamoRevit/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Conceptual-Design/DynamoRevit/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Conceptual-Design/DynamoRevit/git/refs{/sha}","trees_url":"https://api.github.com/repos/Conceptual-Design/DynamoRevit/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Conceptual-Design/DynamoRevit/statuses/{sha}","languages_url":"https://api.github.com/repos/Conceptual-Design/DynamoRevit/languages","stargazers_url":"https://api.github.com/repos/Conceptual-Design/DynamoRevit/stargazers","contributors_url":"https://api.github.com/repos/Conceptual-Design/DynamoRevit/contributors","subscribers_url":"https://api.github.com/repos/Conceptual-Design/DynamoRevit/subscribers","subscription_url":"https://api.github.com/repos/Conceptual-Design/DynamoRevit/subscription","commits_url":"https://api.github.com/repos/Conceptual-Design/DynamoRevit/commits{/sha}","git_commits_url":"https://api.github.com/repos/Conceptual-Design/DynamoRevit/git/commits{/sha}","comments_url":"https://api.github.com/repos/Conceptual-Design/DynamoRevit/comments{/number}","issue_comment_url":"https://api.github.com/repos/Conceptual-Design/DynamoRevit/issues/comments{/number}","contents_url":"https://api.github.com/repos/Conceptual-Design/DynamoRevit/contents/{+path}","compare_url":"https://api.github.com/repos/Conceptual-Design/DynamoRevit/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Conceptual-Design/DynamoRevit/merges","archive_url":"https://api.github.com/repos/Conceptual-Design/DynamoRevit/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Conceptual-Design/DynamoRevit/downloads","issues_url":"https://api.github.com/repos/Conceptual-Design/DynamoRevit/issues{/number}","pulls_url":"https://api.github.com/repos/Conceptual-Design/DynamoRevit/pulls{/number}","milestones_url":"https://api.github.com/repos/Conceptual-Design/DynamoRevit/milestones{/number}","notifications_url":"https://api.github.com/repos/Conceptual-Design/DynamoRevit/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Conceptual-Design/DynamoRevit/labels{/name}","releases_url":"https://api.github.com/repos/Conceptual-Design/DynamoRevit/releases{/id}","created_at":"2014-10-30T09:38:55Z","updated_at":"2014-11-03T05:53:27Z","pushed_at":"2015-10-21T04:45:03Z","git_url":"git://github.com/Conceptual-Design/DynamoRevit.git","ssh_url":"git@github.com:Conceptual-Design/DynamoRevit.git","clone_url":"https://github.com/Conceptual-Design/DynamoRevit.git","svn_url":"https://github.com/Conceptual-Design/DynamoRevit","homepage":null,"size":684523,"stargazers_count":0,"watchers_count":0,"language":"C#","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"DynamoDS:Revit2017","ref":"Revit2017","sha":"0985dae2e3385361cc8c4bba166895eb396c76b0","user":{"login":"DynamoDS","id":6528209,"avatar_url":"https://avatars.githubusercontent.com/u/6528209?v=3","gravatar_id":"","url":"https://api.github.com/users/DynamoDS","html_url":"https://github.com/DynamoDS","followers_url":"https://api.github.com/users/DynamoDS/followers","following_url":"https://api.github.com/users/DynamoDS/following{/other_user}","gists_url":"https://api.github.com/users/DynamoDS/gists{/gist_id}","starred_url":"https://api.github.com/users/DynamoDS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DynamoDS/subscriptions","organizations_url":"https://api.github.com/users/DynamoDS/orgs","repos_url":"https://api.github.com/users/DynamoDS/repos","events_url":"https://api.github.com/users/DynamoDS/events{/privacy}","received_events_url":"https://api.github.com/users/DynamoDS/received_events","type":"Organization","site_admin":false},"repo":{"id":22768182,"name":"DynamoRevit","full_name":"DynamoDS/DynamoRevit","owner":{"login":"DynamoDS","id":6528209,"avatar_url":"https://avatars.githubusercontent.com/u/6528209?v=3","gravatar_id":"","url":"https://api.github.com/users/DynamoDS","html_url":"https://github.com/DynamoDS","followers_url":"https://api.github.com/users/DynamoDS/followers","following_url":"https://api.github.com/users/DynamoDS/following{/other_user}","gists_url":"https://api.github.com/users/DynamoDS/gists{/gist_id}","starred_url":"https://api.github.com/users/DynamoDS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DynamoDS/subscriptions","organizations_url":"https://api.github.com/users/DynamoDS/orgs","repos_url":"https://api.github.com/users/DynamoDS/repos","events_url":"https://api.github.com/users/DynamoDS/events{/privacy}","received_events_url":"https://api.github.com/users/DynamoDS/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/DynamoDS/DynamoRevit","description":"Dynamo Libraries for Revit","fork":false,"url":"https://api.github.com/repos/DynamoDS/DynamoRevit","forks_url":"https://api.github.com/repos/DynamoDS/DynamoRevit/forks","keys_url":"https://api.github.com/repos/DynamoDS/DynamoRevit/keys{/key_id}","collaborators_url":"https://api.github.com/repos/DynamoDS/DynamoRevit/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/DynamoDS/DynamoRevit/teams","hooks_url":"https://api.github.com/repos/DynamoDS/DynamoRevit/hooks","issue_events_url":"https://api.github.com/repos/DynamoDS/DynamoRevit/issues/events{/number}","events_url":"https://api.github.com/repos/DynamoDS/DynamoRevit/events","assignees_url":"https://api.github.com/repos/DynamoDS/DynamoRevit/assignees{/user}","branches_url":"https://api.github.com/repos/DynamoDS/DynamoRevit/branches{/branch}","tags_url":"https://api.github.com/repos/DynamoDS/DynamoRevit/tags","blobs_url":"https://api.github.com/repos/DynamoDS/DynamoRevit/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/DynamoDS/DynamoRevit/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/DynamoDS/DynamoRevit/git/refs{/sha}","trees_url":"https://api.github.com/repos/DynamoDS/DynamoRevit/git/trees{/sha}","statuses_url":"https://api.github.com/repos/DynamoDS/DynamoRevit/statuses/{sha}","languages_url":"https://api.github.com/repos/DynamoDS/DynamoRevit/languages","stargazers_url":"https://api.github.com/repos/DynamoDS/DynamoRevit/stargazers","contributors_url":"https://api.github.com/repos/DynamoDS/DynamoRevit/contributors","subscribers_url":"https://api.github.com/repos/DynamoDS/DynamoRevit/subscribers","subscription_url":"https://api.github.com/repos/DynamoDS/DynamoRevit/subscription","commits_url":"https://api.github.com/repos/DynamoDS/DynamoRevit/commits{/sha}","git_commits_url":"https://api.github.com/repos/DynamoDS/DynamoRevit/git/commits{/sha}","comments_url":"https://api.github.com/repos/DynamoDS/DynamoRevit/comments{/number}","issue_comment_url":"https://api.github.com/repos/DynamoDS/DynamoRevit/issues/comments{/number}","contents_url":"https://api.github.com/repos/DynamoDS/DynamoRevit/contents/{+path}","compare_url":"https://api.github.com/repos/DynamoDS/DynamoRevit/compare/{base}...{head}","merges_url":"https://api.github.com/repos/DynamoDS/DynamoRevit/merges","archive_url":"https://api.github.com/repos/DynamoDS/DynamoRevit/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/DynamoDS/DynamoRevit/downloads","issues_url":"https://api.github.com/repos/DynamoDS/DynamoRevit/issues{/number}","pulls_url":"https://api.github.com/repos/DynamoDS/DynamoRevit/pulls{/number}","milestones_url":"https://api.github.com/repos/DynamoDS/DynamoRevit/milestones{/number}","notifications_url":"https://api.github.com/repos/DynamoDS/DynamoRevit/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/DynamoDS/DynamoRevit/labels{/name}","releases_url":"https://api.github.com/repos/DynamoDS/DynamoRevit/releases{/id}","created_at":"2014-08-08T18:52:34Z","updated_at":"2015-09-14T07:21:16Z","pushed_at":"2015-10-21T04:53:25Z","git_url":"git://github.com/DynamoDS/DynamoRevit.git","ssh_url":"git@github.com:DynamoDS/DynamoRevit.git","clone_url":"https://github.com/DynamoDS/DynamoRevit.git","svn_url":"https://github.com/DynamoDS/DynamoRevit","homepage":"http://www.dynamobim.org","size":713588,"stargazers_count":14,"watchers_count":14,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":48,"mirror_url":null,"open_issues_count":13,"forks":48,"open_issues":13,"watchers":14,"default_branch":"Revit2015"}},"_links":{"self":{"href":"https://api.github.com/repos/DynamoDS/DynamoRevit/pulls/732"},"html":{"href":"https://github.com/DynamoDS/DynamoRevit/pull/732"},"issue":{"href":"https://api.github.com/repos/DynamoDS/DynamoRevit/issues/732"},"comments":{"href":"https://api.github.com/repos/DynamoDS/DynamoRevit/issues/732/comments"},"review_comments":{"href":"https://api.github.com/repos/DynamoDS/DynamoRevit/pulls/732/comments"},"review_comment":{"href":"https://api.github.com/repos/DynamoDS/DynamoRevit/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/DynamoDS/DynamoRevit/pulls/732/commits"},"statuses":{"href":"https://api.github.com/repos/DynamoDS/DynamoRevit/statuses/16d865bc219f7c5b558156d5162e0565dca781ea"}}}}