Programming | How to Create a Custom Optimizer in Visual Studio

Modified on 2020/07/30 17:27 by Eugene — Categorized as: API

Here is a step by step procedure on creating a custom optimizer (courtesy Kurt Meister). An example Visual Studio solution is attached.

  1. Open Visual Studio (as Administrator)
  2. Click on File > New > Project > Windows Desktop > Class Library
    • Change the Name to Example Optimizer and click OK
  3. In Solution Explorer, click on Example Optimizer
    • Click on Project > Build > Output > Browse and navigate to main Wealth-Lab folder under Program Files (C:\Program Files\MS123\Wealth-Lab Developer 6\) and click Open
    • Click on Debug and click on Start external program
    • Click on ... and navigate to the folder above and click Select Folder
  4. In Solution Explorer, right click on Class1.cs > Rename and change it to ExampleOptimizer
    • Click Yes in the message box that appears to rename all references
  5. In Solution Explorer, right click on References > Add Reference > Browse > Browse and navigate to the main WL folder (see Step 4) and click Add
    • Click on Browse again, highlight WealthLab.dll and click Add
    • Click OK
  6. In Solution Explorer, right click on Solution 'Example Optimizer' > Add > User Control > Visual C# Items > User Control
    • Change the Name to Settings and click Add
  7. Settings.cs[Design] should be open and highlighted. If not, in Solution Explorer, double click on Settings.cs
    • Click on View > Toolbox > Common Controls and double click on CheckBox
    • Click on Settings.cs[Design] to hide the Toolbox
    • Right click on checkBox1 > Properties
      • Under Appearance > Checked, click on the dropdown and select True
      • Under Appearance > Text, click on checkBox1, delete that and type Play Sound When Finished
  8. In Solution Explorer, expand Settings.cs and double click on Settings.Designer to open it
    • At the bottom, change:
      //private System.Windows.Forms.CheckBox checkbox1;
      public System.Windows.Forms.CheckBox checkbox1;
  9. In Solution Explorer, right click on Solution 'Example Optimizer' > Add > User Control > Visual C# Items > User Control
    • Change the Name to Tab and click Add
    • Right click on checkBox1 > Properties
      • Under Design > Modifiers, click on the dropdown and select Public
  10. Tab.cs[Design] should be open and highlighted. If not, in Solution Explorer, double click on Tab.cs
    • Click on View > Toolbox > Common Controls and double click on TextBox
    • Click on Tab.cs[Design] to hide the Toolbox
    • Right click on textBox1 > Properties
      • Under Design > Modifiers, click on the dropdown and select Public
    • Click on View > Code
    • Insert the following code:
      public Tab(string putInTextBox1)
      {
      InitializeComponent();
      textBox1.Text = putInTextBox1;
      }
  11. In Solution Explorer, expand Tab.cs and double click on Tab.Designer to open it and change at the bottom:
    //private System.Windows.Forms.TextBox textbox1;
    public System.Windows.Forms.TextBox textbox1;
  12. Now all of your coding will be in Example Optimizer.cs