SmartQuant Discussion

Automated Quantitative Strategy Development, SmartQuant Product Discussion and Technical Support Forums
It is currently Wed Oct 24, 2018 6:17 am

All times are UTC + 3 hours




Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: Thu Jun 25, 2015 6:16 pm 
Offline

Joined: Fri Sep 28, 2012 8:16 am
Posts: 136
Hi,

DemoApp is a very good example, but write base on it will cost a lot of time.

If client can write a custom UI and add it in OpenQuant IDE, it will save much time.
OpenQuant will be more powerful if user can add UI plugin.
people can contribute their codes and work.

I give my code for reference.

Code:
using System;

using SmartQuant;

using System.Windows.Forms;
using OpenQuant.Shared;


namespace OpenQuant
{
    public static class ControlExtention
    {
        public delegate void InvokeHandler();

        public static void SafeInvoke(this Control control, InvokeHandler handler)
        {
            if (control.InvokeRequired)
            {
                control.Invoke(handler);
            }
            else
            {
                handler();
            }
        }
    }

     class Program
     {
          static void AddMenuViewItem(Form mainForm)
          {
               MenuStrip mainMenuStrip = mainForm.MainMenuStrip;
               ToolStripMenuItem menuView = mainMenuStrip.Items[2] as ToolStripMenuItem;
               ToolStripSeparator menu_Sepearator = new ToolStripSeparator();
               menuView.DropDownItems.Add(menu_Sepearator);
               ToolStripMenuItem menuView_Script = new ToolStripMenuItem("Script Explorer");
               menuView.DropDownItems.Add(menuView_Script);

               menuView_Script.Click += menuView_Script_Click;
          }
         
          static void AddToolStripMenuItem(Form mainForm)
          {
               MenuStrip mainMenuStrip = mainForm.MainMenuStrip;
               ToolStripItem menuHello = new ToolStripMenuItem("(^_^)");
               mainMenuStrip.Items.Add(menuHello);

               menuHello.Click += menuHello_Click;
          }

          static void menuHello_Click(object sender, EventArgs e)
          {
               DialogResult dr = MessageBox.Show("Hello");
          }
         
          static void menuView_Script_Click(object sender, EventArgs e)
          {
               OpenQuant.Shared.Global.DockManager.Open(typeof(OrderManagerWindow));
          }
         
          static void Main(string[] args)
          {
            try
            {
                Console.Clear();
            }
            catch
            {
                System.Threading.ThreadPool.QueueUserWorkItem(delegate
                {
                    while (Application.OpenForms.Count == 0 || Application.OpenForms[0].Name != "MainForm")
                    {
                        System.Threading.Thread.Sleep(1000);
                    }
                    Form mainForm = Application.OpenForms[0];

                    try
                    {
                        mainForm.SafeInvoke(() => { AddMenuViewItem(mainForm); });
                        mainForm.SafeInvoke(() => { AddToolStripMenuItem(mainForm); });
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                    }
                });
            }
               
               
               Scenario scenario = new MyScenario(Framework.Current);

               scenario.Run();
          }
     }
}


User can create UI inherit from DockWindow/FrameworkControl.
can add this code in custom provider to show at OpenQuant IDE start.

that code still have some problems.
1.add menu each time if you run it. a lot of menus will show.

I hope SmartQuant could add this feature into IDE natively.

Regards,
wukan


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC + 3 hours


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group