PromptDialog.Choice does not show choices - botframework

I'm looking for how we can show choices to user with IDialog<object> and PromtDialog.Choice method. But the thing is below code sample doesn't show the choices. Very difficult to find code sample. Looking for a help. Thank you.
List<string> BotOptions = new List<string>();
BotOptions.Add("Find a Program");
BotOptions.Add("Find an Event");
PromptDialog.Choice(context,
ChoiceSelectAsync,BotOptions,
"I didn't understand you. I'm cable to help you with",
"Didn't get that",
1,
PromptStyle.None);

You need to change the PromptStyle to anything but None.
The available options are:
Auto
Generate buttons for choices and let connector generate the right style based on channel capabilities
AutoText
Show choices as Text.
The prompt decides if it should generate the text inline or perline based on number of choices.
Inline
Show choices on the same line.
PerLine
Show choices with one per line.
None
Do not show possible choices in the prompt
source

I think to get the prompt of choices you must "call" the promptDialog, use 'PromptChoice' option instead of 'choice'
var choosenResult = new PromptDialog.PromptChoice<string>
(new string[] { "Find a Program", "Find an Event" },
"Which one would you like?",
"Didn't get that", 3);
context.Call(choosenResult, AfterUserHasChosenAsync);

Related

Automate a reoccuring manual task (generate order number based on name) in Visual Studio

I'm currently working on a EpiServer project where we use the ContentType attribute to set the DisplayName and Order of the blocks. The Order is based on the name of the block. Here's an example:
[ContentType(
DisplayName = "My First Block",
Order = 133536,
GUID = "0f02e38a-a6e2-4333-9bd1-c61cf573d8d3",
Description = "Just an example block.",
GroupName = "Blocks.Content"
)]
public class MyFirstBlock : BaseBlock
{
}
Apparently EpiServer can't sort the blocks alphabetically so we generate the order based on the DisplayName as a work around. A formula was invented to determine the order. One colleague has written a JavaScript function that can be used to generate the order number:
function getEPiOrderNumber(value) {
var alphabeticalIndex = function (character) {
return character.toLowerCase().charCodeAt() - 96;
};
var firstSection = alphabeticalIndex(value[0]);
var secondSection = alphabeticalIndex(value[1]) + 10;
var thirdSection = alphabeticalIndex(value[2]) + 100;
return `${firstSection}${secondSection}${thirdSection}`;
}
This function can be executed in the console of a browser. Better than having to calculate the order by hand, but this requires that I switch to a browser, open the console, paste this code and execute it and finally copy the result and paste it in the model I'm working on.
I figured it would be much more convenient to be able to do generate the order number from within VS. I have been looking into using Visual Studio Extensions but can't really find anything that is to my liking.
The most optimal solution would be to be able to select the (part of the) DisplayName, right click and select a new command from the context menu that will generate the order and paste it at the correct location. Or place it on the clip board so I can easily paste it in the right location myself. A pop-up displaying the order would be fine as well.
Is this even possible?
Another option could be a new command in one of the toolbar menu's, say Tools, that would display a small window where I can enter/ paste the text and to have it generate the order that I can then paste in the code.
I have figured out how to add an Custom Command to the Tools menu and how I could generate the code and display it, but how can I enter the text? Or is it maybe possible to retrieve selected text from the editor window? That would solve my problem as well.
If anyone could point me in the right direction, that would be great!
PS. I'm not too happy with the title of this question so I'm open to suggestions if anyone can think of a title that better describes my question.
You could retrieve selected text from Visual Studio editor window with following code.
DTE dte = (DTE)this.ServiceProvider.GetService(typeof(DTE));
string text = "";
if (dte.ActiveDocument != null)
{
var selection = (TextSelection)dte.ActiveDocument.Selection;
text = selection.Text;
}

How to specify a particular order of buttons in a JavaFX 8 Alert

