Beispiel #1
0
        public override void Init(Condition cond, List <string> events, ActionCoreController cp, string appfolder, ActionFile actionfile,
                                  System.Func <string, List <string> > func, Icon ic, ToolTip toolTip)
        {
            cd = cond;      // on creation, the cond with be set to onVoice with one condition, checked in ActionController.cs:SetPackEditor..

            textBoxInput              = new ExtendedControls.TextBoxBorder();
            textBoxInput.Location     = new Point(panelxmargin, panelymargin);
            textBoxInput.Size         = new Size(356, 24); // manually matched to size of eventprogramcondition bits
            textBoxInput.Text         = cd.fields[0].matchstring;
            textBoxInput.TextChanged += TextBoxInput_TextChanged;
            textBoxInput.SetTipDynamically(toolTip, "Enter the voice input to recognise.  Multiple phrases seperate with semicolons");

            Controls.Add(textBoxInput);

            ActionProgram p = cond.action.HasChars() ? actionfile.actionprogramlist.Get(cond.action) : null;

            ActionProgram.ProgramConditionClass classifier = p != null ? p.progclass : ActionProgram.ProgramConditionClass.KeySay;

            ucprog          = new ActionPackEditProgram();
            ucprog.Location = new Point(textBoxInput.Right + 16, 0);
            ucprog.Size     = new Size(400, this.Height);   // init all the panels to 0/this height, select widths
            ucprog.Init(actionfile, cond, cp, appfolder, ic, toolTip, classifier);
            ucprog.onEditKeys         = onEditKeys;
            ucprog.onEditSay          = onEditSay;
            ucprog.onAdditionalNames += () => { return(func(null)); };
            ucprog.SuggestedName     += () => { return("VoiceInput"); };
            ucprog.RefreshEvent      += () => { RefreshIt(); };
            Controls.Add(ucprog);
        }
 void OffsetPos(Point lp, Label lab, Point tp, ExtendedControls.TextBoxBorder box, int i)
 {
     lab.Location = lp;
     box.Location = tp;
     box.Tag      = lab.Tag = i;
     lab.Visible  = box.Visible = true;
 }
 void SetPos(ref Point lp, Label lab, Point tp, ExtendedControls.TextBoxBorder box, int vspacing, int i)
 {
     lab.Location = lp;
     box.Location = tp;
     box.Tag      = lab.Tag = i;
     lab.Visible  = box.Visible = true;
     lp.Y        += vspacing;
 }
Beispiel #4
0
        private void ValidateColumnInput(ExtendedControls.TextBoxBorder txtBox)
        {
            int dummy;

            if (!(string.IsNullOrEmpty(txtBox.Text) || int.TryParse(txtBox.Text, out dummy)))
            {
                txtBox.Text = "";
            }
        }
        private void Value_Click(object sender, EventArgs e)
        {
            ExtendedControls.TextBoxBorder b = sender as ExtendedControls.TextBoxBorder;
            Group g = (Group)b.Tag;

            if (b.ReadOnly)
            {
                ActionConfig_Clicked(g.config, null);
            }
        }
        private void Value_TextChanged(object sender, EventArgs e)
        {
            ExtendedControls.TextBoxBorder tb = sender as ExtendedControls.TextBoxBorder;
            Group      g      = (Group)tb.Tag;
            ActionBase curact = curprog.GetStep(groups.IndexOf(g));

            if (tb.Enabled && curact != null)
            {
                curact.UpdateUserData(tb.Text);
            }
        }
