public void Info(string title, Icon ic, string info, int[] array = null, float pointsize = -1, Action <Object> acknowledgeaction = null, Object acknowledgedata = null, bool usedialogfont = true) { Icon = ic; var enumlist = new Enum[] { ECIDs.InfoForm_buttonAcknowledge }; BaseUtils.Translator.Instance.TranslateControls(this, enumlist); textBoxInfo.SetTabs(array ?? new int[] { 0, 100, 200, 300, 400, 500, 600, 800, 900, 1000, 1100, 1200 }); textBoxInfo.ReadOnly = true; textBoxInfo.Select(0, 0); ackaction = acknowledgeaction; ackdata = acknowledgedata; Theme theme = Theme.Current; if (theme != null) { bool winborder = usedialogfont ? theme.ApplyDialog(this) : theme.ApplyStd(this); if (winborder) { panelTop.Visible = false; } if (pointsize != -1) { textBoxInfo.Font = usedialogfont ? theme.GetDialogScaledFont(pointsize / 12f) : theme.GetScaledFont(pointsize / 12f); // 12 is standard size.. } } else { panelTop.Visible = false; } buttonAcknowledge.Visible = ackaction != null; textBoxInfo.Text = info; labelCaption.Text = title; Text = title; }
} // Tell dragger no resizing. public void Init(Icon i, bool showprocess, string separ = " ", // and separ between entries string keystring = "", // current key string string process = "", // empty means program default, return empty back int defdelay = 50, // -1 means program default, return -1 back bool allowkeysedit = false, List <string> additionalkeys = null, BaseUtils.EnhancedSendKeysParser.IAdditionalKeyParser parser = null) { var enumlist = new Enum[] { ECIDs.KeyForm, ECIDs.KeyForm_radioButtonUp, ECIDs.KeyForm_radioButtonDown, ECIDs.KeyForm_radioButtonPress, ECIDs.KeyForm_checkBoxShift, ECIDs.KeyForm_checkBoxCtrl, ECIDs.KeyForm_checkBoxAlt, ECIDs.KeyForm_checkBoxKey, ECIDs.KeyForm_labelNextDelay, ECIDs.KeyForm_labelSelKeys, ECIDs.KeyForm_labelDelay, ECIDs.KeyForm_labelSendTo, ECIDs.KeyForm_buttonReset, ECIDs.KeyForm_labelKeys, ECIDs.KeyForm_buttonDelete, ECIDs.KeyForm_buttonNext, ECIDs.KeyForm_buttonTest }; BaseUtils.Translator.Instance.TranslateControls(this, enumlist); if (i != null) { Icon = i; } seperator = separ; textBoxKeys.Text = keystring; curinsertpoint = keystring.Length; textBoxSendTo.Text = process.Alt(DefaultProcessID); textBoxNextDelay.Text = textBoxDelay.Text = defdelay != DefaultDelayID?defdelay.ToStringInvariant() : "Default"; radioButtonPress.Checked = true; if (additionalkeys != null) { comboBoxKeySelector.Items.AddRange(additionalkeys); } comboBoxKeySelector.Items.AddRange(KeyObjectExtensions.KeyListString()); additionalkeyparser = parser; //System.Diagnostics.Debug.WriteLine(String.Join(",",KeyObjectExtensions.VKeyList())); comboBoxKeySelector.Text = ""; comboBoxKeySelector.SelectedIndexChanged += new System.EventHandler(this.comboBoxKeySelector_SelectedIndexChanged); if (!showprocess) { textBoxNextDelay.Visible = panelRadio.Visible = labelNextDelay.Visible = labelDelay.Visible = textBoxDelay.Visible = labelSendTo.Visible = textBoxSendTo.Visible = buttonTest.Visible = false; int d = textBoxKeys.Top - textBoxDelay.Top; foreach (Control c in new Control[] { buttonReset, buttonDelete, buttonNext, textBoxKeys, labelKeys }) { c.Top -= d; // shift down } d += 40; // cause of the Send foreach (Control c in new Control[] { buttonOK, buttonCancel }) { c.Top -= d; } panelOuter.Height -= d; this.Height -= d; } //System.Diagnostics.Debug.WriteLine("T" + textBoxKeys.Text + " at " + curinsertpoint + " >" + textBoxSendTo.Text); bool border = true; Theme theme = Theme.Current; if (theme != null) // paranoid { border = theme.ApplyDialog(this); } labelCaption.Visible = !border; AddMF(); AddMF(); if (allowkeysedit) { textBoxKeys.ReadOnly = false; } DisplayKeyString(); labelCaption.Text = this.Text; }
// lab sets the items, def can be less or null public static List <string> ShowDialog(Form p, string caption, Icon ic, string[] lab, string[] def, bool multiline = false, string[] tooltips = null, bool cursoratend = false, int widthboxes = 200, // sizes based on standard dialog size of 12, scaled up int heightboxes = -1) { DraggableForm prompt = new DraggableForm() { FormBorderStyle = FormBorderStyle.FixedDialog, Text = caption, StartPosition = FormStartPosition.CenterScreen, Icon = ic }; int lx = 10; Panel outer = new Panel() { Dock = DockStyle.Fill, BorderStyle = BorderStyle.FixedSingle }; prompt.Controls.Add(outer); outer.MouseDown += (s, e) => { prompt.OnCaptionMouseDown(s as Control, e); }; outer.MouseUp += (s, e) => { prompt.OnCaptionMouseUp(s as Control, e); }; Label textLabel = new Label() { Left = lx, Top = 8, AutoSize = true, Text = caption }; textLabel.MouseDown += (s, e) => { prompt.OnCaptionMouseDown(s as Control, e); }; textLabel.MouseUp += (s, e) => { prompt.OnCaptionMouseUp(s as Control, e); }; Theme theme = Theme.Current; System.Diagnostics.Debug.Assert(theme != null); if (!theme.WindowsFrame) { outer.Controls.Add(textLabel); } Label[] lbs = new Label[lab.Length]; ExtendedControls.ExtRichTextBox[] tbs = new ExtendedControls.ExtRichTextBox[lab.Length]; ToolTip tt = new ToolTip(); tt.ShowAlways = true; int y = theme.WindowsFrame ? 20 : 40; if (heightboxes == -1) { heightboxes = multiline ? 80 : 24; } for (int i = 0; i < lab.Length; i++) { lbs[i] = new Label() { Left = lx, Top = y, AutoSize = true, Text = lab[i] }; outer.Controls.Add(lbs[i]); tbs[i] = new ExtendedControls.ExtRichTextBox() { Left = 0, // will be set once we know the paras of all lines Top = y, Width = widthboxes, Text = (def != null && i < def.Length) ? def[i] : "", Height = heightboxes, }; if (cursoratend) { tbs[i].Select(tbs[i].Text.Length, tbs[i].Text.Length); } outer.Controls.Add(tbs[i]); if (tooltips != null && i < tooltips.Length) { tt.SetToolTip(lbs[i], tooltips[i]); tbs[i].SetTipDynamically(tt, tooltips[i]); // no container here, set tool tip on text boxes using this } y += heightboxes + 20; } ExtendedControls.ExtButton confirmation = new ExtendedControls.ExtButton() { Text = "OK".TxID(ECIDs.MessageBoxTheme_OK), Left = 0, Width = 100, Top = y, DialogResult = DialogResult.OK }; outer.Controls.Add(confirmation); confirmation.Click += (sender, e) => { prompt.Close(); }; ExtendedControls.ExtButton cancel = new ExtendedControls.ExtButton() { Text = "Cancel".TxID(ECIDs.MessageBoxTheme_Cancel), Left = 0, Width = 100, Top = confirmation.Top, DialogResult = DialogResult.Cancel }; outer.Controls.Add(cancel); cancel.Click += (sender, e) => { prompt.Close(); }; if (!multiline) { prompt.AcceptButton = confirmation; } prompt.CancelButton = cancel; prompt.ShowInTaskbar = false; prompt.AutoScaleMode = AutoScaleMode.Font; theme.ApplyDialog(prompt); int controlleft = 0; for (int i = 0; i < lab.Length; i++) { controlleft = Math.Max(controlleft, lbs[i].Right + 16); // seems have to do this after sizing, confusingly } for (int i = 0; i < lab.Length; i++) // all go here { tbs[i].Left = controlleft; } confirmation.Left = tbs[0].Right - confirmation.Width; // cancel/confirm based on this cancel.Left = confirmation.Left - cancel.Width - 16; Size controlsize = outer.FindMaxSubControlArea(0, 0); prompt.Size = new Size(controlsize.Width + 40, controlsize.Height + (theme.WindowsFrame ? 50 : 8)); if (prompt.ShowDialog(p) == DialogResult.OK) { var r = (from t in tbs select t.Text).ToList(); return(r); } else { return(null); } }