/// <summary>
 /// Show Open Projects form, save credentials to file
 /// </summary>
 public static void ShowProjects()
 {
     Login(() =>
     {
         FormOpenProject projectList = new FormOpenProject();
         projectList.StartPosition   = FormStartPosition.CenterScreen;
         projectList.Show();
     });
 }
        private void OpenProjects_Load(object sender, EventArgs e)
        {
            // Load projects
            buttonOpen.Enabled = false;
            this.UseWaitCursor = true;
            List<Project> projectList = new List<Project>();

            try
            {
                Async.Add(new APIJob(APICommand.ProjectList, (projectfiles, errors) =>
                {
                    //Handle login and API errors:
                    switch (QuantConnectPlugin.HandleErrors(errors))
                    {
                        //Handle project specific actions with a login error:
                        case APIErrors.NotLoggedIn:
                            this.SafeInvoke(d => d.ShowLogin(() => { FormOpenProject form = new FormOpenProject(); form.StartPosition = FormStartPosition.CenterScreen; form.Show(); }));
                            this.SafeInvoke(d => d.Close());
                            return;
                    }

                    listViewProjects.SafeInvoke(d => d.Items.Clear());
                    listViewProjects.SafeInvoke(d => d.BeginUpdate());

                    foreach (var project in (List<Project>)projectfiles)
                    {
                        ListViewItem item = new ListViewItem();
                        item.Text = project.Id.ToString();

                        ListViewItem.ListViewSubItem subitem = new ListViewItem.ListViewSubItem();
                        subitem.Text = project.Name.ToString();
                        item.SubItems.Add(subitem);

                        subitem = new ListViewItem.ListViewSubItem();
                        subitem.Text = project.Modified.ToString();
                        item.SubItems.Add(subitem);

                        listViewProjects.SafeInvoke(d => d.Items.Add(item));
                    }
                    listViewProjects.SafeInvoke(d => d.EndUpdate());
                    buttonOpen.SafeInvoke(d => d.Enabled = true);
                    this.SafeInvoke(d => d.UseWaitCursor = false);
                    this.SafeInvoke(d => d.SizeLastColumn(listViewProjects));
                }));
            }
            catch
            {
                MessageBox.Show("Connection timeout.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
                        
        }
        /// <summary>
        /// Refresh the data source, polling the API.
        /// </summary>
        private void timerRefresh_Tick(object sender, EventArgs e)
        {
            if (_processing)
            {
                return;
            }
            _processing = true;

            statusLabel.Text = "Updating Results for Backtest Id: " + _backtestId + "...";

            Async.Add(new APIJob(APICommand.BacktestResults, (backtestResult, errors) =>
            {
                //Handle login and API errors:
                switch (QuantConnectPlugin.HandleErrors(errors))
                {
                //Handle project specific actions with a login error:
                case APIErrors.NotLoggedIn:
                    this.SafeInvoke(d => d.ShowLogin(() => { FormOpenProject form = new FormOpenProject(); form.StartPosition = FormStartPosition.CenterScreen; form.Show(); }));
                    this.SafeInvoke(d => d.Close());
                    return;
                }

                //Handle Results Packet:
                PacketBacktestResult packet = (PacketBacktestResult)backtestResult;

                this.SafeInvoke(d => d.SetBacktestResult(packet));
            }, _backtestId)); // End of Async
        } // End of timer:
        /// <summary>
        /// Refresh the data source, polling the API.
        /// </summary>
        private void timerRefresh_Tick(object sender, EventArgs e)
        {
            if (_processing) return;
            _processing = true;

            statusLabel.Text = "Updating Results for Backtest Id: " + _backtestId + "...";

            Async.Add(new APIJob(APICommand.BacktestResults, (backtestResult, errors) =>
            {
                //Handle login and API errors:
                switch (QuantConnectPlugin.HandleErrors(errors))
                {
                    //Handle project specific actions with a login error:
                    case APIErrors.NotLoggedIn:
                        this.SafeInvoke(d => d.ShowLogin(() => { FormOpenProject form = new FormOpenProject(); form.StartPosition = FormStartPosition.CenterScreen; form.Show(); }));
                        this.SafeInvoke(d => d.Close());
                        return;
                }

                //Handle Results Packet:
                PacketBacktestResult packet = (PacketBacktestResult)backtestResult;

                this.SafeInvoke(d => d.SetBacktestResult(packet));

            }, _backtestId)); // End of Async

        } // End of timer:
Esempio n. 5
0
        private void OpenProjects_Load(object sender, EventArgs e)
        {
            // Load projects
            buttonOpen.Enabled = false;
            this.UseWaitCursor = true;
            List <Project> projectList = new List <Project>();

            try
            {
                Async.Add(new APIJob(APICommand.ProjectList, (projectfiles, errors) =>
                {
                    //Handle login and API errors:
                    switch (QuantConnectPlugin.HandleErrors(errors))
                    {
                    //Handle project specific actions with a login error:
                    case APIErrors.NotLoggedIn:
                        this.SafeInvoke(d => d.ShowLogin(() => { FormOpenProject form = new FormOpenProject(); form.StartPosition = FormStartPosition.CenterScreen; form.Show(); }));
                        this.SafeInvoke(d => d.Close());
                        return;
                    }

                    listViewProjects.SafeInvoke(d => d.Items.Clear());
                    listViewProjects.SafeInvoke(d => d.BeginUpdate());

                    foreach (var project in (List <Project>)projectfiles)
                    {
                        ListViewItem item = new ListViewItem();
                        item.Text         = project.Id.ToString();

                        ListViewItem.ListViewSubItem subitem = new ListViewItem.ListViewSubItem();
                        subitem.Text = project.Name.ToString();
                        item.SubItems.Add(subitem);

                        subitem      = new ListViewItem.ListViewSubItem();
                        subitem.Text = project.Modified.ToString();
                        item.SubItems.Add(subitem);

                        listViewProjects.SafeInvoke(d => d.Items.Add(item));
                    }
                    listViewProjects.SafeInvoke(d => d.EndUpdate());
                    buttonOpen.SafeInvoke(d => d.Enabled = true);
                    this.SafeInvoke(d => d.UseWaitCursor = false);
                    this.SafeInvoke(d => d.SizeLastColumn(listViewProjects));
                }));
            }
            catch
            {
                MessageBox.Show("Connection timeout.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
 /// <summary>
 /// Show Open Projects form, save credentials to file
 /// </summary>
 public static void ShowProjects()
 {
     Login(() =>
     {
         FormOpenProject projectList = new FormOpenProject();
         projectList.StartPosition = FormStartPosition.CenterScreen;
         projectList.Show();
     });            
 }