/// <summary> /// Adds an element to the Toolbar /// </summary> /// <param name="item">Item to add to the Toolbar</param> /// <param name="root">Root Control</param> private void AddToolbarItem(IToolbarItem item, CommandBar root) { if (item == null) { return; } if (!root.PrimaryCommands.Contains(item)) { if (item is ToolbarButton button) { button.Model = this; } if (item.Position != -1 && item.Position <= root.PrimaryCommands.Count) { root.PrimaryCommands.Insert(item.Position, item); } else { item.Position = root.PrimaryCommands.Count; root.PrimaryCommands.Add(item); } } }
private void axMapControl1_OnMouseMove(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseMoveEvent e) { myCursor_axMap = getCursor(); this.Cursor = myCursor_axMap; Console.WriteLine(movecount++); //漫游(BaseTool方法) if (pan != null) { pan.OnMouseMove(e.button, e.shift, e.x, e.y); //调用前面定义的pan.cs的函数 } // 取得鼠标所在工具的索引号 int index = axToolbarControl1.HitTest(e.x, e.y, false); if (index != -1) { // 取得鼠标所在工具的 ToolbarItem IToolbarItem toolbarItem = axToolbarControl1.GetItem(index); // 设置状态栏信息 StatusLabel.Text = toolbarItem.Command.Message; } else { StatusLabel.Text = " 就绪 "; } // 显示当前比例尺 ScaleLabel.Text = " 比例尺 1:" + ((long)this.axMapControl1.MapScale).ToString(); // 显示当前坐标 CoordinateLabel.Text = " 当前坐标 X = " + e.mapX.ToString() + " Y = " + e.mapY.ToString() + " " + pMapUnits.ToString(); }
/// <summary> /// Moves a Toolbar element to a new location on the Toolbar /// </summary> /// <param name="item">Item to Move</param> /// <param name="root">Root Control</param> private void MoveToolbarItem(IToolbarItem item, CommandBar root) { if (root.PrimaryCommands.Contains(item)) { root.PrimaryCommands.Remove(item); root.PrimaryCommands.Insert(item.Position, item); } }
/// <summary> /// Removes an Element from the Toolbar /// </summary> /// <param name="item">Item to Remove</param> public void RemoveToolbarItem(IToolbarItem item) { var root = GetTemplateChild(RootControl) as CommandBar; if (root.PrimaryCommands.Contains(item)) { root.PrimaryCommands.Remove(item); } }
private void SetInfoLabel(object sender, int index) { AxToolbarControl toolbarControl = sender as AxToolbarControl; IToolbarControl2 toolbar = toolbarControl.Object as IToolbarControl2; IToolbarItem item = toolbar.GetItem(index); ICommand command = item.Command; txtInfo.Text = command.Message; }
/// <summary> /// An event handler that will be fired by a click on the custom item added in <see cref="OnAddToolbarItems"/> /// </summary> /// <param name="toolbarItem">The toolbar item that was clicked</param> /// <param name="id">The id of the toolbar item</param> async void ToolbarItem_OnPress(IToolbarItem toolbarItem, string id) { var locationPromptDialog = new ContentDialog { Title = "Custom Dialog", Content = toolbarItem.Attributes.Title + " was pressed.", PrimaryButtonText = "OK" }; await locationPromptDialog.ShowAsync(); }
/// <summary> /// 创建工具栏项的新实例。 /// </summary> /// <returns></returns> public System.Windows.Forms.ToolStripItem CreateToolbarItem() { System.Reflection.ConstructorInfo ci = this.Type.GetConstructor(new System.Type[] { }); object objInstance = ci.Invoke(new object[] { }); IToolbarItem toolbarItem = objInstance as IToolbarItem; toolbarItem.SetApplication(this.m_Application); return(toolbarItem as ToolStripItem); }
private void cmdAddSubMenu_Click(object sender, System.EventArgs e) { //Create a MenuDef object IMenuDef menuDef = new ToolbarSubMenu(); //Get the menu, which is the 6th item on the toolbar (indexing from 0) IToolbarItem toolbarItem = axToolbarControl1.GetItem(5); IToolbarMenu toolbarMenu = toolbarItem.Menu; //Add the sub-menu as the third item on the Navigation menu, making it start a new group toolbarMenu.AddSubMenu(menuDef, 2, true); cmdAddSubMenu.Enabled = false; }
private void axToolbarControl1_OnMouseMove(object sender, IToolbarControlEvents_OnMouseMoveEvent e) { // 取得鼠标所在工具的索引号 int index = axToolbarControl1.HitTest(e.x, e.y, false); if (index != -1) { // 取得鼠标所在工具的 ToolbarItem IToolbarItem toolbarItem = axToolbarControl1.GetItem(index); // 设置状态栏信息 MessageLabel.Text = toolbarItem.Command.Message; } else { MessageLabel.Text = " 就绪 "; } }
protected RibbonPanel GetRibbonPanel(IToolbarItem menuTool) { string targetToolStripName = "toolStrip_" + menuTool.Toolbar; var toolStrip = this.ribbon.Tabs.Find(x => x.Tag == null ? false : x.Tag.ToString() == targetToolStripName); if (toolStrip == null) { toolStrip = new RibbonTab(menuTool.Toolbar); toolStrip.Tag = targetToolStripName; if (menuTool.Toolbar == "Main") { this.ribbon.Tabs.Insert(0, toolStrip); this.ribbon.ActiveTab = toolStrip; } else if (menuTool.Toolbar == "Help") { int index = this.ribbon.Tabs.Count - 1; if (index < 0) { index = 0; } this.ribbon.Tabs.Insert(index, toolStrip); } else { int index = 1; if (this.ribbon.Tabs.Count == 0) { index = 0; } this.ribbon.Tabs.Insert(index, toolStrip); //this.ribbon.Tabs.Add(toolStrip); } } RibbonPanel group = toolStrip.Panels.Find(x => x.Text == menuTool.Group); if (group == null) { group = new RibbonPanel(menuTool.Group); toolStrip.Panels.Add(group); } return(group); }
/// <summary> /// 显示当前状态、比例尺和坐标 /// </summary> private void axMapControl1_OnMouseMove(object sender, IMapControlEvents2_OnMouseMoveEvent e) { // 取得鼠标所在工具的索引号 int index = axToolbarControl1.HitTest(e.x, e.y, false); if (index != -1) { // 取得鼠标所在工具的 ToolbarItem IToolbarItem toolbarItem = axToolbarControl1.GetItem(index); // 设置状态栏信息 MessageLabel.Text = toolbarItem.Command.Message; } else { MessageLabel.Text = " 就绪 "; } // 显示当前比例尺 ScaleLabel.Text = " 比例尺 1:" + ((long)this.axMapControl1.MapScale).ToString(); // 显示当前坐标 CoordinateLabel.Text = " 当前坐标 X = " + e.mapX.ToString() + " Y = " + e.mapY.ToString() + " " + pMapUnits.ToString(); }
public override void OnCreate(Plugin.Application.IApplicationRef hook) { if (hook == null) { return; } _AppHk = hook as Plugin.Application.IAppArcGISRef; if (_AppHk.PageLayoutControl == null) { return; } string progID = base._Name; int index = _AppHk.ToolbarControls.Find(progID); if (index != -1) { IToolbarItem toolItem = _AppHk.ToolbarControls.GetItem(index); _cmd = toolItem.Command; _tool = (ITool)_cmd; } }
/// <summary> /// Builds the extension's user interface. /// </summary> public void SetupUI(IDebugUI UI) { Application.DebuggerChanged += OnDebuggerChanged; /* == Menu Items == */ var clearAllMenu = UI.NewMenuItem(); { clearAllMenu.Label = "Clear all breakpoints"; clearAllMenu.Clicked += clearAllBreakpoints; } UI.AddMenuItem(clearAllMenu, "Debug"); /* == Toolbar Items == */ var panel = UI.NewToolbarPanel(); panel.Title = "Breakpoints"; // Add "Clear all breakpoints" item var clearAllItem = UI.NewToolbarItem(); { clearAllItem.ToolTip = "Clears all breakpoints"; clearAllItem.Clicked += clearAllBreakpoints; } // Add "Toggle breakpoint on mode change" item this.cpuModeToggleItem = UI.NewToolbarItem(isToggle: true); { this.cpuModeToggleItem.IsEnabled = Application.Debugger is Bochs.BochsDebugger; this.cpuModeToggleItem.ToolTip = "Toggle breakpoint on CPU mode change"; this.cpuModeToggleItem.Clicked += this.toggleBPOnModeChange; } panel.AddToolbarItem(clearAllItem); panel.AddToolbarItem(cpuModeToggleItem); // Add the panel to the UI UI.AddToolbarPanel(panel); // Add the search category UI.AddSearchCategory(new SearchCategory()); }
public void UpdateToolItem(IToolbarItem tool) { IMenuToolbarItem menuTool = tool as IMenuToolbarItem; if (menuTool == null) { return; } RibbonPanel group = GetRibbonPanel(menuTool); foreach (RibbonItem gItem in group.Items) { RibbonButton btn = gItem as RibbonButton; if (btn != null) { if (menuTool.Caption == btn.Text) { btn.DropDownItems.Clear(); foreach (var menuItem in menuTool.MenuItems) { RibbonItem item = new RibbonButton(menuItem); btn.DropDownItems.Add(item); } if (btn.DropDownItems.Count > 0) { btn.Style = RibbonButtonStyle.SplitDropDown; } else { btn.Style = RibbonButtonStyle.Normal; } } } } }
private void SetupToolbarItem(IToolbarItem tool, RibbonButton toolItem) { toolItem.Image = tool.Image; toolItem.SmallImage = tool.SmallImage; toolItem.CheckOnClick = tool.IsMapInteractive || tool.CheckOnClick; if (tool.IsMapInteractive) { this.interactiveTools.Add(tool); } this.toolToUiMap[tool] = toolItem; toolItem.Click += delegate { if (tool.CheckOnClick || tool.IsMapInteractive) { toolItem.Checked = !tool.IsChecked; tool.IsChecked = !tool.IsChecked; } if (tool.IsMapInteractive) { foreach (var t in this.interactiveTools) { var ribbonItem = this.toolToUiMap[t]; if (ribbonItem != toolItem) { ribbonItem.Checked = false; t.IsChecked = false; } } } tool.Click(); }; }
public void RemoveToolbarItem(IToolbarItem item) { this.itemHost.Children.Remove((ToolbarItem)item); }
public ToolbarItemCheckChanged(IToolbarItem item, bool isChecked) { Item = item; Checked = isChecked; }
public UTinyToolbar Add(IToolbarItem item) { m_Items.Add(item); return(this); }
private void menuItem49_Click(object sender, EventArgs e) { //enlarge pToolbarItem = this.axToolbarControl2.GetItem(0); pToolbarItem.Command.OnClick(); }
private void frmMain_Load(object sender, System.EventArgs e) { // Add commands to the NALayer context menu // 向Nalayer上下文菜单添加命令 m_menuLayer = new ToolbarMenuClass(); int nItem = -1; m_menuLayer.AddItem(new cmdLoadLocations(), -1, ++nItem, false, esriCommandStyles.esriCommandStyleTextOnly); m_menuLayer.AddItem(new cmdRemoveLayer(), -1, ++nItem, false, esriCommandStyles.esriCommandStyleTextOnly); m_menuLayer.AddItem(new cmdClearAnalysisLayer(), -1, ++nItem, true, esriCommandStyles.esriCommandStyleTextOnly); m_menuLayer.AddItem(new cmdNALayerProperties(), -1, ++nItem, true, esriCommandStyles.esriCommandStyleTextOnly); m_menuLayer.SetHook(axMapControl1); // Add command for Network Analyst env properties to end of "Network Analyst" dropdown menu // 将网络分析env属性的命令添加到“网络分析师”下拉菜单的末尾 nItem = -1; for (int i = 0; i < axToolbarControl1.Count; ++i) { IToolbarItem item = axToolbarControl1.GetItem(i); IToolbarMenu mnu = item.Menu; if (mnu == null) { continue; } IMenuDef mnudef = mnu.GetMenuDef(); string name = mnudef.Name; if (name == "ControlToolsNetworkAnalyst_SolverMenu") { nItem = i; break; } } if (nItem >= 0) { IToolbarItem item = axToolbarControl1.GetItem(nItem); IToolbarMenu mnu = item.Menu; if (mnu != null) { mnu.AddItem(new cmdNAProperties(), -1, mnu.Count, true, esriCommandStyles.esriCommandStyleTextOnly); } } // Initialize naEnv variables // 初始化naEnv变量 m_naEnv = new EngineNetworkAnalystEnvironmentClass(); m_naEnv.ZoomToResultAfterSolve = false; m_naEnv.ShowAnalysisMessagesAfterSolve = (int)(esriEngineNAMessageType.esriEngineNAMessageTypeInformative | esriEngineNAMessageType.esriEngineNAMessageTypeWarning); // Explicitly setup buddy control and initialize NA extension // so we can get to NAWindow to listen to window events // This is necessary the various controls are not yet setup and they // need to be in order to get the NAWindow's events. // 显式设置伙伴控件并初始化na扩展,以便我们可以访问na window来侦听窗口事件。 // 这是必需的,各种控件尚未设置,它们需要用于获取nawindow的事件。 axToolbarControl1.SetBuddyControl(axMapControl1); IExtension ext = m_naEnv as IExtension; object obj = axToolbarControl1.Object; ext.Startup(ref obj); m_naWindow = m_naEnv.NAWindow; m_onContextMenu = new IEngineNAWindowEventsEx_OnContextMenuEventHandler(OnContextMenu); ((IEngineNAWindowEventsEx_Event)m_naWindow).OnContextMenu += m_onContextMenu; }
public ToolbarItemStatusChanged(IToolbarItem item, bool enabled) { Item = item; Enabled = enabled; }
public void AddToolbarItem(IToolbarItem item) { this.Items.Add((ToolStripItem)item); }
private void menuItem25_Click(object sender, EventArgs e) { //open pToolbarItem = this.axToolbarControl1.GetItem(0); pToolbarItem.Command.OnClick(); }
public override void OnMouseDown(int Button, int Shift, int X, int Y) { try { pt = ((m_hookHelper.ActiveView.ScreenDisplay).DisplayTransformation).ToMapPoint(X, Y); } catch (System.Exception ex) { MessageBox.Show(ex.Message); } bool ddd = snapEnvironment.SnapPoint(pt); if (pMPfeedback != null) { pMPfeedback.Stop(); } pMPfeedback = null; bool hasCut = false; ISet newFeaturesSet = null; try { IFeatureSelection featureSelection = m_editLayer.TargetLayer as IFeatureSelection; ISelectionSet selectionSet = featureSelection.SelectionSet; IEnumIDs enumIDs = selectionSet.IDs; int iD = enumIDs.Next(); while (iD != -1) //-1 is reutned after the last valid ID has been reached { m_engineEditor.StartOperation(); IFeatureClass featureClass = m_editLayer.TargetLayer.FeatureClass; IFeature feature = featureClass.GetFeature(iD); // 判断点是否在线上,不是则跳过 ITopologicalOperator pto = feature.Shape as ITopologicalOperator; IGeometry pgeometry = pto.Intersect(pt, esriGeometryDimension.esriGeometry0Dimension); if (pgeometry.IsEmpty == true) { iD = enumIDs.Next(); continue; } IFeatureEdit featureedit = feature as IFeatureEdit; /*ISet*/ newFeaturesSet = featureedit.Split(pgeometry); if (newFeaturesSet != null) { newFeaturesSet.Reset(); hasCut = true; break; } iD = enumIDs.Next(); } } catch (System.Exception ex) { MessageBox.Show(ex.Message); } if (hasCut) { //如果操作成功,选中切割的两条线 //IFeatureSelection featureSelection = m_editLayer.TargetLayer as IFeatureSelection; //ISelectionSet selectionSet = featureSelection.SelectionSet; //for (int i = 0; i < newFeaturesSet.Count; i++) //{ // selectionSet.Add(((IFeature)newFeaturesSet.Next()).OID); //} //selectionSet.Refresh(); //Refresh the display including modified layer and any previously selected component. IActiveView activeView = m_engineEditor.Map as IActiveView; activeView.PartialRefresh(esriViewDrawPhase.esriViewGeography | esriViewDrawPhase.esriViewGeoSelection, null, activeView.Extent); activeView.Refresh(); //Complete the edit operation. m_engineEditor.StopOperation("Split a line"); // 将当前工具设置为选择工具 IToolbarControl toolbarctl = m_hookHelper.Hook as IToolbarControl; //ICommand com = new ControlsEditingEditToolClass(); //com.OnCreate(m_mapControl.Object); //this.m_mapControl.CurrentTool = com as ITool; for (int i = 0; i < toolbarctl.Count; i++) { IToolbarItem tbi = toolbarctl.GetItem(i); if (tbi.Command != null && tbi.Command.Name.Equals("ControlToolsEditing_Edit")) { tbi.Command.OnClick();// = true; toolbarctl.CurrentTool = tbi.Command as ITool; IToolbarBuddy toolbarbuddy = (IToolbarBuddy)((IToolbarControl)m_hookHelper.Hook).Buddy; break; } } // 操作成功后将当前工具置为以前的工具 //IToolbarBuddy toolbarbuddy = (IToolbarBuddy)((IToolbarControl)m_hookHelper.Hook).Buddy; //toolbarbuddy.CurrentTool = oldtool; //((IToolbarControl)m_hookHelper.Hook).SetBuddyControl(toolbarbuddy); this.Deactivate(); } else { m_engineEditor.AbortOperation(); MessageBox.Show("切割点不在线上,未能成功切割选择的线段"); //重新开始选点 this.OnClick(); } base.OnMouseDown(Button, Shift, X, Y); }
private void menuItem28_Click(object sender, EventArgs e) { //back view pToolbarItem = this.axToolbarControl2.GetItem(4); pToolbarItem.Command.OnClick(); }
public void addToolbarItem(IToolbarItem toolbarItem) { this.Items.Add((ToolStripItem)toolbarItem); }
private void menuItem36_Click(object sender, EventArgs e) { //copy pToolbarItem = this.axToolbarControl1.GetItem(3); pToolbarItem.Command.OnClick(); }
public void AddToolbarItem(IToolbarItem item) { this.itemHost.Children.Add((ToolbarItem)item); }
private void frmMain_Load(object sender, System.EventArgs e) { // Add commands to the NALayer context menu m_menuLayer = new ToolbarMenuClass(); int nItem = -1; m_menuLayer.AddItem(new cmdLoadLocations(), -1, ++nItem, false, esriCommandStyles.esriCommandStyleTextOnly); m_menuLayer.AddItem(new cmdRemoveLayer(), -1, ++nItem, false, esriCommandStyles.esriCommandStyleTextOnly); m_menuLayer.AddItem(new cmdClearAnalysisLayer(), -1, ++nItem, true, esriCommandStyles.esriCommandStyleTextOnly); m_menuLayer.AddItem(new cmdNALayerProperties(), -1, ++nItem, true, esriCommandStyles.esriCommandStyleTextOnly); // Since this ToolbarMenu is a standalone popup menu use the SetHook method to // specify the object that will be sent as a "hook" to the menu commands in their OnCreate methods. m_menuLayer.SetHook(axMapControl1); // Add command for ArcGIS Network Analyst extension env properties to end of "Network Analyst" dropdown menu nItem = -1; for (int i = 0; i < axToolbarControl1.Count; ++i) { IToolbarItem item = axToolbarControl1.GetItem(i); IToolbarMenu mnu = item.Menu; if (mnu == null) { continue; } IMenuDef mnudef = mnu.GetMenuDef(); string name = mnudef.Name; // Find the ArcGIS Network Analyst extension solver menu drop down and note the index if (name == "ControlToolsNetworkAnalyst_SolverMenu") { nItem = i; //break; } } if (nItem >= 0) { // Using the index found above, get the solver menu drop down and add the Properties command to the end of it. IToolbarItem item = axToolbarControl1.GetItem(nItem); IToolbarMenu mnu = item.Menu; if (mnu != null) { mnu.AddItem(new cmdNAProperties(), -1, mnu.Count, true, esriCommandStyles.esriCommandStyleTextOnly); } // Since this ToolbarMenu is an item on the ToolbarControl the Hook is shared and initialized by the ToolbarControl. // Therefore, SetHook is not called here, like it is for the menu above. } // Initialize naEnv variables m_naEnv = CommonFunctions.GetTheEngineNetworkAnalystEnvironment(); if (m_naEnv == null) { MessageBox.Show("Error: EngineNetworkAnalystEnvironment is not properly configured"); return; } m_naEnv.ZoomToResultAfterSolve = false; m_naEnv.ShowAnalysisMessagesAfterSolve = (int)(esriEngineNAMessageType.esriEngineNAMessageTypeInformative | esriEngineNAMessageType.esriEngineNAMessageTypeWarning); // Set up the buddy control and initialize the NA extension, so we can get to NAWindow to listen to window events. // This is necessary, as the various controls are not yet set up. They need to be in order to get the NAWindow's events. axToolbarControl1.SetBuddyControl(axMapControl1); IExtension ext = m_naEnv as IExtension; object obj = axToolbarControl1.Object; ext.Startup(ref obj); // m_naWindow is set after Startup of the Network Analyst extension m_naWindow = m_naEnv.NAWindow; if (m_naWindow == null) { MessageBox.Show("Error: Unexpected null NAWindow"); return; } m_onContextMenu = new IEngineNAWindowEventsEx_OnContextMenuEventHandler(OnContextMenu); ((IEngineNAWindowEventsEx_Event)m_naWindow).OnContextMenu += m_onContextMenu; m_OnNetworkLayersChanged = new IEngineNetworkAnalystEnvironmentEvents_OnNetworkLayersChangedEventHandler(OnNetworkLayersChanged); ((IEngineNetworkAnalystEnvironmentEvents_Event)m_naEnv).OnNetworkLayersChanged += m_OnNetworkLayersChanged; m_OnCurrentNetworkLayerChanged = new IEngineNetworkAnalystEnvironmentEvents_OnCurrentNetworkLayerChangedEventHandler(OnCurrentNetworkLayerChanged); ((IEngineNetworkAnalystEnvironmentEvents_Event)m_naEnv).OnCurrentNetworkLayerChanged += m_OnCurrentNetworkLayerChanged; }
private void menuItem53_Click(object sender, EventArgs e) { //whole pToolbarItem = this.axToolbarControl2.GetItem(2); pToolbarItem.Command.OnClick(); }
private void menuItem40_Click(object sender, EventArgs e) { //delete pToolbarItem = this.axToolbarControl1.GetItem(6); pToolbarItem.Command.OnClick(); }
private void menuItem54_Click(object sender, EventArgs e) { //forward view pToolbarItem = this.axToolbarControl2.GetItem(5); pToolbarItem.Command.OnClick(); }
public void Toolbar_ItemClicked(object Sender, ToolStripItemClickedEventArgs Event) { IToolbarItem SelectedToolbarItem = (IToolbarItem)Event.ClickedItem; SelectedToolbarItem.TargetCanvas = DrawingCanvas; }