Exemple #1
0
        private void dgv_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            DataGridView dgv = (DataGridView)sender;

            // Return if its not in one of the data/file columns OR if this is the first time column is being populated
            if (e.ColumnIndex < 1 || e.RowIndex < 0 || dgv.Columns[e.ColumnIndex].Tag == null)
            {
                return;
            }
            PerformanceFile ctfFile = (PerformanceFile)dgv.Columns[e.ColumnIndex].Tag;

            // Do Nothing if Same Value
            if (ctfFile.entry[e.RowIndex] == dgv.Rows[e.RowIndex].Cells[e.ColumnIndex].Value)
            {
                return;
            }
            // Set to Default(Old) Value if the new value is null, Not with Grid/Dirt
            if (string.IsNullOrEmpty(dgv.Rows[e.RowIndex].Cells[e.ColumnIndex].FormattedValue.ToString()) &&
                currentPage.FilterIndex != CtfEditorFilterIndex.CSV)    // currentPage.parentTab != CtfEditorMainTabs.Grid
            {
                dgv.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = currentPage.ctfEntryInfo[e.RowIndex].defaultValue;
                //dgv.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = ctfFile.entry[e.RowIndex];
                return;
            }
            //MessageBox.Show(e.RowIndex.ToString());
            // Set the new value in the backend
            ctfFile.entry[e.RowIndex] = dgv.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
            if (!ctfFile.hasChanges)
            {
                dgv.Columns[e.ColumnIndex].HeaderText += "*";
            }
            ctfFile.hasChanges = true;
        }
        private void dataGridView_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            // Return if its not in one of the data/file columns OR if this is the first time column is being populated
            if (e.ColumnIndex < 0 || e.RowIndex == 0)
            {
                return;
            }
            PerformanceFile ctfFile = (PerformanceFile)dataGridView.Columns[e.ColumnIndex].Tag;
            //MessageBox.Show(e.RowIndex.ToString());
            // Set the new value in the backend
            FloatList fList = ((FloatList)ctfFile.entry[_rowIndex]);

            if (e.RowIndex == 1)
            {
                if (string.IsNullOrEmpty(dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].FormattedValue.ToString()))
                {
                    dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = fList.step;
                    return;
                }
                fList.step = (float)dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
                //MessageBox.Show(fList.unknown.ToString());
            }
            else
            {
                if (string.IsNullOrEmpty(dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].FormattedValue.ToString()))
                {
                    dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = fList.items[e.RowIndex - 2];
                    return;
                }
                fList.items[e.RowIndex - 2] = (float)dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
            }
            ctfFile.entry[_rowIndex] = fList;
            ctfFile.hasChanges       = true;
        }
Exemple #3
0
        private void dgv_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
        {
            DataGridView dgv = (DataGridView)sender;

            // Return if its not in one of the data/file columns OR if this is the first time column is being populated
            if (e.ColumnIndex < 1 || dgv.Columns[e.ColumnIndex].Tag == null)
            {
                return;
            }
            PerformanceFile ctfFile = (PerformanceFile)dgv.Columns[e.ColumnIndex].Tag;

            // Cancel and Return if the entry is not used
            if (!ctfFile.entry.ContainsKey(e.RowIndex))
            {
                e.Cancel = true;
                return;
            }
            // Bring out special editor for FloatList values
            if (dgv.Rows[e.RowIndex].Cells[e.ColumnIndex].ValueType == typeof(FloatList))
            {
                using (DGVListEditor editor = new DGVListEditor((CtfEditorGamePage)mainTabControl.SelectedTab.Tag, e.RowIndex))
                {
                    editor.ShowDialog();
                }
                e.Cancel = true;
            }
        }
        private void dataGridView_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
        {
            // Return if its not in one of the data/file columns
            if (e.ColumnIndex < 0)
            {
                return;
            }
            PerformanceFile ctfFile = (PerformanceFile)dataGridView.Columns[e.ColumnIndex].Tag;

            // Cancel if the current value is null
            if (string.IsNullOrEmpty(dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].FormattedValue.ToString()))
            {
                e.Cancel = true;
            }
        }
Exemple #5
0
 private void dgv_ColumnHeaderMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
 {
     if (e.ColumnIndex < 1)
     {
         return;
     }
     if (e.Clicks == 2 && e.Button == System.Windows.Forms.MouseButtons.Right)
     {
         DataGridView    dgv     = (DataGridView)sender;
         PerformanceFile ctfFile = (PerformanceFile)dgv.Columns[e.ColumnIndex].Tag;
         if (ctfFile.hasChanges && MessageBox.Show("The data in this CTF file has changed." + Environment.NewLine + Environment.NewLine +
                                                   "Are you sure you want to close it without saving?", Properties.Resources.AppTitleLong, MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.Cancel)
         {
             return;
         }
         currentPage.files.Remove(ctfFile);
         dgv.Columns.RemoveAt(e.ColumnIndex);
     }
 }