C# 通过插件向应用程序(特别是Ellie Mae Encomble)添加一个面板。

C# 通过插件向应用程序(特别是Ellie Mae Encomble)添加一个面板。,c#,panel,C#,Panel,我希望添加一个右面板菜单到Enclosure应用程序,以显示贷款时的其他数据。我有一个朋友给了我以下代码作为起点,但我迷路了(不确定我是否丢失了引用,等等)。我是一个相当新手的程序员,从比我好得多的人那里看代码。因此,如果您能帮助我们实现这一目标,我们将不胜感激 using System; using EllieMae.Encompass.ComponentModel; using EllieMae.Encompass.Automation; using System.Windows.Forms

我希望添加一个右面板菜单到Enclosure应用程序,以显示贷款时的其他数据。我有一个朋友给了我以下代码作为起点,但我迷路了(不确定我是否丢失了引用,等等)。我是一个相当新手的程序员,从比我好得多的人那里看代码。因此,如果您能帮助我们实现这一目标,我们将不胜感激

using System;
using EllieMae.Encompass.ComponentModel;
using EllieMae.Encompass.Automation;
using System.Windows.Forms;
using System.Collections.Generic;
using System.Linq;


namespace RightPanel
{

    [Plugin]
    public class RightPanel
    {
        private Form mainForm;
        private TabControl _tabs;
        private bool _created;
        private Panel rightPanel;


        public RightPanel()
        {
            EncompassApplication.Login += new EventHandler(EncompassApplication_Login);
        }
        private void EncompassApplication_Login(object sender, EventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form.Text.ToLower().Contains("encompass"))
                {
                    mainForm = form;
                }
            }

            Control[] controlArray = mainForm.Controls.Find("tabControl", true);
            if ((uint)((IEnumerable<Control>)controlArray).Count<Control>() <= 0U)
                return;

            _tabs = controlArray[0] as TabControl;
            _tabs.SelectedIndexChanged += new EventHandler(SelectedIndex_Changed);
        }

        private void SelectedIndex_Changed(object sender, EventArgs e)
        {
            if (_tabs.SelectedIndex < 0)
                return;
            TabPage tabPage = _tabs.TabPages[_tabs.SelectedIndex];
            if (tabPage != null && (tabPage.Name.Contains("loanTabPage")))
                BindToRightPanel();
        }

        private void BindToRightPanel()
        {
            if (_created)
                return;
            Control[] controlArray = mainForm.Controls.Find("rightPanel", `enter code here`true);
            if (((IEnumerable<Control>)controlArray).Count() > 0)
            {
                rightPanel = controlArray[0] as Panel;
                CreateMenu();
            }
        }

        private void CreateMenu()
        {
            if (mainForm == null)
                return;

            RemoveControlById(Settings.MainMenu, rightPanel);
            RemoveControlById(Settings.MenuButtonPanel, rightPanel);

            MenuButton menuButton = GetMenuButton("Open Loan Tools", "MtgMenuButton");
            menuButton.BackColor = Color.White;

            MenuPanel = new MenuPanel(Settings.GetMenu(), menuButton);
            MenuPanel.Name = Settings.MainMenu;
            MenuPanel.Dock = DockStyle.Right;

            Panel panel = new Panel();
            panel.Name = Settings.MenuButtonPanel;
            panel.Width = 27;
            panel.Dock = DockStyle.Right;
            panel.Controls.Add((Control)menuButton);

            rightPanel.Controls.Add((Control)MenuPanel);
            rightPanel.Controls.Add((Control)panel);
            _created = true;
        }

        private List<MenuPanelSection> GetMenu()
        {
            return new List<MenuPanelSection>()
      {  new MenuPanelSection(Utilities.GetHeading("Loan Information"), Utilities.HighestWeightedPersona() == "Loan Officer", new Control[1]
        {
          (Control) new LoanInformation()
        })
      };
        }

        private void RemoveControlById(string controlID, Panel panel)
        {
            Control[] controlArray = panel.Controls.Find(controlID, true);
            if ((uint)((IEnumerable<Control>)controlArray).Count<Control>() <= 0U)
                return;

            for (int i = 0; i < ((IEnumerable<Control>)controlArray).Count<Control>(); ++i)
                controlArray[i].Parent.Controls.Remove(controlArray[i]);
        }

        private MenuButton GetMenuButton(string buttonText, string buttonName)
        {
            MenuButton menuButton = new MenuButton();
            menuButton.AutoSize = true;
            menuButton.FlatAppearance.BorderSize = 0;
            menuButton.FlatStyle = 0;
            menuButton.Height = 100;
            menuButton.Name = buttonName;
            menuButton.VerticalText = buttonText;
            menuButton.Width = 27;

            return menuButton;
        }
    }
