C # New Document CreateNewDocument

Source: Internet
Author: User

Copyright ESRI
//
All rights reserved Under the copyright laws of the States
and applicable international laws, treaties, and conventions.
//
Freely redistribute and use this sample code, with or
Without modification, provided you include the original copyright
Notice and use restrictions.
//
See the use restrictions at <your ArcGIS install Location>/developerkit10.0/userestrictions.txt.
//

Using System;
Using System.Drawing;
Using System.Runtime.InteropServices;
Using System.Windows.Forms;
Using ESRI. ArcGIS.ADF.BaseClasses;
Using ESRI. ArcGIS.ADF.CATIDs;
Using ESRI. Arcgis.controls;
Using ESRI. Arcgis.carto;
Using ESRI. Arcgis.systemui;

Namespace TemporalStatistics2008
{
<summary>
Summary description for CreateNewDocument.
</summary>
public class Createnewdocument:basecommand
{
Private Ihookhelper m_hookhelper = null;

Constructor
Public CreateNewDocument ()
{
Update the base properties
Base.m_category = ". NET Samples";
Base.m_caption = "NewDocument";
Base.m_message = "Create a new map";
Base.m_tooltip = "Create a new map";
Base.m_name = "Dotnettemplate_newdocumentcommand";
}

#region Overriden Class Methods

<summary>
Occurs when the This command is created
</summary>
<param name= "Hook" >instance of the Application</param>
public override void OnCreate (object hook)
{
if (M_hookhelper = = null)
M_hookhelper = new Hookhelperclass ();

M_hookhelper.hook = Hook;
}

<summary>
Occurs when the this command is clicked
</summary>
public override void OnClick ()
{
IMapControl3 Mapcontrol = null;

Get the Mapcontrol from the hook with 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 are an active edit session and whether edits has 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-save the current document
DialogResult res = MessageBox.Show ("Would to save the current document?", "Aoview", Messageboxbuttons.yesno, Mess Ageboxicon.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;
}

#endregion
}
}

C # New Document CreateNewDocument

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.