private void Groupactionscombobox_SelectedIndexChanged(object sender, EventArgs e)
        {
            ExtendedControls.ExtComboBox cb = sender as ExtendedControls.ExtComboBox;

            if (cb.SelectedIndex > 0)
            {
                Group  selected = cb.Tag as Group;
                string action   = (string)cb.SelectedItem;

                List <Group> todelete = new List <Group>();
                bool         change   = false;
                for (int i = 0; i < groups.Count; i++)
                {
                    Group g = groups[i];

                    if (g.IsGroupName)
                    {
                        if (g == selected)
                        {
                            change = true;
                        }
                        else if (change == true)
                        {
                            break;
                        }
                    }
                    else
                    {
                        if (change)
                        {
                            if (action == "Delete All")
                            {
                                todelete.Add(g);
                            }
                            else
                            {
                                g.usercontrol.PerformAction(action);
                            }
                        }
                    }
                }

                if (todelete.Count > 0)
                {
                    if (ExtendedControls.MessageBoxTheme.Show("Are you sure you want to delete all in this group?", "Warning", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
                    {
                        foreach (Group g in todelete)
                        {
                            g.Dispose();
                            groups.Remove(g);
                        }

                        PositionGroups(false);
                    }
                }


                cb.SelectedIndex = 0;
            }
        }
        private void Evlist_SelectedIndexChanged(object sender, EventArgs e)                // EVENT list changed
        {
            ExtendedControls.ExtComboBox b = sender as ExtendedControls.ExtComboBox;
            Group g = (Group)b.Tag;

            if (g.condlist.Count == 0)                  // if no conditions, create one..
            {
                if (g.evlist.Text.Equals("onKeyPress")) // special fill in for some events..
                {
                    CreateCondition(g, "KeyPress", "== (Str)", "");
                }
                else
                {
                    CreateCondition(g);
                }
            }
            else
            {
                g.variables = CreateVariables(g.evlist?.Text); // rework out variables

                foreach (var c in g.condlist)                  // clear any tool tips
                {
                    c.fname.EndButtonEnable = (g.variables?.Count ?? 0) > 0;
                    c.fname.SetTipDynamically(toolTip, "");
                }
            }

            FixUpGroups();                      // and reposition and maybe turn on/off the group outer cond
        }
        private void Stepname_SelectedIndexChanged(object sender, EventArgs e)                // EVENT list changed
        {
            ExtendedControls.ExtComboBox b = sender as ExtendedControls.ExtComboBox;

            if (b.Enabled)
            {
                Group g     = (Group)b.Tag;
                int   gstep = groups.IndexOf(g);

                ActionBase curact = curprog.GetStep(gstep);

                if (curact == null || !curact.Name.Equals(b.Text))
                {
                    ActionBase a = ActionBase.CreateAction(b.Text);

                    if (!a.ConfigurationMenuInUse || a.ConfigurationMenu(this, actioncorecontroller, currentvarlist))
                    {
                        curprog.SetStep(gstep, a);
                        g.checkit = a;
                        SetValue(g.value, a);
                        RepositionGroups();
                    }
                    else
                    {
                        b.Enabled = false; b.SelectedIndex = -1; b.Enabled = true;
                    }
                }
                else
                {
                    ActionConfig_Clicked(g.config, null);
                }
            }
        }
Example #4
0
        private void Grouptype_SelectedIndexChanged(object sender, EventArgs e)
        {
            ExtendedControls.ExtComboBox b = sender as ExtendedControls.ExtComboBox;
            Group g = (Group)b.Tag;

            CreateUserControl(g, Condition.AlwaysTrue());
        }
Example #5
0
        private void comboBoxClickThruKey_SelectedIndexChanged(object sender, EventArgs e)
        {
            ExtendedControls.ExtComboBox c = sender as ExtendedControls.ExtComboBox;
            Keys k = c.Text.ToVkey();

            EDDConfig.Instance.ClickThruKey = k;
        }
        public bool Set(string controlname, string value)      // set value of dialog control
        {
            Entry t = entries.Find(x => x.controlname.Equals(controlname, StringComparison.InvariantCultureIgnoreCase));

            if (t != null)
            {
                Control c = t.control;
                if (c is ExtendedControls.ExtTextBox)
                {
                    (c as ExtendedControls.ExtTextBox).Text = value;
                    return(true);
                }
                else if (c is Label)
                {
                    (c as Label).Text = value;
                    return(true);
                }
                else if (c is ExtendedControls.ExtCheckBox)
                {
                    (c as ExtendedControls.ExtCheckBox).Checked = !value.Equals("0");
                    return(true);
                }
                else if (c is ExtendedControls.ExtComboBox)
                {
                    ExtendedControls.ExtComboBox cb = c as ExtendedControls.ExtComboBox;
                    if (cb.Items.Contains(value))
                    {
                        cb.Enabled      = false;
                        cb.SelectedItem = value;
                        cb.Enabled      = true;
                        return(true);
                    }
                }
                else if (c is ExtendedControls.NumberBoxDouble)
                {
                    var    cn = c as ExtendedControls.NumberBoxDouble;
                    double?v  = value.InvariantParseDoubleNull();
                    if (v.HasValue)
                    {
                        cn.Value = v.Value;
                        return(true);
                    }
                }
                else if (c is ExtendedControls.NumberBoxLong)
                {
                    var  cn = c as ExtendedControls.NumberBoxLong;
                    long?v  = value.InvariantParseLongNull();
                    if (v.HasValue)
                    {
                        cn.Value = v.Value;
                        return(true);
                    }
                }
            }

            return(false);
        }
        private void Grouptype_SelectedIndexChanged(object sender, EventArgs e)
        {
            ExtendedControls.ExtComboBox b = sender as ExtendedControls.ExtComboBox;
            Group g = (Group)b.Tag;

            CreateUserControl(g, Condition.AlwaysTrue());
            ExtendedControls.Theme.Current.ApplyDialog(g.usercontrol);
            g.usercontrol.Scale(this.CurrentAutoScaleFactor());
            PositionGroups(true);
        }
Example #8
0
        private void Stdtrigger_SelectedIndexChanged(object sender, EventArgs e)
        {
            Group g = ((Control)sender).Tag as Group;

            ExtendedControls.ExtComboBox c = sender as ExtendedControls.ExtComboBox;

            if (!disabletriggers && c.SelectedIndex >= 1)
            {
                g.triggercondition = new ConditionLists(EDDProfiles.StandardTriggers[c.SelectedIndex - 1].TripCondition);
                g.backcondition    = new ConditionLists(EDDProfiles.StandardTriggers[c.SelectedIndex - 1].BackCondition);
            }
        }
        public string Get(string controlname)      // return value of dialog control
        {
            Entry t = entries.Find(x => x.controlname.Equals(controlname, StringComparison.InvariantCultureIgnoreCase));

            if (t != null)
            {
                Control c = t.control;
                if (c is ExtendedControls.ExtTextBox)
                {
                    string s = (c as ExtendedControls.ExtTextBox).Text;
                    if (t.textboxescapeonreport)
                    {
                        s = s.EscapeControlChars();
                    }
                    return(s);
                }
                else if (c is Label)
                {
                    return((c as Label).Text);
                }
                else if (c is ExtendedControls.ExtCheckBox)
                {
                    return((c as ExtendedControls.ExtCheckBox).Checked ? "1" : "0");
                }
                else if (c is ExtendedControls.ExtDateTimePicker)
                {
                    return((c as ExtendedControls.ExtDateTimePicker).Value.ToString("yyyy/dd/MM HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture));
                }
                else if (c is ExtendedControls.NumberBoxDouble)
                {
                    var cn = c as ExtendedControls.NumberBoxDouble;
                    return(cn.IsValid ? cn.Value.ToStringInvariant() : "INVALID");
                }
                else if (c is ExtendedControls.NumberBoxLong)
                {
                    var cn = c as ExtendedControls.NumberBoxLong;
                    return(cn.IsValid ? cn.Value.ToStringInvariant() : "INVALID");
                }
                else if (c is ExtendedControls.ExtComboBox)
                {
                    ExtendedControls.ExtComboBox cb = c as ExtendedControls.ExtComboBox;
                    return((cb.SelectedIndex != -1) ? cb.Text : "");
                }
            }

            return(null);
        }
Example #10
0
        public override void Init(Condition cond, List <string> events, ActionCoreController cp, string appfolder, ActionFile actionfile,
                                  System.Func <string, List <BaseUtils.TypeHelpers.PropertyNameInfo> > func, Icon ic, ToolTip toolTip)
        {
            cd = cond;

            //this.BackColor = Color.Red; // for debug

            // layed out for 12 point.  UC below require 28 point area

            eventtype = new ExtendedControls.ExtComboBox();
            eventtype.Items.AddRange(events);
            eventtype.Location = new Point(panelxmargin, panelymargin);
            eventtype.Size     = new Size(140, 24);
            if (cd.EventName != null)
            {
                eventtype.SelectedItem = cd.EventName;
            }
            eventtype.SelectedIndexChanged += Eventtype_SelectedIndexChanged;

            Controls.Add(eventtype);

            uccond          = new ActionPackEditCondition();
            uccond.Location = new Point(eventtype.Right + 16, 0);
            uccond.Size     = new Size(200, 28);   // init all the panels to 0/this height, select widths
            uccond.Init(cond, ic, toolTip);
            uccond.onAdditionalNames += () => { return(func(eventtype.Text)); };

            Controls.Add(uccond);

            ActionProgram p = cond.Action.HasChars() ? actionfile.ProgramList.Get(cond.Action) : null;

            ActionProgram.ProgramConditionClass classifier = p != null ? p.ProgramClass : ActionProgram.ProgramConditionClass.Full;
            ucprog          = new ActionPackEditProgram();
            ucprog.Location = new Point(uccond.Right + 16, 0);
            ucprog.Size     = new Size(400, 28);   // 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(eventtype.Text)); };
            ucprog.SuggestedName     += () => { return(eventtype.Text); };
            ucprog.RefreshEvent      += () => { RefreshIt(); };
            Controls.Add(ucprog);
        }
Example #11
0
        public static void InitaliseComboBox(ExtendedControls.ExtComboBox cc, string last, bool incldockstartend = true)
        {
            cc.Enabled       = false;
            cc.DisplayMember = nameof(TravelHistoryFilter.Label);

            List <TravelHistoryFilter> el = new List <TravelHistoryFilter>()
            {
                TravelHistoryFilter.NoFilter,
                TravelHistoryFilter.FromHours(6),
                TravelHistoryFilter.FromHours(12),
                TravelHistoryFilter.FromHours(24),
                TravelHistoryFilter.FromDays(3),
                TravelHistoryFilter.FromWeeks(1),
                TravelHistoryFilter.FromWeeks(2),
                TravelHistoryFilter.LastMonth(),
                TravelHistoryFilter.LastQuarter(),
                TravelHistoryFilter.LastHalfYear(),
                TravelHistoryFilter.LastYear(),
                TravelHistoryFilter.LastTwoYears(),
                TravelHistoryFilter.LastThreeYears(),
                TravelHistoryFilter.Last(10),
                TravelHistoryFilter.Last(20),
                TravelHistoryFilter.Last(100),
                TravelHistoryFilter.Last(500),
            };

            if (incldockstartend)
            {
                el.Add(TravelHistoryFilter.LastDock());
                el.Add(TravelHistoryFilter.StartEnd());
            }

            cc.DataSource = el;

            int entry = el.FindIndex(x => x.Label == last);

            //System.Diagnostics.Debug.WriteLine(dbname + "=" + last + "=" + entry);
            cc.SelectedIndex = (entry >= 0) ? entry: 0;

            cc.Enabled = true;
        }
        private void TextChangedInLeft(object sender, EventArgs e)          // something changed in text field..
        {
            ExtendedControls.ExtTextBoxAutoComplete t  = sender as ExtendedControls.ExtTextBoxAutoComplete;
            Tuple <Group, Group.Conditions>         gc = t.Tag as Tuple <Group, Group.Conditions>;

            if (gc.Item1.variables != null)        // if variables associated
            {
                string text = t.Text;
                foreach (var v in gc.Item1.variables)
                {
                    if (text.Equals(v.Name))
                    {
                        t.SetTipDynamically(toolTip, v.Help ?? "");

                        if (v.DefaultCondition != null)
                        {
                            ExtendedControls.ExtComboBox cb = gc.Item2.cond;

                            if (ConditionEntry.MatchTypeFromString(cb.Text, out ConditionEntry.MatchType mt))
                            {
                                ConditionEntry.Classification mtc    = ConditionEntry.Classify(mt);
                                ConditionEntry.Classification defcls = ConditionEntry.Classify(v.DefaultCondition.Value);

                                if (mtc != defcls)
                                {
                                    System.Diagnostics.Debug.WriteLine("Select cond" + v.DefaultCondition.Value + " cur " + mt);
                                    cb.SelectedItem = ConditionEntry.MatchNames[(int)v.DefaultCondition.Value];
                                }
                            }
                        }

                        return;
                    }
                }
            }

            t.SetTipDynamically(toolTip, "");
        }
        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);
        }
Example #14
0
 private void ComboBoxCustomLanguage_SelectedIndexChanged(object sender, EventArgs e)
 {
     ExtendedControls.ExtComboBox c = sender as ExtendedControls.ExtComboBox;
     EDDConfig.Instance.Language = c.Items[c.SelectedIndex];
     ExtendedControls.MessageBoxTheme.Show(this, "Applies at next restart of ED Discovery".T(EDTx.UserControlSettings_Language), "Information".T(EDTx.Information), MessageBoxButtons.OK, MessageBoxIcon.Information);
 }
        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);
        }
Example #16
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.ExtPanelDropDown();
            progmajortype.Items.AddRange(new string[] { "Key", "Say", "Key+Say", "Full Program" });
            indextoclassifier = new ActionProgram.ProgramConditionClass[] { ActionProgram.ProgramConditionClass.Key, ActionProgram.ProgramConditionClass.Say,
                                                                            ActionProgram.ProgramConditionClass.KeySay, ActionProgram.ProgramConditionClass.Full };
            progmajortype.Location              = new Point(0, 0);
            progmajortype.Size                  = new Size(this.Width, this.Height); // outer panel aligns with this UC
            progmajortype.SelectedIndexChanged += PanelType_SelectedIndexChanged;
            toolTip.SetToolTip(progmajortype, "Use the selector (click on bottom right arrow) to select program class type");

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

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

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

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

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

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

            UpdateControls();

            ResumeLayout();
        }
Example #17
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);
        }