private void okButton_Click(object sender, EventArgs e) { if (textBox1.Text == "") { Warning warn = new Warning("Cannot save without a valid name."); warn.ShowDialog(); } else { filePath(textBox1.Text); Close(); } }
private void contentsBox_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == 13 && !ReferenceEquals(clientCommunication, null)) { object o = null; ISet<string> set = null; try { set = spreadsheet.SetContentsOfCell(nameBox.Text, contentsBox.Text); o = spreadsheet.GetCellValue(nameBox.Text); //Get the value of the contents just set. } catch (CircularException) { Warning warn = new Warning("Entering " + contentsBox.Text + " in cell " + nameBox.Text + " will cause a circular dependency."); warn.ShowDialog(); spreadsheet.SetContentsOfCell(nameBox.Text, ""); set = null; } catch (Exception l) { Warning warn = new Warning(l.Message); warn.ShowDialog(); spreadsheet.SetContentsOfCell(nameBox.Text, ""); contentsBox.Text = ""; set = null; } if (!ReferenceEquals(set, null)) { if (o is FormulaError) valueBox.Text = ((FormulaError)o).Reason; else { clientCommunication.ChangeCell(nameBox.Text, contentsBox.Text); spreadsheet.SetContentsOfCell(nameBox.Text, ""); //valueBox.Text = o.ToString(); } Thread t = new Thread(() => RenewCells(set)); t.IsBackground = true; t.Start(); } } else if (ReferenceEquals(clientCommunication, null)) MessageBox.Show("You are not connected to the server", "ERROR!"); }