private void fillComponentsCombo()
        {
            comboBoxComponents.Items.Clear();
            int    addedComponentsCount = 0;
            string libPath = AsposeComponentsManager.getLibaryDownloadPath();

            foreach (AsposeComponent component in AsposeComponents.list.Values)
            {
                if (Directory.Exists(Path.Combine(libPath, component.Name)))
                {
                    comboBoxComponents.Items.Add(component.Name);
                    addedComponentsCount++;
                }
            }

            if (!string.IsNullOrEmpty(GlobalData.SelectedComponent))
            {
                comboBoxComponents.SelectedItem = GlobalData.SelectedComponent;
                GlobalData.SelectedComponent    = string.Empty;
            }

            if (addedComponentsCount == 0)
            {
                ComponentWizardPage components = new ComponentWizardPage();
                components.FormClosed += new FormClosedEventHandler(components_FormClosed);
                components.ShowDialog();

                if (!GlobalData.isComponentFormAborted)
                {
                    fillComponentsCombo();
                }
            }
        }
        private void checkAndUpdateRepo(AsposeComponent component)
        {
            if (null == component)
            {
                return;
            }
            if (null == component.get_remoteExamplesRepository() || component.RemoteExamplesRepository == string.Empty)
            {
                showMessage("Examples not available", component.get_name() + " - " + Constants.EXAMPLES_NOT_AVAILABLE_MESSAGE, MessageBoxButtons.OK, MessageBoxIcon.Information);
                examplesNotAvailable = true;
                return;
            }
            else
            {
                examplesNotAvailable = false;
            }

            if (AsposeComponentsManager.isIneternetConnected())
            {
                CloneOrCheckOutRepo(component);
            }
            else
            {
                showMessage(Constants.INTERNET_CONNECTION_REQUIRED_MESSAGE_TITLE, component.get_name() + " - " + Constants.EXAMPLES_INTERNET_CONNECTION_REQUIRED_MESSAGE, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
 private void Completed(object sender, AsyncCompletedEventArgs e)
 {
     progressBar.Value = 100;
     asyncActiveDownload.Component.Downloaded = true;
     AsposeComponentsManager.storeVersion(asyncActiveDownload.Component);
     UnZipDownloadedFile(asyncActiveDownload);
     AbortButton.Enabled = true;
     processDownloadList();
 }
예제 #4
0
        private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                UpdateProgress(1);
                int total = 10;
                int index = 0;

                AsposeComponentsManager comManager = new AsposeComponentsManager(this);
                foreach (AsposeComponent component in AsposeComponents.list.Values)
                {
                    if (component.is_selected())
                    {
                        GlobalData.SelectedComponent = component.get_name();

                        ProductRelease productRelease = getProductReleaseInfo(component.get_name());
                        component.set_downloadUrl(productRelease.DownloadLink);
                        component.set_downloadFileName(productRelease.FileName);
                        component.set_changeLog(productRelease.ChangeLog);
                        component.set_latestVersion(productRelease.VersionNumber);
                        if (AsposeComponentsManager.libraryAlreadyExists(component.get_downloadFileName()))
                        {
                            component.set_currentVersion(AsposeComponentsManager.readVersion(component));
                            if (AsposeComponentsManager.readVersion(component).CompareTo(component.get_latestVersion()) == 0)
                            {
                                component.set_downloaded(true);
                            }
                            else
                            {
                                AsposeComponentsManager.addToDownloadList(component, component.get_downloadUrl(), component.get_downloadFileName());
                            }
                        }
                        else
                        {
                            AsposeComponentsManager.addToDownloadList(component, component.get_downloadUrl(), component.get_downloadFileName());
                        }
                    }

                    decimal percentage = ((decimal)(index + 1) / (decimal)total) * 100;
                    UpdateProgress(Convert.ToInt32(percentage));

                    index++;
                }

                UpdateProgress(100);
                UpdateText("All operations completed");
            }
            catch (Exception) { }
        }
        private bool performFinish()
        {
            ContinueButton.Enabled = false;
            processComponents();

            if (!AsposeComponentsManager.isIneternetConnected())
            {
                this.showMessage(Constants.INTERNET_CONNECTION_REQUIRED_MESSAGE_TITLE, Constants.INTERNET_CONNECTION_REQUIRED_MESSAGE, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning);
                return(false);
            }

            GlobalData.backgroundWorker = new BackgroundWorker();
            GlobalData.backgroundWorker.WorkerReportsProgress      = true;
            GlobalData.backgroundWorker.WorkerSupportsCancellation = true;

            GlobalData.backgroundWorker.DoWork             += new DoWorkEventHandler(backgroundWorker_DoWork);
            GlobalData.backgroundWorker.ProgressChanged    += new ProgressChangedEventHandler(backgroundWorker_ProgressChanged);
            GlobalData.backgroundWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(backgroundWorker_RunWorkerCompleted);
            GlobalData.backgroundWorker.RunWorkerAsync();

            return(true);
        }
 private void checkAndUpdateRepo(AsposeComponent component)
 {
     if (null == component)
     {
         return;
     }
     if (null == component.get_remoteExamplesRepository() || component.RemoteExamplesRepository == string.Empty)
     {
         showMessage("Examples not available", component.get_name() + " - " + Constants.EXAMPLES_NOT_AVAILABLE_MESSAGE, MessageBoxButtons.OK, MessageBoxIcon.Information);
         examplesNotAvailable = true;
         validateForm();
         return;
     }
     else
     {
         examplesNotAvailable = false;
         validateForm();
     }
     // String repoPath;
     if (GitHelper.isExamplesDefinitionsPresent(component))
     {
         CloneOrCheckOutRepo(component);
     }
     else
     {
         DialogResult result = showMessage("Examples download required", component.get_name() + " - " + Constants.EXAMPLES_DOWNLOAD_REQUIRED, MessageBoxButtons.YesNo, MessageBoxIcon.Information);
         if (result == DialogResult.Yes)
         {
             if (AsposeComponentsManager.isIneternetConnected())
             {
                 CloneOrCheckOutRepo(component);
             }
             else
             {
                 showMessage(Constants.INTERNET_CONNECTION_REQUIRED_MESSAGE_TITLE, component.get_name() + " - " + Constants.EXAMPLES_INTERNET_CONNECTION_REQUIRED_MESSAGE, MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
         }
     }
 }
        private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                UpdateProgress(1);
                int total = 10;
                int index = 0;

                AsposeComponentsManager comManager = new AsposeComponentsManager(this);
                foreach (AsposeComponent component in AsposeComponents.list.Values)
                {
                    if (component.is_selected())
                    {
                        GlobalData.SelectedComponent = component.get_name();

                        if (AsposeComponentsManager.libraryAlreadyExists(component.get_downloadFileName()))
                        {
                            component.set_downloaded(true);
                        }
                        else
                        {
                            AsposeComponentsManager.addToDownloadList(component, component.get_downloadUrl(), component.get_downloadFileName());
                        }
                    }

                    decimal percentage = ((decimal)(index + 1) / (decimal)total) * 100;
                    UpdateProgress(Convert.ToInt32(percentage));

                    index++;
                }

                UpdateProgress(100);
                UpdateText("All operations completed");
            }
            catch (Exception) { }
        }
        bool CopyAndCreateProject()
        {
            progressBar1.Visible           = true;
            progressBar1.Value             = 10;
            toolStripStatusMessage.Visible = true;
            toolStripStatusMessage.Text    = "Fetching Examples: - Please wait while we configure you preferences";
            AsposeComponent component;

            AsposeComponents.list.TryGetValue(Constants.ASPOSE_COMPONENT, out component);
            //TreeNodeData nodeData = (TreeNodeData)selectedNode.Tag;
            string sampleSourcePath = "Examples";
            string repoPath         = GitHelper.getLocalRepositoryPath(component);
            string destinationPath  = GetDestinationPath(textBoxLocation.Text + "\\" + Constants.ASPOSE_COMPONENT, sampleSourcePath);

            progressBar1.Value = 30;

            bool isSuccessfull = false;

            try
            {
                CopyFolderContents(Path.Combine(repoPath, sampleSourcePath), destinationPath);
                progressBar1.Value = 40;

                string   dllsRootPath = AsposeComponentsManager.getLibaryDownloadPath();
                string[] dllsPaths    = Directory.GetFiles(Path.Combine(dllsRootPath, component.Name + "/lib/net2.0/"), "*.dll");
                for (int i = 0; i < dllsPaths.Length; i++)
                {
                    if (!Directory.Exists(Path.Combine(destinationPath, "Bin")))
                    {
                        Directory.CreateDirectory(Path.Combine(destinationPath, "Bin"));
                    }
                    File.Copy(dllsPaths[i], Path.Combine(destinationPath, "Bin", Path.GetFileName(dllsPaths[i])), true);
                }

                progressBar1.Value = 50;

                string[] projectFiles = Directory.GetFiles(Path.Combine(destinationPath, (rdbCSharp.Checked ? "CSharp" : "VisualBasic")), (rdbCSharp.Checked ? "*.csproj" : "*.vbproj"));
                for (int i = 0; i < projectFiles.Length; i++)
                {
                    UpdatePrjReferenceHintPath(projectFiles[i], component);
                }
                progressBar1.Value = 70;

                int vsVersion = GetVSVersion();

                if (vsVersion >= 2010)
                {
                    vsVersion = 2010;                    // Since our examples mostly have 2010 solution files
                }
                string[] solutionFiles = Directory.GetFiles(Path.Combine(destinationPath, (rdbCSharp.Checked ? "CSharp" : "VisualBasic")), (rdbCSharp.Checked ? "*.sln" : "*.sln"));
                progressBar1.Value = 80;

                try
                {
                    if (solutionFiles.Length > 0)
                    {
                        foreach (string sFile in solutionFiles)
                        {
                            if (sFile.Contains(vsVersion.ToString()))
                            {
                                _application.Solution.Open(sFile);
                                isSuccessfull = true;
                                break;
                            }
                        }

                        if (!isSuccessfull)
                        {
                            System.Diagnostics.Process.Start(solutionFiles[solutionFiles.Count() - 1]);
                            isSuccessfull = true;
                        }
                    }
                    else if (projectFiles.Length > 0)
                    {
                        System.Diagnostics.Process.Start(projectFiles[0]);
                        isSuccessfull = true;
                    }
                    progressBar1.Value = 90;
                }
                catch (Exception)
                {
                    if (solutionFiles.Length > 0)
                    {
                        System.Diagnostics.Process.Start(solutionFiles[0]);
                        isSuccessfull = true;
                    }
                    else if (projectFiles.Length > 0)
                    {
                        System.Diagnostics.Process.Start(projectFiles[0]);
                        isSuccessfull = true;
                    }
                    progressBar1.Value = 90;
                }
            }
            catch (Exception)
            { }

            if (!isSuccessfull)
            {
                MessageBox.Show("Oops! We are unable to open the example project. Please open it manually from " + destinationPath);
                return(false);
            }
            progressBar1.Value = 100;

            return(true);
        }
 private void UnZipDownloadedFile(AsyncDownload download)
 {
     AsposeComponentsManager.unZipFile(download.LocalPath, Path.Combine(Path.GetDirectoryName(download.LocalPath), download.Component.Name));
 }
        bool CopyAndCreateProject()
        {
            AsposeComponent component;

            AsposeComponents.list.TryGetValue(comboBoxComponents.Text, out component);
            TreeNodeData nodeData         = (TreeNodeData)selectedNode.Tag;
            string       sampleSourcePath = nodeData.Path;
            string       repoPath         = GitHelper.getLocalRepositoryPath(component);
            string       destinationPath  = GetDestinationPath(textBoxLocation.Text + "\\" + comboBoxComponents.Text, sampleSourcePath);

            bool isSuccessfull = false;

            try
            {
                CopyFolderContents(Path.Combine(repoPath, sampleSourcePath), destinationPath);
                string   dllsRootPath = AsposeComponentsManager.getLibaryDownloadPath();
                string[] dllsPaths    = Directory.GetFiles(Path.Combine(dllsRootPath, component.Name), "*.dll");
                for (int i = 0; i < dllsPaths.Length; i++)
                {
                    if (!Directory.Exists(Path.Combine(destinationPath, "Bin")))
                    {
                        Directory.CreateDirectory(Path.Combine(destinationPath, "Bin"));
                    }
                    File.Copy(dllsPaths[i], Path.Combine(destinationPath, "Bin", Path.GetFileName(dllsPaths[i])), true);
                }

                string[] projectFiles = Directory.GetFiles(Path.Combine(destinationPath, "CSharp"), "*.csproj");
                for (int i = 0; i < projectFiles.Length; i++)
                {
                    UpdatePrjReferenceHintPath(projectFiles[i], component);
                }

                int vsVersion = GetVSVersion();

                if (vsVersion >= 2010)
                {
                    vsVersion = 2010;                    // Since our examples mostly have 2010 solution files
                }
                string[] solutionFiles = Directory.GetFiles(Path.Combine(destinationPath, "CSharp"), "*.sln");

                try
                {
                    if (solutionFiles.Length > 0)
                    {
                        foreach (string sFile in solutionFiles)
                        {
                            if (sFile.Contains(vsVersion.ToString()))
                            {
                                _application.Solution.Open(sFile);
                                isSuccessfull = true;
                                break;
                            }
                        }

                        if (!isSuccessfull)
                        {
                            System.Diagnostics.Process.Start(solutionFiles[solutionFiles.Count() - 1]);
                            isSuccessfull = true;
                        }
                    }
                    else if (projectFiles.Length > 0)
                    {
                        System.Diagnostics.Process.Start(projectFiles[0]);
                        isSuccessfull = true;
                    }
                }
                catch (Exception)
                {
                    if (solutionFiles.Length > 0)
                    {
                        System.Diagnostics.Process.Start(solutionFiles[0]);
                        isSuccessfull = true;
                    }
                    else if (projectFiles.Length > 0)
                    {
                        System.Diagnostics.Process.Start(projectFiles[0]);
                        isSuccessfull = true;
                    }
                }
            }
            catch (Exception)
            { }

            if (!isSuccessfull)
            {
                MessageBox.Show("Oops! We are unable to open the example project. Please open it manually from " + destinationPath);
                return(false);
            }

            return(true);
        }