void CreateCondition( Group g , string initialfname = null , string initialcond = null, string initialvalue = null ) { ExtendedControls.ComboBoxCustom fname = new ExtendedControls.ComboBoxCustom(); fname.Size = new Size(140, 24); fname.DropDownHeight = 400; fname.Name = "Field"; if (g.fieldnames != null) fname.Items.AddRange(g.fieldnames); fname.Items.Add("User Defined"); if (initialfname != null) { if (fname.Items.IndexOf(initialfname) < 0) fname.Items.Add(initialfname); fname.SelectedItem = initialfname; } fname.SelectedIndexChanged += Fname_SelectedIndexChanged; g.panel.Controls.Add(fname); // 1st control ExtendedControls.ComboBoxCustom cond = new ExtendedControls.ComboBoxCustom(); cond.Items.AddRange(JSONFilter.MatchNames); cond.SelectedIndex = 0; cond.Size = new Size(130, 24); cond.DropDownHeight = 400; if (initialcond != null) cond.Text = Tools.SplitCapsWord(initialcond); g.panel.Controls.Add(cond); // must be next ExtendedControls.TextBoxBorder value = new ExtendedControls.TextBoxBorder(); value.Size = new Size(190, 24); if (initialvalue != null) value.Text = initialvalue; g.panel.Controls.Add(value); // must be next ExtendedControls.ButtonExt del = new ExtendedControls.ButtonExt(); del.Size = new Size(24, 24); del.Text = "X"; del.Click += ConditionDelClick; del.Tag = g; g.panel.Controls.Add(del); ExtendedControls.ButtonExt more = new ExtendedControls.ButtonExt(); more.Size = new Size(24, 24); more.Text = "+"; more.Click += ConditionClick; more.Tag = g; g.panel.Controls.Add(more); theme.ApplyToControls(g.panel); RepositionGroup(g); PositionPanels(); }
Group CreateGroup(string initialev = null, string initialaction = null, string initialcondinner = null , string initialcondouter = null) { Panel p = new Panel(); p.BorderStyle = BorderStyle.FixedSingle; ExtendedControls.ComboBoxCustom evliste = new ExtendedControls.ComboBoxCustom(); evliste.Items.AddRange(EDDiscovery.EliteDangerous.JournalEntry.GetListOfEventsWithOptMethod(false).ToArray()); evliste.Items.Add("All"); evliste.Location = new Point(panelmargin, panelmargin); evliste.Size = new Size(140, 24); evliste.DropDownHeight = 400; evliste.Name = "EVList"; if (initialev != null) evliste.Text = initialev; evliste.SelectedIndexChanged += Evlist_SelectedIndexChanged; p.Controls.Add(evliste); ExtendedControls.ComboBoxCustom aclist = new ExtendedControls.ComboBoxCustom(); string[] actions = actionlist.Split(';'); aclist.Items.AddRange(actions); aclist.Location = new Point(evliste.Location.X+evliste.Width+8, panelmargin); aclist.DropDownHeight = 400; aclist.Size = new Size(120, 24); aclist.Name = "ActionList"; aclist.Enabled = actions.Count() > 1; // 1 item, indicate disabled.. won't be displayed if (initialaction != null) aclist.Text = initialaction; else aclist.SelectedIndex = 0; aclist.Visible = false; p.Controls.Add(aclist); ExtendedControls.ComboBoxCustom cond = new ExtendedControls.ComboBoxCustom(); cond.Items.AddRange(Enum.GetNames(typeof(JSONFilter.FilterType))); cond.SelectedIndex = 0; cond.Size = new Size(60, 24); cond.Visible = false; cond.Name = "InnerCond"; if ( initialcondinner != null) cond.Text = initialcondinner; p.Controls.Add(cond); ExtendedControls.ComboBoxCustom condouter = new ExtendedControls.ComboBoxCustom(); condouter.Items.AddRange(Enum.GetNames(typeof(JSONFilter.FilterType))); condouter.SelectedIndex = 0; condouter.Location = new Point(evliste.Location.X , panelmargin + conditionhoff); condouter.Size = new Size(60, 24); condouter.Enabled = condouter.Visible = false; if (initialcondouter != null) condouter.Text = initialcondouter; cond.Name = "OuterCond"; p.Controls.Add(condouter); Label lab = new Label(); lab.Text = " with group(s) above"; lab.Location = new Point(condouter.Location.X + condouter.Width + 4, condouter.Location.Y + 3); lab.AutoSize = true; lab.Visible = false; p.Controls.Add(lab); ExtendedControls.ButtonExt up = new ExtendedControls.ButtonExt(); up.Size = new Size(24, 24); up.Text = "^"; up.Click += Up_Click; p.Controls.Add(up); int hoff = (aclist.Enabled) ? (aclist.Location.X + aclist.Width + 50) : (evliste.Location.X + evliste.Width + 50); Group g = new Group() { panel = p, evlist = evliste, upbutton = up, actionlist = aclist, outercond = condouter, innercond = cond, outerlabel = lab }; p.Size = new Size(panelwidth, panelmargin + conditionhoff); up.Location = new Point(panelwidth - 20 - panelmargin - 4, panelmargin); groups.Add(g); if (initialev != null) { ChangeEventTypes(g); } up.Tag = g; evliste.Tag = g; panelVScroll.Controls.Add(p); theme.ApplyToControls(g.panel); RepositionGroup(g); PositionPanels(); return g; }
// 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) { ITheme theme = ThemeableFormsInstance.Instance; int vstart = theme.WindowsFrame ? 20 : 40; int vspacing = multiline ? 80 : 40; int lw = 100; int lx = 10; int tx = 10 + lw + 8; Form prompt = new Form() { Width = 600, Height = 90 + vspacing * lab.Length + (theme.WindowsFrame ? 20 : 0), FormBorderStyle = FormBorderStyle.FixedDialog, Text = caption, StartPosition = FormStartPosition.CenterScreen, Icon = ic }; Panel outer = new Panel() { Dock = DockStyle.Fill, BorderStyle = BorderStyle.FixedSingle }; prompt.Controls.Add(outer); Label textLabel = new Label() { Left = lx, Top = 8, Width = prompt.Width - 50, Text = caption }; if (!theme.WindowsFrame) { outer.Controls.Add(textLabel); } Label[] lbs = new Label[lab.Length]; ExtendedControls.TextBoxBorder[] tbs = new ExtendedControls.TextBoxBorder[lab.Length]; ToolTip tt = new ToolTip(); tt.ShowAlways = true; int y = vstart; for (int i = 0; i < lab.Length; i++) { lbs[i] = new Label() { Left = lx, Top = y, Width = lw, Text = lab[i] }; tbs[i] = new ExtendedControls.TextBoxBorder() { Left = tx, Top = y, Width = prompt.Width - 50 - tx, Text = (def != null && i < def.Length) ? def[i] : "", Multiline = multiline, // set before height! Height = vspacing - 20, ScrollBars = (multiline) ? ScrollBars.Vertical : ScrollBars.None, WordWrap = multiline }; outer.Controls.Add(lbs[i]); 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 += vspacing; } ExtendedControls.ButtonExt confirmation = new ExtendedControls.ButtonExt() { Text = "Ok".Tx(), Left = tbs[0].Right - 80, Width = 80, Top = y, DialogResult = DialogResult.OK }; outer.Controls.Add(confirmation); confirmation.Click += (sender, e) => { prompt.Close(); }; ExtendedControls.ButtonExt cancel = new ExtendedControls.ButtonExt() { Text = "Cancel".Tx(), Left = confirmation.Location.X - 90, Width = 80, 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; theme.ApplyToFormStandardFontSize(prompt); if (prompt.ShowDialog(p) == DialogResult.OK) { var r = (from ExtendedControls.TextBoxBorder t in tbs select t.Text).ToList(); return(r); } else { return(null); } }
public void Init(ActionFile af, Condition c, ActionCoreController ac, string apf, Icon i, ToolTip toolTip, ActionProgram.ProgramConditionClass cls) { cd = c; // point at common condition, we never new it, just update action data/action actionfile = af; actioncorecontroller = ac; applicationfolder = apf; Icon = i; classifier = cls; progmajortype = new ExtendedControls.PanelSelectionList(); progmajortype.Items.AddRange(new string[] { "Key", "Say", "Key+Say", "Full Program" }); indextoclassifier = new ActionProgram.ProgramConditionClass[] { ActionProgram.ProgramConditionClass.Key, ActionProgram.ProgramConditionClass.Say, ActionProgram.ProgramConditionClass.KeySay, ActionProgram.ProgramConditionClass.Full }; progmajortype.Location = new Point(0, 0); progmajortype.Size = new Size(this.Width, this.Height); // outer panel aligns with this UC progmajortype.SelectedIndexChanged += PanelType_SelectedIndexChanged; toolTip.SetToolTip(progmajortype, "Use the selector (click on bottom right arrow) to select program class type"); proglist = new ExtendedControls.ComboBoxCustom(); proglist.Items.Add("New"); proglist.Items.AddRange(actionfile.actionprogramlist.GetActionProgramList()); proglist.Location = new Point(panelxmargin, panelymargin); proglist.Size = new Size((this.Width - 24 - 8 - 8 - 8 - panelxmargin * 2) / 2, 24); // 24 button, 8+8 gaps, 8 for selector proglist.DropDownHeight = 400; proglist.DropDownWidth = proglist.Width * 3 / 2; proglist.SelectedIndexChanged += Proglist_SelectedIndexChanged; proglist.SetTipDynamically(toolTip, "Select program to associate with this event"); progedit = new ExtendedControls.ButtonExt(); progedit.Text = "P"; progedit.Location = new Point(proglist.Right + 8, panelymargin); progedit.Size = new Size(24, 24); progedit.Click += Progedit_Click; toolTip.SetToolTip(progedit, "Edit associated program"); paras = new ExtendedControls.TextBoxBorder(); paras.Text = (cd.actiondata != null) ? cd.actiondata : ""; paras.Location = new Point(progedit.Right + 8, panelymargin + 2); paras.Size = proglist.Size; paras.ReadOnly = true; paras.Click += Paras_Click; paras.SetTipDynamically(toolTip, "Click to enter parameters to pass to program"); buttonKeys = new ExtendedControls.ButtonExt(); buttonKeys.Location = proglist.Location; buttonKeys.Size = new Size((this.Width - 8 - 8 - panelxmargin * 2) / 2, 24); buttonKeys.Click += Keypress_Click; toolTip.SetToolTip(buttonKeys, "Click to define keystrokes to send"); buttonSay = new ExtendedControls.ButtonExt(); buttonSay.Location = new Point(buttonKeys.Right + 8, buttonKeys.Top); buttonSay.Size = buttonKeys.Size; buttonSay.Click += Saypress_Click; toolTip.SetToolTip(buttonSay, "Click to set speech to say"); SuspendLayout(); progmajortype.Controls.Add(proglist); progmajortype.Controls.Add(progedit); progmajortype.Controls.Add(paras); progmajortype.Controls.Add(buttonKeys); progmajortype.Controls.Add(buttonSay); Controls.Add(progmajortype); UpdateControls(); ResumeLayout(); }
private void Show(Icon icon, System.Drawing.Size size, System.Drawing.Point pos, string caption, string lname, Object callertag) { this.logicalname = lname; // passed back to caller via trigger this.callertag = callertag; // passed back to caller via trigger ITheme theme = ThemeableFormsInstance.Instance; FormBorderStyle = FormBorderStyle.FixedDialog; if (theme.WindowsFrame) { size.Height += 50; } Size = size; if (pos.X == -999) { StartPosition = FormStartPosition.CenterScreen; } else { Location = pos; StartPosition = FormStartPosition.Manual; } Panel outer = new Panel() { Dock = DockStyle.Fill, BorderStyle = BorderStyle.FixedSingle }; outer.MouseDown += FormMouseDown; outer.MouseUp += FormMouseUp; Controls.Add(outer); this.Text = caption; Label textLabel = new Label() { Left = 4, Top = 8, Width = Width - 50, Text = caption }; textLabel.MouseDown += FormMouseDown; textLabel.MouseUp += FormMouseUp; if (!theme.WindowsFrame) { outer.Controls.Add(textLabel); } ToolTip tt = new ToolTip(components); tt.ShowAlways = true; for (int i = 0; i < entries.Count; i++) { Entry ent = entries[i]; Control c = ent.controltype != null ? (Control)Activator.CreateInstance(ent.controltype) : ent.control; ent.control = c; c.Size = ent.size; c.Location = ent.pos; //System.Diagnostics.Debug.WriteLine("Control " + c.GetType().ToString() + " at " + c.Location + " " + c.Size); if (!(ent.controltype == null || c is ExtendedControls.ComboBoxCustom || c is ExtendedControls.CustomDateTimePicker || c is ExtendedControls.NumberBoxDouble || c is ExtendedControls.NumberBoxLong)) // everything but get text { c.Text = ent.text; } c.Tag = ent; // point control tag at ent structure outer.Controls.Add(c); if (ent.tooltip != null) { tt.SetToolTip(c, ent.tooltip); } if (c is ExtendedControls.ButtonExt) { ExtendedControls.ButtonExt b = c as ExtendedControls.ButtonExt; b.Click += (sender, ev) => { Entry en = (Entry)(((Control)sender).Tag); Trigger?.Invoke(logicalname, en.controlname, this.callertag); // pass back the logical name of dialog, the name of the control, the caller tag }; } else if (c is ExtendedControls.NumberBoxDouble) { ExtendedControls.NumberBoxDouble cb = c as ExtendedControls.NumberBoxDouble; cb.Minimum = ent.numberboxdoubleminimum; cb.Maximum = ent.numberboxdoublemaximum; double?v = ent.text.InvariantParseDoubleNull(); cb.Value = v.HasValue ? v.Value : cb.Minimum; if (ent.numberboxformat != null) { cb.Format = ent.numberboxformat; } cb.ReturnPressed += (box) => { Entry en = (Entry)(box.Tag); Trigger?.Invoke(logicalname, en.controlname + ":Return", this.callertag); // pass back the logical name of dialog, the name of the control, the caller tag }; } else if (c is ExtendedControls.NumberBoxLong) { ExtendedControls.NumberBoxLong cb = c as ExtendedControls.NumberBoxLong; cb.Minimum = ent.numberboxlongminimum; cb.Maximum = ent.numberboxlongmaximum; long?v = ent.text.InvariantParseLongNull(); cb.Value = v.HasValue ? v.Value : cb.Minimum; if (ent.numberboxformat != null) { cb.Format = ent.numberboxformat; } cb.ReturnPressed += (box) => { Entry en = (Entry)(box.Tag); Trigger?.Invoke(logicalname, en.controlname + ":Return", this.callertag); // pass back the logical name of dialog, the name of the control, the caller tag }; } else if (c is ExtendedControls.TextBoxBorder) { ExtendedControls.TextBoxBorder tb = c as ExtendedControls.TextBoxBorder; tb.Multiline = tb.WordWrap = ent.textboxmultiline; tb.ClearOnFirstChar = ent.clearonfirstchar; tb.ReturnPressed += (box) => { Entry en = (Entry)(box.Tag); Trigger?.Invoke(logicalname, en.controlname + ":Return", this.callertag); // pass back the logical name of dialog, the name of the control, the caller tag }; } else if (c is ExtendedControls.CheckBoxCustom) { ExtendedControls.CheckBoxCustom cb = c as ExtendedControls.CheckBoxCustom; cb.Checked = ent.checkboxchecked; cb.Click += (sender, ev) => { Entry en = (Entry)(((Control)sender).Tag); Trigger?.Invoke(logicalname, en.controlname, this.callertag); // pass back the logical name of dialog, the name of the control, the caller tag }; } if (c is ExtendedControls.CustomDateTimePicker) { ExtendedControls.CustomDateTimePicker dt = c as ExtendedControls.CustomDateTimePicker; DateTime t; if (DateTime.TryParse(ent.text, System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.AssumeLocal, out t)) // assume local, so no conversion { dt.Value = t; } switch (ent.customdateformat.ToLowerInvariant()) { case "short": dt.Format = DateTimePickerFormat.Short; break; case "long": dt.Format = DateTimePickerFormat.Long; break; case "time": dt.Format = DateTimePickerFormat.Time; break; default: dt.CustomFormat = ent.customdateformat; break; } } if (c is ExtendedControls.ComboBoxCustom) { ExtendedControls.ComboBoxCustom cb = c as ExtendedControls.ComboBoxCustom; if (ent.comboboxdropdownsize != null) { cb.DropDownHeight = ent.comboboxdropdownsize.Value.Height; cb.DropDownWidth = ent.comboboxdropdownsize.Value.Width; } cb.Items.AddRange(ent.comboboxitems.Split(',')); if (cb.Items.Contains(ent.text)) { cb.SelectedItem = ent.text; } cb.SelectedIndexChanged += (sender, ev) => { Control ctr = (Control)sender; if (ctr.Enabled) { Entry en = (Entry)(ctr.Tag); Trigger?.Invoke(logicalname, en.controlname, this.callertag); // pass back the logical name of dialog, the name of the control, the caller tag } }; } } ShowInTaskbar = false; this.Icon = icon; theme.ApplyToFormStandardFontSize(this); //foreach( Control c in Controls[0].Controls ) System.Diagnostics.Debug.WriteLine("Control " + c.GetType().ToString() + " at " + c.Location + " " + c.Size); }
private void Show(Icon icon, System.Drawing.Size size, System.Drawing.Point pos, string caption, string lname, Object callertag) { this.logicalname = lname; // passed back to caller via trigger this.callertag = callertag; // passed back to caller via trigger ITheme theme = ThemeableFormsInstance.Instance; FormBorderStyle = FormBorderStyle.FixedDialog; if (theme.WindowsFrame) { size.Height += 50; } Size = size; if (pos.X == -999) { StartPosition = FormStartPosition.CenterScreen; } else { Location = pos; StartPosition = FormStartPosition.Manual; } Panel outer = new Panel() { Dock = DockStyle.Fill, BorderStyle = BorderStyle.FixedSingle }; outer.MouseDown += FormMouseDown; outer.MouseUp += FormMouseUp; Controls.Add(outer); this.Text = caption; Label textLabel = new Label() { Left = 4, Top = 8, Width = Width - 50, Text = caption }; textLabel.MouseDown += FormMouseDown; textLabel.MouseUp += FormMouseUp; if (!theme.WindowsFrame) { outer.Controls.Add(textLabel); } ToolTip tt = new ToolTip(components); tt.ShowAlways = true; for (int i = 0; i < entries.Count; i++) { Entry ent = entries[i]; Control c = (Control)Activator.CreateInstance(ent.controltype); ent.control = c; c.Size = ent.size; c.Location = ent.pos; if (!(c is ExtendedControls.ComboBoxCustom)) // everything but get text { c.Text = ent.text; } c.Tag = ent; // point control tag at ent structure outer.Controls.Add(c); if (ent.tooltip != null) { tt.SetToolTip(c, ent.tooltip); } if (c is ExtendedControls.ButtonExt) { ExtendedControls.ButtonExt b = c as ExtendedControls.ButtonExt; b.Click += (sender, ev) => { Entry en = (Entry)(((Control)sender).Tag); Trigger?.Invoke(logicalname, en.controlname, this.callertag); // pass back the logical name of dialog, the name of the control, the caller tag }; } if (c is ExtendedControls.TextBoxBorder) { ExtendedControls.TextBoxBorder tb = c as ExtendedControls.TextBoxBorder; tb.Multiline = tb.WordWrap = ent.textboxmultiline; } if (c is ExtendedControls.CheckBoxCustom) { ExtendedControls.CheckBoxCustom cb = c as ExtendedControls.CheckBoxCustom; cb.Checked = ent.checkboxchecked; cb.Click += (sender, ev) => { Entry en = (Entry)(((Control)sender).Tag); Trigger?.Invoke(logicalname, en.controlname, this.callertag); // pass back the logical name of dialog, the name of the control, the caller tag }; } if (c is ExtendedControls.ComboBoxCustom) { ExtendedControls.ComboBoxCustom cb = c as ExtendedControls.ComboBoxCustom; if (ent.comboboxdropdownsize != null) { cb.DropDownHeight = ent.comboboxdropdownsize.Value.Height; cb.DropDownWidth = ent.comboboxdropdownsize.Value.Width; } cb.Items.AddRange(ent.comboboxitems.Split(',')); if (cb.Items.Contains(ent.text)) { cb.SelectedItem = ent.text; } cb.SelectedIndexChanged += (sender, ev) => { Control ctr = (Control)sender; if (ctr.Enabled) { Entry en = (Entry)(ctr.Tag); Trigger?.Invoke(logicalname, en.controlname, this.callertag); // pass back the logical name of dialog, the name of the control, the caller tag } }; } } ShowInTaskbar = false; this.Icon = icon; theme.ApplyToForm(this, System.Drawing.SystemFonts.DefaultFont); }
public void Show(Form p, string lname, System.Drawing.Size size, string caption, Entry[] e, Object t) { logicalname = lname; entries = e; tag = t; EDDiscovery.EDDTheme theme = EDDiscovery.EDDTheme.Instance; Size = size; FormBorderStyle = FormBorderStyle.FixedDialog; Text = caption; StartPosition = FormStartPosition.CenterScreen; Panel outer = new Panel() { Dock = DockStyle.Fill, BorderStyle = BorderStyle.FixedSingle }; Controls.Add(outer); Label textLabel = new Label() { Left = 4, Top = 8, Width = Width - 50, Text = caption }; if (!theme.WindowsFrame) { outer.Controls.Add(textLabel); } ToolTip tt = new ToolTip(); tt.ShowAlways = true; for (int i = 0; i < entries.Length; i++) { Control c = (Control)Activator.CreateInstance(entries[i].controltype); entries[i].control = c; c.Size = entries[i].size; c.Location = entries[i].pos; c.Text = entries[i].text; c.Tag = entries[i]; outer.Controls.Add(c); if (entries[i].tooltip != null) { tt.SetToolTip(c, entries[i].tooltip); } if (c is ExtendedControls.ButtonExt) { ExtendedControls.ButtonExt b = c as ExtendedControls.ButtonExt; b.Click += (sender, ev) => { Entry en = (Entry)(((Control)sender).Tag); if (Trigger != null) { Trigger(logicalname, en.name, tag); } }; } if (c is ExtendedControls.TextBoxBorder) { ExtendedControls.TextBoxBorder tb = c as ExtendedControls.TextBoxBorder; tb.Multiline = tb.WordWrap = entries[i].textboxmultiline; } if (c is ExtendedControls.CheckBoxCustom) { ExtendedControls.CheckBoxCustom cb = c as ExtendedControls.CheckBoxCustom; cb.Checked = entries[i].checkboxchecked; cb.Click += (sender, ev) => { Entry en = (Entry)(((Control)sender).Tag); if (Trigger != null) { Trigger(logicalname, en.name, tag); } }; } } ShowInTaskbar = false; theme.ApplyToForm(this, System.Drawing.SystemFonts.DefaultFont); Show(p); }