Пример #1
0
        /// <summary>
        /// Called when the user clicks a command.
        /// </summary>
        /// <remarks>Note to inheritors: override OnClick and use this method to
        ///             perform the actual work of the custom command.</remarks>
        public override void OnClick()
        {
            try
            {
                //MapAPI.NewDocument();
                //logger.Log(LogLevel.Info, EventType.UserManagement, AppMessage.MSG0103, null);
                bool isCurrrentNew = (String.IsNullOrEmpty(EnviVars.instance.MapControl.DocumentFilename) &&
                                      EnviVars.instance.MapControl.LayerCount > 0);
                if ((!String.IsNullOrEmpty(EnviVars.instance.MapControl.DocumentFilename) &&
                     EnviVars.instance.MapControl.CheckMxFile(EnviVars.instance.MapControl.DocumentFilename)) || isCurrrentNew)
                {
                    //ask the user whether he'd like to save the current doc
                    DialogResult res = XtraMessageBox.Show("保存当前文档?", "提示信息", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (res == DialogResult.Yes)
                    {
                        //if yes, launch the Save command
                        ICommand command = new CmdSaveFile();
                        command.OnCreate(EnviVars.instance.MapControl.Object);
                        command.OnClick();
                    }
                }
                EnviVars.instance.MapControl.ClearLayers();
                //(EnviVars.instance.PageLayoutControl.PageLayout as IGraphicsContainer).DeleteAllElements();
                IMap map = new MapClass();
                map.Name = "图层";
                EnviVars.instance.MapControl.Map = map;
                //EnviVars.instance.Synchronizer.ReplaceMap(map);

                EnviVars.instance.MapControl.DocumentFilename = string.Empty;
            }
            catch (Exception ex)
            {
                //logger.Log(LogLevel.Error, EventType.UserManagement, AppMessage.MSG0103, ex);
                Log.WriteLog(typeof(CmdClearLayers), ex);
            }
            finally
            {
                EnviVars.instance.MainForm.Text = EnviVars.instance.MapControl.DocumentFilename;
            }
        }
Пример #2
0
 private static void UnregisterFunction(Type registerType)
 {
     CmdSaveFile.ArcGISCategoryUnregistration(registerType);
 }