Beispiel #1
0
        public void SetPatrameterTemplate(Dictionary <int, GrblConfig.ParamDescription> parDescs)
        {
            List <string> categories = new List <string>();

            categoryDict  = new Dictionary <string, List <ParameterControl> >();
            parameterDict = new Dictionary <int, ParameterControl>();
            foreach (var keyval in parDescs)
            {
                GrblConfig.ParamDescription parDesc = keyval.Value;
                ParameterControl            parcont = new ParameterControl(parDesc);
                parcont.ParameterChanged   += parcont_ParameterChanged;
                parameterDict[parDesc.code] = parcont;
                foreach (string category in parDesc.groups)
                {
                    if (!categoryDict.ContainsKey(category))
                    {
                        categoryDict[category] = new List <ParameterControl>();
                        if (category.StartsWith("General"))
                        {
                            categories.Insert(0, category);
                        }
                        else
                        {
                            categories.Add(category);
                        }
                    }
                    categoryDict[category].Add(parcont);
                }
            }
            horizTabs.TabTexts = categories.ToArray();
            if (categories.Count > 0)
            {
                ShowCategory(categories[0]);
            }
        }
Beispiel #2
0
        public void SetPatrameterTemplate(Dictionary <int, GrblConfig.ParamDescription> parDescs)
        {
            List <string> categories = new List <string>();

            categoryDict = new Dictionary <string, List <GrblConfig.ParamDescription> >();
            foreach (var keyval in parDescs)
            {
                GrblConfig.ParamDescription parDesc = keyval.Value;
                foreach (string category in parDesc.groups)
                {
                    if (!categoryDict.ContainsKey(category))
                    {
                        categoryDict[category] = new List <GrblConfig.ParamDescription>();
                        if (category.StartsWith("General"))
                        {
                            categories.Insert(0, category);
                        }
                        else
                        {
                            categories.Add(category);
                        }
                    }
                    categoryDict[category].Add(parDesc);
                }
            }
            horizTabs.TabTexts = categories.ToArray();
        }
Beispiel #3
0
        public ParameterControl(GrblConfig.ParamDescription pardesc)
        {
            paramDesc      = pardesc;
            activeControls = new List <Control>();
            switch (pardesc.type)
            {
            case GrblConfig.ParamType.Bool:
            {
                CheckBox cb = new CheckBox();
                this.Controls.Add(cb);
                cb.AutoSize        = true;
                cb.Text            = pardesc.description;
                cb.Name            = "Bool_" + pardesc.code.ToString();
                cb.CheckedChanged += ValueChanged;
                activeControls.Add(cb);
                cb.Location = new Point(0, 0);
                this.Width  = cb.Width;
                this.Height = cb.Height;
            }
            break;

            case GrblConfig.ParamType.Float:
            case GrblConfig.ParamType.Int:
            {
                Label l = new Label();
                l.AutoSize = true;
                l.Text     = pardesc.description + " (" + pardesc.uints + "):";
                l.Name     = "Label_" + pardesc.code.ToString();
                this.Controls.Add(l);
                NumericUpDown nud = new NumericUpDown();
                nud.Name = "Numeric_" + pardesc.code.ToString();
                if (pardesc.type == GrblConfig.ParamType.Float)
                {
                    UpdateNumeric(nud, 3, -999999, 999999, pardesc.options);
                }
                else
                {
                    UpdateNumeric(nud, 0, 0, 999999, pardesc.options);
                }
                l.Location        = new Point(0, (nud.Height - l.Height) / 2);
                nud.Location      = new Point(l.Width, 0);
                nud.ValueChanged += ValueChanged;
                activeControls.Add(nud);
                this.Width  = nud.Location.X + nud.Width;
                this.Height = nud.Height;
                this.Controls.Add(nud);
            }
            break;

            case GrblConfig.ParamType.Mask:
            {
                Label l = new Label();
                l.AutoSize = true;
                l.Text     = pardesc.description + ":";
                l.Name     = "Label_" + pardesc.code.ToString();
                this.Controls.Add(l);
                isSimpleMask = IsSimpleMask(paramDesc.options);
                if (isSimpleMask)
                {
                    MultiSelect ms = new MultiSelect();
                    ms.SetSelectionTexts(paramDesc.options);
                    ms.Height             = 20;
                    ms.Width              = 22 * paramDesc.options.Length;
                    ms.MultiSelectionMode = true;
                    ms.SelectionChanged  += ms_SelectionChanged;
                    l.Location            = new Point(0, (ms.Height - l.Height) / 2);
                    ms.Location           = new Point(l.Width, 0);
                    activeControls.Add(ms);
                    this.Controls.Add(ms);
                    this.Width  = ms.Location.X + ms.Width;
                    this.Height = ms.Height;
                }
                else
                {
                    l.Location = new Point(0, 0);
                    int maxwidth = l.Width;
                    int h        = l.Height + 4;
                    if (pardesc.options != null)
                    {
                        for (int i = 0; i < pardesc.options.Length; i++)
                        {
                            CheckBox cb = new CheckBox();
                            cb.AutoSize        = true;
                            cb.Name            = "Mask_" + pardesc.code.ToString() + "_" + i.ToString();
                            cb.CheckedChanged += ValueChanged;
                            if (pardesc.options[i].Length > 0)
                            {
                                this.Controls.Add(cb);
                                cb.Text = pardesc.options[i];
                                int ident = 10;
                                cb.Location = new Point(ident, h);
                                h          += cb.Height;
                                if (ident + cb.Width > maxwidth)
                                {
                                    maxwidth = cb.Width + ident;
                                }
                            }
                            activeControls.Add(cb);
                        }
                    }
                    this.Width  = maxwidth;
                    this.Height = h;
                }
            }
            break;

            case GrblConfig.ParamType.Selection:
            {
                Label l = new Label();
                l.AutoSize = true;
                l.Text     = pardesc.description + ":";
                l.Name     = "Label_" + pardesc.code.ToString();
                this.Controls.Add(l);
                ComboBox cb = new ComboBox();
                cb.DropDownStyle         = ComboBoxStyle.DropDownList;
                cb.Name                  = "Selection_" + pardesc.code.ToString();
                cb.SelectedIndexChanged += ValueChanged;
                l.Location               = new Point(0, (cb.Height - l.Height) / 2);
                cb.Location              = new Point(l.Width, 0);
                if (pardesc.options != null)
                {
                    for (int i = 0; i < pardesc.options.Length; i++)
                    {
                        cb.Items.Add(paramDesc.options[i]);
                    }
                }
                activeControls.Add(cb);
                this.Width  = cb.Location.X + cb.Width;
                this.Height = cb.Height;
                this.Controls.Add(cb);
            }
            break;

            case GrblConfig.ParamType.String:
            {
                Label l = new Label();
                l.AutoSize = true;
                l.Text     = pardesc.description + ":";
                l.Name     = "Label_" + pardesc.code.ToString();
                this.Controls.Add(l);
                TextBox tb = new TextBox();
                tb.Name         = "String_" + pardesc.code.ToString();
                tb.TextChanged += ValueChanged;
                l.Location      = new Point(0, (tb.Height - l.Height) / 2);
                tb.Location     = new Point(l.Width, 0);
                activeControls.Add(tb);
                this.Width  = tb.Location.X + tb.Width;
                this.Height = tb.Height;
                this.Controls.Add(tb);
            }
            break;
            }
            minimumWidth = Width;
            UpdateColors();
        }