private void Stepname_SelectedIndexChanged(object sender, EventArgs e)                // EVENT list changed
        {
            ExtendedControls.ComboBoxCustom b = sender as ExtendedControls.ComboBoxCustom;

            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 #2
0
        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.TextBoxBorder)
                {
                    return((c as ExtendedControls.TextBoxBorder).Text);
                }
                else if (c is ExtendedControls.CheckBoxCustom)
                {
                    return((c as ExtendedControls.CheckBoxCustom).Checked ? "1" : "0");
                }
                else if (c is ExtendedControls.CustomDateTimePicker)
                {
                    return((c as ExtendedControls.CustomDateTimePicker).Value.ToString("yyyy/dd/MM HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture));
                }
                else if (c is ExtendedControls.ComboBoxCustom)
                {
                    ExtendedControls.ComboBoxCustom cb = c as ExtendedControls.ComboBoxCustom;
                    return((cb.SelectedIndex != -1) ? cb.Text : "");
                }
            }

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

            CreateUserControl(g, Condition.AlwaysTrue());
        }
        public static void InitaliseComboBox(ExtendedControls.ComboBoxCustom cc, string dbname)
        {
            cc.Enabled       = false;
            cc.DisplayMember = nameof(TravelHistoryFilter.Label);
            cc.DataSource    = new[]
            {
                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.Last(10),
                TravelHistoryFilter.Last(20),
                TravelHistoryFilter.Last(100),
                TravelHistoryFilter.Last(500),
            };

            string last  = SQLiteDBClass.GetSettingString(dbname, "");
            int    entry = Array.FindIndex((TravelHistoryFilter[])cc.DataSource, x => x.Label == last);

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

            cc.Enabled = true;
        }
Example #5
0
        public bool Set(string name, string value)
        {
            Entry t = Array.Find(entries, x => x.name.Equals(name, StringComparison.InvariantCultureIgnoreCase));

            if (t != null)
            {
                Control c = t.control;
                if (c is ExtendedControls.TextBoxBorder)
                {
                    (c as ExtendedControls.TextBoxBorder).Text = value;
                    return(true);
                }
                else if (c is ExtendedControls.CheckBoxCustom)
                {
                    (c as ExtendedControls.CheckBoxCustom).Checked = !value.Equals("0");
                    return(true);
                }
                else if (c is ExtendedControls.ComboBoxCustom)
                {
                    ExtendedControls.ComboBoxCustom cb = c as ExtendedControls.ComboBoxCustom;
                    if (cb.Items.Contains(value))
                    {
                        cb.Enabled      = false;
                        cb.SelectedItem = value;
                        cb.Enabled      = true;
                        return(true);
                    }
                }
            }

            return(false);
        }
Example #6
0
        private void comboBoxClickThruKey_SelectedIndexChanged(object sender, EventArgs e)
        {
            ExtendedControls.ComboBoxCustom c = sender as ExtendedControls.ComboBoxCustom;
            Keys k = c.Text.ToVkey();

            EDDConfig.Instance.ClickThruKey = k;
        }
Example #7
0
        private void Grouptype_SelectedIndexChanged(object sender, EventArgs e)
        {
            ExtendedControls.ComboBoxCustom b = sender as ExtendedControls.ComboBoxCustom;
            Group     g = (Group)b.Tag;
            Condition c = new Condition("", "", "", new List <ConditionEntry>()
            {
                new ConditionEntry("Condition", ConditionEntry.MatchType.AlwaysTrue, "")
            });

            CreateUserControl(g, c);
        }
Example #8
0
        private void Stdtrigger_SelectedIndexChanged(object sender, EventArgs e)
        {
            Group g = ((Control)sender).Tag as Group;

            ExtendedControls.ComboBoxCustom c = sender as ExtendedControls.ComboBoxCustom;

            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 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.TextBoxBorder)
                {
                    (c as ExtendedControls.TextBoxBorder).Text = value;
                    return(true);
                }
                else if (c is ExtendedControls.CheckBoxCustom)
                {
                    (c as ExtendedControls.CheckBoxCustom).Checked = !value.Equals("0");
                    return(true);
                }
                else if (c is ExtendedControls.ComboBoxCustom)
                {
                    ExtendedControls.ComboBoxCustom cb = c as ExtendedControls.ComboBoxCustom;
                    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);
        }
