Esempio n. 1
0
        private void Enabled_Click(object sender, EventArgs e)
        {
            ExtendedControls.ExtCheckBox cb = sender as ExtendedControls.ExtCheckBox;
            Group g = cb.Tag as Group;

            VersioningManager.SetEnableFlag(g.di, cb.Checked, EDDOptions.Instance.AppDataDirectory);
            changelist[g.di.itemname] = cb.Checked ? "+" : "-";
        }
Esempio n. 2
0
 private void checkBoxRawJournal_CheckedChanged(object sender, EventArgs e)
 {
     ExtendedControls.ExtCheckBox control = (ExtendedControls.ExtCheckBox)sender;
     if (control.Checked && control.Visible)
     {
         checkBoxIncludeHeader.Checked = false;
         checkBoxIncludeHeader.Enabled = false;
     }
     else
     {
         checkBoxIncludeHeader.Enabled = true;
     }
 }
Esempio n. 3
0
 private void Chkbox_Click(object sender, EventArgs e)
 {
     if (!disablechk)
     {
         ExtendedControls.ExtCheckBox c = sender as ExtendedControls.ExtCheckBox;
         disablechk = true;
         foreach (Group g in groups)
         {
             g.chkbox.Checked = false;
         }
         c.Checked  = true;
         disablechk = false;
     }
 }
        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);
 }
Esempio n. 6
0
        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);
        }
        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);
        }