In this task you will learn how to create a script loader for a new dialog box. We will create the simple script loaded named EditArticleSummary to display the EditArticleSummary dialog box. The example affects the Article.vb. |
You will be able to perform this task only if: •You are able to run a local copy of Ted4 and load an article. •You have access to the add-ins source, and know how to compile them. |
1.In Visual Studio, open the "src\GN4AddIns\GN4AddInsExpress.sln and then open the article.vb file. 2.Locate the End Class of the TxtDesignerBase class. 3.Make one or more empty lines above the found line and then type this code, exactly as it appears below: Public Overridable Sub EditArticleSummary() If ActiveArticle IsNot Nothing Then Dim ids(0) As Integer ids(0) = Ted.GetActiveArticle.Id Dim editDialog As EditObjDialog = New EditObjDialog(TedApp.ClientApp().MainWindow) If Not editDialog.SetIds(ids, "editArticleSummary") Then Exit Sub editDialog.SizeToContent = SizeToContent.WidthAndHeight editDialog.Title = "Summary" editDialog.MinWidth = 300 editDialog.MinHeight = 250 editDialog.ShowDialog() End If End Sub 4.As the code above is totally general, i.e. you can use it to call any objectUI dialog box: just specify the appropriate objectUI name in the If Not editDialog.SetIds(ids, "editArticleSummary") Then Exit Sub block and the appropriate title in the editDialog.Title = "Summary" block. 5.Save changes and then before compiling the solution, make sure no GN4 application is running on your computer. 6.Compile the add-in solution. 7.Start Ted4, load an article, and then from the Script Editor pane, execute EditArticleSummary: you see your new dialog in action. 8. |