private void DGV1_MouseClick(object sender, MouseEventArgs e) { if (e.Button != System.Windows.Forms.MouseButtons.Right) { return; } int rowIndex = DGV1.HitTest(e.X, e.Y).RowIndex; int colIndex = DGV1.HitTest(e.X, e.Y).ColumnIndex; if (rowIndex >= 0 && colIndex == 2) { try { try { Color color = Color.Green; if (DGV1.Rows[rowIndex].Cells[colIndex].Value.ToString() != "") { color = (Color)System.Drawing.ColorTranslator.FromHtml(DGV1.Rows[rowIndex].Cells[colIndex].Value.ToString()); } colorDialog1.Color = color; } catch (Exception ex) { } DialogResult result = colorDialog1.ShowDialog(); if (result == DialogResult.OK) { DGV1.Rows[rowIndex].Cells[colIndex].Value = "#" + ColorToHexString(colorDialog1.Color); } } catch (Exception ex) { } } }
///Все управляющие кноки справочника. private void tb_N1_Click(object sender, EventArgs e) { //Filter. if ((sender == tb_N1) || (sender == cm_N1)) { if (!FormFilter.Filter(this, EntityBrief, DGV1.Left, DGV1.Top, ref filter)) { return; } //sys.SM(filter.FullQuery); Var.con.SelectDT(filter.FullQuerySQL, out dt); DGV1.DataSource = dt; } //Refresh. if ((sender == tb_N2) || (sender == cm_N2)) { Var.con.SelectDT(filter.FullQuerySQL, out dt); DGV1.DataSource = dt; } //ShowSQL. if (sender == cm_N8) { sys.SM(filter.FullQuerySQL, MessageType.Information); } //ShowMSQL. if (sender == cm_N9) { sys.SM(filter.FullQueryMSQL, MessageType.Information); } //Sum of the values //if (sender == cm_N10) sys.SM("Функционал пока не работает!"); //Details if (sender == cm_N8) { DGV1.GridInformation(); } //Export to Excel if (sender == cm_N6) { DGV1.ExportToExcel(); } //Save to CSV if (sender == cm_N7) { DGV1.DataGridViewToCSV(""); } //Форма поиска. if ((sender == tb_N6) || (sender == cm_N9)) { fs = FormSearch.FormSearchShow(this.Name, DGV1, null); } }
private void saveAsBtn_Click(object sender, EventArgs e) { double[,] A; double[,] B; DialogResult Result; DGV1.EndEdit(); DGV2.EndEdit(); A = ReadFromDGV(ref DGV1); B = ReadFromDGV(ref DGV2); Result = SFD.ShowDialog(); try { if (Result == DialogResult.OK) { File.Delete(SFD.FileName); StreamWriter FileFromTable = new StreamWriter(SFD.FileName); SaveFileStream(A, B, FileFromTable); CurrentOpenFileName = SFD.FileName; this.saveBtn.Enabled = true; MatrixUnsavedChangesDone = false; } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); this.Cursor = Cursors.Arrow; } }
private void triangular_Click(object sender, EventArgs e) { double[,] A; double[,] B; if (((Button)sender).Name == "triangularA") { DGV1.EndEdit(); A = ReadFromDGV(ref DGV1); B = MatrixTriangularForm(A); if (B != null) { OutputWindow otpWin = new OutputWindow(); otpWin.Show(); WriteToDGV(ref otpWin.otpDGV, B); } } else if (((Button)sender).Name == "triangularB") { DGV2.EndEdit(); A = ReadFromDGV(ref DGV2); B = MatrixTriangularForm(A); if (B != null) { OutputWindow otpWin = new OutputWindow(); otpWin.Show(); WriteToDGV(ref otpWin.otpDGV, B); } } }
private void saveBtn_Click(object sender, EventArgs e) { double[,] A, B; DGV1.EndEdit(); DGV2.EndEdit(); A = ReadFromDGV(ref DGV1); B = ReadFromDGV(ref DGV2); if (CurrentOpenFileName == "") { SFD.ShowDialog(); CurrentOpenFileName = SFD.FileName; } try { File.Delete(CurrentOpenFileName); StreamWriter FileFromTable = new StreamWriter(CurrentOpenFileName); SaveFileStream(A, B, FileFromTable); MatrixUnsavedChangesDone = false; } catch (Exception ex) { MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); this.Cursor = Cursors.Arrow; } // : DGV1.BackgroundColor = Color.LightGreen }
private void openBtn_Click(object sender, EventArgs e) { DialogResult Result; DGV1.EndEdit(); try { Result = OFD.ShowDialog(); if (Result == DialogResult.OK) { StreamReader FileToOpen = new StreamReader(OFD.FileName); OpenFileStream(FileToOpen); CurrentOpenFileName = OFD.FileName; txtRowCount1.Text = DGV1.RowCount.ToString(); txtColumnCount1.Text = DGV1.ColumnCount.ToString(); this.saveAsBtn.Enabled = true; this.saveBtn.Enabled = true; } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); this.Cursor = Cursors.Arrow; } }
private void reverse_Click(object sender, EventArgs e) { double[,] A; double[,] B; if (((Button)sender).Name == "reverseA") { DGV1.EndEdit(); A = ReadFromDGV(ref DGV1); B = InverseMatrix(A); if (B != null) { OutputWindow otpWin = new OutputWindow(); otpWin.Show(); WriteToDGV(ref otpWin.otpDGV, B); } } else if (((Button)sender).Name == "reverseB") { DGV2.EndEdit(); A = ReadFromDGV(ref DGV2); B = InverseMatrix(A); if (B != null) { OutputWindow otpWin = new OutputWindow(); otpWin.Show(); WriteToDGV(ref otpWin.otpDGV, B); } } }
private void Form1_Load(object sender, EventArgs e) { Build(); game = new Game(DGV1); // game.DGV = DGV1; DGV1.Invalidate(); this.SizeChanged += new EventHandler(Form1_SizeChanged); }
private void swapBtn_Click(object sender, EventArgs e) { double[,] A; DGV1.EndEdit(); DGV2.EndEdit(); A = ReadFromDGV(ref this.DGV1); CopyDGV(ref DGV2, ref DGV1); WriteToDGV(ref DGV2, A); MatrixUnsavedChangesDone = true; }
private void openToolStripMenuItem_Click(object sender, System.EventArgs e) { if (game == null) { game = new Game(DGV1); } game.Open(); HistoryList.Items.Clear(); DGV1.Invalidate(); }
private void btnMultiply_Click(object sender, EventArgs e) { double x; double[,] A; double[,] B; if (((Button)sender).Name == "btnMultiplyA") { DGV1.EndEdit(); A = ReadFromDGV(ref DGV1); if (txtMultiplyA.Text == "") { MessageBox.Show("Enter the value for the number 'x'.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else if (txtMultiplyA.Text == "-") { MessageBox.Show("Incorrect value. Field 'x' contains an invalid character.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { x = Convert.ToDouble(txtMultiplyA.Text); B = MultiplicationByNumber(A, x); OutputWindow otpWin = new OutputWindow(); otpWin.Show(); WriteToDGV(ref otpWin.otpDGV, B); } } else if (((Button)sender).Name == "btnMultiplyB") { DGV2.EndEdit(); A = ReadFromDGV(ref DGV2); if (txtMultiplyA.Text == "") { MessageBox.Show("Enter the value for the number 'x'.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else if (txtMultiplyA.Text == "-") { MessageBox.Show("Incorrect value. Field 'x' contains an invalid character.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { x = Convert.ToDouble(txtMultiplyB.Text); B = MultiplicationByNumber(A, x); OutputWindow otpWin = new OutputWindow(); otpWin.Show(); WriteToDGV(ref otpWin.otpDGV, B); } } }
private void multiplyBtn_Click(object sender, EventArgs e) { double[,] A; double[,] B; double[,] C; DGV1.EndEdit(); DGV2.EndEdit(); A = ReadFromDGV(ref DGV1); B = ReadFromDGV(ref DGV2); C = MatrixMultiplication(A, B); if (C != null) { OutputWindow otpWin = new OutputWindow(); otpWin.Show(); WriteToDGV(ref otpWin.otpDGV, C); } }
private void transposed_Click(object sender, EventArgs e) { double[,] A; double[,] B; if (((Button)sender).Name == "transposedA") { DGV1.EndEdit(); A = ReadFromDGV(ref DGV1); B = MatrixTransposition(A); WriteToDGV(ref DGV1, B); } else if (((Button)sender).Name == "transposedB") { DGV2.EndEdit(); A = ReadFromDGV(ref DGV2); B = MatrixTransposition(A); WriteToDGV(ref DGV2, B); } MatrixUnsavedChangesDone = true; }
private void substractBtn_Click(object sender, EventArgs e) { int m; int n; int k; int l; double[,] A; double[,] B; double[,] C; DGV1.EndEdit(); DGV2.EndEdit(); m = DGV1.RowCount; n = DGV1.ColumnCount; k = DGV2.RowCount; l = DGV2.ColumnCount; if (m != k & n != l) { MessageBox.Show("The dimensions of the matrices do not match. ", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else if (m == k & n == l) { A = new double[m, n]; B = new double[m, n]; C = new double[m, n]; A = ReadFromDGV(ref DGV1); B = ReadFromDGV(ref DGV2); for (int i = 0; i <= m - 1; i++) { for (int j = 0; j <= n - 1; j++) { C[i, j] = A[i, j] - B[i, j]; } } OutputWindow otpWin = new OutputWindow(); otpWin.Show(); WriteToDGV(ref otpWin.otpDGV, C); } }
private void detBtn_Click(object sender, EventArgs e) { double[,] A; DGV1.EndEdit(); if (((Button)sender).Name == "detABtn") { A = ReadFromDGV(ref DGV1); if (A != null) { txtDetA.Text = ((int)MatrixDeterminant(A)).ToString(); } } else if (((Button)sender).Name == "detBBtn") { A = ReadFromDGV(ref DGV2); if (A != null) { txtDetB.Text = ((int)MatrixDeterminant(A)).ToString(); } } }