使用系统;
使用EllieMae.include.ComponentModel;
使用EllieMae.include.Automation;
使用System.Windows.Forms;
使用System.Collections.Generic;
使用System.Linq;
命名空间右面板
{
[插件]
公共类右面板
{
私人形式主要形式;
专用选项卡控件_选项卡;
创建私有布尔;
私人事务委员会;
公共权利小组()
{
EnclosureApplication.Login+=新事件处理程序(EnclosureApplication_Login);
}
私有应用程序登录(对象发送方、事件参数e)
{
foreach(Application.OpenForms中的表单)
{
if(form.Text.ToLower()包含(“包含”))
{
mainForm=form;
}
}
Control[]controlArray=mainForm.Controls.Find(“tabControl”,true);
if((uint)((IEnumerable)controlArray.Count()0)
{
rightPanel=controlArray[0]作为面板;
CreateMenu();
}
}
私有void CreateMenu()
{
if(mainForm==null)
返回;
移除控件ID(Settings.main菜单,右面板);
RemoveControlById(Settings.MenuButtonPanel,rightPanel);
MenuButton MenuButton=GetMenuButton(“打开贷款工具”、“MtgMenuButton”);
menuButton.BackColor=Color.White;
MenuPanel=新建MenuPanel(Settings.GetMenu(),menuButton);
MenuPanel.Name=Settings.main菜单;
MenuPanel.Dock=DockStyle.Right;
面板=新面板();
panel.Name=Settings.MenuButtonPanel;
面板宽度=27;
panel.Dock=DockStyle.Right;
panel.Controls.Add((控制)菜单按钮);
右面板.Controls.Add((控件)菜单面板);
rightPanel.Controls.Add((控制)面板);
_创建=真;
}
私有列表GetMenu()
{
返回新列表()
{新菜单PanelSection(Utilities.GetHeading(“贷款信息”),Utilities.HighestWeightedPersona()=“贷款官员”,新控件[1]
{
(控制)新贷款信息()
})
};
}
私有void RemoveControlById(字符串控件ID,面板)
{
Control[]controlArray=panel.Controls.Find(controlID,true);

如果((uint)((IEnumerable)controlArray).Count()这行代码在上面的示例中出现了几次:

Control[] controlArray = mainForm.Controls.Find("rightPanel", true);
Find函数只接受一个参数,即您正在查找的控件的名称,并且它只在找到该控件时返回该控件,而不返回控件数组

将上述行更改为该行将纠正该问题

Control control = mainForm.Controls.Find("rightPanel");
Ellie Mae提供应用程序中使用的is自己的表单对象和控件。删除对System.Windows.Forms的引用并添加:

using Elliemae.Encompass.Forms;

我还没有尝试运行代码,这是我在查看您提供的示例时发现的。如果您有更具体的错误,我可能可以帮助您解决这些错误。

您能否提供一些关于哪些错误不起作用的详细信息?它是否无法编译?是的,它无法编译。我从CreateMenu()开始出现错误类。其中一些是我不确定我是否引用了我需要的所有内容。我被告知只有System.Windows.Forms,但不确定“设置”、“菜单面板”等项来自何处(它告诉我它们在此上下文中不存在)