private void btnAnimRename_Click(object sender, EventArgs e) { //Rename anim TextInputForm form = new TextInputForm("New Animation Name:", "Rename Animation"); if (form.ShowDialog() == System.Windows.Forms.DialogResult.OK) { KartAnimationSeries existingAnim = Kart.Kart.KartAnimations.SingleOrDefault(k => k.Name == form.TextOutput); if (existingAnim == SelectedAnimation) { return; } if (existingAnim != null) { MessageBox.Show("Animation with the given name already exists! Please use a unique name!", "Warning"); return; } Kart.RenameAnimation(SelectedAnimation, form.TextOutput); PopulateAnimations(); //PopulateAnimationImages(); //UpdateKartPreviewAnimation(); //UpdateAnimationEnableds(); } }
protected override void Update(double deltaTime) { if (form == null && !Input.Ctrl && !Input.Alt && !Input.Shift && Input.IsKeyPressed(OpenTK.Input.Key.Enter)) { if (form == null) { form = new TextInputForm("Chat", 256, true); form.Show(System.Windows.Forms.NativeWindow.FromHandle(MMW.Window.WindowInfo.Handle)); form.Location = new System.Drawing.Point(form.Location.X, (int)MMW.Height - 200); form.TopLevel = true; form.FormClosed += (se, e) => { form.ImeMode = System.Windows.Forms.ImeMode.Off; SendChat(form.InputText); Thread.Sleep(200); form = null; }; } else { form.TopMost = true; } } }
public HelloFlow(IHelloWorldService service) { _askForName = new TextInputForm("What's your name?", "Hello there"); _getAnswer = new RemoteActionsCallerForm( x => x.Add(() => _askForName.Introduced, //service param service.SayHello, y => _sayHello.Init(y))); //consume service reply _sayHello = new InformationalMessageForm(); }
private void neueNotizToolStripMenuItem_Click(object sender, EventArgs e) { string name = TextInputForm.Prompt("Name der neuen Notiz?", this.FindForm()); if (string.IsNullOrEmpty(name)) { return; } CreateNewItem(false, name); }
public HelloWorldFlow(IHelloWorldService service) { _askForName = new TextInputForm( "What's your name?", "Hello there", TextType.TreatAsText, "", Validator.IsNotEmptyOrWhitespaceOnly); _getAnswer = new RemoteActionsCallerForm( x => x.Add(() => _askForName.Introduced, //service param service.SayHello, y => _sayHello.Init(y))); //consume service reply _sayHello = new InformationalMessageForm("", "Server reply"); }
/// <summary> /// 获取输入文本 /// </summary> /// <param name="text"></param> /// <param name="initEnm"></param> /// <param name="formTitle"></param> /// <returns></returns> public static bool ShowTextInputForm(out string text, string initEnm = null, string formTitle = "请输入") { text = ""; TextInputForm form = new TextInputForm(initEnm); form.Text = formTitle; if (form.ShowDialog() == DialogResult.OK) { text = form.TextValue; return(true); } return(false); }
public string GetName() { TextInputForm input = new TextInputForm(); DialogResult diag = input.ShowDialog(); if (diag == DialogResult.OK) { return(input.outputText); } else { return("Nespecifikované"); } }
private bool ShowTextInput(bool isNew) { TextInputForm textInput = new TextInputForm(); if (!isNew) { textInput.UpdateFromLabel(childLabel); } textInput.InputText.ForeColor = childLabel.ForeColor; if (textInput.ShowDialog(parent) == DialogResult.OK && textInput.InputText.Text.Length > 0) { childLabel.Text = textInput.InputText.Text; childLabel.Font = textInput.InputText.Font; ForeColor = textInput.InputText.ForeColor; parent.Invalidate(); return(true); } return(false); }
public TextBox2(Control parent, string text, Vector2 location, Vector2 size) { Parent = parent; Size = size; LocalLocation = location; Text = text; Clicked += (s, e) => { var form = new TextInputForm("", MaxLength, true); form.InputText = Text; var res = form.ShowDialog(); if (res == System.Windows.Forms.DialogResult.OK) { Text = form.InputText; TextChanged(this, EventArgs.Empty); } }; }
private void newKartToolStripMenuItem_Click(object sender, EventArgs e) { //CheckIfNeedToSave(); //kartName = RequestKartName(); //ChompShopFloor.NewKart(kartName); TextInputForm form = new TextInputForm("Kart Name:", "New Kart Name"); if (form.ShowDialog() == System.Windows.Forms.DialogResult.OK) { //Later on, do better name verifcation if (string.IsNullOrWhiteSpace(form.TextOutput)) { MessageBox.Show("Kart Name is invalid!"); } else { ChompShopFloor.NewKart(form.TextOutput); } } }
private bool ShowTextInput(bool isNew) { TextInputForm textInput = new TextInputForm(); if (!isNew) { textInput.UpdateFromLabel(childLabel); } textInput.InputText.ForeColor = childLabel.ForeColor; textInput.ShowDialog(parent); if (textInput.DialogResult == DialogResult.Cancel) { return(false); } string text = textInput.InputText.Text; childLabel.Text = textInput.InputText.Text; childLabel.Font = textInput.InputText.Font; ForeColor = textInput.InputText.ForeColor; parent.Invalidate(); return(true); }
private void OnReadyIAWApp() { var chooseActivity = new VerticalMenuForm <MenuItems>( "Demo choice", EnumExtensions.GetEnumValues <MenuItems>(), x => x.GetLabel(), lbl => new InputTypeButtonActionView(lbl), isCancellable: false); var inputName = new TextInputForm("Name", "What's your nickname?"); var greetUser = new InformationalMessageForm("", "Greetings!"); var scanResultView = new InformationalMessageFormView(customActionBuilder: x => new AnchorBasedActionView(x)); var scanResult = new InformationalMessageForm(scanResultView, "", "Scan result"); //quick hack for sake of demo var photoTakenResultView = new InformationalMessageFormView(customActionBuilder: x => new AnchorBasedActionView(x)); photoTakenResultView.Message.Widget.RemoveAllChildren(); var photoTakenResult = new InformationalMessageForm(photoTakenResultView, "", "Your photo"); var scanCodeView = new QrScannerFormView(); var performScan = new QrScannerForm <string>( scanCodeView, "Scan QR code", "Any QR is fine", x => Task.FromResult(x)); var takePhotoView = new PhotoTakerFormView(); var takePhoto = new PhotoTakerForm(takePhotoView); chooseActivity.Ended += (x, outcome) => { _renderer.ClearMaster(); switch (outcome) { case CompletedOrCanceled.Completed: switch (x.Chosen) { case MenuItems.DataInput: _renderer.ReplaceMaster(inputName); break; case MenuItems.QrCodeScanner: _renderer.ReplaceMaster(performScan); break; case MenuItems.PhotoTaker: takePhoto.ClearImage(); _renderer.ReplaceMaster(takePhoto); break; default: throw new Exception("unsupported MenuItems"); } break; } }; inputName.Ended += async(x, outcome) => { switch (outcome) { case CompletedOrCanceled.Completed: await greetUser.Init("Hi " + inputName.Introduced + "!"); _renderer.ReplaceMaster(greetUser); break; case CompletedOrCanceled.Canceled: _renderer.ReplaceMaster(chooseActivity); break; } }; greetUser.Ended += (x, _) => _renderer.ReplaceMaster(inputName); performScan.Ended += async(x, outcome) => { switch (outcome) { case CompletedOrCanceled.Completed: await scanResult.Init("QR content: " + performScan.ScannedCode); _renderer.AddPopup(scanResult); break; case CompletedOrCanceled.Canceled: _renderer.ReplaceMaster(chooseActivity); break; } }; scanResult.Ended += (x, _) => { _renderer.Remove(x); _renderer.ReplaceMaster(chooseActivity); }; takePhoto.Ended += (x, outcome) => { switch (outcome) { case CompletedOrCanceled.Completed: var img = new HTMLImageElement(); img.Style.MaxWidth = "50vw"; img.Style.MaxHeight = "50vh"; var fr = new FileReader(); fr.OnLoad += _ => img.Src = (string)fr.Result; fr.ReadAsDataURL(takePhoto.PhotoAsFile); photoTakenResultView.Message.Widget.ReplaceChildren(new[] { img }); _renderer.AddPopup(photoTakenResult); break; case CompletedOrCanceled.Canceled: _renderer.ReplaceMaster(chooseActivity); break; } }; photoTakenResult.Ended += (x, _) => { _renderer.Remove(x); _renderer.ReplaceMaster(chooseActivity); }; _renderer.ReplaceMaster(chooseActivity); }
private bool ShowTextInput(bool isNew) { TextInputForm textInput = new TextInputForm(); if (!isNew) { textInput.UpdateFromLabel(childLabel); } textInput.InputText.ForeColor = childLabel.ForeColor; if (textInput.ShowDialog(parent) == DialogResult.OK && textInput.InputText.Text.Length > 0) { childLabel.Text = textInput.InputText.Text; childLabel.Font = textInput.InputText.Font; ForeColor = textInput.InputText.ForeColor; parent.Invalidate(); return true; } return false; }
public static string TryGetPassword(string url, string username) { if (group != null) { return(InternalGetPassword(url, username)); } if (failed) { return(null); } context = AzusaContext.GetInstance(); DirectoryInfo di = new DirectoryInfo("."); FileInfo dbFileInfo = di.GetFiles("*.kdbx").FirstOrDefault(x => x.Extension.ToLower().Equals(".kdbx")); if (dbFileInfo == null) { dbFileInfo = di.Parent.GetFiles("*.kdbx").FirstOrDefault(x => x.Extension.ToLower().Equals(".kdbx")); } if (dbFileInfo == null) { failed = true; return(null); } string pw = null; context.Splash.Invoke((MethodInvoker) delegate { pw = TextInputForm.PromptPassword(String.Format("Passwort für {0}?", dbFileInfo.Name), context.Splash); }); if (string.IsNullOrEmpty(pw)) { failed = true; return(null); } IOConnectionInfo connectionInfo = IOConnectionInfo.FromPath(dbFileInfo.FullName); KcpPassword kcpPassword = new KcpPassword(pw); CompositeKey compositeKey = new CompositeKey(); compositeKey.AddUserKey(kcpPassword); database = new PwDatabase(); try { database.Open(connectionInfo, compositeKey, null); group = FindPwGroup(database.RootGroup); if (group == null) { failed = true; return(null); } return(InternalGetPassword(url, username)); } catch (InvalidCompositeKeyException) { failed = true; return(null); } }
public void ExecutePostConnectionTask() { if (File.Exists(lastMailTimestampFilename)) { DateTime lastTime = new DateTime(Convert.ToInt64(File.ReadAllText(lastMailTimestampFilename))); TimeSpan sinceLastTime = DateTime.Now - lastTime; if (sinceLastTime.TotalMinutes < 11) { return; } } AzusaContext context = AzusaContext.GetInstance(); if (!context.Ini.ContainsKey(iniCategoryName)) { return; } if (context.Ini[iniCategoryName].ContainsKey("enabled")) { bool isEnabled = Convert.ToInt32(context.Ini[iniCategoryName]["enabled"]) > 0; if (!isEnabled) { return; } } bool allcerts = Convert.ToInt32(context.Ini[iniCategoryName]["acceptAllCerts"]) > 0; string server = context.Ini[iniCategoryName]["server"]; int port = context.Ini[iniCategoryName].ContainsKey(portName) ? Convert.ToUInt16(context.Ini[iniCategoryName][portName]) : 143; bool useSsl = Convert.ToInt32(context.Ini[iniCategoryName]["ssl"]) > 0; string username = context.Ini[iniCategoryName]["username"]; string password = context.Ini[iniCategoryName].ContainsKey(passwordName) ? context.Ini[iniCategoryName][passwordName] : ""; if (string.IsNullOrEmpty(password)) { password = PasswordManagement.Boundary.PasswordManagement.TryGetPassword(server, username); } if (string.IsNullOrEmpty(password)) { context.Splash.Invoke((MethodInvoker) delegate { password = TextInputForm.PromptPassword(String.Format("Passwort für {0} auf {1}?", username, server), context.Splash); }); if (string.IsNullOrEmpty(password)) { return; } } ImapClient client = new ImapClient(new MailProtocolLogger()); if (allcerts) { client.ServerCertificateValidationCallback = (sender, certificate, chain, errors) => true; } client.SslProtocols = System.Security.Authentication.SslProtocols.Tls12; client.Connect(server, port, useSsl); client.AuthenticationMechanisms.Remove("XOAUTH2"); client.Authenticate(username, password); FolderNamespace rootFolderNamespace = client.PersonalNamespaces[0]; IList <IMailFolder> folders = client.GetFolders(rootFolderNamespace); foreach (IMailFolder folder in folders) { Folder child = new Folder(); child.id = MakeId(folder); child.name = folder.Name; child.parentId = MakeId(folder.ParentFolder); bool created = FolderService.CreateIfNotExists(child); CopyFolder(folder, child, !created, password); } client.Disconnect(true); File.WriteAllText(lastMailTimestampFilename, DateTime.Now.Ticks.ToString()); }