Changeset 903
- Timestamp:
- 4/28/2009 10:34:04 AM (4 years ago)
- Location:
- branches/eraser6/Eraser
- Files:
-
- 8 edited
-
AboutForm.Designer.cs (modified) (1 diff)
-
AboutForm.cs (modified) (3 diffs)
-
LogForm.cs (modified) (1 diff)
-
Program.cs (modified) (22 diffs)
-
TaskDataSelectionForm.cs (modified) (1 diff)
-
TaskPropertiesForm.cs (modified) (2 diffs)
-
ToolBar.cs (modified) (6 diffs)
-
UpdateForm.cs (modified) (20 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eraser6/Eraser/AboutForm.Designer.cs
r856 r903 39 39 components.Dispose(); 40 40 } 41 42 ParentBitmap.Dispose(); 43 AboutBitmap.Dispose(); 44 AboutTextBitmap.Dispose(); 45 DoubleBufferBitmap.Dispose(); 41 46 base.Dispose(disposing); 42 47 } -
branches/eraser6/Eraser/AboutForm.cs
r856 r903 129 129 string disclaimerText = S._("Eraser is free open-source software!"); 130 130 PointF disclaimerPos = new PointF(websitePos.X, websitePos.Y + websiteSize.Height * 1.5f); 131 SizeF disclaimerSize = g.MeasureString(disclaimerText, Font);132 131 g.DrawString(disclaimerText, Font, textBrush, disclaimerPos); 133 132 … … 175 174 } 176 175 177 ParentOpacity = 0;178 176 AboutTextScrollTop = AboutTextRect.Height / 2; 179 177 animationTimer_Tick(null, null); … … 215 213 ParentOpacity += 8; 216 214 if (AboutTextBitmap.Height < -AboutTextScrollTop) 217 {218 215 AboutTextScrollTop = AboutTextRect.Height; 219 GC.Collect();220 }221 216 else 222 217 AboutTextScrollTop -= 1; -
branches/eraser6/Eraser/LogForm.cs
r900 r903 109 109 { 110 110 StringBuilder text = new StringBuilder(); 111 Dictionary<DateTime, List<LogEntry>> log = task.Log.Entries; 112 Dictionary<DateTime, List<LogEntry>>.Enumerator iter = log.GetEnumerator(); 113 foreach (DateTime sessionTime in log.Keys) 111 Dictionary<DateTime, List<LogEntry>> logEntries = task.Log.Entries; 112 foreach (DateTime sessionTime in logEntries.Keys) 114 113 { 115 114 text.AppendLine(S._("Session: {0}", sessionTime.ToString(DATEPATTERN))); 116 foreach (LogEntry entry in log [sessionTime])115 foreach (LogEntry entry in logEntries[sessionTime]) 117 116 { 118 117 text.AppendFormat("{0} {1} {2}\n", -
branches/eraser6/Eraser/Program.cs
r858 r903 37 37 using Eraser.Util; 38 38 using Microsoft.Win32; 39 using System.Runtime.Serialization; 39 40 40 41 namespace Eraser … … 127 128 { 128 129 //Create the program instance 129 GUIProgram program = new GUIProgram(commandLine, "Eraser-BAD0DAC6-C9EE-4acc-" +130 using (GUIProgram program = new GUIProgram(commandLine, "Eraser-BAD0DAC6-C9EE-4acc-" + 130 131 "8701-C9B3C64BC65E-GUI-" + 131 System.Security.Principal.WindowsIdentity.GetCurrent().User.ToString()) ;132 System.Security.Principal.WindowsIdentity.GetCurrent().User.ToString())) 132 133 133 134 //Then run the program instance. … … 155 156 System.Threading.Thread.CurrentThread.CurrentUICulture = 156 157 new CultureInfo(settings.Language); 157 program.SafeTopLevelCaptionFormat = S._("Eraser");158 GUIProgram.SafeTopLevelCaptionFormat = S._("Eraser"); 158 159 159 160 //Load the task list … … 164 165 eraserClient.LoadTaskList(stream); 165 166 } 166 catch ( Exception)167 catch (SerializationException e) 167 168 { 168 169 settings.TaskList = null; 169 170 MessageBox.Show(S._("Could not load task list. All task entries have " + 170 "been lost. "), S._("Eraser"), MessageBoxButtons.OK,171 MessageBox Icon.Error);171 "been lost. The error returned was: {0}", e.Message), S._("Eraser"), 172 MessageBoxButtons.OK, MessageBoxIcon.Error); 172 173 } 173 174 … … 242 243 } 243 244 244 class GUIProgram 245 class GUIProgram : IDisposable 245 246 { 246 247 /// <summary> … … 260 261 //Check if there already is another instance of the program. 261 262 globalMutex = new Mutex(true, instanceID, out isFirstInstance); 263 } 264 265 public void Dispose() 266 { 267 globalMutex.Close(); 268 GC.SuppressFinalize(this); 262 269 } 263 270 … … 278 285 //If no other instances are running, set up our pipe server so clients 279 286 //can connect and give us subsequent command lines. 280 if ( isFirstInstance)287 if (IsAlreadyRunning) 281 288 { 282 289 try … … 324 331 int count = Encoding.UTF8.GetBytes(commandLineStr.ToString(), 0, 325 332 commandLineStr.Length, buffer, 0); 326 client.Write(buffer, 0, buffer.Length);333 client.Write(buffer, 0, count); 327 334 } 328 335 catch (UnauthorizedAccessException) … … 422 429 /// they are displayed with a warning banner. 423 430 /// </summary> 424 public st ring SafeTopLevelCaptionFormat431 public static string SafeTopLevelCaptionFormat 425 432 { 426 433 get … … 657 664 if (parameter[1] == '-') 658 665 return parameter.Substring(2) == expectedParameter; 659 else if (s hortParameter == null || shortParameter == string.Empty)666 else if (string.IsNullOrEmpty(shortParameter)) 660 667 return parameter.Substring(1) == expectedParameter; 661 668 else … … 666 673 parameter = parameter.Substring(1); 667 674 return parameter == expectedParameter || ( 668 shortParameter != null && shortParameter != string.Empty && 669 parameter == shortParameter 675 !string.IsNullOrEmpty(shortParameter) && parameter == shortParameter 670 676 ); 671 677 … … 767 773 List<KeyValuePair<string, string>> subParams = 768 774 GetSubParameters(param.Substring(equalPos + 1)); 769 ErasureMethod = new Guid(subParams[0].Key);775 erasureMethod = new Guid(subParams[0].Key); 770 776 } 771 777 else if (IsParam(param, "schedule", "s")) … … 780 786 { 781 787 case "now": 782 Schedule = Schedule.RunNow;788 schedule = Schedule.RunNow; 783 789 break; 784 790 case "restart": … … 872 878 return erasureMethod; 873 879 } 874 private set875 {876 erasureMethod = value;877 }878 880 } 879 881 … … 887 889 return schedule; 888 890 } 889 set890 {891 schedule = value;892 }893 891 } 894 892 … … 901 899 { 902 900 return new List<Task.ErasureTarget>(targets.ToArray()); 903 }904 set905 {906 targets = value;907 901 } 908 902 } … … 967 961 /// defaults. 968 962 /// </summary> 969 private void CreateConsole()963 private static void CreateConsole() 970 964 { 971 965 if (KernelAPI.AllocConsole()) … … 1088 1082 private void AddTask() 1089 1083 { 1090 AddTaskCommandLine arguments = (AddTaskCommandLine)Arguments;1084 AddTaskCommandLine taskArgs = (AddTaskCommandLine)Arguments; 1091 1085 1092 1086 //Create the task, and set the method to use. 1093 1087 Task task = new Task(); 1094 ErasureMethod method = arguments.ErasureMethod == Guid.Empty ?1088 ErasureMethod method = taskArgs.ErasureMethod == Guid.Empty ? 1095 1089 ErasureMethodManager.Default : 1096 ErasureMethodManager.GetInstance( arguments.ErasureMethod);1097 foreach (Task.ErasureTarget target in arguments.Targets)1090 ErasureMethodManager.GetInstance(taskArgs.ErasureMethod); 1091 foreach (Task.ErasureTarget target in taskArgs.Targets) 1098 1092 { 1099 1093 target.Method = method; … … 1106 1100 1107 1101 //Set the schedule for the task. 1108 task.Schedule = arguments.Schedule;1102 task.Schedule = taskArgs.Schedule; 1109 1103 1110 1104 //Send the task out. … … 1122 1116 1123 1117 if (!((RemoteExecutorClient)Program.eraserClient).Connect()) 1124 throw new Exception("Eraser cannot connect to the running " +1118 throw new IOException("Eraser cannot connect to the running " + 1125 1119 "instance for erasures."); 1126 1120 } … … 1171 1165 /// </summary> 1172 1166 /// <param name="key">The registry key to look for the settings in.</param> 1173 public RegistrySettings(Guid pluginID, RegistryKey key)1167 public RegistrySettings(Guid guid, RegistryKey key) 1174 1168 { 1175 1169 this.key = key; … … 1187 1181 return new BinaryFormatter().Deserialize(stream); 1188 1182 } 1189 catch ( Exception)1183 catch (SerializationException) 1190 1184 { 1191 1185 key.DeleteValue(setting); -
branches/eraser6/Eraser/TaskDataSelectionForm.cs
r865 r903 176 176 } 177 177 else 178 throw new Exception("Unknown erasure target.");178 throw new ArgumentException("Unknown erasure target."); 179 179 } 180 180 } -
branches/eraser6/Eraser/TaskPropertiesForm.cs
r493 r903 119 119 } 120 120 else 121 throw new Exception("No such scheduling method.");121 throw new ArgumentException("No such scheduling method."); 122 122 } 123 123 } … … 187 187 break; 188 188 default: 189 throw new Exception("Unknown schedule type.");189 throw new ArgumentException("Unknown schedule type."); 190 190 } 191 191 } -
branches/eraser6/Eraser/ToolBar.cs
r492 r903 28 28 using System.Windows.Forms; 29 29 using System.Runtime.InteropServices; 30 using System.Collections.ObjectModel; 30 31 31 32 namespace Eraser … … 81 82 /// </summary> 82 83 /// <param name="dc">Graphics object to draw on.</param> 83 public void Draw(Graphics sdc)84 public void Draw(Graphics rawDC) 84 85 { 85 86 //Create a backing bitmap buffer to prevent flicker … … 145 146 } 146 147 147 sdc.DrawImage(back_bmp, new Point(0, 0));148 rawDC.DrawImage(back_bmp, new Point(0, 0)); 148 149 } 149 150 … … 160 161 /// </summary> 161 162 /// <param name="pe">Paint event object.</param> 162 protected override void OnPaint(PaintEventArgs pe)163 { 164 Draw( pe.Graphics);163 protected override void OnPaint(PaintEventArgs e) 164 { 165 Draw(e.Graphics); 165 166 166 167 // Calling the base class OnPaint 167 base.OnPaint( pe);168 base.OnPaint(e); 168 169 } 169 170 … … 176 177 /// Accesses or modifies the items in the tool bar. 177 178 /// </summary> 178 /// <param name="i ">Index of item.</param>179 /// <param name="index">Index of item.</param> 179 180 /// <returns>ToolBarItem describing the item at index i.</returns> 180 public ToolBarItem this[int i ]181 public ToolBarItem this[int index] 181 182 { 182 183 get 183 184 { 184 return items[i ];185 return items[index]; 185 186 } 186 187 187 188 set 188 189 { 189 items[i ] = value;190 items[index] = value; 190 191 Redraw(); 191 192 } 192 193 } 193 194 194 public List<ToolBarItem> Items195 public ICollection<ToolBarItem> Items 195 196 { 196 197 get { return items; } 197 set { items = value; }198 198 } 199 199 } … … 233 233 /// Item click event handler 234 234 /// </summary> 235 public event ToolbarItemClickedEventFunction ToolbarItemClicked; 236 public delegate void ToolbarItemClickedEventFunction(object sender, EventArgs e); 235 public EventHandler<EventArgs> ToolbarItemClicked 236 { 237 get; 238 set; 239 } 240 237 241 internal void OnToolbarItemClicked(object sender) 238 242 { -
branches/eraser6/Eraser/UpdateForm.cs
r864 r903 87 87 { 88 88 updates.OnProgressEvent += updateListDownloader_ProgressChanged; 89 updates. GetUpdates();89 updates.DownloadUpdateList(); 90 90 } 91 91 finally … … 107 107 throw new OperationCanceledException(); 108 108 109 Invoke(new UpdateManager.ProgressEventFunction(updateListDownloader_ProgressChanged),110 sender, e);109 Invoke(new EventHandler<UpdateManager.ProgressEventArgs>( 110 updateListDownloader_ProgressChanged), sender, e); 111 111 return; 112 112 } … … 306 306 throw new OperationCanceledException(); 307 307 308 Invoke(new UpdateManager.ProgressEventFunction(downloader_ProgressChanged),308 Invoke(new EventHandler<UpdateManager.ProgressEventArgs>(downloader_ProgressChanged), 309 309 sender, e); 310 310 return; … … 312 312 313 313 UpdateData update = uiUpdates[(UpdateManager.Update)e.UserState]; 314 long amountLeft = (long)((1 - e.ProgressPercentage) * update.Update.FileSize);315 314 316 315 if (e is UpdateManager.ProgressErrorEventArgs) … … 415 414 throw new OperationCanceledException(); 416 415 417 Invoke(new UpdateManager.ProgressEventFunction(installer_ProgressChanged),416 Invoke(new EventHandler<UpdateManager.ProgressEventArgs>(installer_ProgressChanged), 418 417 sender, e); 419 418 return; … … 480 479 Update = update; 481 480 LVItem = item; 482 amountDownloaded = 0;483 Error = null;484 481 } 485 482 … … 527 524 { 528 525 public Mirror(string location, string link) 526 : this() 529 527 { 530 528 Location = location; … … 535 533 /// The location where the mirror is at. 536 534 /// </summary> 537 public string Location; 535 public string Location 536 { 537 get; 538 set; 539 } 538 540 539 541 /// <summary> 540 542 /// The URL prefix to utilise the mirror. 541 543 /// </summary> 542 public string Link; 544 public string Link 545 { 546 get; 547 set; 548 } 543 549 544 550 public override string ToString() … … 648 654 /// Retrieves the update list from the server. 649 655 /// </summary> 650 public void GetUpdates()656 public void DownloadUpdateList() 651 657 { 652 658 WebRequest.DefaultCachePolicy = new HttpRequestCachePolicy( 653 659 HttpRequestCacheLevel.Refresh); 654 660 HttpWebRequest req = (HttpWebRequest) 655 WebRequest.Create( "http://eraser.heidi.ie/updates?action=listupdates&" +656 "version=" + Assembly.GetExecutingAssembly().GetName().Version.ToString()) ;661 WebRequest.Create(new Uri("http://eraser.heidi.ie/updates?action=listupdates&" + 662 "version=" + Assembly.GetExecutingAssembly().GetName().Version.ToString())); 657 663 658 664 using (WebResponse resp = req.GetResponse()) … … 781 787 /// <param name="updates">The updates to retrieve and install.</param> 782 788 /// <returns>An opaque object for use with InstallUpdates.</returns> 783 public object DownloadUpdates( List<Update> updates)789 public object DownloadUpdates(ICollection<Update> downloadQueue) 784 790 { 785 791 //Create a folder to hold all our updates. … … 789 795 int currUpdate = 0; 790 796 Dictionary<string, Update> tempFilesMap = new Dictionary<string, Update>(); 791 foreach (Update update in updates)797 foreach (Update update in downloadQueue) 792 798 { 793 799 try … … 800 806 reqUri = new Uri(update.Link); 801 807 else 802 reqUri = new Uri(new Uri(SelectedMirror.Link), update.Link);808 reqUri = new Uri(new Uri(SelectedMirror.Link), new Uri(update.Link)); 803 809 804 810 //Then grab the download. … … 823 829 //Compute progress 824 830 float itemProgress = tempStrm.Position / (float)resp.ContentLength; 825 float overallProgress = (currUpdate - 1 + itemProgress) / updates.Count;831 float overallProgress = (currUpdate - 1 + itemProgress) / downloadQueue.Count; 826 832 OnProgress(new ProgressEventArgs(itemProgress, overallProgress, 827 833 update, S._("Downloading: {0}", update.Name))); … … 833 839 834 840 //Let the event handler know the download is complete. 835 OnProgress(new ProgressEventArgs(1.0f, (float)currUpdate / updates.Count,841 OnProgress(new ProgressEventArgs(1.0f, (float)currUpdate / downloadQueue.Count, 836 842 update, S._("Downloaded: {0}", update.Name))); 837 843 } … … 840 846 { 841 847 OnProgress(new ProgressErrorEventArgs(new ProgressEventArgs(1.0f, 842 (float)currUpdate / updates.Count, update,848 (float)currUpdate / downloadQueue.Count, update, 843 849 S._("Error downloading {0}: {1}", update.Name, e.Message)), 844 850 e)); … … 849 855 } 850 856 851 public void InstallUpdates(object downloadObject)852 { 853 Dictionary<string, Update> tempFiles = (Dictionary<string, Update>) downloadObject;857 public void InstallUpdates(object value) 858 { 859 Dictionary<string, Update> tempFiles = (Dictionary<string, Update>)value; 854 860 Dictionary<string, Update>.KeyCollection files = tempFiles.Keys; 855 861 int currItem = 0; … … 876 882 OnProgress(new ProgressErrorEventArgs(new ProgressEventArgs(1.0f, 877 883 progress, item, S._("Error installing {0}", item.Name)), 878 new Exception(S._("The installer exited with an error code {0}",884 new ApplicationException(S._("The installer exited with an error code {0}", 879 885 process.ExitCode)))); 880 886 } … … 898 904 899 905 /// <summary> 900 /// Prototype of the callback functions from this object.901 /// </summary>902 /// <param name="sender">The source of the event.</param>903 /// <param name="arg">The ProgressEventArgs object holding information904 /// about the progress of the current operation.</param>905 public delegate void ProgressEventFunction(object sender, ProgressEventArgs arg);906 907 /// <summary>908 906 /// Called when the progress of the operation changes. 909 907 /// </summary> 910 public ProgressEventFunction OnProgressEvent; 908 public EventHandler<ProgressEventArgs> OnProgressEvent 909 { 910 get { return onProgressEvent; } 911 set { onProgressEvent = value; } 912 } 913 private EventHandler<ProgressEventArgs> onProgressEvent; 911 914 912 915 /// <summary> … … 956 959 } 957 960 958 throw new IndexOutOfRangeException();961 throw new ArgumentException(S._("Unknown mirror selected.")); 959 962 } 960 963 } … … 987 990 /// <param name="key">The category to retrieve.</param> 988 991 /// <returns>All updates in the given category.</returns> 989 public List<Update> this[string key]992 public ICollection<Update> this[string key] 990 993 { 991 994 get
Note: See TracChangeset
for help on using the changeset viewer.