Beispiel #7
0
        public override void InitSub(List <string> events)
        {
            eventtype = new ExtendedControls.ComboBoxCustom();
            eventtype.Items.AddRange(events);
            eventtype.Location       = new Point(panelxmargin, panelymargin);
            eventtype.Size           = new Size(140, 24);
            eventtype.DropDownHeight = 400;
            eventtype.DropDownWidth  = eventtype.Width * 3 / 2;
            if (cd.eventname != null)
            {
                eventtype.SelectedItem = cd.eventname;
            }
            eventtype.SelectedIndexChanged += Actiontype_SelectedIndexChanged;

            proglist = new ExtendedControls.ComboBoxCustom();
            proglist.Items.Add("New");
            proglist.Items.AddRange(actionfile.actionprogramlist.GetActionProgramList());
            proglist.Location       = new Point(eventtype.Right + 16, panelymargin);
            proglist.Size           = new Size(140, 24);
            proglist.DropDownHeight = 400;
            proglist.DropDownWidth  = proglist.Width * 3 / 2;
            if (cd.action != null)
            {
                proglist.Text = cd.action;
            }
            else
            {
                proglist.SelectedIndex = 0;
            }

            proglist.SelectedIndexChanged += Proglist_SelectedIndexChanged;

            progedit          = new ExtendedControls.ButtonExt();
            progedit.Text     = "P";
            progedit.Location = new Point(proglist.Right + 8, panelymargin);
            progedit.Size     = new Size(24, 24);
            progedit.Click   += Progedit_Click;

            paras          = new ExtendedControls.TextBoxBorder();
            paras.Text     = (cd.actiondata != null) ? cd.actiondata : "";
            paras.Location = new Point(progedit.Right + 8, panelymargin + 2);
            paras.Size     = new Size(96, 24);
            paras.ReadOnly = true;
            paras.Click   += Paras_Click;

            SuspendLayout();
            Controls.Add(proglist);
            Controls.Add(eventtype);
            Controls.Add(progedit);
            Controls.Add(paras);
            ResumeLayout();
        }
        void SetValue(ExtendedControls.TextBoxBorder value, ActionBase step)
        {
            value.Enabled  = false;
            value.Text     = "";
            value.ReadOnly = true;

            if (step != null)
            {
                value.ReadOnly = !step.AllowDirectEditingOfUserData;
                value.Visible  = step.DisplayedUserData != null;
                if (step.DisplayedUserData != null)
                {
                    value.Text = step.DisplayedUserData;
                }
            }

            value.Enabled = true;
        }
Beispiel #9
0
        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;

            panelConditionType                       = new ExtendedControls.PanelSelectionList();
            panelConditionType.Location              = new Point(0, 0);
            panelConditionType.Size                  = new Size(this.Width, this.Height); // 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.TextBoxBorder();
            textBoxCondition.Location = new Point(panelxmargin, panelymargin + 2);
            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.ButtonExt();
            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 + 4);
            labelAlwaysTrue.Size     = textBoxCondition.Size;
            labelAlwaysTrue.Text     = "Always Action/True";

            labelAlwaysFalse          = new Label();
            labelAlwaysFalse.Location = new Point(panelxmargin, panelymargin + 4);
            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();
        }
 void UpdateSkinny()
 {
     if (IsTransparent && (Selection & (1 << BitSelSkinny)) != 0)
     {
         foreach (Control c in Controls)
         {
             if (c is ExtendedControls.TextBoxBorder)
             {
                 ExtendedControls.TextBoxBorder b = c as ExtendedControls.TextBoxBorder;
                 b.ControlBackground = Color.Red;
                 b.BorderStyle       = BorderStyle.None;
                 b.BorderColor       = Color.Transparent;
             }
         }
     }
     else
     {
         EDDTheme.Instance.ApplyToControls(this);
     }
 }
Beispiel #11
0
        public override void InitSub(List <string> events)
        {
            base.InitSub(events);

            condition          = new ExtendedControls.TextBoxBorder();
            condition.Text     = cd.ToString();
            condition.Location = new Point(paras.Right + 16, panelymargin + 2);
            condition.Size     = new Size(200, 24);
            condition.ReadOnly = true;
            condition.Click   += Condition_Click;
            condition.Tag      = this;

            delete          = new ExtendedControls.ButtonExt();
            delete.Text     = "X";
            delete.Location = new Point(condition.Right + 8, panelymargin);
            delete.Size     = new Size(24, 24);
            delete.Click   += Delete_Click;

            SuspendLayout();
            Controls.Add(condition);
            Controls.Add(delete);
            ResumeLayout();
        }
