How to access parent page methods from usercontrol Button in silverlight? - silverlight-3.0

I am designing a dash board which contains Pods and pod containers and every pod container can have multiple pods.and every pods can have multiple user controls.
In one of my pods i have a usercontrol which bears a back button.Once i click it means i need to hide the existing pod and have to show some other pod.For that i have hardcoded some method in MainPage.xaml.
So can you just suggest me how to invoke that method in parent page from usecontrol which has back button.
Waiting for your reply.

First, think if you can find another design with better separation of concerns. Who should be responsible for closing a pod? And showing a new one?
Then, if you still need this kind of communication, try with an event. When the button is pressed, you could raise a Close event, which would be handled by the pod.

Related

unable to register device via web page. Page does not follow tutorial

In the page below, it specifies that you can register your device in the left hand column of the page, under advanced options:
https://developers.google.com/assistant/sdk/guides/library/python/embed/register-device
This is no longer the case, the option is not there. Instead there is a backend option.
Is there any kind of web page to do this action at all?
Would prefer a graphical option to a command line one.
Ok. sorted this out.
My thanks to those who looked over this question. Basically I deleted the current projects and started again. the device model registration is right down (scroll right down to) the bottom of the page on the first screen after you have first created the project. Apparently you need to not skip this step, or navigate away from this page before you do the device creation.
after that everything went well and is up and running. Thanks again

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

Titanium Facebook module issue

I'm using the native Facebook Titanium module and I have the following issue.
In my app, you can login to FB from two different windows.
In the first one, I instatiated the module and added to the module a 'login' listener.
In the second window I did the same, I instantiated the module and added a 'login' listener.
Problem is the following: the second addEventListener doesn't overwrite the first (it looks like the second Facebook 'require' is simply a pointer to the module instantiated in the first window).
So, it happens the following: when I try to authorize the user and I enter the login listener, it turns out I'm always calling the first one, not the second (the second never gets called).
I tried to remove the first eventListener with no luck. Moreover, they 'live' in distant windows and it seems there's no way to remove this listener correctly.
Any help is appreciated,
Iannis
I hope this will clarify what you are seeing:
It's standard CommonJS behaviour that modules are cached and the second and following require() will get you a reference to the first instance.
Like the name says addEventListener adds an event listener and does not replace one added earlier.
You should get the login event twice, once for each event listener you add. I can't tell why it doesn't do that for you without further insight in your code.

How to implement Submit and Cancel buttons in IWizard implementation

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)

How to disable TAction.Shortcut or TMenuItem.Shortcut?

I'm developing a Word addin, and somehow the shortcuts defined in TAction.ShortCut are always trigged more than one time, and this is tricky to me and hard to solve, so I resort to TForm.OnKeyDown event and cleared all TAction.ShortCut properties, this approach works well, except that the shortcuts are not shown on the corresponding menu items, but I want them to be displayed on those menu items.
So I come up this idea: Set values for TMenuItem.Shortcut so that the program can show the shortcut hint to the end user, and does not allow VCL to handle these shortcuts, instead, handle them in TForm.OnKeyDown. So my question is how to disable TAction.Shortcut or TMenuItem.Shortcut? Thank you in advance.
For a start, you have an Enabled property on both TAction and TMenuItem. Just set it to False.
Next, one of the possible causes of your event being triggered more than once is that you may be using Application.ProcessMessages; or at least a badly written component that you're using is doing so. One should be very wary of using that Delphi feature because it can cause 're-entrant' code (unintentional recursion).
The root cause of your problem is the events being triggered more than one time. You could try to workaround this problem offcourse but I would suggest to:
Place a breakpoint in your eventhandler.
Copy the Call Stack's content [CTRL+ALT+S] to whatever editor you like for every time you hit the breakpoint.
Start brainstorming as to why the calls lead to hitting the event multiple times.
Fix your code if it is your code to fix.
Hacker way (usually not recommended):
copy unit that contain TAction in separate folder, modify source of TAction that makes ShortCut method do nothing. Put this folder to search path as first item.
rebuild your app.
I use this technique to fix bugs in VCL, but after installing Delphi patches you should not forget to update 'hacked' version of modified units.

Resources