private void Icon_Click(object sender, EventArgs e) { ExtendedControls.ExtButton but = sender as ExtendedControls.ExtButton; dropdown = new ExtendedControls.ExtListBoxForm("", true); List <string> Dickeys = new List <string>(EDDiscovery.Icons.IconSet.Icons.Keys); Dickeys.Sort(); List <Image> images = (from x in Dickeys select EDDiscovery.Icons.IconSet.Icons[x]).ToList(); dropdown.ItemHeight = 26; dropdown.FitImagesToItemHeight = true; dropdown.Items = Dickeys; dropdown.ImageItems = images; dropdown.FlatStyle = FlatStyle.Popup; dropdown.Activated += (s, ea) => { Point location = (sender as Control).PointToScreen(new Point(0, 0)); dropdown.Location = dropdown.PositionWithinScreen(location.X, location.Y); this.Invalidate(true); }; dropdown.SelectedIndexChanged += (s, ea) => { Image img = images[dropdown.SelectedIndex]; but.Image = img; }; dropdown.Size = new Size(400, 800); EDDTheme.Instance.ApplyToControls(dropdown); dropdown.Show(this.FindForm()); }
public override void LoadLayout() { DateTime firstofmonth = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1); curmonth = SQLiteConnectionUser.GetSettingDate(DbDateSave, firstofmonth); string daynames = "Sun;Mon;Tue;Wed;Thu;Fri;Sat".T(EDTx.CaptainsLogDiary_Daysofweek); string[] daynamesplit = daynames.Split(';'); for (int i = 0; i < 7; i++) { Label lb = new Label(); lb.Text = daynamesplit[i]; lb.TextAlign = ContentAlignment.MiddleCenter; daynameslabels[i] = lb; Controls.Add(lb); } for (int i = 1; i <= 31; i++) { ExtendedControls.ExtButton b = new ExtendedControls.ExtButton(); b.Click += DayClick; Controls.Add(b); daybuttons[i - 1] = b; } layoutdone = true; }
private void Icon_Click(object sender, EventArgs e) { ExtendedControls.ExtButton but = sender as ExtendedControls.ExtButton; dropdown = new ExtendedControls.ExtListBoxForm("", true); List <string> Dickeys = new List <string>(BaseUtils.Icons.IconSet.Instance.Names()); Dickeys.Sort(); List <Image> images = new List <Image>(); foreach (var x in Dickeys) { Image i = BaseUtils.Icons.IconSet.Instance.Get(x); i.Tag = x; images.Add(i); } dropdown.FitImagesToItemHeight = true; dropdown.Items = Dickeys; dropdown.ImageItems = images; dropdown.FlatStyle = FlatStyle.Popup; dropdown.PositionBelow(sender as Control); dropdown.SelectedIndexChanged += (s, ea) => { Image img = images[dropdown.SelectedIndex]; but.Image = img; }; EDDTheme.Instance.ApplyDialog(dropdown, true); dropdown.Show(this.FindForm()); }
private void NewConditionClick(object sender, EventArgs e) { ExtendedControls.ExtButton b = sender as ExtendedControls.ExtButton; Group g = (Group)b.Tag; CreateCondition(g); }
private void DayClick(object sender, EventArgs e) // send a button click up { ExtendedControls.ExtButton b = sender as ExtendedControls.ExtButton; int dayno = b.Text.Replace("*", "").InvariantParseInt(-1); ClickedonDate?.Invoke(new DateTime(curmonth.Year, curmonth.Month, dayno), (int)b.Tag == 0); }
private List <ExtendedControls.ExtGroupBox> AdditionalCmdrControls() { var gb = new List <ExtendedControls.ExtGroupBox>(); ExtendedControls.ExtGroupBox g1 = new ExtendedControls.ExtGroupBox() { Name = "CAPIGB", Height = 60, Text = "Frontier CAPI" }; capiButton = new ExtendedControls.ExtButton() { Location = new System.Drawing.Point(240, 23), ClientSize = new System.Drawing.Size(80, 20), Name = "CAPIButton" }; capiButton.Click += CapiButton_Click; capiclearloginButton = new ExtendedControls.ExtButton() { Location = new System.Drawing.Point(340, 23), ClientSize = new System.Drawing.Size(80, 20), Name = "ClearCAPIButton", Text = "Clear" }; capiclearloginButton.Click += clearLoginButton_Click; capiStateLabel = new Label() { Location = new System.Drawing.Point(4, 23), Name = "CAPIStatus" }; g1.Controls.Add(capiButton); g1.Controls.Add(capiclearloginButton); g1.Controls.Add(capiStateLabel); gb.Add(g1); return(gb); }
private void Icon_Click(object sender, EventArgs e) { ExtendedControls.ExtButton but = sender as ExtendedControls.ExtButton; dropdown = new ExtendedControls.ExtListBoxForm("", true); List <string> Dickeys = new List <string>(EDDiscovery.Icons.IconSet.Icons.Keys); Dickeys.Sort(); List <Image> images = (from x in Dickeys select EDDiscovery.Icons.IconSet.Icons[x]).ToList(); dropdown.FitImagesToItemHeight = true; dropdown.Items = Dickeys; dropdown.ImageItems = images; dropdown.FlatStyle = FlatStyle.Popup; dropdown.PositionBelow(sender as Control); dropdown.SelectedIndexChanged += (s, ea) => { Image img = images[dropdown.SelectedIndex]; but.Image = img; }; EDDTheme.Instance.ApplyDialog(dropdown); dropdown.Show(this.FindForm()); }
private void ActionbuttonEdit_Click(object sender, EventArgs e) { ExtendedControls.ExtButton cb = sender as ExtendedControls.ExtButton; Group g = cb.Tag as Group; EditActionFile?.Invoke(g.name.Text); ReadyToDisplay(); }
private void Up_Click(object sender, EventArgs e) { ExtendedControls.ExtButton b = sender as ExtendedControls.ExtButton; Group g = (Group)b.Tag; int indexof = groups.IndexOf(g); groups.Remove(g); groups.Insert(indexof - 1, g); FixUpGroups(); }
private void Del_Clicked(object sender, EventArgs e) { ExtendedControls.ExtButton b = sender as ExtendedControls.ExtButton; Group g = (Group)b.Tag; g.panel.Controls.Clear(); panelVScroll1.Controls.Remove(g.panel); groups.Remove(g); Invalidate(true); FixUpGroups(); }
private void Up_Clicked(object sender, EventArgs e) { ExtendedControls.ExtButton b = sender as ExtendedControls.ExtButton; Group g = (Group)b.Tag; int gstep = groups.IndexOf(g); groups.RemoveAt(gstep); groups.Insert(gstep - 1, g); curprog.MoveUp(gstep); RepositionGroups(); }
private void Deletebutton_Click(object sender, EventArgs e) { ExtendedControls.ExtButton cb = sender as ExtendedControls.ExtButton; Group g = cb.Tag as Group; if (ExtendedControls.MessageBoxTheme.Show(this, string.Format("Do you really want to delete {0}".T(EDTx.AddOnManagerForm_DeleteWarn), g.di.itemname), "Warning".T(EDTx.Warning), MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK) { VersioningManager.DeleteInstall(g.di, EDDOptions.Instance.AppDataDirectory, EDDOptions.Instance.TempMoveDirectory()); changelist[g.di.itemname] = "-"; ReadyToDisplay(); } }
private void ActionConfig_Clicked(object sender, EventArgs e) { ExtendedControls.ExtButton b = sender as ExtendedControls.ExtButton; Group g = (Group)b.Tag; ActionBase curact = curprog.GetStep(groups.IndexOf(g)); if (curact != null) { if (curact.ConfigurationMenu(this, actioncorecontroller, currentvarlist)) { SetValue(g.value, curact); } } }
public void Init(Condition c, Icon ic, ToolTip toolTip) { cd = c; // point to common condition. We only change the fields, not the cd.action/actiondata, and we don't replace it. Icon = ic; // layed out for 12 point. Requires a 28 pixel area to sit in panelConditionType = new ExtendedControls.ExtPanelDropDown(); panelConditionType.Location = new Point(0, 0); panelConditionType.Size = new Size(this.Width, 28); // outer panel aligns with this UC panelConditionType.SelectedIndexChanged += PanelConditionType_SelectedIndexChanged; toolTip.SetToolTip(panelConditionType, "Use the selector (click on bottom right arrow) to select condition class type"); textBoxCondition = new ExtendedControls.ExtTextBox(); textBoxCondition.Location = new Point(panelxmargin, panelymargin); textBoxCondition.Size = new Size(this.Width - 8 - panelxmargin * 2, 24); // 8 for selector textBoxCondition.ReadOnly = true; textBoxCondition.Click += Condition_Click; textBoxCondition.SetTipDynamically(toolTip, "Click to edit the condition that controls when the event is generated"); buttonKeys = new ExtendedControls.ExtButton(); buttonKeys.Location = textBoxCondition.Location; buttonKeys.Size = textBoxCondition.Size; buttonKeys.Click += Keypress_Click; toolTip.SetToolTip(buttonKeys, "Click to set the key list that associated this event with key presses"); labelAlwaysTrue = new Label(); labelAlwaysTrue.Location = new Point(panelxmargin, panelymargin + 1); labelAlwaysTrue.Size = textBoxCondition.Size; labelAlwaysTrue.Text = "Always Action/True"; labelAlwaysFalse = new Label(); labelAlwaysFalse.Location = new Point(panelxmargin, panelymargin + 1); labelAlwaysFalse.Size = textBoxCondition.Size; labelAlwaysFalse.Text = "Never Action/False"; SuspendLayout(); panelConditionType.Controls.Add(textBoxCondition); panelConditionType.Controls.Add(labelAlwaysTrue); panelConditionType.Controls.Add(labelAlwaysFalse); panelConditionType.Controls.Add(buttonKeys); Controls.Add(panelConditionType); SelectRepresentation(); ResumeLayout(); }
private void Prog_Clicked(object sender, EventArgs e) { ExtendedControls.ExtButton b = sender as ExtendedControls.ExtButton; Group g = (Group)b.Tag; ActionBase curact = curprog.GetStep(groups.IndexOf(g)); if (curact != null) { string pname = ((ActionCall)curact).GetProgramName(); if (pname != null) { EditProgram(curact.UserData); } else { ExtendedControls.MessageBoxTheme.Show(this, "No program name assigned"); } } }
private void Right_Clicked(object sender, EventArgs e) { ExtendedControls.ExtButton b = sender as ExtendedControls.ExtButton; Group g = (Group)b.Tag; int step = groups.IndexOf(g); ActionBase curact = curprog.GetStep(step); if (curact != null) { curact.LevelUp = Math.Max(curact.LevelUp - 1, 0); ActionBase nextact = curprog.GetStep(step + 1); if (!curact.IsStructStart && nextact != null) // move next up back 1 level, to keep it the same but if its a struct start dont { nextact.LevelUp++; } } RepositionGroups(); }
private void Actionbutton_Click(object sender, EventArgs e) { ExtendedControls.ExtButton cb = sender as ExtendedControls.ExtButton; Group g = cb.Tag as Group; if (g.di.localmodified) { if (ExtendedControls.MessageBoxTheme.Show(this, "Modified locally, do you wish to overwrite the changes".T(EDTx.AddOnManagerForm_Modwarn), "Warning".T(EDTx.Warning), MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.Cancel) { return; } } if (mgr.InstallFiles(g.di, EDDOptions.Instance.AppDataDirectory, EDDOptions.Instance.TempMoveDirectory())) { changelist[g.di.itemname] = g.di.localfound ? "++" : "+"; ExtendedControls.MessageBoxTheme.Show(this, "Add-on updated"); ReadyToDisplay(); } else { ExtendedControls.MessageBoxTheme.Show(this, "Add-on failed to update. Check files for read only status".T(EDTx.AddOnManagerForm_Failed), "Warning".T(EDTx.Warning), MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private List <ExtendedControls.ExtGroupBox> AdditionalCmdrControls() { var gb = new List <ExtendedControls.ExtGroupBox>(); ExtendedControls.ExtGroupBox g1 = new ExtendedControls.ExtGroupBox() { Height = 60, Text = "Frontier CAPI" }; capiButton = new ExtendedControls.ExtButton() { Location = new System.Drawing.Point(210, 23), ClientSize = new System.Drawing.Size(80, 20), Text = "Login" }; capiButton.Click += CapiButton_Click; capiStateLabel = new Label() { Location = new System.Drawing.Point(4, 23) }; g1.Controls.Add(capiButton); g1.Controls.Add(capiStateLabel); gb.Add(g1); return(gb); }
// 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, int width = 600, int vspacing = -1, bool cursoratend = false) { ITheme theme = ThemeableFormsInstance.Instance; int vstart = theme.WindowsFrame ? 20 : 40; if ( vspacing == -1 ) vspacing = multiline ? 80 : 40; int lw = 100; int lx = 10; int tx = 10 + lw + 8; DraggableForm prompt = new DraggableForm() { Width = width, 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); 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, Width = prompt.Width - 50, Text = caption }; textLabel.MouseDown += (s, e) => { prompt.OnCaptionMouseDown(s as Control, e); }; textLabel.MouseUp += (s, e) => { prompt.OnCaptionMouseUp(s as Control, e); }; if (!theme.WindowsFrame) outer.Controls.Add(textLabel); Label[] lbs = new Label[lab.Length]; ExtendedControls.ExtTextBox[] tbs = new ExtendedControls.ExtTextBox[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.ExtTextBox() { 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 }; if (cursoratend) tbs[i].Select(tbs[i].Text.Length, tbs[i].Text.Length); 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.ExtButton confirmation = new ExtendedControls.ExtButton() { 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.ExtButton cancel = new ExtendedControls.ExtButton() { 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.ExtTextBox t in tbs select t.Text).ToList(); return r; } else return null; }
private void ConditionDelClick(object sender, EventArgs e) { ExtendedControls.ExtButton b = sender as ExtendedControls.ExtButton; Group.Conditions c = (Group.Conditions)b.Tag; Delete(c); }
void ReadyToDisplay() { this.Cursor = Cursors.Default; mgr = new VersioningManager(); int[] edversion = System.Reflection.Assembly.GetExecutingAssembly().GetVersionInts(); System.Diagnostics.Debug.Assert(edversion != null); ReadLocalFiles(mgr, managedownloadmode); if (managedownloadmode) { mgr.ReadInstallFiles(EDDiscovery.Properties.Resources.URLGithubDataDownload, "ActionFiles/V1", downloadactfolder, EDDOptions.Instance.AppDataDirectory, "*.act", edversion, "Action File"); mgr.ReadInstallFiles(EDDiscovery.Properties.Resources.URLGithubDataDownload, "AddonFiles/V1", downloadaddonfolder, EDDOptions.Instance.AppDataDirectory, "*.inf", edversion, "Other File"); #if DEBUG mgr.ReadInstallFiles(EDDiscovery.Properties.Resources.URLGithubDataDownload, "ActionFiles/Debug", downloadactdebugfolder, EDDOptions.Instance.AppDataDirectory, "*.act", edversion, "Action File"); #endif } mgr.Sort(); panelVScroll.RemoveAllControls(); // blank panelVScroll.SuspendLayout(); int[] tabs; if (managedownloadmode) { // type, n, ver des stat act, del, ena tabs = new int[] { 0, 80, 280, 360, 560, 660, 760, 820, 880 } } ; else { tabs = new int[] { 0, 80, 280, 360, 560, 560, 660, 720, 780 } }; var theme = ExtendedControls.Theme.Current; int fonth = (int)theme.GetFont.GetHeight() + 1; int headervsize = fonth + panelheightmargin + 2; int vpos = headervsize + 8; // draw everything in 8.25 point position then scale int maxpanelwidth = 0; foreach (VersioningManager.DownloadItem di in mgr.DownloadItems) { Group g = new Group(); g.di = di; g.panel = new Panel(); g.panel.BorderStyle = BorderStyle.FixedSingle; g.panel.Tag = g; g.panel.MouseEnter += MouseEnterControl; g.type = new Label(); g.type.Location = new Point(tabs[0], labelheightmargin); // 8 spacing, allow 8*4 to indent g.type.Size = new Size(tabs[1] - tabs[0], 24); g.type.Text = di.itemtype; g.panel.Controls.Add(g.type); g.info = new ExtendedControls.ExtButton(); g.info.Location = new Point(tabs[1], labelheightmargin - 4); // 8 spacing, allow 8*4 to indent g.info.Size = new Size(16, 16); g.info.Text = "i"; g.info.Click += Info_Click; g.info.Tag = g; g.panel.Controls.Add(g.info); g.name = new Label(); g.name.Location = new Point(tabs[1] + 32, labelheightmargin); // 8 spacing, allow 8*4 to indent g.name.Size = new Size(tabs[2] - tabs[1] - 32, 24); g.name.Text = di.itemname; g.panel.Controls.Add(g.name); g.version = new Label(); g.version.Location = new Point(tabs[2], labelheightmargin); // 8 spacing, allow 8*4 to indent g.version.Size = new Size(tabs[3] - tabs[2], 24); g.version.Text = (di.localversion != null) ? di.localversion.ToString(".") : "N/A"; g.panel.Controls.Add(g.version); g.shortdesc = new Label(); g.shortdesc.Location = new Point(tabs[3], labelheightmargin); // 8 spacing, allow 8*4 to indent g.shortdesc.Size = new Size(tabs[4] - tabs[3], 24); g.shortdesc.Text = di.ShortLocalDescription; if (g.shortdesc.Text.Length == 0) { g.shortdesc.Text = "N/A"; } g.panel.Controls.Add(g.shortdesc); if (managedownloadmode) { bool isversion = false; string text; if (di.state == VersioningManager.ItemState.EDOutOfDate) { text = "Newer EDD required".T(EDTx.AddOnManagerForm_Newer); } else if (di.state == VersioningManager.ItemState.EDTooOld) { text = "Too old for EDD".T(EDTx.AddOnManagerForm_Old); } else if (di.state == VersioningManager.ItemState.UpToDate) { text = (di.localmodified) ? "Locally modified".T(EDTx.AddOnManagerForm_Locallymodified) : "Up to Date".T(EDTx.AddOnManagerForm_UptoDate); } else if (di.state == VersioningManager.ItemState.LocalOnly) { text = "Local Only".T(EDTx.AddOnManagerForm_LocalOnly); } else if (di.state == VersioningManager.ItemState.NotPresent) { isversion = true; text = "Version".T(EDTx.AddOnManagerForm_Version) + " " + di.downloadedversion.ToString(".") + ((di.localmodified) ? "*" : ""); } else { isversion = true; text = "New version".T(EDTx.AddOnManagerForm_Newversion) + " " + di.downloadedversion.ToString(".") + ((di.localmodified) ? "*" : ""); } g.actionlabel = new Label(); g.actionlabel.Location = new Point(tabs[4], labelheightmargin); // 8 spacing, allow 8*4 to indent g.actionlabel.Size = new Size(tabs[5] - tabs[4], 24); g.actionlabel.Text = text; g.panel.Controls.Add(g.actionlabel); if (isversion) { g.actionbutton = new ExtendedControls.ExtButton(); g.actionbutton.Location = new Point(tabs[5], labelheightmargin - 4); // 8 spacing, allow 8*4 to indent g.actionbutton.Size = new Size(tabs[6] - tabs[5] - 20, 24); g.actionbutton.Text = (di.state == VersioningManager.ItemState.NotPresent) ? "Install".T(EDTx.AddOnManagerForm_Install) : "Update".T(EDTx.AddOnManagerForm_Update); g.actionbutton.Click += Actionbutton_Click; g.actionbutton.Tag = g; g.panel.Controls.Add(g.actionbutton); } } else { bool loaded = CheckActionLoaded != null?CheckActionLoaded(g.di.itemname) : false; if (loaded) // may not be loaded IF its got an error. { if (!di.localnoteditable) { g.actionbutton = new ExtendedControls.ExtButton(); g.actionbutton.Location = new Point(tabs[5], labelheightmargin - 4); // 8 spacing, allow 8*4 to indent g.actionbutton.Size = new Size(tabs[6] - tabs[5] - 20, 24); g.actionbutton.Text = "Edit".T(EDTx.AddOnManagerForm_Edit); g.actionbutton.Click += ActionbuttonEdit_Click; g.actionbutton.Tag = g; g.panel.Controls.Add(g.actionbutton); } } } if (di.HasLocalCopy) { g.deletebutton = new ExtendedControls.ExtButton(); g.deletebutton.Location = new Point(tabs[6], labelheightmargin - 4); // 8 spacing, allow 8*4 to indent g.deletebutton.Size = new Size(24, 24); g.deletebutton.Text = "X"; g.deletebutton.Click += Deletebutton_Click; g.deletebutton.Tag = g; g.panel.Controls.Add(g.deletebutton); } if (di.localenable.HasValue) { g.enabled = new ExtendedControls.ExtCheckBox(); g.enabled.Location = new Point(tabs[7], labelheightmargin - 4); g.enabled.Size = new Size(tabs[8] - tabs[7], 24); g.enabled.Text = ""; g.enabled.Checked = di.localenable.Value; g.enabled.Click += Enabled_Click; g.enabled.Tag = g; g.enabled.Enabled = !di.localnotdisableable; g.panel.Controls.Add(g.enabled); } g.panel.Location = new Point(panelleftmargin, vpos); g.panel.Size = g.panel.FindMaxSubControlArea(4, 4); maxpanelwidth = Math.Max(maxpanelwidth, g.panel.Width); panelVScroll.Controls.Add(g.panel); vpos += g.panel.Height + 4; } foreach (Control c in panelVScroll.Controls) // set all the sub items, which are panels, to max panel width { c.Width = maxpanelwidth; } // then add the titles panelVScroll.Controls.Add(new Label() { Location = new Point(tabs[0] + panelleftmargin, panelheightmargin), Size = new Size(tabs[1] - tabs[0] - 2, headervsize), Text = "Type".T(EDTx.AddOnManagerForm_Type) }); panelVScroll.Controls.Add(new Label() { Location = new Point(tabs[1] + panelleftmargin, panelheightmargin), Size = new Size(tabs[2] - tabs[1] - 2, headervsize), Text = "Name".T(EDTx.AddOnManagerForm_Name) }); panelVScroll.Controls.Add(new Label() { Location = new Point(tabs[2] + panelleftmargin, panelheightmargin), Size = new Size(tabs[3] - tabs[2] - 2, headervsize), Text = "Version".T(EDTx.AddOnManagerForm_Version) }); panelVScroll.Controls.Add(new Label() { Location = new Point(tabs[3] + panelleftmargin, panelheightmargin), Size = new Size(tabs[4] - tabs[3] - 2, headervsize), Text = "Description".T(EDTx.AddOnManagerForm_Description) }); if (managedownloadmode) { panelVScroll.Controls.Add(new Label() { Location = new Point(tabs[4] + panelleftmargin, panelheightmargin), Size = new Size(tabs[5] - tabs[4] - 2, headervsize), Text = "Status".T(EDTx.AddOnManagerForm_Status) }); } panelVScroll.Controls.Add(new Label() { Location = new Point(tabs[5] + panelleftmargin, panelheightmargin), Size = new Size(tabs[6] - tabs[5] - 2, headervsize), Text = "Action".T(EDTx.AddOnManagerForm_Action) }); panelVScroll.Controls.Add(new Label() { Location = new Point(tabs[6] + panelleftmargin, panelheightmargin), Size = new Size(tabs[7] - tabs[6] - 2, headervsize), Text = "Delete".T(EDTx.AddOnManagerForm_Delete) }); panelVScroll.Controls.Add(new Label() { Location = new Point(tabs[7] + panelleftmargin, panelheightmargin), Size = new Size(tabs[8] - tabs[7] - 2, headervsize), Text = "Enabled".T(EDTx.AddOnManagerForm_Enabled) }); if (!managedownloadmode) // add on a more button if in edit pack mode { ExtendedControls.ExtButton dynmore = new ExtendedControls.ExtButton(); dynmore.Size = new System.Drawing.Size(24, 24); dynmore.Text = "+"; dynmore.Click += new System.EventHandler(this.buttonMore_Click); dynmore.UseVisualStyleBackColor = true; dynmore.Location = new Point(panelleftmargin, vpos); panelVScroll.Controls.Add(dynmore); } panelVScroll.Scale(this.CurrentAutoScaleFactor()); // scale newly added children to form theme.ApplyStd(panelVScroll); panelVScroll.ResumeLayout(); } bool infoclicked = false;
private void extPictureTrades_ClickElement(object sender, MouseEventArgs eventargs, ExtendedControls.ExtPictureBox.ImageElement i, object tag) { if (i != null && tag is ElementTrade && last_mcl != null) // must be an element, with a tag, must have a current mcl { ElementTrade current = (ElementTrade)tag; System.Diagnostics.Debug.WriteLine("Clicked on " + current.type + " " + current.element.Name); if (selected != null) { List <MaterialCommodityMicroResource> mcl = discoveryform.history.MaterialCommoditiesMicroResources.Get(last_mcl.Value); int currenttotal = mcl.Find(x => x.Details == current.element)?.Count ?? 0; // current mat total. If not there, its zero foreach (var trade in tradelist) { if (trade.fromelement.FDName == current.element.FDName) { currenttotal -= trade.offer; // may go negative if over offered } if (trade.element.FDName == current.element.FDName) { currenttotal += trade.receive; } } if (selected.element.FDName == current.element.FDName) // clicked on same.. deselect { selected = null; } else if (currenttotal >= current.offer) // if we have enough for at least 1 trade { DisplayTradeSelection(current.element); ExtendedControls.ConfigurableForm f = new ExtendedControls.ConfigurableForm(); int width = 250; int margin = 20; var butl = new ExtendedControls.ExtButton(); butl.Image = BaseUtils.Icons.IconSet.GetIcon("Controls.MaterialTrader.LeftArrow"); f.Add(new ExtendedControls.ConfigurableForm.Entry(butl, "less", "", new Point(margin, 64), new Size(32, 32), null)); var butr = new ExtendedControls.ExtButton(); butr.Image = BaseUtils.Icons.IconSet.GetIcon("Controls.MaterialTrader.RightArrow"); f.Add(new ExtendedControls.ConfigurableForm.Entry(butr, "more", "", new Point(width - margin - 32, 64), new Size(32, 32), null)); f.Add(new ExtendedControls.ConfigurableForm.Entry("olabel", typeof(Label), "Offer".T(EDTx.UserControlMaterialTrader_Offer), new Point(margin, 30), new Size(width - margin * 2, 20), null, 1.5f, ContentAlignment.MiddleCenter)); f.Add(new ExtendedControls.ConfigurableForm.Entry("offer", typeof(Label), "0/" + currenttotal.ToStringInvariant(), new Point(width / 2 - 12, 50), new Size(width / 2 - 20, 20), null, 1.2f, ContentAlignment.MiddleLeft)); var bar = new PictureBox(); bar.SizeMode = PictureBoxSizeMode.StretchImage; bar.Image = BaseUtils.Icons.IconSet.GetIcon("Controls.MaterialTrader.TraderBar"); f.Add(new ExtendedControls.ConfigurableForm.Entry(bar, "bar", "", new Point(width / 2 - 32, 70), new Size(64, 16), null)); f.Add(new ExtendedControls.ConfigurableForm.Entry("receive", typeof(Label), "0", new Point(width / 2 - 12, 90), new Size(width / 2 - 20, 20), null, 1.2f, ContentAlignment.MiddleLeft)); f.Add(new ExtendedControls.ConfigurableForm.Entry("rlabel", typeof(Label), "Receive".T(EDTx.UserControlMaterialTrader_Receive), new Point(margin, 110), new Size(width - margin * 2, 20), null, 1.5f, ContentAlignment.MiddleCenter)); f.AddOK(new Point(width - margin - 80, 150), "Press to Accept".T(EDTx.UserControlModules_PresstoAccept)); f.AddCancel(new Point(margin, 150), "Press to Cancel".T(EDTx.UserControlModules_PresstoCancel)); int currentoffer = 0; int currentreceive = 0; f.Trigger += (dialogname, controlname, xtag) => { if (controlname == "OK") { f.ReturnResult(DialogResult.OK); } else if (controlname == "Cancel" || controlname == "Close") { f.ReturnResult(DialogResult.Cancel); } else if (controlname == "less" || controlname == "more") { if (controlname == "less") { if (currentoffer > 0) { currentoffer -= current.offer; currentreceive -= current.receive; } } else { int newoffer = currentoffer + current.offer; if (newoffer <= currenttotal) { currentoffer = newoffer; currentreceive += current.receive; } } f.GetControl <Label>("offer").Text = currentoffer.ToStringInvariant() + "/" + currenttotal.ToStringInvariant(); f.GetControl <Label>("receive").Text = currentreceive.ToStringInvariant(); } }; f.RightMargin = margin; f.InitCentred(this.FindForm(), this.FindForm().Icon, " ", closeicon: true); DialogResult res = f.ShowDialog(); if (res == DialogResult.OK) { ElementTrade t = new ElementTrade() { element = selected.element, fromelement = current.element, offer = currentoffer, receive = currentreceive }; tradelist.Add(t); selected = null; StoreTrades(); DisplayTradeList(); } DisplayTradeSelection(); } } else { selected = current; } DisplayTradeSelection(); } }
private void Init(Icon icon, System.Drawing.Size minsize, System.Drawing.Size maxsize, System.Drawing.Point pos, string caption, string lname, Object callertag, bool closeicon, HorizontalAlignment?halign, ControlHelpersStaticFunc.VerticalAlignment?valign, AutoScaleMode asm, bool transparent) { this.logicalname = lname; // passed back to caller via trigger this.callertag = callertag; // passed back to caller via trigger this.halign = halign; this.valign = valign; this.minsize = minsize; // set min size window this.maxsize = maxsize; ITheme theme = ThemeableFormsInstance.Instance; FormBorderStyle = FormBorderStyle.FixedDialog; //outer = new ExtPanelScroll() { Dock = DockStyle.Fill, BorderStyle = BorderStyle.FixedSingle, Margin = new Padding(0), Padding = new Padding(0) }; outer = new ExtPanelScroll() { Name = "Outer", BorderStyle = BorderStyle.FixedSingle, Margin = new Padding(0), Padding = new Padding(0) }; outer.MouseDown += FormMouseDown; outer.MouseUp += FormMouseUp; Controls.Add(outer); ExtScrollBar scr = new ExtScrollBar(); scr.HideScrollBar = true; outer.Controls.Add(scr); this.Text = caption; int yoffset = 0; // adjustment to move controls up if windows frame present. if (theme.WindowsFrame && !ForceNoBorder) { yoffset = int.MaxValue; for (int i = 0; i < entries.Count; i++) // find minimum control Y { yoffset = Math.Min(yoffset, entries[i].pos.Y); } yoffset -= 8; // place X spaces below top } else { titlelabel = new Label() { Name = "title", Left = 4, Top = 8, Width = 10, Text = caption, AutoSize = true }; // autosize it, and set width small so it does not mess up the computation below titlelabel.MouseDown += FormMouseDown; titlelabel.MouseUp += FormMouseUp; titlelabel.Name = "title"; outer.Controls.Add(titlelabel); if (closeicon) { closebutton = new ExtButtonDrawn() { Name = "closebut", Size = new Size(18, 18), Location = new Point(0, 0) }; // purposely at top left to make it not contribute to overall size closebutton.ImageSelected = ExtButtonDrawn.ImageType.Close; closebutton.Click += (sender, f) => { if (!ProgClose) { Trigger?.Invoke(logicalname, "Close", callertag); } }; outer.Controls.Add(closebutton); // add now so it gets themed } } 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 = new Point(ent.pos.X, ent.pos.Y - yoffset); c.Name = ent.controlname; if (!(ent.text == null || c is ExtendedControls.ExtComboBox || c is ExtendedControls.ExtDateTimePicker || 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 System.Diagnostics.Debug.WriteLine("Control " + c.GetType().ToString() + " at " + c.Location + " " + c.Size + " " + c.Text); outer.Controls.Add(c); if (ent.tooltip != null) { tt.SetToolTip(c, ent.tooltip); } if (c is Label) { Label l = c as Label; if (ent.textalign.HasValue) { l.TextAlign = ent.textalign.Value; } } else if (c is ExtendedControls.ExtButton) { ExtendedControls.ExtButton b = c as ExtendedControls.ExtButton; if (ent.textalign.HasValue) { b.TextAlign = ent.textalign.Value; } b.Click += (sender, ev) => { if (!ProgClose) { 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) => { SwallowReturn = false; if (!ProgClose) { 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 } return(SwallowReturn); }; cb.ValidityChanged += (box, s) => { if (!ProgClose) { Entry en = (Entry)(box.Tag); Trigger?.Invoke(logicalname, en.controlname + ":Validity:" + s.ToString(), 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) => { SwallowReturn = false; if (!ProgClose) { 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 } return(SwallowReturn); }; cb.ValidityChanged += (box, s) => { if (!ProgClose) { Entry en = (Entry)(box.Tag); Trigger?.Invoke(logicalname, en.controlname + ":Validity:" + s.ToString(), this.callertag); // pass back the logical name of dialog, the name of the control, the caller tag } }; } else if (c is ExtendedControls.ExtTextBox) { ExtendedControls.ExtTextBox tb = c as ExtendedControls.ExtTextBox; tb.Multiline = tb.WordWrap = ent.textboxmultiline; tb.Size = ent.size; // restate size in case multiline is on tb.ClearOnFirstChar = ent.clearonfirstchar; tb.ReturnPressed += (box) => { SwallowReturn = false; if (!ProgClose) { 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 } return(SwallowReturn); }; if (tb.ClearOnFirstChar) { tb.SelectEnd(); } } else if (c is ExtendedControls.ExtCheckBox) { ExtendedControls.ExtCheckBox cb = c as ExtendedControls.ExtCheckBox; cb.Checked = ent.checkboxchecked; cb.Click += (sender, ev) => { if (!ProgClose) { 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.ExtDateTimePicker) { ExtendedControls.ExtDateTimePicker dt = c as ExtendedControls.ExtDateTimePicker; 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.ExtComboBox) { ExtendedControls.ExtComboBox cb = c as ExtendedControls.ExtComboBox; 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 && !ProgClose) { 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; this.AutoScaleMode = asm; // outer.FindMaxSubControlArea(0, 0,null,true); // debug //this.DumpTree(0); theme.ApplyStd(this, ForceNoBorder); //theme.Apply(this, new Font("ms Sans Serif", 16f)); //this.DumpTree(0); if (transparent) { TransparencyKey = BackColor; } for (int i = 0; i < entries.Count; i++) // post scale any controls which ask for different font ratio sizes { if (entries[i].PostThemeFontScale != 1.0f) { entries[i].control.Font = new Font(entries[i].control.Font.Name, entries[i].control.Font.SizeInPoints * entries[i].PostThemeFontScale); } } // position StartPosition = FormStartPosition.Manual; this.Location = pos; //System.Diagnostics.Debug.WriteLine("Bounds " + Bounds + " ClientRect " + ClientRectangle); //System.Diagnostics.Debug.WriteLine("Outer Bounds " + outer.Bounds + " ClientRect " + outer.ClientRectangle); }
/// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.components = new System.ComponentModel.Container(); this.dataViewScrollerPanel = new ExtendedControls.ExtPanelDataGridViewScroll(); this.dataGridViewMC = new System.Windows.Forms.DataGridView(); this.NameCol = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.ShortName = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.Category = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.Type = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.Number = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.Price = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.vScrollBarCustomMC = new ExtendedControls.ExtScrollBar(); this.panelButtons = new System.Windows.Forms.Panel(); this.buttonFilter = new ExtendedControls.ExtButton(); this.textBoxItems2 = new ExtendedControls.ExtTextBox(); this.textBoxItems1 = new ExtendedControls.ExtTextBox(); this.labelItems2 = new System.Windows.Forms.Label(); this.labelItems1 = new System.Windows.Forms.Label(); this.checkBoxClear = new ExtendedControls.ExtCheckBox(); this.toolTip = new System.Windows.Forms.ToolTip(this.components); this.dataViewScrollerPanel.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridViewMC)).BeginInit(); this.panelButtons.SuspendLayout(); this.SuspendLayout(); // // dataViewScrollerPanel // this.dataViewScrollerPanel.Controls.Add(this.dataGridViewMC); this.dataViewScrollerPanel.Controls.Add(this.vScrollBarCustomMC); this.dataViewScrollerPanel.Dock = System.Windows.Forms.DockStyle.Fill; this.dataViewScrollerPanel.InternalMargin = new System.Windows.Forms.Padding(0); this.dataViewScrollerPanel.Location = new System.Drawing.Point(0, 28); this.dataViewScrollerPanel.Name = "dataViewScrollerPanel"; this.dataViewScrollerPanel.ScrollBarWidth = 20; this.dataViewScrollerPanel.Size = new System.Drawing.Size(704, 536); this.dataViewScrollerPanel.TabIndex = 0; this.dataViewScrollerPanel.VerticalScrollBarDockRight = true; // // dataGridViewMC // this.dataGridViewMC.AllowUserToAddRows = false; this.dataGridViewMC.AllowUserToDeleteRows = false; this.dataGridViewMC.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; this.dataGridViewMC.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dataGridViewMC.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.NameCol, this.ShortName, this.Category, this.Type, this.Number, this.Price}); this.dataGridViewMC.Location = new System.Drawing.Point(0, 0); this.dataGridViewMC.Name = "dataGridViewMC"; this.dataGridViewMC.RowHeadersVisible = false; this.dataGridViewMC.ScrollBars = System.Windows.Forms.ScrollBars.None; this.dataGridViewMC.Size = new System.Drawing.Size(684, 536); this.dataGridViewMC.TabIndex = 1; this.dataGridViewMC.SortCompare += new System.Windows.Forms.DataGridViewSortCompareEventHandler(this.dataGridViewMC_SortCompare); // // NameCol // this.NameCol.HeaderText = "Name"; this.NameCol.MinimumWidth = 50; this.NameCol.Name = "NameCol"; this.NameCol.ReadOnly = true; // // ShortName // this.ShortName.HeaderText = "Abv"; this.ShortName.MinimumWidth = 25; this.ShortName.Name = "ShortName"; this.ShortName.ReadOnly = true; // // Category // this.Category.HeaderText = "Category"; this.Category.MinimumWidth = 50; this.Category.Name = "Category"; this.Category.ReadOnly = true; // // Type // this.Type.HeaderText = "Type"; this.Type.MinimumWidth = 50; this.Type.Name = "Type"; this.Type.ReadOnly = true; // // Number // this.Number.HeaderText = "Number"; this.Number.MinimumWidth = 50; this.Number.Name = "Number"; this.Number.ReadOnly = true; // // Price // this.Price.HeaderText = "Avg. Price"; this.Price.MinimumWidth = 50; this.Price.Name = "Price"; this.Price.ReadOnly = true; // // vScrollBarCustomMC // this.vScrollBarCustomMC.ArrowBorderColor = System.Drawing.Color.LightBlue; this.vScrollBarCustomMC.ArrowButtonColor = System.Drawing.Color.LightGray; this.vScrollBarCustomMC.ArrowColorScaling = 0.5F; this.vScrollBarCustomMC.ArrowDownDrawAngle = 270F; this.vScrollBarCustomMC.ArrowUpDrawAngle = 90F; this.vScrollBarCustomMC.BorderColor = System.Drawing.Color.White; this.vScrollBarCustomMC.FlatStyle = System.Windows.Forms.FlatStyle.System; this.vScrollBarCustomMC.HideScrollBar = false; this.vScrollBarCustomMC.LargeChange = 0; this.vScrollBarCustomMC.Location = new System.Drawing.Point(684, 21); this.vScrollBarCustomMC.Maximum = -1; this.vScrollBarCustomMC.Minimum = 0; this.vScrollBarCustomMC.MouseOverButtonColor = System.Drawing.Color.Green; this.vScrollBarCustomMC.MousePressedButtonColor = System.Drawing.Color.Red; this.vScrollBarCustomMC.Name = "vScrollBarCustomMC"; this.vScrollBarCustomMC.Size = new System.Drawing.Size(20, 515); this.vScrollBarCustomMC.SliderColor = System.Drawing.Color.DarkGray; this.vScrollBarCustomMC.SmallChange = 1; this.vScrollBarCustomMC.TabIndex = 0; this.vScrollBarCustomMC.Text = "vScrollBarCustom1"; this.vScrollBarCustomMC.ThumbBorderColor = System.Drawing.Color.Yellow; this.vScrollBarCustomMC.ThumbButtonColor = System.Drawing.Color.DarkBlue; this.vScrollBarCustomMC.ThumbColorScaling = 0.5F; this.vScrollBarCustomMC.ThumbDrawAngle = 0F; this.vScrollBarCustomMC.Value = -1; this.vScrollBarCustomMC.ValueLimited = -1; // // panelButtons // this.panelButtons.Controls.Add(this.buttonFilter); this.panelButtons.Controls.Add(this.textBoxItems2); this.panelButtons.Controls.Add(this.textBoxItems1); this.panelButtons.Controls.Add(this.labelItems2); this.panelButtons.Controls.Add(this.labelItems1); this.panelButtons.Controls.Add(this.checkBoxClear); this.panelButtons.Dock = System.Windows.Forms.DockStyle.Top; this.panelButtons.Location = new System.Drawing.Point(0, 0); this.panelButtons.Name = "panelButtons"; this.panelButtons.Size = new System.Drawing.Size(704, 28); this.panelButtons.TabIndex = 2; // // buttonFilter // this.buttonFilter.Location = new System.Drawing.Point(6, 2); this.buttonFilter.Name = "buttonFilter"; this.buttonFilter.Size = new System.Drawing.Size(75, 23); this.buttonFilter.TabIndex = 5; this.buttonFilter.Text = "Filter"; this.toolTip.SetToolTip(this.buttonFilter, "Filter out items"); this.buttonFilter.UseVisualStyleBackColor = true; this.buttonFilter.Click += new System.EventHandler(this.buttonFilter_Click); // // textBoxItems2 // this.textBoxItems2.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.None; this.textBoxItems2.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.None; this.textBoxItems2.BackErrorColor = System.Drawing.Color.Red; this.textBoxItems2.BorderColor = System.Drawing.Color.Transparent; this.textBoxItems2.BorderColorScaling = 0.5F; this.textBoxItems2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.textBoxItems2.ClearOnFirstChar = false; this.textBoxItems2.ControlBackground = System.Drawing.SystemColors.Control; this.textBoxItems2.InErrorCondition = false; this.textBoxItems2.Location = new System.Drawing.Point(295, 3); this.textBoxItems2.Multiline = false; this.textBoxItems2.Name = "textBoxItems2"; this.textBoxItems2.ReadOnly = false; this.textBoxItems2.ScrollBars = System.Windows.Forms.ScrollBars.None; this.textBoxItems2.SelectionLength = 0; this.textBoxItems2.SelectionStart = 0; this.textBoxItems2.Size = new System.Drawing.Size(75, 20); this.textBoxItems2.TabIndex = 4; this.textBoxItems2.TextAlign = System.Windows.Forms.HorizontalAlignment.Left; this.toolTip.SetToolTip(this.textBoxItems2, "Count of Items"); this.textBoxItems2.WordWrap = true; // // textBoxItems1 // this.textBoxItems1.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.None; this.textBoxItems1.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.None; this.textBoxItems1.BackErrorColor = System.Drawing.Color.Red; this.textBoxItems1.BorderColor = System.Drawing.Color.Transparent; this.textBoxItems1.BorderColorScaling = 0.5F; this.textBoxItems1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.textBoxItems1.ClearOnFirstChar = false; this.textBoxItems1.ControlBackground = System.Drawing.SystemColors.Control; this.textBoxItems1.InErrorCondition = false; this.textBoxItems1.Location = new System.Drawing.Point(145, 3); this.textBoxItems1.Multiline = false; this.textBoxItems1.Name = "textBoxItems1"; this.textBoxItems1.ReadOnly = false; this.textBoxItems1.ScrollBars = System.Windows.Forms.ScrollBars.None; this.textBoxItems1.SelectionLength = 0; this.textBoxItems1.SelectionStart = 0; this.textBoxItems1.Size = new System.Drawing.Size(75, 20); this.textBoxItems1.TabIndex = 4; this.textBoxItems1.TextAlign = System.Windows.Forms.HorizontalAlignment.Left; this.toolTip.SetToolTip(this.textBoxItems1, "Count of Items"); this.textBoxItems1.WordWrap = true; // // labelItems2 // this.labelItems2.AutoSize = true; this.labelItems2.Location = new System.Drawing.Point(245, 4); this.labelItems2.Name = "labelItems2"; this.labelItems2.Size = new System.Drawing.Size(43, 13); this.labelItems2.TabIndex = 3; this.labelItems2.Text = "<code>"; // // labelItems1 // this.labelItems1.AutoSize = true; this.labelItems1.Location = new System.Drawing.Point(95, 4); this.labelItems1.Name = "labelItems1"; this.labelItems1.Size = new System.Drawing.Size(43, 13); this.labelItems1.TabIndex = 3; this.labelItems1.Text = "<code>"; // // checkBoxClear // this.checkBoxClear.AutoSize = true; this.checkBoxClear.CheckBoxColor = System.Drawing.Color.Gray; this.checkBoxClear.CheckBoxInnerColor = System.Drawing.Color.White; this.checkBoxClear.CheckColor = System.Drawing.Color.DarkBlue; this.checkBoxClear.FontNerfReduction = 0.5F; this.checkBoxClear.ImageButtonDisabledScaling = 0.5F; this.checkBoxClear.Location = new System.Drawing.Point(376, 6); this.checkBoxClear.MouseOverColor = System.Drawing.Color.CornflowerBlue; this.checkBoxClear.Name = "checkBoxClear"; this.checkBoxClear.Size = new System.Drawing.Size(116, 17); this.checkBoxClear.TabIndex = 2; this.checkBoxClear.Text = "Remove zero items"; this.checkBoxClear.TickBoxReductionSize = 10; this.toolTip.SetToolTip(this.checkBoxClear, "Remove zero items the time after they go to zero"); this.checkBoxClear.UseVisualStyleBackColor = true; // // toolTip // this.toolTip.ShowAlways = true; // // UserControlMaterialCommodities // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.Controls.Add(this.dataViewScrollerPanel); this.Controls.Add(this.panelButtons); this.Name = "UserControlMaterialCommodities"; this.Size = new System.Drawing.Size(704, 564); this.dataViewScrollerPanel.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.dataGridViewMC)).EndInit(); this.panelButtons.ResumeLayout(false); this.panelButtons.PerformLayout(); this.ResumeLayout(false); }
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.ExtPanelDropDown(); 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.ExtComboBox(); 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.ExtButton(); 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.ExtTextBox(); 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.ExtButton(); 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.ExtButton(); 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 Init(Icon icon, System.Drawing.Point pos, string caption, string lname, Object callertag, bool posiscentrecoords = false, AutoScaleMode asm = AutoScaleMode.Font) { 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; ExtPanelScroll outer = new ExtPanelScroll() { Dock = DockStyle.Fill, BorderStyle = BorderStyle.FixedSingle }; outer.MouseDown += FormMouseDown; outer.MouseUp += FormMouseUp; Controls.Add(outer); ExtScrollBar scr = new ExtScrollBar(); scr.HideScrollBar = true; outer.Controls.Add(scr); 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.ExtComboBox || c is ExtendedControls.ExtDateTimePicker || 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.ExtButton) { ExtendedControls.ExtButton b = c as ExtendedControls.ExtButton; b.Click += (sender, ev) => { if (!ProgClose) { 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) => { SwallowReturn = false; if (!ProgClose) { 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 } return(SwallowReturn); }; cb.ValidityChanged += (box, s) => { if (!ProgClose) { Entry en = (Entry)(box.Tag); Trigger?.Invoke(logicalname, en.controlname + ":Validity:" + s.ToString(), 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) => { SwallowReturn = false; if (!ProgClose) { 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 } return(SwallowReturn); }; cb.ValidityChanged += (box, s) => { if (!ProgClose) { Entry en = (Entry)(box.Tag); Trigger?.Invoke(logicalname, en.controlname + ":Validity:" + s.ToString(), this.callertag); // pass back the logical name of dialog, the name of the control, the caller tag } }; } else if (c is ExtendedControls.ExtTextBox) { ExtendedControls.ExtTextBox tb = c as ExtendedControls.ExtTextBox; tb.Multiline = tb.WordWrap = ent.textboxmultiline; tb.Size = ent.size; // restate size in case multiline is on tb.ClearOnFirstChar = ent.clearonfirstchar; tb.ReturnPressed += (box) => { SwallowReturn = false; if (!ProgClose) { 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 } return(SwallowReturn); }; } else if (c is ExtendedControls.ExtCheckBox) { ExtendedControls.ExtCheckBox cb = c as ExtendedControls.ExtCheckBox; cb.Checked = ent.checkboxchecked; cb.Click += (sender, ev) => { if (!ProgClose) { 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.ExtDateTimePicker) { ExtendedControls.ExtDateTimePicker dt = c as ExtendedControls.ExtDateTimePicker; 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.ExtComboBox) { ExtendedControls.ExtComboBox cb = c as ExtendedControls.ExtComboBox; 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 && !ProgClose) { 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; this.AutoScaleMode = asm; //this.DumpTree(0); theme.ApplyStd(this); //this.DumpTree(0); int fh = (int)this.Font.GetHeight(); // use the FH to nerf the extra area so it scales with FH.. this helps keep the controls within a framed window // measure the items after scaling. Exclude the scroll bar Size measureitemsinwindow = outer.FindMaxSubControlArea(fh + 8, (theme.WindowsFrame ? 50 : 16) + fh, new Type[] { typeof(ExtScrollBar) }); StartPosition = FormStartPosition.Manual; Location = pos; this.PositionSizeWithinScreen(measureitemsinwindow.Width, measureitemsinwindow.Height, false, 64, centrecoords: posiscentrecoords); }
private void extPictureTrades_ClickElement(object sender, MouseEventArgs eventargs, ExtendedControls.ExtPictureBox.ImageElement i, object tag) { if (i != null) { ElementTag e = (ElementTag)tag; System.Diagnostics.Debug.WriteLine("Clicked on " + e.type + " " + e.element.Name); if (selected != null) { if (selected.element.FDName == e.element.FDName) // clicked on same.. deselect { selected = null; } else { ExtendedControls.ConfigurableForm f = new ExtendedControls.ConfigurableForm(); int width = 250; int margin = 20; var butl = new ExtendedControls.ExtButton(); butl.Image = EDDiscovery.Icons.IconSet.GetIcon("Controls.MaterialTrader.LeftArrow"); f.Add(new ExtendedControls.ConfigurableForm.Entry(butl, "left", "", new Point(margin, 64), new Size(32, 32), null)); var butr = new ExtendedControls.ExtButton(); butr.Image = EDDiscovery.Icons.IconSet.GetIcon("Controls.MaterialTrader.RightArrow"); f.Add(new ExtendedControls.ConfigurableForm.Entry(butr, "right", "", new Point(width - margin - 32, 64), new Size(32, 32), null)); f.Add(new ExtendedControls.ConfigurableForm.Entry("olabel", typeof(Label), "Offer".Tx(EDTx.UserControlMaterialTrader_Offer), new Point(margin, 30), new Size(width - margin * 2, 20), null, 1.5f, ContentAlignment.MiddleCenter)); f.Add(new ExtendedControls.ConfigurableForm.Entry("offer", typeof(Label), "0/0", new Point(width / 2 - 12, 50), new Size(width / 2 - 20, 20), null, 1.2f, ContentAlignment.MiddleLeft)); var bar = new PictureBox(); bar.SizeMode = PictureBoxSizeMode.StretchImage; bar.Image = EDDiscovery.Icons.IconSet.GetIcon("Controls.MaterialTrader.TraderBar"); f.Add(new ExtendedControls.ConfigurableForm.Entry(bar, "bar", "", new Point(width / 2 - 32, 70), new Size(64, 16), null)); f.Add(new ExtendedControls.ConfigurableForm.Entry("receive", typeof(Label), "0", new Point(width / 2 - 12, 90), new Size(width / 2 - 20, 20), null, 1.2f, ContentAlignment.MiddleLeft)); f.Add(new ExtendedControls.ConfigurableForm.Entry("rlabel", typeof(Label), "Receive".Tx(EDTx.UserControlMaterialTrader_Receive), new Point(margin, 110), new Size(width - margin * 2, 20), null, 1.5f, ContentAlignment.MiddleCenter)); f.Add(new ExtendedControls.ConfigurableForm.Entry("OK", typeof(ExtendedControls.ExtButton), "OK".T(EDTx.OK), new Point(width - margin - 80, 150), new Size(80, 24), "Press to Accept".T(EDTx.UserControlModules_PresstoAccept))); f.Add(new ExtendedControls.ConfigurableForm.Entry("Cancel", typeof(ExtendedControls.ExtButton), "Cancel".T(EDTx.Cancel), new Point(margin, 150), new Size(80, 24), "Press to Cancel".T(EDTx.UserControlModules_PresstoCancel))); f.Trigger += (dialogname, controlname, xtag) => { if (controlname == "OK") { f.ReturnResult(DialogResult.OK); } else if (controlname == "Cancel") { f.ReturnResult(DialogResult.Cancel); } else if (controlname == "Less") { } else if (controlname == "More") { } }; f.RightMargin = margin; f.InitCentred(this.FindForm(), this.FindForm().Icon, "Trade".T(EDTx.UserControlMaterialTrader_Trade)); //f.GetControl<Label>("offer").Font = new Font() DialogResult res = f.ShowDialog(); if (res == DialogResult.OK) { Display(); } } } else { selected = e; } Display(); } }
// 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); }; ITheme theme = ThemeableFormsInstance.Instance; 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".Tx(), 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".Tx(), 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); } }
public void Init(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.ExtComboBox || c is ExtendedControls.ExtDateTimePicker || 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.ExtButton) { ExtendedControls.ExtButton b = c as ExtendedControls.ExtButton; b.Click += (sender, ev) => { if (!ProgClose) { 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) => { if (!ProgClose) { 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 } }; cb.ValidityChanged += (box, s) => { if (!ProgClose) { Entry en = (Entry)(box.Tag); Trigger?.Invoke(logicalname, en.controlname + ":Validity:" + s.ToString(), 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) => { if (!ProgClose) { 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 } }; cb.ValidityChanged += (box, s) => { if (!ProgClose) { Entry en = (Entry)(box.Tag); Trigger?.Invoke(logicalname, en.controlname + ":Validity:" + s.ToString(), this.callertag); // pass back the logical name of dialog, the name of the control, the caller tag } }; } else if (c is ExtendedControls.ExtTextBox) { ExtendedControls.ExtTextBox tb = c as ExtendedControls.ExtTextBox; tb.Multiline = tb.WordWrap = ent.textboxmultiline; tb.Size = ent.size; // restate size in case multiline is on tb.ClearOnFirstChar = ent.clearonfirstchar; tb.ReturnPressed += (box) => { if (!ProgClose) { 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.ExtCheckBox) { ExtendedControls.ExtCheckBox cb = c as ExtendedControls.ExtCheckBox; cb.Checked = ent.checkboxchecked; cb.Click += (sender, ev) => { if (!ProgClose) { 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.ExtDateTimePicker) { ExtendedControls.ExtDateTimePicker dt = c as ExtendedControls.ExtDateTimePicker; 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.ExtComboBox) { ExtendedControls.ExtComboBox cb = c as ExtendedControls.ExtComboBox; 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 && !ProgClose) { 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); }