Beispiel #1
0
        private void LoadTimers()
        {
            string stringSQL = "Select * From Timers";

            DataTable table = QueryHandler.DBExecuteQuery(stringSQL);

            // Add a StackPanel
            StackPanel timerStackPanel = new StackPanel {
                Orientation = Orientation.Vertical
            };

            for (int i = 0; i < table.Rows.Count; i++)
            {
                TimerModel timer = new TimerModel(table.Rows[i][0].ToString(), int.Parse(table.Rows[i][1].ToString()));
                // MessageBox.Show(timer.ToString());

                StackPanel buttonStackPanel = new StackPanel {
                    Orientation = Orientation.Horizontal
                };

                Button button = new Button();
                button.Click  += new RoutedEventHandler(this.Timer_Button_Click);
                button.Content = timer.ToString();
                buttonStackPanel.Children.Add(button);

                Button deleteButton = new Button();
                deleteButton.Click  += new RoutedEventHandler(this.Delete_Button_Click);
                deleteButton.Content = "Delete";
                buttonStackPanel.Children.Add(deleteButton);

                timerStackPanel.Children.Add(buttonStackPanel);
            }

            mainGrid.Children.Add(timerStackPanel);
        }
Beispiel #2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            TimerModel timer  = new TimerModel("Timer 1", 3601);
            TimerModel timer2 = new TimerModel("Timer 2", 3, 15, 5);

            MessageBox.Show(timer.ToString());
            MessageBox.Show(timer2.ToString());
        }