How to implement Submit and Cancel buttons in IWizard implementation - visual-studio-addins

How do we implement the OK/Submit button if the user chose his preferences and he is ready to start working on his new project? Furthermore - Cancel button - gracefully exit from the wizard and return to New Project dialog box without creating the project.

The IWizard interface (Microsoft.VisualStudio.TemplateWizard namespace) doesn't give you full control of the project creation. It allows you to do some things at specific phases of the project creation. It is cancelable throwing a WizardCancelledException. See also this explanation and also:
Pitfalls of cancelling a VSIX project template in an IWizard
If you want full control you can use the old COM-based IDTWizard interface (EnvDTE namespace) instead, which provides a single Execute method where you can show a form (cancelable) and add the project/files using EnvDTE.Solution.AddFromTempleate, EnvDTE.ProjectItems.AddFromTemplate, etc. See my post:
Project templates wizards (IWizard vs IDTWizard)

Related

Umbraco - editing preview window sidebar options

I have a project which is using Umbraco v7.7.9 installed with nuget.
I was wondering if it is possible to change the buttons displayed in the sidebar section when a user selects to preview a content node. Particularly I want to remove the option that allows the user to close the preview.
The reason I want to hide this option is because some of the content the backoffice users will be previewing will not actually be published yet so clicking the close preview button causes an error.
I first asked this question on the Umbraco forums but haven't received a response yet, here is the link to the question: https://our.umbraco.org/forum/extending-umbraco-and-using-the-api/90878-editing-preview-window-sidebar-options
Thank you in advance.
Currently no - it would not be possible without doing hacks in the Core that would be overwritten when you upgrade your site (unless you manually merge your changes in when updating).
If you however don't mind doing that - the file used for the preview function is /umbraco/preview/index.html. You should look for the element with an exitPreview() click handler attached to it.
In later versions (7.10+) this modification will have to be done in /umbraco/Views/Preview/Index.cshtml instead, as these static files will be changed to MVC actions.

VSCode extension IPC with UI inside HTML preview

I wish to develop a unit test runner extension for VSCode. The extension should display discovered tests grouped into expandable hierarchy, annotate run status, display output and errors for each test, provide run/debug commands on different levels, and of course the red/green bar.
Roughly spearating this into "model" and "view", I plan to implement the model in the extension process, and I plan to implement the view as HTML preview based on a TextDocumentContentProvider. (Is there a better approach?)
Now, the model and the view should communicate with each other. I want to implement the view as a single-page application. The view will send commands to the model, and the model will send events to the view (or the view will poll the model for events). The view will update itself according to received events.
My question is, what communication technique should I use? Can HTML page inside the HTML preview access VSCode/Atom/Electron/Node APIs? Can I share object instances, or do some lightweight IPC? By far I didn't figure out.
I've found that I can invoke VSCode commands or refresh the entire page, when the user clicks a link with href set to specific scheme (command:// or the one I registered for my TextDocumentContentProvider).
I do succeed to open an HTTP listener (http.createServer) in the extension process, and communicate through XMLHttpRequest on the HTML preview side. But it looks to me like a heavy overkill.
I wonder if there are more appropriate ways to do this?
Almenon is referring to the currently proposed Webview API that was released in version 1.21 (Feb 2018). For the time being, this appears to be a much better approach for HTML previews. But in order to use the API, there are special instructions. From the release notes:
These APIs are still proposed, so in order to use it, you must opt into it by adding a "enableProposedApi": true to package.json and you'll have to copy the vscode.proposed.d.ts into your extension project.
What isn't clarified (and probably should be) is how to add the downloaded declaration file to a project. One way to do it is place the file in $/node_modules/vscode, next to vscode.d.ts, which is generated during postinstall. Then add the following line to the top of vscode.d.ts:
/// <reference path="vscode.proposed.d.ts" />
That will link the type declaration files. To make this part of the installation process, write a build task to do it and then call it in the vscode:postinstall script in package.json.
VSCode has a new API that makes this easier.
https://github.com/Microsoft/vscode/issues/43713
You can find the new API here
To try the new API:
Add "enableProposedApi": true to your package.json
Manually download vscode.proposed.d.ts and add it to your project: https://raw.githubusercontent.com/Microsoft/vscode/master/src/vs/vscode.proposed.d.ts
Run your extension with the latest VS Code insiders build

How to disable code template in Delphi 7 [duplicate]

Every time I type if and press the space bar, Delphi completes it with if True then and a new empty line above.
Is there a way to remove this "autocomplete" feature or at least edit it to not create the new line?
From the Tools | Options | Editor Options | Code Insight menu, deselect the Auto complete check box under Code template completion.
Once you disable template auto complete then you need to manually invoke the template if you want it. Do that with CTRL+J.
That's called a live template, and you can edit the list of live templates in the template window, from the View menu.
Find the template you don't like, select it, and click the "remove template code" button.
Since the default location for the live code templates is C:\Program Files (x86)\Embarcadero\Studio\16.0\ObjRepos\en\Code_Templates (for XE8, similar for other editions), you will need to change the permissions on this directory (and its subdirectories) in order to edit or add live templates. Default permissions do not include write permission to this directory.

How to disable autocomplete code statements in code editor?

Every time I type if and press the space bar, Delphi completes it with if True then and a new empty line above.
Is there a way to remove this "autocomplete" feature or at least edit it to not create the new line?
From the Tools | Options | Editor Options | Code Insight menu, deselect the Auto complete check box under Code template completion.
Once you disable template auto complete then you need to manually invoke the template if you want it. Do that with CTRL+J.
That's called a live template, and you can edit the list of live templates in the template window, from the View menu.
Find the template you don't like, select it, and click the "remove template code" button.
Since the default location for the live code templates is C:\Program Files (x86)\Embarcadero\Studio\16.0\ObjRepos\en\Code_Templates (for XE8, similar for other editions), you will need to change the permissions on this directory (and its subdirectories) in order to edit or add live templates. Default permissions do not include write permission to this directory.

How to create Modal and Modeless forms in borland c++ builder

I have an assignment to enhance an already existing tool written in Borland c++, I am new to programming and c++ builder. The task is to integrate message box which pops up, in to the main form itself,which I have successfully done by adding a new form to the project and calling it in place of message box.
I have made my new form modal so that control is blocked,till user selects an option.
Now I have added another form named graph to the project to show a graph and I want the control to go to the graph when user clicks a button in the new form.
Is there a way to make two children modeless and block only the parent form(modal).In short I want to access both the new forms I have added to my project and I don't want to access my main form,till I make all selections in these two forms.Kindly help!
Rather than using ShowModal(), you could set the parent Form's Enabled property to false, use Show() to show both forms, and then set the parent Form's Enabled property back to true when both forms have been closed.
You could move the functions you don't want to run automatically during create from the OnCreate() method. You may move them to e.g. OnClick(). I faced a similar situation where a Show()
method was running during program create. I implemented the OnActivate() method and called the Show() method from there, instead from OnCreate().

Resources