Beispiel #12
0
        public void Init(ActionFile af, Condition c, ActionCoreController ac, string apf, Icon i, ToolTip toolTip,
                         ActionProgram.ProgramConditionClass cls)
        {
            cd                   = c; // point at common condition, we never new it, just update action data/action
            actionfile           = af;
            actioncorecontroller = ac;
            applicationfolder    = apf;
            Icon                 = i;
            classifier           = cls;

            progmajortype = new ExtendedControls.PanelSelectionList();
            progmajortype.Items.AddRange(new string[] { "Key", "Say", "Key+Say", "Full Program" });
            indextoclassifier = new ActionProgram.ProgramConditionClass[] { ActionProgram.ProgramConditionClass.Key, ActionProgram.ProgramConditionClass.Say,
                                                                            ActionProgram.ProgramConditionClass.KeySay, ActionProgram.ProgramConditionClass.Full };
            progmajortype.Location              = new Point(0, 0);
            progmajortype.Size                  = new Size(this.Width, this.Height); // outer panel aligns with this UC
            progmajortype.SelectedIndexChanged += PanelType_SelectedIndexChanged;
            toolTip.SetToolTip(progmajortype, "Use the selector (click on bottom right arrow) to select program class type");

            proglist = new ExtendedControls.ComboBoxCustom();
            proglist.Items.Add("New");
            proglist.Items.AddRange(actionfile.actionprogramlist.GetActionProgramList());
            proglist.Location              = new Point(panelxmargin, panelymargin);
            proglist.Size                  = new Size((this.Width - 24 - 8 - 8 - 8 - panelxmargin * 2) / 2, 24); // 24 button, 8+8 gaps, 8 for selector
            proglist.DropDownHeight        = 400;
            proglist.DropDownWidth         = proglist.Width * 3 / 2;
            proglist.SelectedIndexChanged += Proglist_SelectedIndexChanged;
            proglist.SetTipDynamically(toolTip, "Select program to associate with this event");

            progedit          = new ExtendedControls.ButtonExt();
            progedit.Text     = "P";
            progedit.Location = new Point(proglist.Right + 8, panelymargin);
            progedit.Size     = new Size(24, 24);
            progedit.Click   += Progedit_Click;
            toolTip.SetToolTip(progedit, "Edit associated program");

            paras          = new ExtendedControls.TextBoxBorder();
            paras.Text     = (cd.actiondata != null) ? cd.actiondata : "";
            paras.Location = new Point(progedit.Right + 8, panelymargin + 2);
            paras.Size     = proglist.Size;
            paras.ReadOnly = true;
            paras.Click   += Paras_Click;
            paras.SetTipDynamically(toolTip, "Click to enter parameters to pass to program");

            buttonKeys          = new ExtendedControls.ButtonExt();
            buttonKeys.Location = proglist.Location;
            buttonKeys.Size     = new Size((this.Width - 8 - 8 - panelxmargin * 2) / 2, 24);
            buttonKeys.Click   += Keypress_Click;
            toolTip.SetToolTip(buttonKeys, "Click to define keystrokes to send");

            buttonSay          = new ExtendedControls.ButtonExt();
            buttonSay.Location = new Point(buttonKeys.Right + 8, buttonKeys.Top);
            buttonSay.Size     = buttonKeys.Size;
            buttonSay.Click   += Saypress_Click;
            toolTip.SetToolTip(buttonSay, "Click to set speech to say");

            SuspendLayout();
            progmajortype.Controls.Add(proglist);
            progmajortype.Controls.Add(progedit);
            progmajortype.Controls.Add(paras);
            progmajortype.Controls.Add(buttonKeys);
            progmajortype.Controls.Add(buttonSay);
            Controls.Add(progmajortype);

            UpdateControls();

            ResumeLayout();
        }
Beispiel #13
0
        void CreateCondition( Group g , string initialfname = null , string initialcond = null, string initialvalue = null )
        {
            ExtendedControls.ComboBoxCustom fname = new ExtendedControls.ComboBoxCustom();
            fname.Size = new Size(140, 24);
            fname.DropDownHeight = 400;
            fname.Name = "Field";
            if (g.fieldnames != null)
                fname.Items.AddRange(g.fieldnames);
            fname.Items.Add("User Defined");

            if (initialfname != null)
            {
                if (fname.Items.IndexOf(initialfname) < 0)
                    fname.Items.Add(initialfname);

                fname.SelectedItem = initialfname;
            }

            fname.SelectedIndexChanged += Fname_SelectedIndexChanged;

            g.panel.Controls.Add(fname);                                                // 1st control

            ExtendedControls.ComboBoxCustom cond = new ExtendedControls.ComboBoxCustom();
            cond.Items.AddRange(JSONFilter.MatchNames);
            cond.SelectedIndex = 0;
            cond.Size = new Size(130, 24);
            cond.DropDownHeight = 400;

            if (initialcond != null)
                cond.Text = Tools.SplitCapsWord(initialcond);

            g.panel.Controls.Add(cond);         // must be next

            ExtendedControls.TextBoxBorder value = new ExtendedControls.TextBoxBorder();
            value.Size = new Size(190, 24);

            if (initialvalue != null)
                value.Text = initialvalue;

            g.panel.Controls.Add(value);         // must be next

            ExtendedControls.ButtonExt del = new ExtendedControls.ButtonExt();
            del.Size = new Size(24, 24);
            del.Text = "X";
            del.Click += ConditionDelClick;
            del.Tag = g;
            g.panel.Controls.Add(del);

            ExtendedControls.ButtonExt more = new ExtendedControls.ButtonExt();
            more.Size = new Size(24, 24);
            more.Text = "+";
            more.Click += ConditionClick;
            more.Tag = g;
            g.panel.Controls.Add(more);

            theme.ApplyToControls(g.panel);
            RepositionGroup(g);
            PositionPanels();
        }
