public EditViewModel() { CloseCommand = new RelayCommand((e) => { EditWindows.Hide(); var MainWindow = new MainWindow(); MainWindow.Show(); }); // CloseCommand = new RelayCommand((e) => { MainWindow.Show(); }); ChangeImageCommand = new RelayCommand((e) => { var EditWindow = new EditWindow(); OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "Media files (*.jpg;*.png;)|*.jpg;*.png|All files (*.*)|*.*"; if (openFileDialog.ShowDialog() == true) { imagelocation = openFileDialog.FileName; EditFood.ImagePath = imagelocation; var MainWindow = new MainWindow(); } }); SaveCommand = new RelayCommand((e) => { var MainWindow = new MainWindow(); MainViewModel = new MainViewModel(); MainViewModel.Food = EditFood; MainViewModel.MainWindows = MainWindow; MainWindow.DataContext = MainViewModel; EditWindows.Hide(); }); }
private void ShowNewForm(object sender, EventArgs e) { bool messageshow = false; foreach (var k in mustSave) { if (k) { messageshow = true; if (MessageBox.Show("There are still nodes not saved. Do you really want dismiss your changes?", "save", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) != DialogResult.Yes) { return; } for (var j = 0; j < mustSave.Count; j++) { mustSave[j] = false; } break; } } if (!messageshow && xmlModified) { if (MessageBox.Show("Current project is not saved, do you want close without saving the changes?", "save", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) != DialogResult.Yes) { return; } } toolStripButton1.Enabled = true; toolStripButton2.Enabled = true; if (formProject != null) { formProject.Hide(); editWindows.Hide(); log.Hide(); formProject.Close(); editWindows.Close(); log.Close(); } richTextBox1.Hide(); formChat.Hide(); editWindows = new EditWindows(); editWindows.MdiParent = this; editWindows.Parent = splitContainer2.Panel1; editWindows.Dock = DockStyle.Fill; editWindows.Show(); log = new Log(); log.MdiParent = this; log.Parent = splitContainer2.Panel2; log.Dock = DockStyle.Fill; log.Show(); formProject = new ProjectStructure(); formProject.MdiParent = this; formProject.Parent = splitContainer1.Panel1; formProject.Dock = DockStyle.Fill; formProject.Show(); xmlViewer = new Tools(); xmlViewer.MdiParent = this; xmlViewer.Parent = splitContainer2.Panel1; xmlViewer.Dock = DockStyle.Fill; Program.LogForm = log; XmlTools.LoadXML(""); XmlTools.FillMissingDataOnXML(); UpdateData(); if (e != null) { UpdateData(); } for (var k = 0; k < 8; k++) { mustSave[k] = false; } XmlModified(true); }