private void Form1_FormClosing(object sender, System.Windows.Forms.FormClosingEventArgs e) { if (hasChanged()) { DialogResult response = MessageBox.Show("Появились изменения.Сохранить сейчас? ", this.Text, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); if (response == DialogResult.Yes) { SaveAsToolStripMenuItem.PerformClick(); } else if (response == DialogResult.Cancel) { e.Cancel = true; } } }
private void NewToolStripMenuItem_Click(System.Object sender, System.EventArgs e) { if (hasChanged()) { DialogResult response = MessageBox.Show("Появились изменения.Сохранить сейчас?", this.Text, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); if (response == DialogResult.Yes) { SaveAsToolStripMenuItem.PerformClick(); } else if (response == DialogResult.Cancel) { return; } } props = new properties(); props.propertiesChanged += props_propertiesChanged; PropertyGrid1.SelectedObject = props; propertiesDictionary["Общая прибыль"] = 0; propertiesDictionary["Дом"] = 0; propertiesDictionary["Транспорт"] = 0; propertiesDictionary["Финансы"] = 0; propertiesDictionary["Свободное время"] = 0; propertiesDictionary["Постоянные платежи"] = 0; propertiesDictionary["Страховые выплаты"] = 0; propertiesDictionary["Дети"] = 0; propertiesDictionary["Прочие выплаты"] = 0; propertiesDictionary["Остаток"] = 0; PictureBox1.Invalidate(); original.d1 = 0; original.d2 = 0; original.d3 = 0; original.d4 = 0; original.d5 = 0; original.d6 = 0; original.d7 = 0; original.d8 = 0; original.d9 = 0; original.d10 = 0; openFileName = "Untitled.budget"; this.Text = string.Format("{0} - Менеджер домашней бухгалтерии", openFileName); }
private void NewToolStripMenuItem_Click(System.Object sender, System.EventArgs e) { if (hasChanged()) { DialogResult response = MessageBox.Show("Budget has changes. Save it now?", this.Text, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); if (response == DialogResult.Yes) { SaveAsToolStripMenuItem.PerformClick(); } else if (response == DialogResult.Cancel) { return; } } props = new properties(); props.propertiesChanged += props_propertiesChanged; PropertyGrid1.SelectedObject = props; propertiesDictionary["Total Income"] = 0; propertiesDictionary["Household"] = 0; propertiesDictionary["Transport"] = 0; propertiesDictionary["Finance"] = 0; propertiesDictionary["Leisure"] = 0; propertiesDictionary["Regular Bills"] = 0; propertiesDictionary["Insurance"] = 0; propertiesDictionary["Children"] = 0; propertiesDictionary["Other Bills"] = 0; propertiesDictionary["Remaining"] = 0; PictureBox1.Invalidate(); original.d1 = 0; original.d2 = 0; original.d3 = 0; original.d4 = 0; original.d5 = 0; original.d6 = 0; original.d7 = 0; original.d8 = 0; original.d9 = 0; original.d10 = 0; openFileName = "Untitled.budget"; this.Text = string.Format("{0} - Household Budget Calculator", openFileName); }
/// <summary> /// Initializes a new instance of the <see cref="RichTextEditor"/> class. /// </summary> public RichTextEditor() { InitializeComponent(); if (DesignMode) { return; } SaveAsToolStripMenuItem.BindCommand(rtbDoc.SaveAsCommand); SaveToolStripMenuItem.BindCommand(rtbDoc.SaveCommand); OpenToolStripMenuItem.BindCommand(rtbDoc.OpenFileCommand); NewToolStripMenuItem.BindCommand(rtbDoc.NewFileCommand); InsertImageToolStripMenuItem.BindCommand(rtbDoc.InsertImageCommand); tbrSave.BindCommand(rtbDoc.SaveCommand); tbrOpen.BindCommand(rtbDoc.OpenFileCommand); tbrNew.BindCommand(rtbDoc.NewFileCommand); rtbDoc.CurrentFileNameChanged += rtbDoc_CurrentFileNameChanged; }
private void openBudget(string fileName) { if (hasChanged()) { DialogResult response = MessageBox.Show("Появились изменения.Сохранить сейчас?", this.Text, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); if (response == DialogResult.Yes) { SaveAsToolStripMenuItem.PerformClick(); } else if (response == DialogResult.Cancel) { return; } } System.Runtime.Serialization.Formatters.Binary.BinaryFormatter formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); System.IO.FileStream fs = new System.IO.FileStream(fileName, System.IO.FileMode.Open); props = (properties)formatter.Deserialize(fs); fs.Close(); openFileName = System.IO.Path.GetFileName(fileName); PropertyGrid1.SelectedObject = props; props.removeEventHandlers(); props.addEventHandlers(); props.propertiesChanged += props_propertiesChanged; decimal decValue = default(decimal); decimal.TryParse(props.totalIncome, NumberStyles.Currency, CultureInfo.CurrentCulture, out decValue); propertiesDictionary["Общая прибыль"] = decValue; propertiesDictionary["Дом"] = props.houseHold.totalHousehold; propertiesDictionary["Транспорт"] = props.transport.totalTransport; propertiesDictionary["Финансы"] = props.finance.totalFinance; propertiesDictionary["Свободное время"] = props.leisure.totalLeisure; propertiesDictionary["Постоянные платежи"] = props.regularBills.totalRegularBills; propertiesDictionary["Страховые выплаты"] = props.insurance.totalInsurance; propertiesDictionary["Дети"] = props.children.totalChildren; propertiesDictionary["Прочие выплаты"] = props.otherBills.totalOtherBills; if (propertiesDictionary["Общая прибыль"] != 0) { propertiesDictionary["Остаток"] = propertiesDictionary["Общая прибыль"] - propertiesDictionary.Values.Skip(1).Take(8).Sum(); } else { propertiesDictionary["Остаток"] = 0; } PictureBox1.Invalidate(); original.d1 = propertiesDictionary["Общая прибыль"]; original.d2 = propertiesDictionary["Дом"]; original.d3 = propertiesDictionary["Транспорт"]; original.d4 = propertiesDictionary["Финансы"]; original.d5 = propertiesDictionary["Свободное время"]; original.d6 = propertiesDictionary["Постоянные платежи"]; original.d7 = propertiesDictionary["Страховые выплаты"]; original.d8 = propertiesDictionary["Дети"]; original.d9 = propertiesDictionary["Прочие выплаты"]; original.d10 = propertiesDictionary["Остаток"]; this.Text = string.Format("{0} - Менеджер домашней бухгалтерии", openFileName); }
private void openBudget(string fileName) { if (hasChanged()) { DialogResult response = MessageBox.Show("Budget has changes. Save it now?", this.Text, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); if (response == DialogResult.Yes) { SaveAsToolStripMenuItem.PerformClick(); } else if (response == DialogResult.Cancel) { return; } } System.Runtime.Serialization.Formatters.Binary.BinaryFormatter formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); System.IO.FileStream fs = new System.IO.FileStream(fileName, System.IO.FileMode.Open); props = (properties)formatter.Deserialize(fs); fs.Close(); openFileName = System.IO.Path.GetFileName(fileName); PropertyGrid1.SelectedObject = props; props.removeEventHandlers(); props.addEventHandlers(); props.propertiesChanged += props_propertiesChanged; decimal decValue = default(decimal); decimal.TryParse(props.totalIncome, NumberStyles.Currency, CultureInfo.CurrentCulture, out decValue); propertiesDictionary["Total Income"] = decValue; propertiesDictionary["Household"] = props.houseHold.totalHousehold; propertiesDictionary["Transport"] = props.transport.totalTransport; propertiesDictionary["Finance"] = props.finance.totalFinance; propertiesDictionary["Leisure"] = props.leisure.totalLeisure; propertiesDictionary["Regular Bills"] = props.regularBills.totalRegularBills; propertiesDictionary["Insurance"] = props.insurance.totalInsurance; propertiesDictionary["Children"] = props.children.totalChildren; propertiesDictionary["Other Bills"] = props.otherBills.totalOtherBills; if (propertiesDictionary["Total Income"] != 0) { propertiesDictionary["Remaining"] = propertiesDictionary["Total Income"] - propertiesDictionary.Values.Skip(1).Take(8).Sum(); } else { propertiesDictionary["Remaining"] = 0; } PictureBox1.Invalidate(); original.d1 = propertiesDictionary["Total Income"]; original.d2 = propertiesDictionary["Household"]; original.d3 = propertiesDictionary["Transport"]; original.d4 = propertiesDictionary["Finance"]; original.d5 = propertiesDictionary["Leisure"]; original.d6 = propertiesDictionary["Regular Bills"]; original.d7 = propertiesDictionary["Insurance"]; original.d8 = propertiesDictionary["Children"]; original.d9 = propertiesDictionary["Other Bills"]; original.d10 = propertiesDictionary["Remaining"]; this.Text = string.Format("{0} - Household Budget Calculator", openFileName); }