Example #10
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();
        }
Example #11
0
        private void Evlist_SelectedIndexChanged(object sender, EventArgs e)                // EVENT list changed
        {
            ExtendedControls.ComboBoxCustom b = sender as ExtendedControls.ComboBoxCustom;
            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);
                }
            }

            FixUpGroups();                      // and reposition and maybe turn on/off the group outer cond
        }
Example #12
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;
            anfunc = func;

            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 += Eventtype_SelectedIndexChanged;

            Controls.Add(eventtype);

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

            Controls.Add(uccond);

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

            ActionProgram.ProgramConditionClass classifier = p != null ? p.progclass : ActionProgram.ProgramConditionClass.Full;
            ucprog          = new ActionPackEditProgram();
            ucprog.Location = new Point(uccond.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(anfunc(eventtype.Text)); };
            ucprog.SuggestedName     += () => { return(eventtype.Text); };
            ucprog.RefreshEvent      += () => { RefreshIt(); };
            Controls.Add(ucprog);
        }
Example #13
0
        public static void InitaliseComboBox(ExtendedControls.ComboBoxCustom cc, string dbname)
        {
            cc.Enabled    = false;
            cc.DataSource = new[]
            {
                TravelHistoryFilter.FromHours(6),
                TravelHistoryFilter.FromHours(12),
                TravelHistoryFilter.FromHours(24),
                TravelHistoryFilter.FromDays(3),
                TravelHistoryFilter.FromWeeks(1),
                TravelHistoryFilter.FromWeeks(2),
                TravelHistoryFilter.LastMonth(),
                TravelHistoryFilter.Last(20),
                TravelHistoryFilter.NoFilter,
            };

            cc.DisplayMember = nameof(TravelHistoryFilter.Label);
            cc.SelectedIndex = SQLiteDBClass.GetSettingInt(dbname, DefaultTravelHistoryFilterIndex);
            cc.Enabled       = true;
        }
Example #14
0
        public static void InitaliseComboBox(ExtendedControls.ComboBoxCustom cc, string dbname, 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.Last(10),
                TravelHistoryFilter.Last(20),
                TravelHistoryFilter.Last(100),
                TravelHistoryFilter.Last(500),
            };

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

            cc.DataSource = el;

            string last  = SQLiteDBClass.GetSettingString(dbname, "");
            int    entry = el.FindIndex(x => x.Label == last);

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

            cc.Enabled = true;
        }
Example #15
0
        public string Get(string name)
        {
            Entry t = Array.Find(entries, x => x.name.Equals(name, StringComparison.InvariantCultureIgnoreCase));

            if (t != null)
            {
                Control c = t.control;
                if (c is ExtendedControls.TextBoxBorder)
                {
                    return((c as ExtendedControls.TextBoxBorder).Text);
                }
                else if (c is ExtendedControls.CheckBoxCustom)
                {
                    return((c as ExtendedControls.CheckBoxCustom).Checked ? "1" : "0");
                }
                else if (c is ExtendedControls.ComboBoxCustom)
                {
                    ExtendedControls.ComboBoxCustom cb = c as ExtendedControls.ComboBoxCustom;
                    return((cb.SelectedIndex != -1) ? cb.Text : "");
                }
            }

            return(null);
        }
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.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();
        }
        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);
        }