Beispiel #14
0
 private void textBox_Range_KeyPress(object sender, KeyPressEventArgs e)
 {
     ExtendedControls.TextBoxBorder tbb = sender as ExtendedControls.TextBoxBorder;
     tbb.NumericKeyPressHandler(e);
 }
Beispiel #15
0
        public void Show(Form p, string lname, Icon icon, System.Drawing.Size size, System.Drawing.Point pos, string caption, Entry[] e, Object t)
        {
            logicalname = lname; // passed back to caller via trigger
            entries     = e;
            callertag   = t;     // 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.Length; i++)
            {
                Entry   ent = entries[i];
                Control c   = (Control)Activator.CreateInstance(ent.controltype);
                ent.control = c;
                c.Size      = ent.size;
                c.Location  = ent.pos;
                if (!(c is ExtendedControls.ComboBoxCustom))        // everything but get text
                {
                    c.Text = ent.text;
                }
                c.Tag = ent;     // point control tag at ent structure
                outer.Controls.Add(c);
                if (ent.tooltip != null)
                {
                    tt.SetToolTip(c, ent.tooltip);
                }

                if (c is ExtendedControls.ButtonExt)
                {
                    ExtendedControls.ButtonExt b = c as ExtendedControls.ButtonExt;
                    b.Click += (sender, ev) =>
                    {
                        Entry en = (Entry)(((Control)sender).Tag);
                        Trigger?.Invoke(logicalname, en.name, callertag);       // pass back the logical name of dialog, the name of the control, the caller tag
                    };
                }

                if (c is ExtendedControls.TextBoxBorder)
                {
                    ExtendedControls.TextBoxBorder tb = c as ExtendedControls.TextBoxBorder;
                    tb.Multiline = tb.WordWrap = ent.textboxmultiline;
                }

                if (c is ExtendedControls.CheckBoxCustom)
                {
                    ExtendedControls.CheckBoxCustom cb = c as ExtendedControls.CheckBoxCustom;
                    cb.Checked = ent.checkboxchecked;
                    cb.Click  += (sender, ev) =>
                    {
                        Entry en = (Entry)(((Control)sender).Tag);
                        Trigger?.Invoke(logicalname, en.name, callertag);       // pass back the logical name of dialog, the name of the control, the caller tag
                    };
                }

                if (c is ExtendedControls.ComboBoxCustom)
                {
                    ExtendedControls.ComboBoxCustom cb = c as ExtendedControls.ComboBoxCustom;
                    cb.Items.AddRange(ent.comboboxitems.Split(','));
                    if (cb.Items.Contains(ent.text))
                    {
                        cb.SelectedItem = ent.text;
                    }
                    cb.SelectedIndexChanged += (sender, ev) =>
                    {
                        Control ctr = (Control)sender;
                        if (ctr.Enabled)
                        {
                            Entry en = (Entry)(ctr.Tag);
                            Trigger?.Invoke(logicalname, en.name, callertag);       // pass back the logical name of dialog, the name of the control, the caller tag
                        }
                    };
                }
            }

            ShowInTaskbar = false;

            this.Icon = icon;

            theme.ApplyToForm(this, System.Drawing.SystemFonts.DefaultFont);

            Show(p);
        }
