本文整理汇总了C#中ICommand.OnCreate方法的典型用法代码示例。如果您正苦于以下问题:C# ICommand.OnCreate方法的具体用法?C# ICommand.OnCreate怎么用?C# ICommand.OnCreate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICommand
的用法示例。
在下文中一共展示了ICommand.OnCreate方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CallMapToolLibrary
public void CallMapToolLibrary(string toolName)
{
switch (toolName)
{
case"CallMapByCoor":
CallMap.frmOpenMapByCoordinate frmCoor = new frmOpenMapByCoordinate(m_mapControl);
frmCoor.ShowDialog();
break;
case"CallMapByPolygon":
m_command = new CallMap.OpenMapByPolygon();
m_command.OnCreate(m_mapControl);
m_mapControl.CurrentTool = (ITool)m_command;
break;
//case "CallMapByCommon":
// CallMap.frmCallMapByCommon frmCommon = new frmCallMapByCommon(this.m_frmMian.OraCmd,this.m_mapControl,m_workSpace);
// frmCommon.ShowDialog();
// break;
}
}
示例2: SetCurrentTool
/// <summary>
/// 设定当前工具
/// </summary>
/// <params name="tool">ICommand</params>
public static void SetCurrentTool(ICommand tool)
{
tool.OnCreate(DataEditCommon.g_pAxMapControl.Object);
if (tool.Enabled)
{
DataEditCommon.g_pAxMapControl.CurrentTool = (ITool)tool;
}
else
{
System.Windows.Forms.MessageBox.Show("当前工具未激活!");
}
}
示例3: ucMapNavigate1_OnNavigate
private void ucMapNavigate1_OnNavigate(enumNavigate navigate, int scale)
{
switch (navigate)
{
case enumNavigate.Left:
PanMap(-0.3d, 0d);
break;
case enumNavigate.Up:
PanMap(0d, 0.3d);
break;
case enumNavigate.Right:
PanMap(0.3d, 0d);
break;
case enumNavigate.Down:
PanMap(0d, -0.3d);
break;
case enumNavigate.Full:
//ILayer pLayer = EngineAPI.GetLayerFromMapByName(this.Map, Hy.Common.UI.GT_COMMONNOUN.XZQChnName);
//if (pLayer == null)
//{
// return;
//}
//IActiveView pActiveView = this.ActiveView;
//pActiveView.Extent = pLayer.AreaOfInterest;
//pActiveView.Refresh();
if (pControlsMapFullExtentCommand == null)
{
pControlsMapFullExtentCommand = new ControlsMapFullExtentCommandClass();
pControlsMapFullExtentCommand.OnCreate(base.Object);
}
pControlsMapFullExtentCommand.OnClick();
break;
case enumNavigate.ZoomInOut:
base.MapScale = scale;
Refresh();
break;
default:
break;
}
//this.Refresh();
}
示例4: 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文件!");
}
//.........这里部分代码省略.........
示例5: 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;
}
}
}
}
示例6: 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();
}
}
示例7: AddCommand
public void AddCommand(ICommand cmdNew)
{
if (cmdNew == null)
return;
string strKey=cmdNew.GetType().FullName;
if (m_DictCommands.ContainsKey(strKey))
return;
cmdNew.OnCreate(m_Hook);
m_DictCommands.Add(strKey,cmdNew);
}
示例8: AddCommand
public void AddCommand(ICommand cmdNew)
{
if (cmdNew == null)
return;
string strKey=cmdNew.Name;
if (m_DictCommands.ContainsKey(strKey))
return;
cmdNew.OnCreate(m_Hook);
m_DictCommands.Add(strKey,cmdNew);
cmdNew.OnMessage += this.SendMessage;
}
示例9: uiCommandBar2_CommandClick
private void uiCommandBar2_CommandClick(object sender, Janus.Windows.UI.CommandBars.CommandEventArgs e)
{
if (e.Command.Key == "cmdPageSet")
{
/* if (this.axPageLayoutControl1.PageLayout.Page.Orientation == 2)
pageSetupDialog1.PageSettings.Landscape = true ;
else pageSetupDialog1.PageSettings.Landscape = false ; */
#region//ҳ������
//Show the page setup dialog storing the result.
DialogResult result = pageSetupDialog1.ShowDialog();
//set the printer settings of the preview document to the selected printer settings
document.PrinterSettings = pageSetupDialog1.PrinterSettings;
//set the page settings of the preview document to the selected page settings
document.DefaultPageSettings = pageSetupDialog1.PageSettings;
//due to a bug in PageSetupDialog the PaperSize has to be set explicitly by iterating through the
//available PaperSizes in the PageSetupDialog finding the selected PaperSize
int i;
IEnumerator paperSizes = pageSetupDialog1.PrinterSettings.PaperSizes.GetEnumerator();
paperSizes.Reset();
for (i = 0; i < pageSetupDialog1.PrinterSettings.PaperSizes.Count; ++i)
{
paperSizes.MoveNext();
if (((PaperSize)paperSizes.Current).Kind == document.DefaultPageSettings.PaperSize.Kind)
{
document.DefaultPageSettings.PaperSize = ((PaperSize)paperSizes.Current);
}
}
///initialize the current printer from the printer settings selected
///in the page setup dialog
IPaper paper;
paper = new PaperClass(); //create a paper object
IPrinter printer;
printer = new EmfPrinterClass(); //create a printer object
//in this case an EMF printer, alternatively a PS printer could be used
//initialize the paper with the DEVMODE and DEVNAMES structures from the windows GDI
//these structures specify information about the initialization and environment of a printer as well as
//driver, device, and output port names for a printer
paper.Attach(pageSetupDialog1.PrinterSettings.GetHdevmode(pageSetupDialog1.PageSettings).ToInt32(), pageSetupDialog1.PrinterSettings.GetHdevnames().ToInt32());
//pass the paper to the emf printer
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);
//.........这里部分代码省略.........