示例#1
0
 private void saveToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         if (codeTabControl.TabCount == 0)
         {
             return;
         }
         TabPage      currentTab = codeTabControl.SelectedTab;
         string       methodName = currentTab.Name;
         DataGridView dg         = (DataGridView)(currentTab.Controls.Find("codeGridView" + methodName, true)[0]);
         char[,] table = new char[16, 16];
         for (int i = 0; i < 16; i++)
         {
             for (int j = 0; j < 16; j++)
             {
                 table[i, j] = dg.Rows[i].Cells[j].Value.ToString()[0];
             }
         }
         OpenedProject.ChangeSource(methodName, table);
         OpenedProject.SaveFile(methodName);
     }
     catch (Exception exc)
     {
         MessageBox.Show(exc.Message);
     }
 }
示例#2
0
 private void dataGridView_CellEndEdit(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         if (!(sender is DataGridView) || OpenedProject == null)
         {
             return;
         }
         DataGridView dg = sender as DataGridView;
         char[,] source = new char[16, 16];
         for (int i = 0; i < 16; i++)
         {
             for (int j = 0; j < 16; j++)
             {
                 source[i, j] = (dg.Rows[i].Cells[j].Value != null)?dg.Rows[i].Cells[j].Value.ToString()[0]:'0';
             }
         }
         string methodName = dg.Name.Remove(0, "codeGridView".Length);
         OpenedProject.ChangeSource(methodName, source);
         this.LoadCodeToTab(codeTabControl.TabPages[codeTabControl.TabPages.IndexOfKey(methodName)]);
     }
     catch (Exception exc)
     {
         MessageBox.Show(exc.Message);
     }
 }
示例#3
0
 private void codeTextBox_Leave(object sender, EventArgs e)
 {
     try
     {
         if (!(sender is TextBox) || OpenedProject == null)
         {
             return;
         }
         TextBox tb      = sender as TextBox;
         bool    IsValid = tb.Lines.Length == 16;
         if (IsValid)
         {
             for (int i = 0; i < 16; i++)
             {
                 if (tb.Lines[i].Length != 16)
                 {
                     IsValid = false;
                     break;
                 }
             }
         }
         if (!IsValid)
         {
             MessageBox.Show("Table of code must be 16x16");
             tb.Focus();
             return;
         }
         char[,] source = new char[16, 16];
         for (int i = 0; i < 16; i++)
         {
             for (int j = 0; j < 16; j++)
             {
                 source[i, j] = tb.Lines[i][j];
             }
         }
         string methodName = tb.Name.Remove(0, "codeTextBox".Length);
         OpenedProject.ChangeSource(methodName, source);
         this.LoadCodeToTab(codeTabControl.TabPages[codeTabControl.TabPages.IndexOfKey(methodName)]);
     }
     catch (Exception exc)
     {
         MessageBox.Show(exc.Message);
     }
 }