当前位置: 首页>>代码示例>>C#>>正文


C# ICommand.OnClick方法代码示例

本文整理汇总了C#中ICommand.OnClick方法的典型用法代码示例。如果您正苦于以下问题:C# ICommand.OnClick方法的具体用法?C# ICommand.OnClick怎么用?C# ICommand.OnClick使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ICommand的用法示例。


在下文中一共展示了ICommand.OnClick方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ThreeDToolLibrary

        public void ThreeDToolLibrary(string toolName)
        {
            switch (toolName)
            {
                case"3DOpen":
                    m_command = new ControlsSceneOpenDocCommandClass();
                    break;

                case "Navigation":
                    m_command = new ControlsSceneNavigateToolClass();
                    break;

                case"3DZoomIn":
                    m_command = new ControlsSceneZoomInToolClass();
                    break;

                case "3DZoomOut":
                    m_command = new ControlsSceneZoomOutToolClass();
                    break;

                case "3DPan":
                    m_command = new ControlsScenePanToolClass();
                    break;

                case"3DExtent":
                    m_command = new ControlsSceneFullExtentCommandClass();
                    break;

                case"3DSel":
                    m_command = new ControlsSceneSelectGraphicsToolClass();
                    break;

            }
            if (m_command is ITool)
            {
                m_command.OnCreate(m_sceneControl.Object);
                m_sceneControl.CurrentTool = (ITool)m_command;
            }
            if (m_command is ICommand)
            {
                m_command.OnCreate(m_sceneControl.Object);
                m_command.OnClick();
            }
            m_command = null;

            if (toolName == "3DAddTIN")
            {
                FolderBrowserDialog fdlg = new FolderBrowserDialog();
                fdlg.Description = "打开TIN";
                if (fdlg.ShowDialog() == DialogResult.OK)
                {
                    IWorkspaceFactory wsFac = new TinWorkspaceFactoryClass();
                    if (wsFac.IsWorkspace(System.IO.Path.GetDirectoryName(fdlg.SelectedPath)))
                    {
                        ITinWorkspace tinWS = wsFac.OpenFromFile(System.IO.Path.GetDirectoryName(fdlg.SelectedPath), 0) as ITinWorkspace;
                        ITinLayer tinLyr = new TinLayerClass();
                        try
                        {
                            tinLyr.Dataset = tinWS.OpenTin(System.IO.Path.GetFileName(fdlg.SelectedPath));
                            this.m_sceneControl.Scene.AddLayer((ILayer)tinLyr,false);
                            SetTinAsBase(tinLyr);

                        }
                        catch
                        {
                            MessageBox.Show("请选择有效的TIN文件!");
                        }
                    }
                    else
                    {
                        MessageBox.Show("请选择有效的TIN文件!");
                        return;
                    }

                }
            }

            if (toolName == "3DAddDEM")
            {
                FolderBrowserDialog fdlg = new FolderBrowserDialog();
                fdlg.Description = "打开DEM";
                if (fdlg.ShowDialog() == DialogResult.OK)
                {
                    IWorkspaceFactory wsFac = new RasterWorkspaceFactoryClass();
                    if (wsFac.IsWorkspace(System.IO.Path.GetDirectoryName(fdlg.SelectedPath)))
                    {
                        IRasterWorkspace tinWS = wsFac.OpenFromFile(System.IO.Path.GetDirectoryName(fdlg.SelectedPath), 0) as IRasterWorkspace;
                        IRasterLayer rasLyr = new RasterLayerClass();
                        try
                        {
                            rasLyr.CreateFromDataset(tinWS.OpenRasterDataset(System.IO.Path.GetFileName(fdlg.SelectedPath)));
                            this.m_sceneControl.Scene.AddLayer((ILayer)rasLyr, false);
                            SetlayerSurface(rasLyr, 1);
                            //this.axSceneControl1.Refresh();
                        }
                        catch
                        {
                            MessageBox.Show("请选择有效的DEM文件!");
                        }

//.........这里部分代码省略.........
开发者ID:chinasio,项目名称:minegis,代码行数:101,代码来源:ToolLib.cs

示例2: NavigationToolLibrary

        public void NavigationToolLibrary(string toolName)
        {
            switch (toolName)
            {
                case"ZoomIn":
                    m_command = new ControlsMapZoomInToolClass();
                    break;

                case "ZoomOut":
                    m_command = new ControlsMapZoomOutToolClass();
                    break;

                case "Pan":
                    m_command = new ControlsMapPanToolClass();
                    break;

                case "FullExtent":
                    m_command = new ControlsMapFullExtentCommandClass();
                    m_mapControl.ActiveView.FocusMap.ClipGeometry = null;
                    m_mapControl.ActiveView.Refresh();
                    break;

                case "Back":
                    m_command = new ControlsMapZoomToLastExtentBackCommandClass();
                    break;

                case "Forward":
                    m_command = new ControlsMapZoomToLastExtentForwardCommandClass();
                    break;

                case"SelectFeature":
                    m_command = new ControlsSelectFeaturesToolClass();
                    break;

                case"SelectElement":
                    m_command = new ControlsSelectToolClass();
                    break;

                case"Identify":
                    m_command = new ControlsMapIdentifyToolClass();
                    break;

                case"ClearSel":
                    m_command = new ControlsClearSelectionCommandClass();
                    break;

            }
            if (this.CurrentControl == "map" && m_command is ITool)
            {
                m_command.OnCreate(m_mapControl);
                m_mapControl.CurrentTool = (ITool)m_command;
            }
            else if (this.CurrentControl == "pagelayout" && m_command is ITool)
            {
                m_command.OnCreate(m_pageLayoutControl);
                m_pageLayoutControl.CurrentTool = (ITool)m_command;
            }
            else if (this.CurrentControl == "map")
            {
                m_command.OnCreate(m_mapControl);
                m_command.OnClick();
            }
            else
            {
                m_command.OnCreate(m_pageLayoutControl);
                m_command.OnClick();
            }
        }
开发者ID:chinasio,项目名称:minegis,代码行数:68,代码来源:ToolLib.cs

示例3: StandardToolLibrary

        public void StandardToolLibrary(string toolName)
        {
            switch (toolName)
            {
                case "AddData":
                    m_command = new ControlsAddDataCommandClass();
                    break;
                case"New":
                    m_command = new CreateNewDocument();
                    break;
                case"Open":
                    m_command = new ControlsOpenDocCommandClass();
                    break;
                case"Save":
                    break;
                case"SaveAs":
                    m_command = new ControlsSaveAsDocCommandClass();
                    break;
                case "CADToVec":
                    m_command = new AddCADToFeatures();
                    break;

                case "CADToRas":
                    m_command = new AddCADToRaster();
                    break;
            }
            if(m_command!=null)
            {
                m_command.OnCreate(m_mapControl.Object);
                m_command.OnClick();
                m_command = null;
            }

            if (toolName == "Open")
            {
                m_frmMian.ControlsSynchronizer.ReplaceMap(m_mapControl.Map);
            }

            if (toolName == "AddTin")
            {
                FolderBrowserDialog fdlg = new FolderBrowserDialog();
                fdlg.Description = "打开TIN";
                if (fdlg.ShowDialog() == DialogResult.OK)
                {
                    IWorkspaceFactory wsFac = new TinWorkspaceFactoryClass();
                    if (wsFac.IsWorkspace(System.IO.Path.GetDirectoryName(fdlg.SelectedPath)))
                    {
                        ITinWorkspace tinWS = wsFac.OpenFromFile(System.IO.Path.GetDirectoryName(fdlg.SelectedPath), 0) as ITinWorkspace;
                        ITinLayer tinLyr = new TinLayerClass();
                        try
                        {
                            tinLyr.Dataset = tinWS.OpenTin(System.IO.Path.GetFileName(fdlg.SelectedPath));
                            tinLyr.Name = System.IO.Path.GetFileName(fdlg.SelectedPath);
                            this.m_mapControl.Map.AddLayer((ILayer)tinLyr);
                        }
                        catch
                        {
                            MessageBox.Show("请选择有效的TIN文件!");
                        }
                    }
                    else
                    {
                        MessageBox.Show("请选择有效的TIN文件!");
                        return;
                    }

                }
            }

            if (toolName == "AddDEM")
            {
                FolderBrowserDialog fdlg = new FolderBrowserDialog();
                fdlg.Description = "打开DEM";
                if (fdlg.ShowDialog() == DialogResult.OK)
                {
                    IWorkspaceFactory wsFac = new RasterWorkspaceFactoryClass();
                    if (wsFac.IsWorkspace(System.IO.Path.GetDirectoryName(fdlg.SelectedPath)))
                    {
                        IRasterWorkspace tinWS = wsFac.OpenFromFile(System.IO.Path.GetDirectoryName(fdlg.SelectedPath), 0) as IRasterWorkspace;
                        IRasterLayer rasLyr = new RasterLayerClass();
                        try
                        {
                            rasLyr.CreateFromDataset(tinWS.OpenRasterDataset(System.IO.Path.GetFileName(fdlg.SelectedPath)));
                            this.m_mapControl.Map.AddLayer((ILayer)rasLyr);
                        }
                        catch
                        {
                            MessageBox.Show("请选择有效的DEM文件!");
                        }

                    }
                    else
                    {
                        MessageBox.Show("请选择有效的DEM文件!");
                        return;
                    }

                }
            }
        }
开发者ID:chinasio,项目名称:minegis,代码行数:100,代码来源:ToolLib.cs

示例4: uiCommandBar2_CommandClick


//.........这里部分代码省略.........
                printer.Paper = paper;

                //set the page layout control's printer to the currently selected printer
                axPageLayoutControl1.Printer = printer;
                #endregion

            }
            if (e.Command.Key == "cmdPrintView")
            {

                #region//��ӡԤ��
                //initialize the currently printed page number
                m_CurrentPrintPage = 0;

                //check if a document is loaded into PageLayout  control
                if (axPageLayoutControl1.ActiveView.FocusMap == null) return;
                //set the name of the print preview document to the name of the mxd doc
                document.DocumentName = axPageLayoutControl1.DocumentFilename;

                //set the PrintPreviewDialog.Document property to the PrintDocument object selected by the user
                printPreviewDialog1.Document = document;
               //   printPreviewDialog1 .pa
                printPreviewDialog1.Document.DefaultPageSettings = pageSetupDialog1.PageSettings;

                //show the dialog - this triggers the document's PrintPage event
                printPreviewDialog1.ShowDialog();
                #endregion
            }
            if (e.Command.Key == "cmdPrint")
            {
                #region //��ӡ
                //allow the user to choose the page range to be printed
                printDialog1.AllowSomePages = true;
                //show the help button.
                printDialog1.ShowHelp = true;

                //set the Document property to the PrintDocument for which the PrintPage Event
                //has been handled. To display the dialog, either this property or the
                //PrinterSettings property must be set
                printDialog1.Document = document;

                //show the print dialog and wait for user input
                DialogResult result = printDialog1.ShowDialog();

                // If the result is OK then print the document.
                if (result == DialogResult.OK) document.Print();
                #endregion
            }
            if (e.Command.Key == "cmdOpenFile")
            {

                m_Command = new ControlsOpenDocCommandClass();
                m_Command.OnCreate(axPageLayoutControl1.Object);
                m_Command.OnClick();

            }
            if (e.Command.Key == "cmdSaveFile")
            {
                m_Command = new ControlsSaveAsDocCommandClass();
                m_Command.OnCreate(axPageLayoutControl1.Object);
                m_Command.OnClick();
            }
            if (e.Command.Key == "cmdSelectElement")
            {
                m_Command = new ControlsSelectToolClass();
                this.axPageLayoutControl1.CurrentTool = (ITool)m_Command;
                m_Command.OnCreate(axPageLayoutControl1.Object);
                m_Command.OnClick();
            }
            if (e.Command.Key == "CmdExportMapAsPicture")
            {
                ICommand pExportMapAsPicture = new ExportMapProj.CmdExoprtMapAsPicture();
                pExportMapAsPicture.OnCreate(m_pageLayoutControl.Object);
                pExportMapAsPicture.OnClick();

            }
            if (e.Command.Key == "cmdChoseTemplete")
            {
                ChoseTemple chosetem = new ChoseTemple();
                chosetem.ShowDialog();
                if (chosetem.m_templateName != "")
                {
                    this.axPageLayoutControl1.ActiveView.Clear();
                    this.axPageLayoutControl1.LoadMxFile(System.Windows.Forms.Application.StartupPath + @"\pagelayoutTemplate\" + chosetem.m_templateName, Type.Missing);
                    SetMapFrame();
                    IMaps maps = new Maps();
                    maps.Add(m_Map);
                    m_pageLayoutControl.PageLayout.ReplaceMaps(maps);
                    axPageLayoutControl1.ActiveView.Refresh();

                }
            }
            if (e.Command.Key == "cmdScaleSetandPrint")//��������
            {
                frmSetMapScale frmSMS = new frmSetMapScale();
                 double pnewMapScale=frmSMS.setMapScale(m_mapScale,this .axPageLayoutControl1 .ActiveView .FocusMap.MapScale );
                 this.axPageLayoutControl1.ActiveView.FocusMap.MapScale = pnewMapScale;
                 this.axPageLayoutControl1.ActiveView.Refresh();
            }
        }
开发者ID:chinasio,项目名称:minegis,代码行数:101,代码来源:frmPrintByAnyRegion.cs


注:本文中的ICommand.OnClick方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。