public void AddScrollBar(ExtScrollBar bar) // for use of an external scroll bar { ScrollBar = bar; ScrollBar.MouseWheel += Control_MouseWheel; // grab the controls mouse wheel and direct to our scroll, including the ExtScrollBar ScrollBar.Scroll += new System.Windows.Forms.ScrollEventHandler(OnScrollBarChanged); InternalScrollbar = false; }
public CheckedIconListBoxForm() { FormBorderStyle = FormBorderStyle.None; ShowInTaskbar = false; StartPosition = FormStartPosition.Manual; AutoSize = false; Padding = new Padding(0); controllist = new List <ControlSet>(); panelscroll = new ExtPanelScroll(); panelscroll.Dock = DockStyle.Fill; Controls.Add(panelscroll); sb = new ExtScrollBar(); panelscroll.Controls.Add(sb); panelscroll.ScrollBar.HideScrollBar = true; }
public ExtListBox() : base() { items = new List <string>(); SetStyle(ControlStyles.SupportsTransparentBackColor | ControlStyles.OptimizedDoubleBuffer, true); vScrollBar = new ExtScrollBar(); vScrollBar.SmallChange = 1; vScrollBar.LargeChange = 1; Controls.Add(vScrollBar); vScrollBar.Visible = false; vScrollBar.Scroll += new System.Windows.Forms.ScrollEventHandler(vScroll); lbsys = new ListBox(); this.Controls.Add(lbsys); lbsys.SelectedIndexChanged += lbsys_SelectedIndexChanged; lbsys.DrawItem += Lbsys_DrawItem; lbsys.DrawMode = DrawMode.OwnerDrawFixed; }
protected override void OnControlRemoved(ControlEventArgs e) { if (e.Control is ExtScrollBar) { ScrollBar = null; } else { e.Control.LocationChanged -= Control_LocationChanged; // and any location/size/visible changes means scroll bar is changed e.Control.VisibleChanged -= Control_VisibleChanged; e.Control.SizeChanged -= Control_SizeChanged; } e.Control.MouseWheel -= Control_MouseWheel; // grab the controls mouse wheel and direct to our scroll, including the ExtScrollBar base.OnControlRemoved(e); }
public CheckedIconListBoxForm() { FormBorderStyle = FormBorderStyle.None; ShowInTaskbar = false; StartPosition = FormStartPosition.Manual; AutoSize = false; Padding = new Padding(0); IsOpen = true; controllist = new List <ControlSet>(); panelscroll = new ExtPanelScroll(); panelscroll.Dock = DockStyle.Fill; Controls.Add(panelscroll); sb = new ExtScrollBar(); panelscroll.Controls.Add(sb); panelscroll.ScrollBar.HideScrollBar = true; //this.Activated += new System.EventHandler(this.FormActivated); //this.Shown += new System.EventHandler(this.FormActivated); }
protected override void OnControlAdded(ControlEventArgs e) { if (e.Control is ExtScrollBar) { ScrollBar = e.Control as ExtScrollBar; ScrollBar.Width = ScrollBarWidth; ScrollBar.Scroll += new System.Windows.Forms.ScrollEventHandler(OnScrollBarChanged); ScrollBar.Name = "VScrollPanel"; } else { e.Control.LocationChanged += Control_LocationChanged; // and any location/size/visible changes means scroll bar is changed e.Control.VisibleChanged += Control_VisibleChanged; e.Control.SizeChanged += Control_SizeChanged; } e.Control.MouseWheel += Control_MouseWheel; // grab the controls mouse wheel and direct to our scroll, including the ExtScrollBar }
public ExtRichTextBox() : base() { TextBox = new RichTextBoxBack(); ScrollBar = new ExtScrollBar(); Controls.Add(TextBox); Controls.Add(ScrollBar); TextBox.ScrollBars = RichTextBoxScrollBars.None; TextBox.BorderStyle = BorderStyle.None; TextBox.BackColor = BackColor; TextBox.ForeColor = ForeColor; TextBox.MouseUp += TextBox_MouseUp; TextBox.MouseDown += TextBox_MouseDown; TextBox.MouseMove += TextBox_MouseMove; TextBox.MouseEnter += TextBox_MouseEnter; TextBox.MouseLeave += TextBox_MouseLeave; TextBox.Show(); ScrollBar.Show(); TextBox.VScroll += OnVscrollChanged; TextBox.MouseWheel += new MouseEventHandler(MWheel); // richtextbox without scroll bars do not handle mouse wheels TextBox.TextChanged += TextChangeEventHandler; ScrollBar.Scroll += new System.Windows.Forms.ScrollEventHandler(OnScrollBarChanged); }
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); }
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); }