private void OnWxsChanged() { wxsWatcher.EnableRaisingEvents = false; DialogResult result = DialogResult.None; if (undoManager.HasChanges()) { Form mainForm = FindForm(); result = MessageBox.Show(mainForm, String.Format("An external program changed \"{0}\", do you want to load the changes from disk and ignore the changes in memory?", wxsFile.Name), "Reload?", MessageBoxButtons.YesNo, MessageBoxIcon.Question); } else { Form mainForm = FindForm(); result = MessageBox.Show(mainForm, String.Format("An external program changed \"{0}\", do you want to load the changes from disk?", wxsFile.Name), "Reload?", MessageBoxButtons.YesNo, MessageBoxIcon.Question); } if (result == DialogResult.Yes) { try { LoadWxsFile(); } catch (UnauthorizedAccessException) { MessageBox.Show(String.Format("Access is denied. ({0}))", wxsFile.Name), "Acces denied", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } catch (XmlException ex) { MessageBox.Show(String.Format("Failed to open file. ({0}) The xml is not valid:\r\n\r\n{1}", wxsFile.Name, ex.Message), "Open failed", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } catch (WixEditException ex) { MessageBox.Show(String.Format("Cannot open file:\r\n\r\n{0}", ex.Message), "Open failed", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } catch { MessageBox.Show(String.Format("Failed to open file. ({0}))", wxsFile.Name), "Open failed", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } UndoManager.Clear(); UndoManager.DocumentIsSaved(); if (wxsChanged != null) { wxsChanged(this, new EventArgs()); } } wxsWatcher.EnableRaisingEvents = true; }
public bool HasChanges() { return(UndoManager.HasChanges() || projectSettings.HasChanges() || IsNew); }