Example #18
0
        Group CreateGroup(string initialev = null, string initialaction = null, 
            string initialcondinner = null , string initialcondouter = null)
        {
            Panel p = new Panel();
            p.BorderStyle = BorderStyle.FixedSingle;

            ExtendedControls.ComboBoxCustom evliste = new ExtendedControls.ComboBoxCustom();
            evliste.Items.AddRange(EDDiscovery.EliteDangerous.JournalEntry.GetListOfEventsWithOptMethod(false).ToArray());
            evliste.Items.Add("All");
            evliste.Location = new Point(panelmargin, panelmargin);
            evliste.Size = new Size(140, 24);
            evliste.DropDownHeight = 400;
            evliste.Name = "EVList";
            if (initialev != null)
                evliste.Text = initialev;
            evliste.SelectedIndexChanged += Evlist_SelectedIndexChanged;
            p.Controls.Add(evliste);

            ExtendedControls.ComboBoxCustom aclist = new ExtendedControls.ComboBoxCustom();
            string[] actions = actionlist.Split(';');
            aclist.Items.AddRange(actions);
            aclist.Location = new Point(evliste.Location.X+evliste.Width+8, panelmargin);
            aclist.DropDownHeight = 400;
            aclist.Size = new Size(120, 24);
            aclist.Name = "ActionList";
            aclist.Enabled = actions.Count() > 1;           // 1 item, indicate disabled.. won't be displayed
            if (initialaction != null)
                aclist.Text = initialaction;
            else
                aclist.SelectedIndex = 0;
            aclist.Visible = false;
            p.Controls.Add(aclist);

            ExtendedControls.ComboBoxCustom cond = new ExtendedControls.ComboBoxCustom();
            cond.Items.AddRange(Enum.GetNames(typeof(JSONFilter.FilterType)));
            cond.SelectedIndex = 0;
            cond.Size = new Size(60, 24);
            cond.Visible = false;
            cond.Name = "InnerCond";
            if ( initialcondinner != null)
                cond.Text = initialcondinner;
            p.Controls.Add(cond);

            ExtendedControls.ComboBoxCustom condouter = new ExtendedControls.ComboBoxCustom();
            condouter.Items.AddRange(Enum.GetNames(typeof(JSONFilter.FilterType)));
            condouter.SelectedIndex = 0;
            condouter.Location = new Point(evliste.Location.X , panelmargin + conditionhoff);
            condouter.Size = new Size(60, 24);
            condouter.Enabled = condouter.Visible = false;
            if (initialcondouter != null)
                condouter.Text = initialcondouter;
            cond.Name = "OuterCond";
            p.Controls.Add(condouter);

            Label lab = new Label();
            lab.Text = " with group(s) above";
            lab.Location = new Point(condouter.Location.X + condouter.Width + 4, condouter.Location.Y + 3);
            lab.AutoSize = true;
            lab.Visible = false;
            p.Controls.Add(lab);

            ExtendedControls.ButtonExt up = new ExtendedControls.ButtonExt();
            up.Size = new Size(24, 24);
            up.Text = "^";
            up.Click += Up_Click;
            p.Controls.Add(up);

            int hoff = (aclist.Enabled) ? (aclist.Location.X + aclist.Width + 50) : (evliste.Location.X + evliste.Width + 50);

            Group g = new Group()
            {
                panel = p,
                evlist = evliste,
                upbutton = up,
                actionlist = aclist,
                outercond = condouter,
                innercond = cond,
                outerlabel = lab
            };

            p.Size = new Size(panelwidth, panelmargin + conditionhoff);
            up.Location = new Point(panelwidth - 20 - panelmargin - 4, panelmargin);

            groups.Add(g);

            if (initialev != null)
            {
                ChangeEventTypes(g);
            }

            up.Tag = g;
            evliste.Tag = g;
            panelVScroll.Controls.Add(p);

            theme.ApplyToControls(g.panel);
            RepositionGroup(g);
            PositionPanels();

            return g;
        }
Example #19
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();
        }
Example #20
0
 private void ComboBoxCustomLanguage_SelectedIndexChanged(object sender, EventArgs e)
 {
     ExtendedControls.ComboBoxCustom c = sender as ExtendedControls.ComboBoxCustom;
     EDDConfig.Instance.Language = c.Items[c.SelectedIndex];
     ExtendedControls.MessageBoxTheme.Show(this, "Applies at next restart of ED Discovery".Tx(this, "Language"), "Information".Tx(), MessageBoxButtons.OK, MessageBoxIcon.Information);
 }
Example #21
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);
        }