private ComposerStep Replace(ComposerStep oldStep) { switch (curEditingStep.Type) { case "Microsoft.SendActivity": default: return(new SendActivity(this.activity.Text, curEditingStep.RelatedShape)); case "Microsoft.IfCondition": if (oldStep is IfCondition) { (oldStep as IfCondition).Condition = this.condition.Text; } return(oldStep); case "Microsoft.SetProperty": return(new SetProperty(this.property.Text + "=" + this.value.Text, curEditingStep.RelatedShape)); case "Microsoft.HttpRequest": return(new HttpRequest(this.url.Text, this.method.Text, this.body.Text, this.property.Text, curEditingStep.RelatedShape)); case "Microsoft.TextInput": return(new TextInput(this.prompt.Text, this.property.Text, curEditingStep.RelatedShape)); } }
private async void InkCanvas_RightTapped(object sender, Windows.UI.Xaml.Input.RightTappedRoutedEventArgs e) { var inchToMillimeterFactor = 25.4f; List <Point> points = new List <Point>(); var scalingX = DpiX / inchToMillimeterFactor; var scalingY = DpiY / inchToMillimeterFactor; var xCord = e.GetPosition(inkCanvas).X / scalingX; var yCord = e.GetPosition(inkCanvas).Y / scalingY; var step = GetRelatedStep((float)xCord, (float)yCord); if (step != null) { curEditingStep = step; var fly = this.myFlyout; SetForm(); this.Type.SelectedIndex = TypeToIndex[curEditingStep.Type]; var options = new Windows.UI.Xaml.Controls.Primitives.FlyoutShowOptions() { Position = e.GetPosition(sender as UIElement) }; fly.ShowAt(sender as FrameworkElement, options); } else { // should say something? } }
private void ClearCanvas() { this.recogCanvas.Children.Clear(); this.debugCanvas.Children.Clear(); this.inkRecognizer.ClearStrokes(); this.inkCanvas.InkPresenter.StrokeContainer.Clear(); this.botInstance = null; this.curEditingStep = null; this.gButton.Visibility = Visibility.Collapsed; }
private List <ComposerStep> FindInBotInstanceAndGenerateNew(List <ComposerStep> steps, ComposerStep stepToFind) { var result = new List <ComposerStep>(); for (var i = 0; i < steps.Count; i++) { if (steps[i].RelatedShape.Equals(stepToFind.RelatedShape)) { var stepToReplace = steps[i]; var newStep = Replace(stepToReplace); result.Add(newStep); } else if (steps[i].Type == "Microsoft.IfCondition") { var ifStep = steps[i] as IfCondition; var newIfStep = new IfCondition(ifStep.Condition, ifStep.RelatedShape); newIfStep.Steps.AddRange(FindInBotInstanceAndGenerateNew(ifStep.Steps, stepToFind)); newIfStep.ElseSteps.AddRange(FindInBotInstanceAndGenerateNew(ifStep.ElseSteps, stepToFind)); result.Add(newIfStep); } else { result.Add(steps[i]); } } return(result); }