/// <summary> /// /// </summary> public override bool Equals(object obj) { if (this == obj) { return(true); } if ((obj == null) || !(obj is RibbonCommandInfo)) { return(false); } RibbonCommandInfo castObj = (RibbonCommandInfo)obj; return(castObj.ID == this.ID); }
private void SaveCommandNode(TreeListNode nodeCommand, TreeListNode nodePage, TreeListNode nodeGroup, int pageOrder, int groupOrder, int cmdOrder) { SendMessage(string.Format("正在保存第{0}个命令...",++m_SaveIndex)); RibbonCommandInfo rcInfo = null; if (nodeCommand.Tag is RibbonCommandInfo) { rcInfo = nodeCommand.Tag as RibbonCommandInfo; } else { rcInfo = new RibbonCommandInfo(); } rcInfo.Page = nodePage.GetValue(tlColCaption) as string; rcInfo.PageGroup = nodeGroup.GetValue(tlColCaption) as string; rcInfo.Caption = nodeCommand.GetValue(tlColCaption) as string; rcInfo.CommandClass = nodeCommand.GetValue(tlColContent) as ClassInfo; object objIcon= nodeCommand.GetValue(tlColIcon); rcInfo.Icon =objIcon is byte[]?Image.FromStream(new System.IO.MemoryStream(objIcon as byte[])):objIcon as Image; rcInfo.Parent = nodeCommand.ParentNode.Tag as RibbonCommandInfo;// nodeCommand.ParentNode.Tag is RibbonCommandInfo ? nodeCommand.ParentNode.Tag as RibbonCommandInfo : null; if (rcInfo.Parent != null) { rcInfo.Order = rcInfo.Parent.Order + cmdOrder.ToString("00"); } else { rcInfo.Order = pageOrder.ToString("00") + groupOrder.ToString("00") + cmdOrder.ToString("00"); } int typeIndex=m_TypeNames.IndexOf(nodeCommand.GetValue(tlColCommandType) as string); rcInfo.Type = (enumCommandType)(typeIndex<0?0:typeIndex); //if (nodeCommand.Tag is RibbonCommandInfo) //{ // m_HibernateHelper.UpdateObject(rcInfo); //} //else //{ // m_HibernateHelper.SaveObject(rcInfo); // nodeCommand.Tag = rcInfo; //} m_HibernateHelper.SaveObject(rcInfo); nodeCommand.Tag = rcInfo; //m_HibernateHelper.RefreshObject(rcInfo); for (int i = 0; i < nodeCommand.Nodes.Count;i++ ) { SaveCommandNode(nodeCommand.Nodes[i], nodePage, nodeGroup, pageOrder, groupOrder, i+1); } //foreach (TreeListNode nodeSub in nodeCommand.Nodes) //{ // SaveCommandNode(nodeSub, nodePage, nodeGroup, pageOrder, groupOrder, cmdOrder); //} }
private ICommand LoadFromCommandInfo(RibbonCommandInfo cmdInfo) { if (cmdInfo == null) return null; string curPage = cmdInfo.Page; string curPageGroup = cmdInfo.PageGroup; // BarItem ICommand cmd = null; try { cmd = ResourceFactory.CreateCommand(cmdInfo.CommandClass); if (cmd != null) LoadFromCommand(cmd, curPage, curPageGroup, cmdInfo.Caption, cmdInfo.Icon, cmdInfo.Type, cmdInfo.ID, cmdInfo.Parent == null ? null : cmdInfo.Parent.ID); } catch (Exception exp) { SendMessage(string.Format("创建{0}实例时出错,信息:{1};将跳过此命令。", cmdInfo.CommandClass.ClassName, exp.ToString(), exp.ToString())); } return cmd; }