vspackage: how could I make a command in the context menu available for specific file type - vspackage

in the solution explorer, there are projects and files. and I want my custom command only to show up when user right click on certain file type, let's say ".cs" or ".html". How could I make so happen?

Assuming your package is loaded, you can control the visible/enabled state of a command through the BeforeQueryStatus event of the OleMenuCommand.
In the event handler you set if the command is supported (OleMenuCommand.Supported property) the visible state (OleMenuCommand.Visible property) and enabled state (OleMenuCommand.Enabled property) etc. according to whichever conditions, such as the type of file selected in Solution Explorer.

Related

How to hide URL Selector content tab?

I am creating a custom webpart using the Url Selector from kentico. I want the user to select content just from the Media Library. I went to form controls -> Url Selector -> Properties -> Dialogs_Content_Hide -> Default Value -> Yes and it still showing it in the Web Part. If I select the Dialogs_Web_Hide, Dialogs_Libraries_Hide and select the yes option in the default values, they hide, all except the Content_Dialogs.
Is this a bug? Or its something wrong?
Here is an example of the tabs
First set the form controls properties back to the way they were. If you don't, it will cause all kinds of problems later on.
Secondly, when you create the property in the webpart in the UI, select the URL selector form control for your text fields control. The scroll down just a bit and under the Editing Control Settings you'll see an "Configure" link. Click it. In there you will be able to tell the form control what tabs you want to enable and disable.
To add to Brenden's answer; if this is something you need to do a lot for your current build, then I'd also suggest making a copy of the Url selector form control and customize the properties as you originally mentioned. This way, you leave the default control in place for the system and have a control tailored to your needs. I've done this just now to check with a new form control that I called Media URL selector. Do make sure that you select the same source file as the original control in the Cloned form control file name property - Kentico by default will try to locate a new file called <original filename>_1.ascx. The reason for this is that admin section of your site also makes use of this control, so you may cause a nasty side effect somewhere else in the system.
As for why the settings had no effect; these are the default values you are setting. If you already have the form control in use, then the default setting would have been applied as they originally were. If you find one of the fields in question, you can change the control type to Text box, click Save, and then reassign it to Media URL selector.

How to interact with control properties after a call to a managed action?

I have a managed action with returns bool when a button is pressed.
Depending on if true / false is returned I want to be able to change the properties of controls on the dialog. Not limited to just the text value.
Is this possible, for example the visibility, etc?
It is possible, however you will have to make sure there is a set-property control event (after your managed code custom action do-event) that touches a property related to anything you want the UI to update. If you change a property value within the managed code, or via the wrapper InstallShield provides, the Windows Installer UI doesn't track the change and update in response.
So, for example, you could wire your return value to the property RETURNVALUE, and then add a control event that sets better named properties like MYCONTROLTEXT or SHOWMYCONTROL; the control or its conditions would be wired to those better named properties.

Single Instance Window in Catel v4.0

If I have a button (bound to Command 'OpenOtherWindow') that opens a DataWindow by using IUIVisualizerService.Show(viewModel), how can I prevent another instance of said DataWindow to open?
I do not think that creating a Singleton ViewModel is the correct way to do it and having a boolean 'IsWindowOpen' in the ViewModel where my 'OpenOtherWindow' Command is located would not be very MVVM, although this is the current way we have done it.
How would I do it in Catel?
The key is to create a service that manages the state and instances of the windows. Then you never have to worry about the actual behavior and can change it in one place.
Then you can just call the following (pseudo) code:
_myFeatureService.Show();
In this service you can keep track if the window is already open and open the window if not. If you want to change this behavior in the future, you only have to do it in a single location: the service.

Why is my fileDownload control showing the trashcan even in read mode?

This is a rather strange one I think, and I'm sure I made a mistake here myself:
in one of my applications I'm showing a fileDownload control bound to a Richtext field in my underlying NotesDocument. The control's properties a are set to Hide if no attachments, show size, type and created as well as allow delete. The control itself sits inside a custom control, being part of another custom control, similar to this:
Xpage.xsp
- ccContainer
- - ccInnerDoc
Document datasources for both the container and the "inner" doc are defined at the root of ccContainer and passed into the inner doc.
The inner doc's datasource is comnputed based on a document selection, and it's igenoreRequestParams property is set to false so that I can display the contents of the selected datasource in a given panel etc.
The selected doc is first opened in read mode, and I can set it to edit mode using a button.
Problem now is that my file download control always is showing the delete icon (trashcan) no matter which mode the doc is opened in. And it's not only the icon showing, it also pretends to work by asking me whether I really want to delete and then really removes the file attachment. Only that this change of course cannot be stored into the datasource because it's only open in read mode.
I'm sure that this behaviour is some side-effect of something else in my application (to a certain extent I rebuilt this in a plain new db and until now cannot reproduce it), but I'm at the end of my knowledge of what this could be.
Any hint of what could be causing this is more than welcome.
In place of #Frantisek Kossuth I answer this myself: see compute dynamically the allowDelete property of file download xpages
Thanks again, Frantisek!

Can I create a custom DialogPreference based on a pre-existing custom Dialog?

In my Android project I've already created a custom dialog: A class named SelectColorDialog, extending Dialog, that allows the user to view a large matrix of color cells in order to select a particular color. The dialog returns the selected color value (as Integer) to the dialog initiator – typically an Activity – via a callback function.
I've a similar custom dialog, SelectTypefaceDialog, to allow easy font selection. A list of available typefaces are shown, as ListView rows, each identified by name and with an associated short sample text rendered in that typeface. The available typefaces include usual droid fonts, such as NORMAL, MONOSPACE, etc. as well as any externally sourced TTF font files that the user cares to load into a particular subdirectory on the SDCard.
These custom dialogs were not initially designed to be used directly in conjunction with SharedPreferences, preferences definition XML files or with any PreferenceActivity. Instead of, each dialog can be popped up from any activity, via the user pressing a button or via a menu item. The activity classes that create these dialogs also have internal callback classes, selection event listeners, to detect when the user selects a color or font.
These two dialogs do not have OK and Cancel buttons. Instead, the user just clicks on an item - a view of some kind - in the dialog to select the corresponding color or typeface value (implicit OK) or else presses the device’s back button to dismiss the dialog with no action taken (implicit Cancel).
I would now like to go further and incorporate these two custom dialogs into the shared preferences framework via a preferences.XML and an associated PreferenceActivity.
I would prefer to base two DialogPreference subclasses directly on these existing dialogs if possible, but I cannot see how to do so. I suspect that I cannot, and that I'll need to start all over again, and copy or adapt all the java code that is presently in the custom dialog classes – for color or font display and selection – directly into the custom DialogPreference classes instead, perhaps by overriding onCreateDialogView() and/or other methods?
This question may be a bit old, but I hope to help those, looking at the same problem in future: just extend Preference instead of DialogPreference. DialogPreference is designed badly and expected "official" way to use custom Dialog - overriding protected showDialog method does not work, because this single method contains half of class logic.

Resources