private void DimmLevelValueRefresh(object sender, EventArgs e)
        {
            if (sender is List <string> li)
            {
                if (Int32.Parse(li[0]) == ControllerIdx && Connected)
                {
                    DimLevelValue.Clear();
                    DimLevelValue.AddRange(li);

                    foreach (Control c in dimmLevelPanel.Controls)
                    {
                        if (c.GetType() == typeof(BunifuCustomLabel) &&
                            c.Name.Contains("dimmLevelLabel"))
                        {
                            int levelIndex = Int32.Parse(c.Name.Remove(0, "dimmLevelLabel".Length));
                            try
                            {
                                Invoke(new Action(() =>
                                {
                                    c.Text = DimLevelValue[levelIndex];
                                }));
                            }
                            catch (Exception ex)
                            {
                                Debug.WriteLine($"DimmLevelValueRefresh: {ex}");
                                return;
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void Apply_Click(object sender, EventArgs e)
        {
            DimLevelValue.Clear();
            DimLevelValue.AddRange(new string[dimmLevelPanel.ColumnCount]);

            foreach (Control c in dimmLevelPanel.Controls)
            {
                if (c.GetType() == typeof(BunifuMaterialTextbox) &&
                    c.Name.Contains("dimmTextBox"))
                {
                    int levelIndex = Int32.Parse(c.Name.Remove(0, "dimmTextBox".Length));
                    DimLevelValue[levelIndex] = c.Text;
                }
            }

            DimLevelValue[0] = ControllerIdx.ToString();

            UserChangedDimmLevelValue?.Invoke(this, e);

            Close();
        }