Changeset 1748
- Timestamp:
- 02/04/10 08:47:01 (3 years ago)
- File:
-
- 1 edited
-
branches/eraser6/CodeReview/Eraser/UpdateForm.cs (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eraser6/CodeReview/Eraser/UpdateForm.cs
r1747 r1748 146 146 //Get a list of translatable categories (this will change as more categories 147 147 //are added) 148 Dictionary<DownloadType, string> categories = new Dictionary<DownloadType, string>();149 categories.Add(DownloadType.Update, S._("Updates"));150 categories.Add(DownloadType.Plugin, S._("Plugins"));148 updatesLv.Groups.Add(DownloadType.Update.ToString(), S._("Updates")); 149 updatesLv.Groups.Add(DownloadType.Plugin.ToString(), S._("Plugins")); 150 updatesLv.Groups.Add(DownloadType.Build.ToString(), S._("Nightly builds")); 151 151 152 152 //Only include those whose architecture is compatible with ours. … … 176 176 continue; 177 177 178 //Create or retrieve the ListViewGroup object to categorise our downloads. 179 string categoryText = categories.ContainsKey(download.Type) ? 180 categories[download.Type] : download.Type.ToString(); 181 int groupIndex = updatesLv.Groups.IndexOf(new ListViewGroup(categoryText)); 182 if (groupIndex == -1) 183 groupIndex = updatesLv.Groups.Add(new ListViewGroup(categoryText)); 184 ListViewGroup group = updatesLv.Groups[groupIndex]; 178 //Get the group this download belongs to. 179 ListViewGroup group = updatesLv.Groups[download.Type.ToString()]; 185 180 186 181 //Add the item to the list of downloads available. … … 320 315 else 321 316 { 322 if ( e.Progress.Progress >= 1.0f)317 if (overallProgress.CurrentStep.Progress.Progress >= 1.0f) 323 318 { 324 319 downloadUIInfo.ListViewItem.ImageIndex = -1; … … 327 322 else 328 323 { 329 downloadUIInfo.Downloaded = (long)(overallProgress.Progress * download.FileSize); 324 downloadUIInfo.Downloaded = (long) 325 (overallProgress.CurrentStep.Progress.Progress * download.FileSize); 330 326 downloadUIInfo.ListViewItem.ImageIndex = 0; 331 327 downloadUIInfo.ListViewItem.SubItems[1].Text = FileSize.ToString(download.FileSize - … … 397 393 { 398 394 ++progress.Completed; 399 int exitCode = download.Install(); 400 401 if (exitCode == 0)395 396 try 397 { 402 398 installer_ProgressChanged(download, 403 399 new ProgressChangedEventArgs(progress, null)); 404 else400 download.Install(); 405 401 installer_ProgressChanged(download, 406 new ProgressChangedEventArgs(progress, 407 new ApplicationException(S._( 408 "The installer exited with an error code {0}", exitCode)))); 402 new ProgressChangedEventArgs(progress, null)); 403 } 404 catch (Exception ex) 405 { 406 installer_ProgressChanged(download, 407 new ProgressChangedEventArgs(progress, ex)); 408 } 409 409 } 410 410 … … 441 441 else 442 442 { 443 downloadUIInfo.ListViewItem.SubItems[1].Text = S._("Installed {0}", download.Name);444 443 switch (downloadUIInfo.ListViewItem.ImageIndex) 445 444 { 446 445 case -1: 446 downloadUIInfo.ListViewItem.SubItems[1].Text = 447 S._("Installing {0}", download.Name); 447 448 downloadUIInfo.ListViewItem.ImageIndex = 1; 448 449 break; 449 450 case 1: 451 downloadUIInfo.ListViewItem.SubItems[1].Text = 452 S._("Installed {0}", download.Name); 450 453 downloadUIInfo.ListViewItem.ImageIndex = 2; 451 454 break; … … 525 528 HttpRequestCacheLevel.Revalidate); 526 529 HttpWebRequest request = (HttpWebRequest)WebRequest.Create( 527 new Uri("http://eraser.heidi.ie/scripts/updates?action=listupdates&version= "+528 Assembly.GetExecutingAssembly().GetName().Version.ToString() ));530 new Uri("http://eraser.heidi.ie/scripts/updates?action=listupdates&version=6.1.0.0" /*+ 531 Assembly.GetExecutingAssembly().GetName().Version.ToString()*/)); 529 532 530 533 using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) … … 561 564 { 562 565 //Move the XmlReader to the root node 563 XmlReader r dr = XmlReader.Create(strm);564 r dr.ReadToFollowing("updateList");566 XmlReader reader = XmlReader.Create(strm); 567 reader.ReadToFollowing("updateList"); 565 568 566 569 //Read the descendants of the updateList node (ignoring the <mirrors> element) 567 570 //These are categories. 568 XmlReader categories = rdr.ReadSubtree();569 bool cont = categories.ReadToDescendant("mirrors");570 if (!cont)571 throw new InvalidDataException();572 cont = categories.Read();571 bool cont = reader.Read(); 572 while (reader.NodeType != XmlNodeType.Element) 573 cont = reader.Read(); 574 if (reader.NodeType != XmlNodeType.Element) 575 return new List<DownloadInfo>(); 573 576 574 577 List<DownloadInfo> result = new List<DownloadInfo>(); 575 while (cont) 576 { 577 if (categories.NodeType == XmlNodeType.Element) 578 { 579 result.AddRange(ParseDownloadCategory(categories.Name, categories.ReadSubtree())); 580 } 581 582 cont = categories.Read(); 583 } 578 do 579 { 580 if (reader.NodeType == XmlNodeType.Element) 581 { 582 result.AddRange(ParseDownloadCategory(reader.Name, reader.ReadSubtree())); 583 } 584 585 cont = reader.Read(); 586 } 587 while (cont); 584 588 585 589 return result; … … 605 609 606 610 result.Add(new DownloadInfo(rdr.GetAttribute("name"), 607 (DownloadType) Convert.ChangeType(category, typeof(DownloadType)),611 (DownloadType)Enum.Parse(typeof(DownloadType), category, true), 608 612 new Version(rdr.GetAttribute("version")), rdr.GetAttribute("publisher"), 609 613 rdr.GetAttribute("architecture"), Convert.ToInt64(rdr.GetAttribute("filesize")), … … 634 638 /// The download is a plugin. 635 639 /// </summary> 636 Plugin 640 Plugin, 641 642 /// <summary> 643 /// The download is a nightly build. 644 /// </summary> 645 Build 637 646 } 638 647 … … 752 761 /// </summary> 753 762 /// <returns>The exit code of the program.</returns> 754 public intInstall()763 public void Install() 755 764 { 756 765 if (DownloadedFile == null || !DownloadedFile.Exists || DownloadedFile.Length == 0) … … 761 770 info.FileName = DownloadedFile.FullName; 762 771 info.UseShellExecute = true; 763 //info.Verb = "runas";764 772 765 773 Process process = Process.Start(info); 766 774 process.WaitForExit(Int32.MaxValue); 767 return process.ExitCode;768 775 } 769 776
Note: See TracChangeset
for help on using the changeset viewer.