I need to ask the user to confirm doing an action. The set of buttons of the confirmation dialog are "Yes", "No" and "Cancel". My code is below:
private ButtonType askYesNoCancel(String question) {
Alert alert = new Alert(AlertType.CONFIRMATION);
alert.setContentText(question);
alert.getButtonTypes().setAll(ButtonType.YES,
ButtonType.NO,
ButtonType.CANCEL);
return alert.showAndWait().get();
}
which gives me
The problem I am facing is that regardless in what order I specify the ButtonTypes for an Alert, I get the same button order (No - Cancel - Yes). I took a look at API documentation for Alert, Button and ButtonType, alas, not to find an answer.
What I try to accomplish, is the button order Yes - No - Cancel. Any advice?
Example if you really need to specify button order...
private static class FixedOrderButtonDialog extends DialogPane {
#Override
protected Node createButtonBar() {
ButtonBar node = (ButtonBar) super.createButtonBar();
node.setButtonOrder(ButtonBar.BUTTON_ORDER_NONE);
return node;
}
}
And then when you create your Alert.
alert.setDialogPane(new FixedOrderButtonDialog());
Check the answer to: Enter Key Event Is Not Working On Dialog In Javafx?, though I guess that answer more appropriately belongs with this question and perhaps doesn't fully explain what is going on. Also read the ButtonBar javadoc.
Basically, the button position is determined by a combination of the ButtonType of each button and the ButtonBar's buttonOrder. By changing either of these things, you will end up with different button layouts.
As I recall, customizing the ButtonBar was kind of tricky. You might need to subclass the alert and override createButtonBar.
What I try to accomplish, is the button order Yes - No - Cancel. Any advice?
My advice is: Don't try to customize the button order, but let the system default order be applied. The button order has already been preconfigured to match the standard button layout for dialogs for various operating systems. Reordering the buttons to deviate from that standard may make your application just slightly more confusing for users (that's a pretty subjective opinion though).
This is a modified version of #Adam solution. Advantage - no need in extra class, no need to remove existing dialog pane with all its content.
ButtonBar buttonBar = (ButtonBar) alert.getDialogPane().lookup(".button-bar");
buttonBar.setButtonOrder(ButtonBar.BUTTON_ORDER_NONE);

Find a button on a web page looking for part of its InnerText string in Visual Studio

I am writing automated tests for a website. On the website there is a button that will have the inner text "All Open" + four random digits. For example: "All Open2957". Is there a way to find the button using only the "All Open" part of the string?
This does not work since the string is missing the four last digits:
HtmlSpan uIAllOpenPane = new HtmlSpan();
uIAllOpenPane.SearchProperties[HtmlDiv.PropertyNames.InnerText] = "All Open";
The simple answer is to use the PropertyExpressionOperator.Contains rather than PropertyExpressionOperator.EqualTo comparator and search for just the required text.
For recorded tests, find the control in the UI Map editor and view its properties panel. Click the "Search properties" field and then click the ellipsis. The window that appears allows the comparator and the required text to be altered.
For hand coded tests use code of the form:
uIAllOpenPane.SearchProperties.Add(HtmlDiv.PropertyNames.InnerText,
"All Open",
PropertyExpressionOperator.Contains);
According to this Microsoft blog the array index style (ie with [ and ]) as used in the question internally calls the SearchProperties.Add(...) but that style has no variation to specify ...Contains, so call the ...Add(...) explicitly.
Check this out
Button allOpenButton = (Button)BrowserWindow.ExecuteScript("allOpenButton = function(){var found; $('input[type=\"button\"]').each(function(){ if($(this).val().indexOf('All Open') > -1){ found = $(this);};}); return found;}; return allOpenButton();");
When trying to locate the controller I only got the FailedToPerformActionOnHiddenC‌​ontrolException. Eventually I was able to locate the DIV container that contained the controller I was trying to locate instead of focusing on finding the controller directly. After finding the container I could locate the controller using
HtmlSpan uIAllOpenPane = new HtmlSpan(container);
uIAllOpenPane.SearchProperties.Add(HtmlDiv.PropertyNames.InnerText, "All Open",
PropertyExpressionOperator.Contains);
The code from #AdrianHHH helped with the problem when part of the string is randomized each time you encounter the controller.

