private LayoutAnchorSide GetAnchorSide(RDocumentData.ToolsDockPosition pos, LayoutRoot root) { switch (pos) { case RDocumentData.ToolsDockPosition.Top: return(root.TopSide); case RDocumentData.ToolsDockPosition.Bottom: return(root.BottomSide); case RDocumentData.ToolsDockPosition.Left: return(root.LeftSide); case RDocumentData.ToolsDockPosition.Right: return(root.RightSide); default: return(null); } }
public bool RegisterTool(string ToolName, string documentType, string iconPath, Type ToolType, RDocumentData.ToolsDockPosition toolDockPosition) { try { Type ty; if (!DocumentTypesLoaded.TryGetValue(documentType, out ty)) { List <Tuple <string, string, string, Type, RDocumentData.ToolsDockPosition> > val; if (_dicDocSpecificToolFromPluginData.TryGetValue(documentType, out val)) { val.Add(new Tuple <string, string, string, Type, RDocumentData.ToolsDockPosition>(ToolName, documentType, iconPath, ToolType, toolDockPosition)); } else { _dicDocSpecificToolFromPluginData.Add(documentType, new List <Tuple <string, string, string, Type, RDocumentData.ToolsDockPosition> >() { new Tuple <string, string, string, Type, RDocumentData.ToolsDockPosition>(ToolName, documentType, iconPath, ToolType, toolDockPosition), }); } } else { ITab tab = UIManager.GetTab(documentType, "Tools"); IButtonGroup groupbox = tab?.GetButtonGroup("DockingTools"); if (tab == null) { tab = UIManager.CreateNewTab(documentType, "Tools"); groupbox = tab.CreateButtonGroup("DockingTools"); } if (groupbox == null) { groupbox = tab.CreateButtonGroup("DockingTools"); } groupbox.CreateToggleButton(ToolName, iconPath, new RelayCommand <RRibbonToggleButton>( (togglebtn) => { try { _eventaggregator.GetEvent <DockableToolToggleButtonClickedEvent>().Publish(new KeyValuePair <IRibbonToggleButton, Type>(togglebtn, ToolType)); } catch (Exception ex) { } })); Type doc = this.DocumentTypesLoaded[documentType]; //if (doc == null) // return false; var docdata = this.DocumentTypeData.FirstOrDefault(a => a.DocType == doc); docdata.DicToolDockPosition.Add(ToolType, toolDockPosition); } return(true); } catch (Exception ex) { return(false); } }