/// <summary> /// Main method which is invoked on each conversation turn. /// </summary> /// <param name="turnContext"></param> /// <param name="cancellation"></param> /// <returns></returns> public async Task OnTurnAsync(ITurnContext turnContext, CancellationToken cancellationToken = default(CancellationToken)) { DialogContext dc = null; string adaptiveCardPath = string.Empty; //based upon the activity received, the decision needs to be made if a new dialog is created or an existing one is used. switch (turnContext.Activity.Type) { case ActivityTypes.Message: await ProcessCommandsAsync(turnContext, cancellationToken); break; case ActivityTypes.Event: if (turnContext.Activity.Name == "setUserIdEvent") { adaptiveCardPath = string.Format(Constants.AdaptiveCardPath, Constants.AdaptiveCards.WelcomeMessage.ToString()); await turnContext.SendActivityAsync(DialogHelpers.CreateReply(turnContext, adaptiveCardPath, true), cancellationToken); } else { dc = await _dialogs.CreateContextAsync(turnContext, cancellationToken); await dc.ContinueDialogAsync(cancellationToken); if (!turnContext.Responded) { await dc.BeginDialogAsync(Constants.RootDialogName, cancellationToken); } } break; case ActivityTypes.ContactRelationUpdate: adaptiveCardPath = string.Format(Constants.AdaptiveCardPath, Constants.AdaptiveCards.WelcomeMessage.ToString()); await turnContext.SendActivityAsync(DialogHelpers.CreateReply(turnContext, adaptiveCardPath, true), cancellationToken); break; case ActivityTypes.ConversationUpdate: foreach (var member in turnContext.Activity.MembersAdded) { if (member.Id != turnContext.Activity.Recipient.Id) { adaptiveCardPath = string.Format(Constants.AdaptiveCardPath, Constants.AdaptiveCards.WelcomeMessage.ToString()); await turnContext.SendActivityAsync(DialogHelpers.CreateReply(turnContext, adaptiveCardPath, true), cancellationToken); } } break; } }
public void ClickApplyAndWaitForFeature(string expectedTitle, string featureName) { DialogHelpers.PressButtonWithNameFromDialogWithName( GetMainWindowHWnd(), expectedTitle, "Apply" ); VisualStudioInstance.Workspace.WaitForAsyncOperations( Helper.HangMitigatingTimeout, featureName ); }
public bool CloseWindow() { var dialog = DialogHelpers.FindDialogByAutomationId(GetMainWindowHWnd(), ChangeSignatureDialogAutomationId, isOpen: true, wait: false); if (dialog == null) { return(false); } ClickCancel(); return(true); }
/// <summary> /// Verifies that the Extract Interface dialog is currently open. /// </summary> public void VerifyOpen() { var dialog = DialogHelpers.FindDialogByAutomationId(GetMainWindowHWnd(), ExtractInterfaceDialogID, isOpen: true); if (dialog == null) { throw new InvalidOperationException($"Expected the '{ExtractInterfaceDialogID}' dialog to be open but it is not."); } // Wait for application idle to ensure the dialog is fully initialized VisualStudioInstance.WaitForApplicationIdle(CancellationToken.None); }
public bool CloseWindow() { var dialog = DialogHelpers.FindDialogByAutomationId(GetMainWindowHWnd(), ExtractInterfaceDialogID, isOpen: true, wait: false); if (dialog == null) { return(false); } ClickCancel(); return(true); }
/// <summary> /// Creates and adds the required GUI elements /// </summary> private void CreateGUI() { // Create the add button AddButton = ControlsFactory.CreateStandardAddCircularButton(); AddButton.Command = new RelayCommand(async() => { // Create the form var form = new DataForm <DataGridPresenterMap>(new DataGridPresenterMap(QueryMap)) { Mapper = CeidDiplomatikiDataModelHelpers.DataGridPresenterMapMapper.Value } .ShowInput(x => x.Name, settings => { settings.Name = CeidDiplomatikiDataModelHelpers.DataGridPresenterMapMapper.Value.GetTitle(x => x.Name); settings.IsRequired = true; }) .ShowInput(x => x.Description, settings => settings.Name = CeidDiplomatikiDataModelHelpers.DataGridPresenterMapMapper.Value.GetTitle(x => x.Description)) .ShowStringColorInput(x => x.Color, settings => settings.Name = CeidDiplomatikiDataModelHelpers.DataGridPresenterMapMapper.Value.GetTitle(x => x.Color)); // Show an add dialog var dialogResult = await DialogHelpers.ShowConventionalAddDialogAsync(this, "Data grid creation", null, form); // If we didn't get positive feedback... if (!dialogResult.Feedback) { // Return return; } // Get the manager var manager = CeidDiplomatikiDI.GetCeidDiplomatikiManager; // Register it QueryMap.Add(form.Model); // Save the changes var result = await manager.SaveChangesAsync(); // If there was an error... if (!result.Successful) { // Show the error await result.ShowDialogAsync(this); // Return return; } // Add the model DataPresenter.Add(form.Model); }); // Add it to the content grid ContentGrid.Children.Add(AddButton); }
private void MenuItemCallback(object sender, EventArgs e) { var injectDependencyCaption = "Inject Dependency"; if (_dte.ActiveDocument == null) { DialogHelpers.Error("Open a code file first.", injectDependencyCaption); return; } using (var injectDependencyDialog = new InjectDependencyDialog( _fieldNameGenerators, _dependencyNameProviders, _dependencyInjector.GetExpectedClassName(_dte.ActiveDocument))) { if (injectDependencyDialog.ShowDialog() == DialogResult.OK) { var dependencyInjectionData = injectDependencyDialog.GetDependencyInjectionData(); if (string.IsNullOrEmpty(dependencyInjectionData.FieldName) || string.IsNullOrEmpty(dependencyInjectionData.FieldType) || string.IsNullOrEmpty(dependencyInjectionData.ConstructorParameterName) || string.IsNullOrEmpty(dependencyInjectionData.ConstructorParameterType)) { DialogHelpers.Warning("Field and constructor parameter names and types must be filled.", injectDependencyCaption); return; } var result = _dependencyInjector.Inject( _dte.ActiveDocument, injectDependencyDialog.GetDependencyInjectionData()); if (!result.Success) { switch (result.ErrorCode) { case DependencyInjectorErrorCodes.ClassNotFound: DialogHelpers.Warning( "Could not inject dependency because the class was not found in this file.", injectDependencyCaption); break; default: DialogHelpers.Warning("Could not inject dependency.", injectDependencyCaption); break; } } } } }
/// <summary> /// Creates and adds the required GUI elements /// </summary> private void CreateGUI() { // Create the add button AddButton = ControlsFactory.CreateStandardAddCircularButton(); AddButton.Command = new RelayCommand(async() => { // Create the form var form = CeidDiplomatikiDataModelHelpers.CreatePageMapDataForm(); // Set the model form.Model = new PageMap(); // Show the dialog var dialogResult = await DialogHelpers.ShowConventionalAddDialogAsync(this, "Page creation", null, form); // If we didn't get positive feedback... if (!dialogResult.Feedback) { // Return return; } // Update the values of the model form.UpdateModelValues(); // Get the manager var manager = CeidDiplomatikiDI.GetCeidDiplomatikiManager; // Register it manager.Register(form.Model); // Save the changes var result = await manager.SaveChangesAsync(); // If there was an error... if (!result.Successful) { // Show the error await result.ShowDialogAsync(this); // Return return; } // Add it to the presenter DataPresenter.Add(form.Model); }); // Add it to the content grid ContentGrid.Children.Add(AddButton); }
private void CommandOpen_Executed(object sender, ExecutedRoutedEventArgs e) { string str = DialogHelpers.OpenLoksimFile(string.Empty, FileExtensions.AllLoksimFiles, this, MAIN_DLG_OPEN); if (!string.IsNullOrEmpty(str)) { L3dFilePath p = new L3dFilePath(str); if (!L3dFilePath.IsNullOrEmpty(p)) { OpenFile(p); } } }
private void CreateNewNote(bool secure) { var settings = DialogHelpers.GetDefaultDialogSettings(); MainWindowInstance.ShowInputAsync("New note", "Name of the new note:", settings).ContinueWith(delegate(Task <string> task) { string name = task.Result; if (!string.IsNullOrWhiteSpace(name)) { CreateNewNote(name, secure); } }); }
public string[] GetNewFileComboBoxItems() { var dialog = DialogHelpers.GetOpenDialog(GetMainWindowHWnd(), GenerateTypeDialogID); var createNewFileComboBox = dialog.FindDescendantByAutomationId("CreateNewFileComboBox"); createNewFileComboBox.Expand(); var children = createNewFileComboBox.FindDescendantsByClass("ListBoxItem"); createNewFileComboBox.Collapse(); return(children.Cast <AutomationElement>().Select(element => element.Current.Name).ToArray()); }
public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position) { DialogHelpers dialogs = new DialogHelpers(); TasksViewHolder vh = holder as TasksViewHolder; vh.taskName.Text = mTasks[position].mTaskName; vh.taskProjectName.Text = mTasks[position].mTaskProjectName; vh.taskPercentComplete.Text = mTasks[position].mTasksPercentComplete; vh.taskWork.Text = mTasks[position].mtasksWork; vh.taskDuration.Text = mTasks[position].mTasksDuration; vh.deleteTask.Click += delegate { dialogs.DeleteTaskDialog(main, mTasks[position].mTaskProjectName, mTasks[position].mTaskName).Show(); }; vh.editTask.Click += delegate { dialogs.EditTaskDialog(main, mTasks[position].mTaskProjectName, mTasks[position].mTaskName).Show(); }; }
/// <summary> /// Gets the set of members that are currently checked. /// </summary> public string[] GetSelectedItems() { var dialog = DialogHelpers.GetOpenDialogById(GetMainWindowHWnd(), ExtractInterfaceDialogID); var memberSelectionList = dialog.FindDescendantByAutomationId("MemberSelectionList"); var listItems = memberSelectionList.FindDescendantsByClass("ListBoxItem"); return(listItems.Cast <AutomationElement>() .Select(item => item.FindDescendantByClass("CheckBox")) .Where(checkBox => checkBox.IsToggledOn()) .Select(checkbox => checkbox.Current.AutomationId) .ToArray()); }
private void InjectDependencyCallback(object sender, EventArgs e) { var injectDependencyCaption = "Inject Dependency"; if (_dte.ActiveDocument == null) { DialogHelpers.Error("Open a code file first.", injectDependencyCaption); return; } using (var injectDependencyDialog = new InjectDependencyDialog()) { if (injectDependencyDialog.ShowDialog() == DialogResult.OK) { if (string.IsNullOrEmpty(injectDependencyDialog.DependencyName)) { DialogHelpers.Warning("Dependency name cannot be empty.", injectDependencyCaption); return; } if (string.IsNullOrEmpty(injectDependencyDialog.PrivateFieldName)) { DialogHelpers.Warning("Private field name cannot be empty.", injectDependencyCaption); return; } var result = _dependencyInjector.Inject(_dte.ActiveDocument, injectDependencyDialog.DependencyName, injectDependencyDialog.PrivateFieldName); if (!result.Success) { switch (result.ErrorCode) { case DependencyInjectorErrorCodes.ClassNotFound: DialogHelpers.Warning("Could not inject depencency because the class was not found in this file.", injectDependencyCaption); break; case DependencyInjectorErrorCodes.ConstructorNotFound: DialogHelpers.Warning("Could not inject depencency because the constructor was not found.", injectDependencyCaption); break; default: DialogHelpers.Warning("Could not inject dependency.", injectDependencyCaption); break; } } } } }
public void VerifyClosed(string dialogName) { using var cancellationTokenSource = new CancellationTokenSource( Helper.HangMitigatingTimeout ); // FindDialog will wait until the dialog is closed, so the return value is unused. DialogHelpers.FindDialogByName( GetMainWindowHWnd(), dialogName, isOpen: false, cancellationTokenSource.Token ); }
private void DeleteCurrentNoteBook() { if (MenuContext.SelectedNotebook != null) { var notes = Hub.Instance.Storage.GetNotes(MenuContext.SelectedNotebook.Notebook); if (!notes.Any()) { var settings = DialogHelpers.GetDefaultDialogSettings(); if (MenuContext.Notebooks.Count == 1) { MainWindowInstance.ShowMessageAsync("Delete", "You can't delete the last notebook, rename it if the name is wrong.", MessageDialogStyle.Affirmative, settings); return; } MainWindowInstance.ShowMessageAsync("Delete", $"Do you want to delete the notebook {MenuContext.SelectedNotebook.Name}?", MessageDialogStyle.AffirmativeAndNegative, settings).ContinueWith(delegate(Task <MessageDialogResult> task) { if (task.Result == MessageDialogResult.Affirmative) { InvokeOnCurrentDispatcher(() => { int index = MenuContext.Notebooks.IndexOf(MenuContext.SelectedNotebook); if (index >= MenuContext.Notebooks.Count - 1) { index--; } MenuContext.SelectedNotebook.Notebook.Delete(); if (MenuContext.Notebooks.Contains(MenuContext.SelectedNotebook)) { MenuContext.Notebooks.Remove(MenuContext.SelectedNotebook); } if (NotebookMenuItems.Contains(MenuContext.SelectedNotebook)) { NotebookMenuItems.Remove(MenuContext.SelectedNotebook); } MenuContext.SelectedNotebook = MenuContext.Notebooks[index]; }); } }); } else { MainWindowInstance.ShowMessageAsync("Delete", "You can't delete a notebook that contains notes."); } } }
private void OpenErrorLogCallback(object sender, EventArgs e) { _hasSeenErrorLogUpdate = true; if (_latestUpdatedLogFileStatus != null && File.Exists(_latestUpdatedLogFileStatus.Path)) { System.Diagnostics.Process.Start(_latestUpdatedLogFileStatus.Path); } else { DialogHelpers.Error("The log file doesn't exist.", "Open Orchard Error Log"); } UpdateOpenErrorLogCommandAccessibilityAndText(); }
private void DeleteLibrary() { var settings = DialogHelpers.GetDefaultDialogSettings(); var message = $"Do you want to delete the library '{Library.Name}'?\nAll files will be left untouched, it's just the connection that is removed."; MainWindowInstance.ShowMessageAsync("Delete library", message, MessageDialogStyle.AffirmativeAndNegative, settings).ContinueWith(delegate(Task<MessageDialogResult> task) { if (task.Result == MessageDialogResult.Affirmative) InvokeOnCurrentDispatcher(() => { Hub.Instance.AppSettings.Librarys.Remove(Library); Library.Delete(); }); }); }
private async void MapView_PinClicked(object sender, PinClickedEventArgs e) { if (selectedPin == e.Pin) { switch (await DisplayActionSheet("Select Action", "Cancel", null, new string[] { "Get Directions" })) { case "Get Directions": { var merchant = e.Pin.Tag as Models.Merchant; using (DialogHelpers.ShowProgress()) { switch (Device.RuntimePlatform) { case Device.Android: Device.OpenUri(new Uri($"google.navigation:q={merchant.LocationLat},{merchant.LocationLng}")); break; case Device.iOS: { if (Plugin.Geolocator.CrossGeolocator.Current.IsGeolocationAvailable) { UserDialogs.Instance.ShowLoading("Processing..."); try { var location = await Plugin.Geolocator.CrossGeolocator.Current.GetPositionAsync(); Device.OpenUri(new Uri($"http://maps.apple.com/?saddr={location.Latitude},{location.Longitude}&daddr={merchant.LocationLat},{merchant.LocationLng}")); } catch { await DisplayAlert("Directions", "Failed getting current location", "Ok"); } finally{ UserDialogs.Instance.HideLoading(); } } } break; } } } break; } } selectedPin = e.Pin; }
public void AssignColorSingleFaceClick(object source, ContextMenuArgs e) { if (!(entity is Prim)) { return; } int FaceNumber = Picker3dController.GetInstance().GetClickedFace(entity as Prim, iMouseX, iMouseY); Color newcolor = DialogHelpers.GetColor(); if (newcolor != null) { AssignColor(FaceNumber, newcolor); } }
public void AssignColorAllFacesClick(object source, ContextMenuArgs e) { if (!(entity is Prim)) { return; } int FaceNumber = FractalSpline.Primitive.AllFaces; Color newcolor = DialogHelpers.GetColor(); if (newcolor != null) { AssignColor(FaceNumber, newcolor); } }
public void VerifyOpen(string dialogName) { using var cancellationTokenSource = new CancellationTokenSource( Helper.HangMitigatingTimeout ); // FindDialog will wait until the dialog is open, so the return value is unused. DialogHelpers.FindDialogByName( GetMainWindowHWnd(), dialogName, isOpen: true, cancellationTokenSource.Token ); // Wait for application idle to ensure the dialog is fully initialized VisualStudioInstance.WaitForApplicationIdle(cancellationTokenSource.Token); }
/// <summary> /// Creates a new, empty JSON settings file /// </summary> /// <param name="filepath">Complete path and file name</param> private static void CreateNewSettingsJson(string filepath) { try { if (!Directory.Exists(Path.GetDirectoryName(filepath))) { _ = Directory.CreateDirectory(Path.GetDirectoryName(filepath)); } File.Create(filepath).Dispose(); const string braces = "{ }"; File.WriteAllText(filepath, braces); } catch (Exception ex) { DialogHelpers.ShowErrorDialog($"The settings file could not be created.\n\n{ex.Message}"); } }
private void RenameNote() { // TODO: i18n string name = Note.Name; var settings = DialogHelpers.GetDefaultDialogSettings(); settings.DefaultText = name; MainWindowInstance.ShowInputAsync("Rename", "Enter new name:", settings).ContinueWith(delegate(Task <string> task) { string newName = task.Result; if (!string.IsNullOrWhiteSpace(newName)) { Note.Name = newName; //NoteMenuContext.SelectedNote.Note.Save(); } }); }
/// <summary> /// Writes settings to settings file /// </summary> public static void SaveSettings() { try { JsonSerializerOptions opts = new() { AllowTrailingCommas = true, ReadCommentHandling = JsonCommentHandling.Skip, WriteIndented = true }; string json = JsonSerializer.Serialize(Setting, opts); File.WriteAllText(FilePath, json); } catch (Exception ex) { DialogHelpers.ShowErrorDialog($"The settings file could not be saved.\n\n{ex.Message}"); } }
/// <summary> /// Reads settings from a JSON format settings file /// </summary> public static void LoadSettings() { if (File.Exists(FilePath)) { try { Setting = JsonSerializer.Deserialize <T>(File.ReadAllText(FilePath)); } catch (Exception ex) { DialogHelpers.ShowErrorDialog($"The settings file could not be read.\n\n{ex.Message}"); } } else { Setting = new T(); } }
//Constructor Through which the accessors get injected at the StartUp public BizTalkAdminBot(BizTalkAdminBotAccessors accessors, IConfiguration configuration) { //Connection Name is required to enable the Bot to connect to service providers through OAuth if (string.IsNullOrWhiteSpace(Constants.OAuthConnectionName)) { throw new ArgumentNullException("Connection name needs to be set in the Constants class"); } _accessors = accessors ?? throw new ArgumentNullException(nameof(accessors)); _configuration = configuration ?? throw new ArgumentException(nameof(configuration)); _storageAccountKey = _configuration["storageAccount"].ToString(); _dialogs = new DialogSet(_accessors.ConversationDialogState); _dialogs.Add(DialogHelpers.OAuthPrompt(Constants.OAuthConnectionName)); _dialogs.Add(new WaterfallDialog(Constants.RootDialogName, new WaterfallStep[] { PromptStepAsync, ProcessStepAsync })); }
public void AssignTextureSingleFaceClick( object source, ContextMenuArgs e ) { if( ! ( entity is Prim ) ) { return; } int FaceNumber = Picker3dController.GetInstance().GetClickedFace( entity as Prim, iMouseX, iMouseY ); string filename = DialogHelpers.GetFilePath("Select image file (*.bmp,*.jpg,*.gif,*.tga):","*.JPG"); if( filename != "" ) { Console.WriteLine ( filename ); if( File.Exists( filename ) ) { AssignTexture( FaceNumber, new Uri( filename ) ); } } }
protected override void OnDeactivate(CancelEventArgs e) { base.OnDeactivate(e); // Check if the log file folder path is empty only if the feature is enabled. Don't allow invalid paths at all. if (LogWatcherEnabled && string.IsNullOrEmpty(LogFileFolderPathsSerialized)) { DialogHelpers.Warning("Log file folder path is required if the feature is enabled.", "Log Watcher settings"); e.Cancel = true; } if (GetLogFileFolderPaths().Any(path => !Uri.IsWellFormedUriString(path, UriKind.Relative))) { DialogHelpers.Warning("The given log file folder path is invalid.", "Log Watcher settings"); e.Cancel = true; } }
public void VerifyOpen(string expectedTitle, TimeSpan?timeout = null) { using ( var cancellationTokenSource = timeout != null ? new CancellationTokenSource(timeout.Value) : null ) { var cancellationToken = cancellationTokenSource?.Token ?? CancellationToken.None; DialogHelpers.FindDialogByName( GetMainWindowHWnd(), expectedTitle, isOpen: true, cancellationToken ); // Wait for application idle to ensure the dialog is fully initialized VisualStudioInstance.WaitForApplicationIdle(cancellationToken); } }