Beispiel #1
0
        public Status GetStatus()
        {
            using var lightpack = new ApiLightpack(_configuration.Host, _configuration.Port);

            return(lightpack.Connect()
                ? lightpack.GetStatus()
                : Status.Error);
        }
Beispiel #2
0
 /// <summary>
 /// Метод изменения состояния кнопки Connect/Disconnect и соединения
 /// </summary>
 private void ConnectChanged()
 {
     try
     {
         if (button1.Text == "Connect")
         {
             host     = textBox1.Text;
             port     = (int)numericUpDown1.Value;
             api.Host = host;
             api.Port = port;
             if (api.Connect())
             {
                 label15.Text         = "Version API: " + api.Version + ", Status: " + api.GetStatus().ToString();
                 button1.Text         = "Disconnect";
                 connectMenuItem.Text = "Disconnect";
                 string[] list = api.GetProfiles();
                 listBox1.Items.Clear();
                 foreach (string s in list)
                 {
                     listBox1.Items.Add(s);
                 }
                 connected = true;
             }
         }
         else
         {
             label15.Text = "---";
             connected    = false;
             api.UnLock();
             api.Disconnect();
             button1.Text         = "Connect";
             button2.Text         = "Lock";
             connectMenuItem.Text = "Connect";
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Сообщение: " + ex.Message + Environment.NewLine + "StackTrace: " + Environment.NewLine + ex.StackTrace, "Произошла ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Beispiel #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (button1.Text != "Disconnect")
            {
                api.Host   = textBox1.Text;
                api.Port   = Convert.ToInt32(textBox2.Text);
                api.ApiKey = textBox3.Text;
                api.Connect();
                if (api.Connected)
                {
                    button1.Text = "Disconnect";
                }

                label1.Text = "Version API - " + api.Version;

                label1.Text += " Auth:" + api.IsAuth.ToString();

                label1.Text += " Count leds:" + api.CountLeds.ToString();

                button3.Text = "Lock";

                button2.Enabled = api.IsLock;
                button4.Enabled = api.IsLock;
                button5.Enabled = api.IsLock;



                if (api.IsAuth)
                {
                    label6.Text = " Status:" + api.GetStatus().ToString();

                    button3.Enabled = true;
                    button6.Enabled = true;
                    string[] list = api.GetProfiles();
                    listBox1.Items.Clear();
                    foreach (string s in list)
                    {
                        listBox1.Items.Add(s);
                    }
                    listBox1.Enabled = true;
                }
                else
                {
                    button3.Enabled  = false;
                    button6.Enabled  = false;
                    listBox1.Enabled = false;
                }
            }
            else
            {
                api.UnLock();
                api.Disconnect();
                label1.Text     = String.Empty;
                label6.Text     = String.Empty;
                button1.Text    = "Connect";
                button2.Enabled = false;
                button4.Enabled = false;
                button3.Enabled = false;
                button5.Enabled = false;
                button6.Enabled = false;

                listBox1.Enabled = false;
                listBox1.Items.Clear();
            }
        }