2017-11-13 8 views
0

ローン中に追加データを表示するために、右パネルメニューをEncompassアプリケーションに追加する予定です。私は友人に次のコードを出発点として与えてもらいましたが、紛失してしまいました。私はかなり初心者のプログラマーで、私よりはるかに優れたコードを見ています。だから、これを働かせるための助けに感謝します!プラグインを使用してアプリケーション(特にEllie Mae Encompass)にパネルを追加します。

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; 
     } 
    } 
+1

何が機能していないかについてさらに情報を教えてください。コンパイルに失敗していますか? – burnttoast11

+0

はい、コンパイルに失敗しています。私はCreateMenu()クラスで始まるエラーを取得しています。私が必要とするすべてを参照しているかどうかはわかりません。私はちょうどSystem.Windows.Formsに言われましたが、 "Settings"、 "MenuPanel"などの項目がどこから来ているのかはわかりません(この文脈では存在しないと言っています) – graysond99

答えて

0

上記のコードのこのラインはあなたのサンプルで数回に表示されます。唯一のリターンをControls.Find機能のみを、一つのパラメータを取るコントロールの名前は、あなたが探していると、それ

Control[] controlArray = mainForm.Controls.Find("rightPanel", true); 

コントロールの配列ではなく、見つかった場合にコントロールします。

上記の行をこれに変更すると、問題が解決されます。

Control control = mainForm.Controls.Find("rightPanel"); 

Ellie Maeは、アプリケーション側で使用する独自のフォームオブジェクトとコントロールを提供します。 System.Windows.Formsへの参照を削除し、追加します。

using Elliemae.Encompass.Forms; 

私はコードを実行しようとしていない、これは私はあなたが提供されているサンプルを通して見て見つけたものです。より具体的なエラーがある場合、私はあなたを助けることができるかもしれません。

関連する問題