zoukankan      html  css  js  c++  java
  • C# 新建文档CreateNewDocument

    // Copyright 2010 ESRI
    //
    // All rights reserved under the copyright laws of the United States
    // and applicable international laws, treaties, and conventions.
    //
    // You may 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 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 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;
    }

    #endregion
    }
    }

  • 相关阅读:
    k64 datasheet学习笔记26--Oscillator (OSC)
    k64 datasheet学习笔记22---Direct Memory Access Controller (eDMA)
    k64 datasheet学习笔记21--Direct Memory Access Multiplexer (DMAMUX)
    System.getProperty()获取系统的配置信息
    Zoomit的用法总结
    .bat文件调用java类的main方法
    电脑快捷键总结
    验证java引用的小例子
    java随机数
    java调用删除文件的方法删除文件,却删除不干净
  • 原文地址:https://www.cnblogs.com/gisoracle/p/4827862.html
Copyright © 2011-2022 走看看