Ejemplo n.º 1
0
        /// <summary>
        /// Download the file and open a new visual studio solution
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OpenBtn_Click(object sender, EventArgs e)
        {
            int selectedProject = 0;

            if (listViewProjects.SelectedItems.Count == 0)
            {
                return;
            }

            selectedProject = Convert.ToInt32(listViewProjects.SelectedItems[0].Text);
            projectName     = listViewProjects.FocusedItem.SubItems[1].Text;

            buttonOpen.Enabled = false;
            this.UseWaitCursor = true;

            //Run the function that downloads and handles the projects
            bool success = QuantConnectPlugin.OpenProject(selectedProject, projectName, () => {
                buttonOpen.SafeInvoke((d) => d.Enabled = true);
                this.SafeInvoke((d) => d.UseWaitCursor = false);
                this.SafeInvoke((d) => d.Close());
                QuantConnectPlugin.SetButtonsState(true);
            });

            if (!success)
            {
                buttonOpen.Enabled           = true;
                this.UseWaitCursor           = false;
                QuantConnectPlugin.ProjectID = 0;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Create a new project.
        /// </summary>
        public void CreateProject(bool retry = false)
        {
            progressBar.Value = 10;
            labelMessage.Text = "Creating Project on QuantConnect...";

            // Create New Project on QC
            Async.Add(new APIJob(APICommand.NewProject, (projectIdObj, 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(() => { FormCreateProject form = new FormCreateProject(); form.StartPosition = FormStartPosition.CenterScreen; form.Show(); }));
                    this.SafeInvoke(d => d.Close());
                    return;
                }

                int projectId = projectIdObj == null ? 0 : Convert.ToInt32(projectIdObj);
                if (projectId == 0)
                {
                    //Show the error form
                    labelMessage.SafeInvoke(d => d.Text    = "Sorry there was an error with your request. ");
                    pictureError.SafeInvoke(d => d.Visible = true);
                }
                else
                {
                    //Else we have a new id, time to load the template:
                    labelMessage.SafeInvoke(d => d.Text = "Project Created, Opening...");
                    progressBar.SafeInvoke(d => d.Value = 90);

                    //Open the project and close the loading dialog.
                    QuantConnectPlugin.OpenProject(projectId, ProjectName, () => {
                        this.SafeInvoke(d => d.Close());
                        QuantConnectPlugin.SetButtonsState(true);
                    });
                }
            }, ProjectName));
        }