Exemplo n.º 1
0
 private static void UpdateDownloadProgress(DownloadAndInstallProcess process, int downloadedBytes)
 {
     process.DownloadedBytes += downloadedBytes;
     if(process.Monitor != null && process.WebResponse.ContentLength > 0 && process.DownloadedBytes <= process.WebResponse.ContentLength)
     {
         var state = new OperationProgress
         {
             CurrentProgress = (int)process.DownloadedBytes,
             MaxProgress     = (int)process.WebResponse.ContentLength,
             IsIndeterminate = false,
             ActionName      = "Downloading MSysGit...",
         };
         process.Monitor.Report(state);
     }
 }
Exemplo n.º 2
0
 private static void OnGotResponse(IAsyncResult ar)
 {
     var process = (DownloadAndInstallProcess)ar.AsyncState;
     var state = new OperationProgress
     {
         CurrentProgress = 0,
         MaxProgress     = 0,
         IsIndeterminate = true,
         ActionName      = "Downloading MSysGit...",
     };
     if(process.Monitor != null)
     {
         process.Monitor.Report(state);
     }
     process.WebResponse = process.WebRequest.EndGetResponse(ar);
     process.ResponseStream = process.WebResponse.GetResponseStream();
     if(process.WebResponse.ContentLength > 0)
     {
         state.IsIndeterminate = false;
         state.MaxProgress = (int)process.WebResponse.ContentLength;
         if(process.Monitor != null)
         {
             process.Monitor.Report(state);
         }
     }
     process.Buffer = new byte[1024*4];
     process.ResponseStream.BeginRead(
         process.Buffer,
         0,
         process.Buffer.Length,
         OnResponseStreamRead,
         process);
 }
Exemplo n.º 3
0
 private static void RunInstaller(DownloadAndInstallProcess process)
 {
     var state = new OperationProgress
     {
         CurrentProgress = 0,
         MaxProgress     = 0,
         IsIndeterminate = true,
         ActionName      = "Installing MSysGit...",
     };
     if(process.Monitor != null)
     {
         process.Monitor.Report(state);
     }
     try
     {
         process.InstallerProcess = new Process()
         {
             StartInfo = new ProcessStartInfo()
             {
                 FileName = process.InstallerFileName,
                 Arguments = @"/verysilent",
             },
             EnableRaisingEvents = true,
         };
         process.InstallerProcess.Exited += process.OnInstallerProcessExited;
         process.InstallerProcess.Start();
     }
     catch(Exception exc)
     {
         process.Exception = exc;
         process.Dispose();
     }
 }
Exemplo n.º 4
0
 private static void SetProgress(IProgress<OperationProgress> progress, int val, string action)
 {
     if(progress != null)
     {
         var status = new OperationProgress
         {
             ActionName      = action,
             MaxProgress     = 8,
             CurrentProgress = val,
         };
         progress.Report(status);
     }
 }