Beispiel #16
0
        // lab sets the items, def can be less or null
        public static List <string> ShowDialog(Form p, string caption, Icon ic, string[] lab, string[] def, bool multiline = false, string[] tooltips = null)
        {
            ITheme theme = ThemeableFormsInstance.Instance;

            int vstart   = theme.WindowsFrame ? 20 : 40;
            int vspacing = multiline ? 80 : 40;
            int lw       = 100;
            int lx       = 10;
            int tx       = 10 + lw + 8;

            Form prompt = new Form()
            {
                Width           = 600,
                Height          = 90 + vspacing * lab.Length + (theme.WindowsFrame ? 20 : 0),
                FormBorderStyle = FormBorderStyle.FixedDialog,
                Text            = caption,
                StartPosition   = FormStartPosition.CenterScreen,
                Icon            = ic
            };

            Panel outer = new Panel()
            {
                Dock = DockStyle.Fill, BorderStyle = BorderStyle.FixedSingle
            };

            prompt.Controls.Add(outer);

            Label textLabel = new Label()
            {
                Left = lx, Top = 8, Width = prompt.Width - 50, Text = caption
            };

            if (!theme.WindowsFrame)
            {
                outer.Controls.Add(textLabel);
            }

            Label[] lbs = new Label[lab.Length];
            ExtendedControls.TextBoxBorder[] tbs = new ExtendedControls.TextBoxBorder[lab.Length];

            ToolTip tt = new ToolTip();

            tt.ShowAlways = true;

            int y = vstart;

            for (int i = 0; i < lab.Length; i++)
            {
                lbs[i] = new Label()
                {
                    Left = lx, Top = y, Width = lw, Text = lab[i]
                };
                tbs[i] = new ExtendedControls.TextBoxBorder()
                {
                    Left       = tx,
                    Top        = y,
                    Width      = prompt.Width - 50 - tx,
                    Text       = (def != null && i < def.Length) ? def[i] : "",
                    Multiline  = multiline,     // set before height!
                    Height     = vspacing - 20,
                    ScrollBars = (multiline) ? ScrollBars.Vertical : ScrollBars.None,
                    WordWrap   = multiline
                };
                outer.Controls.Add(lbs[i]);
                outer.Controls.Add(tbs[i]);

                if (tooltips != null && i < tooltips.Length)
                {
                    tt.SetToolTip(lbs[i], tooltips[i]);
                    tbs[i].SetTipDynamically(tt, tooltips[i]);      // no container here, set tool tip on text boxes using this
                }

                y += vspacing;
            }

            ExtendedControls.ButtonExt confirmation = new ExtendedControls.ButtonExt()
            {
                Text = "Ok", Left = tbs[0].Right - 80, Width = 80, Top = y, DialogResult = DialogResult.OK
            };
            outer.Controls.Add(confirmation);
            confirmation.Click += (sender, e) => { prompt.Close(); };

            ExtendedControls.ButtonExt cancel = new ExtendedControls.ButtonExt()
            {
                Text = "Cancel", 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.ApplyToForm(prompt, System.Drawing.SystemFonts.DefaultFont);

            if (prompt.ShowDialog(p) == DialogResult.OK)
            {
                var r = (from ExtendedControls.TextBoxBorder t in tbs select t.Text).ToList();
                return(r);
            }
            else
            {
                return(null);
            }
        }
        private void Show(Icon icon, System.Drawing.Size size, System.Drawing.Point pos, string caption, string lname, Object callertag)
        {
            this.logicalname = lname;     // passed back to caller via trigger
            this.callertag   = callertag; // passed back to caller via trigger

            ITheme theme = ThemeableFormsInstance.Instance;

            FormBorderStyle = FormBorderStyle.FixedDialog;

            if (theme.WindowsFrame)
            {
                size.Height += 50;
            }

            Size = size;

            if (pos.X == -999)
            {
                StartPosition = FormStartPosition.CenterScreen;
            }
            else
            {
                Location      = pos;
                StartPosition = FormStartPosition.Manual;
            }

            Panel outer = new Panel()
            {
                Dock = DockStyle.Fill, BorderStyle = BorderStyle.FixedSingle
            };

            outer.MouseDown += FormMouseDown;
            outer.MouseUp   += FormMouseUp;

            Controls.Add(outer);

            this.Text = caption;

            Label textLabel = new Label()
            {
                Left = 4, Top = 8, Width = Width - 50, Text = caption
            };

            textLabel.MouseDown += FormMouseDown;
            textLabel.MouseUp   += FormMouseUp;

            if (!theme.WindowsFrame)
            {
                outer.Controls.Add(textLabel);
            }

            ToolTip tt = new ToolTip(components);

            tt.ShowAlways = true;
            for (int i = 0; i < entries.Count; i++)
            {
                Entry   ent = entries[i];
                Control c   = ent.controltype != null ? (Control)Activator.CreateInstance(ent.controltype) : ent.control;
                ent.control = c;
                c.Size      = ent.size;
                c.Location  = ent.pos;
                //System.Diagnostics.Debug.WriteLine("Control " + c.GetType().ToString() + " at " + c.Location + " " + c.Size);
                if (!(ent.controltype == null || c is ExtendedControls.ComboBoxCustom || c is ExtendedControls.CustomDateTimePicker || c is ExtendedControls.NumberBoxDouble || c is ExtendedControls.NumberBoxLong))         // everything but get text
                {
                    c.Text = ent.text;
                }
                c.Tag = ent;     // point control tag at ent structure
                outer.Controls.Add(c);
                if (ent.tooltip != null)
                {
                    tt.SetToolTip(c, ent.tooltip);
                }

                if (c is ExtendedControls.ButtonExt)
                {
                    ExtendedControls.ButtonExt b = c as ExtendedControls.ButtonExt;
                    b.Click += (sender, ev) =>
                    {
                        Entry en = (Entry)(((Control)sender).Tag);
                        Trigger?.Invoke(logicalname, en.controlname, this.callertag);       // pass back the logical name of dialog, the name of the control, the caller tag
                    };
                }
                else if (c is ExtendedControls.NumberBoxDouble)
                {
                    ExtendedControls.NumberBoxDouble cb = c as ExtendedControls.NumberBoxDouble;
                    cb.Minimum = ent.numberboxdoubleminimum;
                    cb.Maximum = ent.numberboxdoublemaximum;
                    double?v = ent.text.InvariantParseDoubleNull();
                    cb.Value = v.HasValue ? v.Value : cb.Minimum;
                    if (ent.numberboxformat != null)
                    {
                        cb.Format = ent.numberboxformat;
                    }
                    cb.ReturnPressed += (box) =>
                    {
                        Entry en = (Entry)(box.Tag);
                        Trigger?.Invoke(logicalname, en.controlname + ":Return", this.callertag);       // pass back the logical name of dialog, the name of the control, the caller tag
                    };
                }
                else if (c is ExtendedControls.NumberBoxLong)
                {
                    ExtendedControls.NumberBoxLong cb = c as ExtendedControls.NumberBoxLong;
                    cb.Minimum = ent.numberboxlongminimum;
                    cb.Maximum = ent.numberboxlongmaximum;
                    long?v = ent.text.InvariantParseLongNull();
                    cb.Value = v.HasValue ? v.Value : cb.Minimum;
                    if (ent.numberboxformat != null)
                    {
                        cb.Format = ent.numberboxformat;
                    }
                    cb.ReturnPressed += (box) =>
                    {
                        Entry en = (Entry)(box.Tag);
                        Trigger?.Invoke(logicalname, en.controlname + ":Return", this.callertag);       // pass back the logical name of dialog, the name of the control, the caller tag
                    };
                }
                else if (c is ExtendedControls.TextBoxBorder)
                {
                    ExtendedControls.TextBoxBorder tb = c as ExtendedControls.TextBoxBorder;
                    tb.Multiline        = tb.WordWrap = ent.textboxmultiline;
                    tb.ClearOnFirstChar = ent.clearonfirstchar;
                    tb.ReturnPressed   += (box) =>
                    {
                        Entry en = (Entry)(box.Tag);
                        Trigger?.Invoke(logicalname, en.controlname + ":Return", this.callertag);       // pass back the logical name of dialog, the name of the control, the caller tag
                    };
                }
                else if (c is ExtendedControls.CheckBoxCustom)
                {
                    ExtendedControls.CheckBoxCustom cb = c as ExtendedControls.CheckBoxCustom;
                    cb.Checked = ent.checkboxchecked;
                    cb.Click  += (sender, ev) =>
                    {
                        Entry en = (Entry)(((Control)sender).Tag);
                        Trigger?.Invoke(logicalname, en.controlname, this.callertag);       // pass back the logical name of dialog, the name of the control, the caller tag
                    };
                }


                if (c is ExtendedControls.CustomDateTimePicker)
                {
                    ExtendedControls.CustomDateTimePicker dt = c as ExtendedControls.CustomDateTimePicker;
                    DateTime t;
                    if (DateTime.TryParse(ent.text, System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.AssumeLocal, out t))     // assume local, so no conversion
                    {
                        dt.Value = t;
                    }

                    switch (ent.customdateformat.ToLower())
                    {
                    case "short":
                        dt.Format = DateTimePickerFormat.Short;
                        break;

                    case "long":
                        dt.Format = DateTimePickerFormat.Long;
                        break;

                    case "time":
                        dt.Format = DateTimePickerFormat.Time;
                        break;

                    default:
                        dt.CustomFormat = ent.customdateformat;
                        break;
                    }
                }

                if (c is ExtendedControls.ComboBoxCustom)
                {
                    ExtendedControls.ComboBoxCustom cb = c as ExtendedControls.ComboBoxCustom;
                    if (ent.comboboxdropdownsize != null)
                    {
                        cb.DropDownHeight = ent.comboboxdropdownsize.Value.Height;
                        cb.DropDownWidth  = ent.comboboxdropdownsize.Value.Width;
                    }

                    cb.Items.AddRange(ent.comboboxitems.Split(','));
                    if (cb.Items.Contains(ent.text))
                    {
                        cb.SelectedItem = ent.text;
                    }
                    cb.SelectedIndexChanged += (sender, ev) =>
                    {
                        Control ctr = (Control)sender;
                        if (ctr.Enabled)
                        {
                            Entry en = (Entry)(ctr.Tag);
                            Trigger?.Invoke(logicalname, en.controlname, this.callertag);       // pass back the logical name of dialog, the name of the control, the caller tag
                        }
                    };
                }
            }

            ShowInTaskbar = false;

            this.Icon = icon;

            theme.ApplyToFormStandardFontSize(this);

            //foreach( Control c in Controls[0].Controls )   System.Diagnostics.Debug.WriteLine("Control " + c.GetType().ToString() + " at " + c.Location + " " + c.Size);
        }
Beispiel #18
0
        public void Show(Form p, string lname, System.Drawing.Size size, string caption, Entry[] e, Object t)
        {
            logicalname = lname;
            entries     = e;
            tag         = t;

            EDDiscovery.EDDTheme theme = EDDiscovery.EDDTheme.Instance;

            Size            = size;
            FormBorderStyle = FormBorderStyle.FixedDialog;
            Text            = caption;
            StartPosition   = FormStartPosition.CenterScreen;

            Panel outer = new Panel()
            {
                Dock = DockStyle.Fill, BorderStyle = BorderStyle.FixedSingle
            };

            Controls.Add(outer);

            Label textLabel = new Label()
            {
                Left = 4, Top = 8, Width = Width - 50, Text = caption
            };

            if (!theme.WindowsFrame)
            {
                outer.Controls.Add(textLabel);
            }

            ToolTip tt = new ToolTip();

            tt.ShowAlways = true;
            for (int i = 0; i < entries.Length; i++)
            {
                Control c = (Control)Activator.CreateInstance(entries[i].controltype);
                entries[i].control = c;
                c.Size             = entries[i].size;
                c.Location         = entries[i].pos;
                c.Text             = entries[i].text;
                c.Tag = entries[i];
                outer.Controls.Add(c);
                if (entries[i].tooltip != null)
                {
                    tt.SetToolTip(c, entries[i].tooltip);
                }

                if (c is ExtendedControls.ButtonExt)
                {
                    ExtendedControls.ButtonExt b = c as ExtendedControls.ButtonExt;
                    b.Click += (sender, ev) =>
                    {
                        Entry en = (Entry)(((Control)sender).Tag);
                        if (Trigger != null)
                        {
                            Trigger(logicalname, en.name, tag);
                        }
                    };
                }

                if (c is ExtendedControls.TextBoxBorder)
                {
                    ExtendedControls.TextBoxBorder tb = c as ExtendedControls.TextBoxBorder;
                    tb.Multiline = tb.WordWrap = entries[i].textboxmultiline;
                }

                if (c is ExtendedControls.CheckBoxCustom)
                {
                    ExtendedControls.CheckBoxCustom cb = c as ExtendedControls.CheckBoxCustom;
                    cb.Checked = entries[i].checkboxchecked;
                    cb.Click  += (sender, ev) =>
                    {
                        Entry en = (Entry)(((Control)sender).Tag);
                        if (Trigger != null)
                        {
                            Trigger(logicalname, en.name, tag);
                        }
                    };
                }
            }

            ShowInTaskbar = false;

            theme.ApplyToForm(this, System.Drawing.SystemFonts.DefaultFont);

            Show(p);
        }