internal async Task Initialize() { try { // var worker = new ProgressWorker(); // await worker.Run((cts) => // { var cts = new CancellationTokenSource(); _Client = CarouselClient.CreateInstance(cts, () => { var prompt = new TextPrompt("Please enter your Google username"); prompt.ShowDialog(); return(prompt.TextResult); }).Result; // }); } catch (Exception) { MessageBox.Show("Error authorizing Google Drive API. Please check configuration files."); return; } using (var cts = new CancellationTokenSource()) { this.GamesListBox.DataSource = _Client.GetGamesList(); } }
private void listDataCopyToolStripMenuItem_Click(object sender, EventArgs e) { var t = new TextPrompt(this, "Type the name of the new list:", currentItem.Name); DialogResult dResult = t.ShowDialog(); if (dResult == DialogResult.OK) { ExecuteMethod <CopyListParameters>(CopyList, new CopyListParameters { MarketingList = currentItem, NewName = t.Value, NextFunction = CopyListWithData }); } }
private void ButtonNewCategory_Click(object sender, EventArgs e) { using (var form = new TextPrompt(LanguageSettings.Current.SubStationAlphaStylesCategoriesManager.NewCategory, LanguageSettings.Current.SubStationAlphaStylesCategoriesManager.CategoryName, string.Empty)) { if (form.ShowDialog() == DialogResult.OK) { var newName = form.InputText; if (string.IsNullOrWhiteSpace(newName)) { return; } var insertIndex = listViewCategories.Items.Count; var overridingDefault = false; if (_assaCategories.Exists(category => category.Name == newName)) { var result = MessageBox.Show(string.Format(LanguageSettings.Current.SubStationAlphaStyles.OverwriteX, newName), string.Empty, MessageBoxButtons.YesNoCancel); if (result == DialogResult.Yes) { var overriddenCategory = _assaCategories.Single(category => category.Name == newName); overridingDefault = overriddenCategory.IsDefault; _assaCategories.Remove(overriddenCategory); insertIndex = listViewCategories.FindItemWithText(newName, false, 0, false).Index; listViewCategories.Items.RemoveAt(insertIndex); } else if (result == DialogResult.No) { newName = FixDuplicateName(newName, _assaCategories); } else { return; } } var newCategory = new AssaStorageCategory { Name = newName, IsDefault = overridingDefault, Styles = new List <SsaStyle>() }; if (overridingDefault) { newCategory.Styles.Add(new SsaStyle()); } _assaCategories.Insert(insertIndex, newCategory); var lvi = GetCategoryListViewItem(newCategory); listViewCategories.Items.Insert(insertIndex, lvi); UpdateSelectedIndices(insertIndex); } } }
public RecordCameraNode(Canvas parentCanvas) : base(parentCanvas) { TextPrompt textPrompt = new TextPrompt(); Text = "Record"; if (textPrompt.ShowDialog() == true) { if (!string.IsNullOrEmpty(textPrompt.ResponseText)) { Text = textPrompt.ResponseText; } } AddSocket(SocketType.Input); }
public TimedNode(Canvas parentCanvas) : base(parentCanvas) { TextPrompt textPrompt = new TextPrompt(); if (textPrompt.ShowDialog() == true) { if (!string.IsNullOrEmpty(textPrompt.ResponseText)) { time = int.Parse(textPrompt.ResponseText); } } Text = "Timer: " + time; timer = new Timer(time * 1000); timer.AutoReset = false; timer.Elapsed += TimerTick; AddSocket(SocketType.Input); AddSocket(SocketType.Output); }
private void ToolStripMenuItemRenameClick(object sender, EventArgs e) { if (listViewCategories.SelectedItems.Count != 1) { return; } using (var form = new TextPrompt(string.Empty, LanguageSettings.Current.SubStationAlphaStylesCategoriesManager.CategoryName, listViewCategories.SelectedItems[0].Text)) { if (form.ShowDialog() == DialogResult.OK) { var newName = form.InputText; if (string.IsNullOrWhiteSpace(newName)) { return; } newName = FixDuplicateName(newName, _assaCategories); SelectedCategory.Name = newName; listViewCategories.SelectedItems[0].Text = newName; } } }
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { string Property = e.Link.LinkData as string; PropertyInfo info = action.GetType().GetProperty(Property); if (info == null) { MessageBox.Show("Property " + Property + " Does not exist for " + action.GetType().Name); return; } DialogResult result = DialogResult.Cancel; string valueResult = ""; if (info.PropertyType == typeof(NumberValue)) { VariableEditor editor = new VariableEditor(); if (Variables != null) { editor.SetVariable(Variables.Select(x => x.Name)); } else { editor.SetVariable(new string[] { }); } NumberValue val = info.GetMethod.Invoke(action, new object[] { }) as NumberValue; editor.SetDefault(val == null ? "" : val.ToString()); editor.Text = "Variable Editor - " + Property; result = editor.ShowDialog(); if (result == DialogResult.OK) { info.SetMethod.Invoke(action, new object[] { new NumberValue(valueResult) }); } } if (info.PropertyType == typeof(TargetKey)) { TargetKeyEditor editor = new TargetKeyEditor(); editor.SetPresets(ActionContext); editor.VariableList = Variables; TargetKey t = info.GetMethod.Invoke(action, new object[] { }) as TargetKey; if (t == null) { t = new TargetKey(); } editor.Target = t; result = editor.ShowDialog(); if (result == DialogResult.OK) { TargetKey target = editor.Target; info.SetMethod.Invoke(action, new object[] { target }); } } //It's an Enum! if (typeof(Enum).IsAssignableFrom(info.PropertyType)) { Enum enumValue = info.GetMethod.Invoke(action, new object[] { }) as Enum; //Find out if it's a flag and open the flag editor if (info.PropertyType.GetCustomAttribute <FlagsAttribute>() != null) { FlagCheckBoxEditor editor = new FlagCheckBoxEditor(); editor.EnumValue = enumValue; result = editor.ShowDialog(); enumValue = editor.EnumValue; } else { EnumEditor editor = new EnumEditor(); editor.EnumValue = enumValue; result = editor.ShowDialog(); enumValue = editor.EnumValue; } if (result == DialogResult.OK) { info.SetMethod.Invoke(action, new object[] { enumValue }); valueResult = enumValue.ToString(); } } if (typeof(bool) == info.PropertyType) { bool val = (bool)info.GetMethod.Invoke(action, new object[] { }); BoolEditor editor = new BoolEditor(); editor.Value = val; result = editor.ShowDialog(); if (result == DialogResult.OK) { info.SetMethod.Invoke(action, new object[] { editor.Value }); } } if (typeof(string) == info.PropertyType) { string val = (string)info.GetMethod.Invoke(action, new object[] { }); TextPrompt editor = new TextPrompt(); editor.Text = Property; editor.PromptText = val; result = editor.ShowDialog(); if (result == DialogResult.OK) { info.SetMethod.Invoke(action, new object[] { editor.PromptText }); } } if (typeof(ActionCollection) == info.PropertyType) { ActionCollection actions = info.GetMethod.Invoke(action, new object[] { }) as ActionCollection; ActionListEditor editor = new ActionListEditor(); if (actions == null) { actions = new ActionCollection(Property); } editor.ActionContext = ActionContext; editor.Variables = Variables; editor.Actions = actions; result = editor.ShowDialog(); if (result == DialogResult.OK) { info.SetMethod.Invoke(action, new object[] { editor.Actions }); } } if (result == DialogResult.OK) { UpdateLinkTexts(); } if (LinkClicked != null) { LinkClicked.Invoke(this, new LinkClickedEventArgs(e.Link.LinkData as string)); } }