Skip to content

Commit

Permalink
added dropdown UIEditor to UIBinaries
Browse files Browse the repository at this point in the history
  • Loading branch information
mirik123 committed Jul 23, 2016
1 parent 7343dd6 commit bd930b3
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
1 change: 1 addition & 0 deletions QCStudioPlugin/Forms/OptionPageGrid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public string UIBinaries {
[Category("UI")]
[DefaultValue("QCTerminalControl.JSChartControl")]
[DisplayName("Full class name for UI library")]
[Editor("QuantConnect.QCStudioPlugin.ClassListEditor", typeof(UITypeEditor))]
public string UIClassName {
get {
return _UIClassName;
Expand Down
31 changes: 30 additions & 1 deletion QCStudioPlugin/Forms/VistaFolderBrowser.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using Microsoft.VisualStudio.Shell;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing.Design;
Expand All @@ -7,6 +8,7 @@
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Windows.Forms.Design;

//http:// stackoverflow.com/questions/15368771/show-detailed-folder-browser-from-a-propertygrid
//http:// stackoverflow.com/users/403671/simon-mourier
Expand Down Expand Up @@ -34,6 +36,33 @@ public override object EditValue(ITypeDescriptorContext context, IServiceProvide
}
}

public class ClassListEditor : UITypeEditor
{
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
{
return UITypeEditorEditStyle.DropDown;
}

public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
{
IWindowsFormsEditorService wfes = provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService;
if (wfes != null)
{
var dte = (EnvDTE80.DTE2)ServiceProvider.GlobalProvider.GetService(typeof(EnvDTE.DTE));
string UIBinaries = (string)dte.Properties["QuantConnect Client", "General"].Item("UIBinaries").Value;
var items = QuantConnect.QCStudioPlugin.QCPluginUtilities.GetClassesList(UIBinaries, "QCInterfaces.ChartControl");

var lbc = new ListBox();
lbc.Items.AddRange(items);
lbc.SelectedIndexChanged += (sender, e) => wfes.CloseDropDown();

wfes.DropDownControl(lbc);
value = lbc.SelectedItem as string ?? value as string ?? string.Empty;
}
return value;
}
}

public class VistaFolderBrowser
{
public string DirectoryPath { get; set; }
Expand Down
11 changes: 11 additions & 0 deletions QCStudioPlugin/Utilities/QCPluginUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,17 @@ public static string[] GetAlgorithmsList(string filePath, string classDll)
return algorithms;
}

public static string[] GetClassesList(string classDll, string parentClass)
{
var algoass = Assembly.LoadFrom(classDll);
var algorithms = algoass.GetTypes()
.Where(x => x.BaseType.FullName == parentClass)
.Select(x => x.FullName)
.ToArray();

return algorithms;
}

private static string RetrieveAssemblyDirectory()
{
string codeBase = Assembly.GetExecutingAssembly().CodeBase;
Expand Down

0 comments on commit bd930b3

Please sign in to comment.