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
 private void buttLoad_Click(object sender, EventArgs e)
 {
     if (openFileDialog.ShowDialog() == DialogResult.OK)
     {
         try
         {
             string[] lines = File.ReadAllLines(openFileDialog.FileName);
             foreach (string line in lines)
             {
                 string[] vars = line.Split(new char[] { '$', '=', ' ' }, StringSplitOptions.RemoveEmptyEntries);
                 if (vars.Length < 2)
                 {
                     continue;
                 }
                 if (vars[0][0] == '#')
                 {
                     continue;
                 }
                 try
                 {
                     int code            = int.Parse(vars[0]);
                     ParameterControl pc = parameterDict[code];
                     pc.FromString(vars[1]);
                 }
                 catch { }
             }
             UpdateGuiByChanges();
         }
         catch
         {
             MessageBox.Show("Unable to read selected file.", "Read Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
Beispiel #3
0
 void UpdateParametersWidth()
 {
     foreach (Control con in panelParams.Controls)
     {
         ParameterControl pc = (ParameterControl)con;
         int w = panelParams.ClientSize.Width - 3;
         pc.Width = w > pc.minimumWidth ? w : pc.minimumWidth;
     }
 }
Beispiel #4
0
        private void buttProgram_Click(object sender, EventArgs e)
        {
            if (Global.grblComm == null)
            {
                return;
            }
            bool valChanged = false;

            foreach (var keyVal in parameterDict)
            {
                ParameterControl pc = keyVal.Value;
                if (pc.IsChanged && pc.Visible)
                {
                    Global.grblComm.SetGrblParameter(pc.paramDesc.code, pc.GetParamString());
                    valChanged = true;
                }
            }
            if (valChanged)
            {
                Global.grblComm.GetAllGrblParameters(); // refresh view
            }
        }