/// <summary> /// Occurs when this command is clicked /// </summary> public override void OnClick() { IMapControl3 mapControl = null; //get the MapControl from the hook in case the container is a ToolbarControl if (m_hookHelper.Hook is IToolbarControl) { mapControl = (IMapControl3)((IToolbarControl)m_hookHelper.Hook).Buddy; } //In case the container is MapControl else if (m_hookHelper.Hook is IMapControl3) { mapControl = (IMapControl3)m_hookHelper.Hook; } else { MessageBox.Show("Active control must be MapControl!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } //check to see if there is an active edit session and whether edits have been made DialogResult result; IEngineEditor engineEditor = new EngineEditorClass(); if ((engineEditor.EditState == esriEngineEditState.esriEngineStateEditing) && (engineEditor.HasEdits() == true)) { result = MessageBox.Show("Would you like to save your edits", "Save Edits", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); switch (result) { case DialogResult.Cancel: return; case DialogResult.No: engineEditor.StopEditing(false); break; case DialogResult.Yes: engineEditor.StopEditing(true); break; } } //allow the user to save the current document DialogResult res = MessageBox.Show("Would you like to save the current document?", "AoView", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (res == DialogResult.Yes) { //launch the save command ICommand command = new ControlsSaveAsDocCommandClass(); command.OnCreate(m_hookHelper.Hook); command.OnClick(); } //create a new Map IMap map = new MapClass(); map.Name = "Map"; //assign the new map to the MapControl mapControl.DocumentFilename = string.Empty; mapControl.Map = map; }
/// <summary> /// Occurs when this command is clicked /// </summary> public override void OnClick() { IMapControl3 mapControl = null; //get the MapControl from the hook in case the container is a ToolbarControl if (getSetHookHelper.Hook is IToolbarControl) { mapControl = (IMapControl3)((IToolbarControl)getSetHookHelper.Hook).Buddy; } //In case the container is MapControl else if (getSetHookHelper.Hook is IMapControl3) { mapControl = (IMapControl3)getSetHookHelper.Hook; } else { MessageBox.Show("Active control must be MapControl!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } //check to see if there is an active edit session and whether edits have been made DialogResult result; IEngineEditor engineEditor = new EngineEditorClass(); if ((engineEditor.EditState == esriEngineEditState.esriEngineStateEditing) && (engineEditor.HasEdits() == true)) { result = MessageBox.Show("Would you like to save your edits", "Save Edits", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); switch (result) { case DialogResult.Cancel: return; case DialogResult.No: engineEditor.StopEditing(false); break; case DialogResult.Yes: engineEditor.StopEditing(true); break; } } //allow the user to save the current document DialogResult res = MessageBox.Show("Would you like to save the current document?", "AoView", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (res == DialogResult.Yes) { //launch the save command ICommand command = new ControlsSaveAsDocCommandClass(); command.OnCreate(getSetHookHelper.Hook); command.OnClick(); } //create a new Map IMap map = new MapClass(); map.Name = "Map"; //assign the new map to the MapControl mapControl.DocumentFilename = string.Empty; mapControl.Map = map; }
/// <summary> /// Occurs when this command is clicked /// </summary> public override void OnClick() { //check to see if there is an active edit session and whether edits have been made IEngineEditor engineEditor = new EngineEditorClass(); if ((engineEditor.EditState == esriEngineEditState.esriEngineStateEditing) && engineEditor.HasEdits()) { DialogResult result = MessageBox.Show(@"Is save the edit?", @"Save the edit", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); switch (result) { case DialogResult.Cancel: return; case DialogResult.No: engineEditor.StopEditing(false); break; case DialogResult.Yes: engineEditor.StopEditing(true); break; } } //allow the user to save the current document DialogResult res = MessageBox.Show(@"Is save the current document?", @"Save document", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (res == DialogResult.Yes) { //launch the save command ICommand command = new ControlsSaveAsDocCommandClass(); command.OnCreate(m_controlsSynchronizer.PageLayoutControl.Object); command.OnClick(); } //create a new Map IMap map = new MapClass(); map.Name = "Map"; //assign the new map to the MapControl //m_controlsSynchronizer.MapControl.DocumentFilename = string.Empty; m_controlsSynchronizer.ReplaceMap(map); }