multiple textboxes in input prompt WP7

coding4fun toolkit's input prompt has one textbox but I can't find any way to add another!
Here is the sample I found from google:
InputPrompt input = new InputPrompt();
input.Completed += new EventHandler<PopUpEventArgs<string, PopUpResult>>(input_Completed);
input.Title = "Test Title";
input.Message = "Test message !";
input.InputScope = new InputScope { Names = { new InputScopeName() { NameValue = InputScopeNameValue.EmailSmtpAddress } } };
input.Show();
Here i can add only single inputscope...but i need to add multiple text boxes here!
can anyone help me ?
Thanks in advance !
The Coding4Fun control does not support this. You'll need to create your own control for such an interface. (hint. You could extend the code of the C4F control.)
My understanding and expectation of the C4F control is that it was intended for quickly gathering an single piece of information which wouldn't warrant the need for its own page.
If you're looking to require the user to enter data into "multiple text boxes" you'll likely be able to create a better user experience (and one that is like the native apps on the phone) if you use a separate page to gather such information.

Tying a data source from dojo.xhrPost to a text box for autocomplete

I inherited a web app that uses Dojo 1.5 and the template toolkit. I am enjoying learning dojo but it's at a slow pace.
Initially when bringing up our web form, we'll have a list of files on the right side of the page like so....
AAA_text
BBB_text_1
BBB_text_2
CCC_text
....
....
On the left side we have a search box that asks for the subset of file to use. Normally we would just type in "AAA" and then the div on the right side would find those files that match and display them after you press the "Search" key below the box.
What we are looking to do is to eliminate the "Search box" and have the list of files matching "AAA" to come up in the right side div as "AAA" is being typed, (or "BBB" or "CCC", etc).
I suppose in a nutshell it's the equivalent having the "Search" button pressed after every key is typed in the Search box.
Does this sound like a realistic goal or even possible? The code itself uses a ton of Template Tookit so I'm not looking to do any major rewrite.
If I am not making myself clear, let me know. I can elaborate for clarity. Many many thanks! Janie
EDIT: OK, I have solved a good deal of my problem so far and as it turns out, as so many of these things have a propensity to do, that what I am really needing is to get clear on how to make autocomplete work. Which is to say that I have a data source for my text box but not really sure how to tie it to the text box. I have a dojo.xhrPost routine that can handle grabbing the values.
It looks like this....
dijit.byId('files_matching').getValue(),
Googling dojo autocomplete examples gives me a zillion links and none of which are proving helpful. So I suppose my questions have transitioned to....
1. Can you even use autocomplete on a mere text box (I've seen links that say that you can only use it on combo boxes)
2. Is there a link out there somewhere that describes/shows in detail how to tie a dojo text box to a data source using dojo.xhrPost.
I am so close to solving this and I still seem to have a gaping chasm in front of me.
It's difficult to say for sure without seeing your code but if you don't have one already, I would recommend to create an ItemFileReadStore or something similar to start with. That way you can query that store locally on the client without having server requests after every key stroke.
It could look something like this:
var file_store = new dojo.data.ItemFileReadStore({ data: {
items: [{ name:"AAA_text" },
{ name:"AAA_text_1" },
{ name:"BBB_text_2" }]
}});
When you have that in place you can call a function from your text input's onChange event:
<input type="text" onchange="query_store(this.value);" />
And then you handle to actual query from the function called from the onchange event:
var query_store = function(search_for) {
var my_query = { name: search_for+"*" }; // * for wildcard match
completed = function(items, result){
for(var i = 0; i < items.length; i++){
var value = file_store.getValue(items[i], "name");
alert(value); // Instead of alert, you can save the values to your div.
}
};
file_store.fetch({ query: my_query, onComplete: completed });
}
A lot of good information about this can be found here
Hope this is at least a little helpful.

Resources