コード例 #1
0
        private void DownloadMSI(string path,
            PluginInstallUpdateCB updateCB,
            PluginInstallFinishCB doneCB,
            PluginInstallErrorCB errorCB)
        {
            localFile = Path.Combine(Path.GetTempPath(), Path.GetFileName(path));

            // Initialise Async Web Request
            int BUFFER_SIZE = 1024;
            Uri fileURI = new Uri(path);

            WebRequest request = WebRequest.Create(fileURI);
            State requestState = new State(BUFFER_SIZE, localFile);
            requestState.request = request;
            requestState.fileURI = fileURI;
            requestState.progCB = updateCB;
            requestState.doneCB = doneCB;
            requestState.errorCB = errorCB;
            requestState.name = "";

            IAsyncResult result = (IAsyncResult)request.BeginGetResponse(new AsyncCallback(ResponseCallback), requestState);
        }
コード例 #2
0
ファイル: Kernel.cs プロジェクト: arthurwayne/metavideoeditor
        public void InstallPlugin(string path, 
            string name,
            PluginInstallUpdateCB updateCB,
            PluginInstallFinishCB doneCB,
            PluginInstallErrorCB errorCB)
        {
            string target = Path.Combine(ApplicationPaths.AppPluginPath, Path.GetFileName(path));

            if (path.ToLower().StartsWith("http"))
            {
                // Initialise Async Web Request
                int BUFFER_SIZE = 1024;
                Uri fileURI = new Uri(path);

                WebRequest request = WebRequest.Create(fileURI);
                State requestState = new State(BUFFER_SIZE, target);
                requestState.request = request;
                requestState.fileURI = fileURI;
                requestState.progCB = updateCB;
                requestState.doneCB = doneCB;
                requestState.errorCB = errorCB;
                requestState.name = name;

                IAsyncResult result = (IAsyncResult)request.BeginGetResponse(new AsyncCallback(ResponseCallback), requestState);
            }
            else
            {
                File.Copy(path, target);
                InitialisePlugin(target);
            }

            // Moved code to InitialisePlugin()
            //Function needs to be called at end of Async dl process as well
        }
コード例 #3
0
        public void DownloadUpdate(ProgressBar progress, Form window, Delegate done)
        {
            m_progress = progress;
            m_window = window;
            m_done = done;

            PluginInstallUpdateCB updateDelegate = new PluginInstallUpdateCB(InstallUpdate);
            PluginInstallFinishCB doneDelegate = new PluginInstallFinishCB(DownloadDone);
            PluginInstallErrorCB errorDelegate = new PluginInstallErrorCB(InstallError);

            try
            {
                DownloadMSI(Updater.UpdatePath + AppUpdatePath, updateDelegate, doneDelegate, errorDelegate);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Impossible d'installer le plugin.\n" + ex.Message, "MetaVideoEditor", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }