コード例 #1
0
        private void OnAddConsumerClicked(object sender, EventArgs e)
        {
            string   newName     = AddNameInput.Text;
            int      newCount    = (int)AddCountInput.Value;
            int      newWatts    = (int)AddWattsInput.Value;
            Consumer newConsumer = new Consumer(newName, newCount, newWatts);

            AllConsumers.Add(newConsumer);
            ConsumerSelection newForm = new ConsumerSelection(newConsumer, this);

            ConsumerForms.Add(newForm);
            ConsumerTable.Controls.Add(newForm);
            UpdateConsumption();
        }
コード例 #2
0
        public void PopulateConsumers()
        {
            ConsumerTable.Controls.Clear();
            ConsumerTable.RowStyles.Clear();

            foreach (Consumer consumer in AllConsumers)
            {
                ConsumerSelection form = new ConsumerSelection(consumer, this);
                ConsumerForms.Add(form);
                ConsumerTable.Controls.Add(form);

                Console.WriteLine($"Added {consumer.Name}");
            }

            UpdateConsumption();
        }