/// <summary> /// 从ClassInfo创建Command /// </summary> /// <param name="classInfo"></param> /// <returns></returns> public static ICommand CreateCommand(ClassInfo classInfo) { object obj = CreateInstance(classInfo.DllName, classInfo.ClassName); //if (obj is ESRI.ArcGIS.SystemUI.ICommandSubType) // return null; //if (obj is ESRI.ArcGIS.SystemUI.IToolControl) //{ // obj = new EsriExProxy(obj as ESRI.ArcGIS.SystemUI.IToolControl); //}else if (obj is ESRI.ArcGIS.SystemUI.ICommand) //{ // obj = new EsriCommandProxy(obj as ESRI.ArcGIS.SystemUI.ICommand); //} //return obj as ICommand; return Frame.Environment.ResourceManager.CommandProxy(obj); }
private void buttonEdit1_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e) { if (this.openFileDialog1.ShowDialog() == DialogResult.OK) { string strPath = openFileDialog1.FileName; m_DllName = System.IO.Path.GetFileName(strPath); Dictionary<string,enumResourceType> dicResource= ResourceFactory.GetResources(strPath); m_NodeAll.Nodes.Clear(); int count = dicResource.Count; for (int i = 0; i < count; i++) { ClassInfo cInfo = new ClassInfo(); cInfo.ClassName = dicResource.Keys.ElementAt(i); cInfo.DllName = m_DllName; cInfo.Type = dicResource.Values.ElementAt(i); object objResource= ResourceFactory.CreateInstance(cInfo.DllName,cInfo.ClassName); ICommand cmd = objResource as ICommand; if (cmd != null) { cInfo.Category = cmd.Category; cInfo.Description = cmd.Caption; } else { IPlugin plugin = objResource as IPlugin; if (plugin != null) { cInfo.Category="插件"; cInfo.Description = plugin.Description; } } TreeListNode nodeResource = tlResource.AppendNode(new object[] { dicResource.Values.ElementAt(i) == enumResourceType.Command ? "命令" : "插件",string.IsNullOrWhiteSpace(cInfo.Description)? dicResource.Keys.ElementAt(i):cInfo.Description }, m_NodeAll); nodeResource.Tag = cInfo; } m_NodeAll.ExpandAll(); } }
public static IPlugin CreatePlugin(ClassInfo classInfo) { return CreateInstance(classInfo.DllName, classInfo.ClassName) as IPlugin; }
private void ucCommandCategory2_SelectedClassInfoChanged(ClassInfo cInfo) { m_SelectedClassInfo = cInfo; RefreshRibbonEnabled(); }
private void ucCommandCategory2_ClassInfoDoubleClicked(ClassInfo cInfo) { AddCommand(null, null); }
private void SelectedResourceChanged(ClassInfo cInfo) { m_SelectedResource = cInfo; ucClassInfo1.ClassInfo = cInfo; barBtnUnRegister.Enabled = (m_SelectedResource != null); }
private void tlCommands_FocusedNodeChanged(object sender, DevExpress.XtraTreeList.FocusedNodeChangedEventArgs e) { if (e.Node == null) m_SelectedClassInfo = null; else m_SelectedClassInfo = e.Node.Tag as ClassInfo; if (SelectedClassInfoChanged != null) SelectedClassInfoChanged.Invoke(m_SelectedClassInfo); }