public bool SetCurrentTool(YutaiTool tool) { if (tool.ItemType == RibbonItemType.Tool) { ITool oldTool = MainView.CurrentTool; _oldToolName = oldTool == null ? string.Empty : ((YutaiTool)oldTool).Name; MainView.CurrentTool = (YutaiTool)tool; CurrentToolName = tool.Name; RibbonMenu.ChangeCurrentTool(_oldToolName, tool.Name); if (tool is IToolContextMenu) { RibbonMenu.SetContextMenu(MainView.MapControlContainer); } return(true); } return(false); }
public void SetCurrentTool(object control, YutaiTool tool) { throw new NotImplementedException(); }
public void SetContextMenu(Control mapControl) { if (string.IsNullOrEmpty(_oldToolName)) { _ribbonManager.SetPopupContextMenu(mapControl, null); return; } BarItem item = _ribbonManager.Items[_oldToolName]; if (item == null) { _ribbonManager.SetPopupContextMenu(mapControl, null); return; } YutaiTool tool = item.Tag as YutaiTool; if (!(tool is IToolContextMenu)) { _ribbonManager.SetPopupContextMenu(mapControl, null); return; } PopupMenu mPCurrentPopupMenu = this.m_pCurrentPopupMenu; mPCurrentPopupMenu.ClearLinks(); string[] keys = ((IToolContextMenu)tool).ContextMenuKeys; if (keys == null) { return; } item = null; bool nextGroup = false; for (int i = 0; i < keys.Length; i++) { if (keys[i].Equals('-')) { nextGroup = true; continue; } item = _ribbonManager.Items[keys[i]]; if (item == null) { continue; } BarItemLink link = mPCurrentPopupMenu.AddItem(item); if (nextGroup) { link.BeginGroup = true; nextGroup = false; } } if (mPCurrentPopupMenu.ItemLinks.Count <= 0) { _ribbonManager.SetPopupContextMenu(mapControl, this.m_pSystemPopupMenu); } else { _ribbonManager.SetPopupContextMenu(mapControl, mPCurrentPopupMenu); } }