Exemplo n.º 1
0
        private void DeleteButton_Click(object sender, RoutedEventArgs e)
        {
            Message m = new Message("Are you sure you want to delete? This cannot be undone.", "Delete?", false, true);

            m.ShowDialog();
            int i = m.response;

            //DialogResult dr = MessageBox.Show("Are you sure you want to delete? This cannot be undone.", "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);
            if (i == 1)
            {
                TextBlock t      = AutomataGrid.Columns[1].GetCellContent(AutomataGrid.Items[selectedRow]) as TextBlock;
                int       result = Operations.Delete(
                    string.Format("DELETE FROM automata WHERE automata_name='{0}';", t.Text));
                if (result != 0)
                {
                    //MessageBox.Show("Error deleting automata (" + result + ").", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    new Message("Error deleting automata (" + result + ").", "Error", false, false).ShowDialog();
                    return;
                }
                d.BeginInvoke(new Action(() =>
                {
                    AutomataGrid.UnselectAll();
                    PopulateDataGrid();
                    AutomataGrid.Items.Refresh();
                }));
            }
        }
Exemplo n.º 2
0
        private void ToggleButton_Click(object sender, RoutedEventArgs e)
        {
            //toggle automata enabled
            var c = AutomataGrid.Columns[0].GetCellContent(AutomataGrid.Items[selectedRow]);
            ContentPresenter cp = (ContentPresenter)c;
            AutomataData     ad = (AutomataData)cp.Content;

            ad.Enabled = !ad.Enabled;

            //get name of changed status' automata
            TextBlock t = AutomataGrid.Columns[1].GetCellContent(AutomataGrid.Items[selectedRow]) as TextBlock;

            //update DB
            var result = Operations.Update(
                string.Format("UPDATE automata SET enabled={0}, updated_date='{1}' WHERE automata_name='{2}';",
                              ad.Enabled,
                              Operations.GetDateTime(),
                              t.Text));

            if (result != 0)
            {
                //MessageBox.Show("Error changing automata status (" + result + ").", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                new Message("Error changing automata status (" + result + ").", "Error", false, false).ShowDialog();
            }

            d.BeginInvoke(new Action(() =>
            {
                AutomataGrid.UnselectAll();
                AutomataGrid.Items.Refresh();
            }));
        }
Exemplo n.º 3
0
 public CellularAutomata(AutomataGrid grid, ICellularAutomataRule rule)
 {
     _grid = grid;
     _rule = rule;
 }