Beispiel #1
0
        public configControl()
        {
            InitializeComponent();
            configData deserialized = JsonConvert.DeserializeObject <configData>(File.ReadAllText(filePath));

            textBox1.Text = deserialized.ip;
            textBox2.Text = deserialized.port;
            textBox3.Text = deserialized.sampleTime.ToString();
            textBox4.Text = deserialized.maxSamples.ToString();
            textBox5.Text = deserialized.decimalPlaces.ToString();
        }
Beispiel #2
0
        //SEND
        private void button4_Click(object sender, EventArgs e)
        {
            //lista
            List <colorTag> listOfColors = new List <colorTag>();

            //sprawdzanie koloru kazdego przycisku, jesli jest inny niz transparent to wpisz do listy
            foreach (Control c in tableLayoutPanel2.Controls)
            {
                /* if(c.Tag == i.ToString()+j.ToString())*/ if (c.BackColor != Color.Transparent)
                {
                    char[] characters = c.Tag.ToString().ToCharArray();  //zmieniamy tag na string na char[]
                                                                         //zeby zmienic go na xy
                                                                         //zeby zrobic wydobywanie pojedynczych cyfr
                                                                         //z typ object
                    var cT = new colorTag
                    {
                        x = Int16.Parse(characters[0].ToString()),
                        y = Int16.Parse(characters[1].ToString()),
                        r = c.BackColor.R,
                        g = c.BackColor.G,
                        b = c.BackColor.B
                    };
                    listOfColors.Add(cT);
                }
            }
            //tworzenie wynikowego json'a
            string json = JsonConvert.SerializeObject(listOfColors, Formatting.Indented);
            //odczytanie ip i portu z pliku konfiguracyjnego
            //sciezka do pliku config
            const string filePath     = @"C:\Users\Klient\Documents\GitHub\RPiDG\DesktopApp\rpiDataGrabber\rpiDataGrabber\config.json";
            configData   deserialized = JsonConvert.DeserializeObject <configData>(File.ReadAllText(filePath));
            string       ip           = deserialized.ip;
            string       port         = deserialized.port.ToString();

            HttpClient client  = new HttpClient();
            var        content = new StringContent(json.ToString(), Encoding.UTF8, "application/json");
            var        result  = client.PostAsync("http://" + ip + ":" + port + "/setLeds.php", content).Result;

            //sciezka do pliku colors
            const string filePath1 = @"C:\Users\Klient\Desktop\colors.json";

            System.IO.File.WriteAllText(filePath1, json);
        }
Beispiel #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            var conf = new configData
            {
                ip            = textBox1.Text,
                port          = textBox2.Text,
                sampleTime    = Int16.Parse(textBox3.Text),
                maxSamples    = Int16.Parse(textBox4.Text),
                decimalPlaces = Int16.Parse(textBox5.Text)
            };

            Serialize(conf);

            // Inicjalizacja zmiennych do przekazania do metody MessageBox.Show.
            string            message = "Your configuration have been successfully saved.";
            string            caption = "Data Confirmation";
            MessageBoxButtons buttons = MessageBoxButtons.OK;

            // Wyswietl MessageBox.
            MessageBox.Show(message, caption, buttons);
        }