private void enableToolStripMenuItem_Click(object sender, EventArgs e) { ToolStripMenuItem ts = (ToolStripMenuItem)sender; foreach (ListViewItem item in listViewDetails.SelectedItems) { ProgramSettings pSettings = UpdateCacher.GetPackage(item.Name); if (pSettings != null) { UpdateCacher.CheckPackage(item.Name, ts.Checked, false); } iUpgradeable file = MainForm.Instance.UpdateHandler.UpdateData.FindByName(item.Name); Version latest = file.AvailableVersion; if (pSettings != null && !pSettings.UpdateAllowed()) { item.SubItems["Status"].Text = EnumProxy.Create(PackageStatus.Disabled).ToString(); item.Checked = false; } else if (!file.isAvailable()) { item.SubItems["Status"].Text = EnumProxy.Create(PackageStatus.Reinstall).ToString(); item.Checked = true; } else if (latest != null && file.CurrentVersion == null || latest.CompareTo(file.CurrentVersion) != 0) { item.SubItems["Status"].Text = EnumProxy.Create(PackageStatus.UpdateAvailable).ToString(); item.Checked = true; } else { item.SubItems["Status"].Text = EnumProxy.Create(PackageStatus.NoUpdateAvailable).ToString(); item.Checked = false; } } }
public ListViewItem CreateListViewItem() { ListViewItem myitem = new ListViewItem(); ListViewItem.ListViewSubItem name = new ListViewItem.ListViewSubItem(); ListViewItem.ListViewSubItem existingVersion = new ListViewItem.ListViewSubItem(); ListViewItem.ListViewSubItem latestVersion = new ListViewItem.ListViewSubItem(); ListViewItem.ListViewSubItem existingDate = new ListViewItem.ListViewSubItem(); ListViewItem.ListViewSubItem latestDate = new ListViewItem.ListViewSubItem(); ListViewItem.ListViewSubItem lastUsed = new ListViewItem.ListViewSubItem(); ListViewItem.ListViewSubItem status = new ListViewItem.ListViewSubItem(); myitem.Name = this.Name; name.Name = "Name"; existingVersion.Name = "Existing Version"; latestVersion.Name = "Latest Version"; existingDate.Name = "Existing Date"; latestDate.Name = "Latest Date"; lastUsed.Name = "Last Used"; status.Name = "Status"; name.Text = this.DisplayName; Version v = this.availableVersion; if (v != null) { latestVersion.Text = v.FileVersion; latestDate.Text = v.UploadDate.ToShortDateString(); } else { latestVersion.Text = "unknown"; latestDate.Text = "unknown"; } if (this.CurrentVersion != null && !String.IsNullOrEmpty(this.CurrentVersion.FileVersion)) { existingVersion.Text = this.CurrentVersion.FileVersion; if (this.CurrentVersion.UploadDate.Year > 1) { existingDate.Text = this.CurrentVersion.UploadDate.ToShortDateString(); } else { existingDate.Text = "N/A"; } } else { existingVersion.Text = "N/A"; existingDate.Text = "N/A"; } ProgramSettings pSettings = UpdateCacher.GetPackage(this.name); if (pSettings != null && !pSettings.UpdateAllowed()) { status.Text = EnumProxy.Create(PackageStatus.Disabled).ToString(); } else if (!this.isAvailable()) { status.Text = EnumProxy.Create(PackageStatus.Reinstall).ToString(); this.DownloadChecked = this.AllowUpdate = true; } else if (!HasAvailableVersion) { if (this.DownloadChecked) { status.Text = EnumProxy.Create(PackageStatus.Reinstall).ToString(); } else { status.Text = EnumProxy.Create(PackageStatus.NoUpdateAvailable).ToString(); } } else { if (this.AllowUpdate) { status.Text = EnumProxy.Create(PackageStatus.UpdateAvailable).ToString(); } else { status.Text = EnumProxy.Create(PackageStatus.UpdateIgnored).ToString(); } } if (this.AllowUpdate) { if (this.DownloadChecked) { myitem.Checked = true; } else { myitem.Checked = false; } } if (pSettings != null) { if (pSettings.LastUsed.Year > 1) { lastUsed.Text = pSettings.LastUsed.ToShortDateString(); } else { lastUsed.Text = "N/A"; } } else { lastUsed.Text = "---"; } myitem.SubItems.Add(name); myitem.SubItems.Add(existingVersion); myitem.SubItems.Add(latestVersion); myitem.SubItems.Add(existingDate); myitem.SubItems.Add(latestDate); myitem.SubItems.Add(lastUsed); myitem.SubItems.Add(status); return(myitem); }
public static EnumProxy[] CreateArray(System.Collections.IList list) { EnumProxy[] arr = new EnumProxy[list.Count]; for(int i=0; i<arr.Length; i++) { arr[i] = Create(list[i]); } return arr; }
public static EnumProxy[] CreateArray(System.Type enumType) { if (enumType == null) throw new ArgumentNullException("enumType"); if (!enumType.IsEnum) throw new ArgumentException("enumType must be Enum", "enumType"); FieldInfo[] enumItems = enumType.GetFields(BindingFlags.Public | BindingFlags.Static); EnumProxy[] arr = new EnumProxy[enumItems.Length]; for (int i = 0; i < arr.Length; i++) { arr[i] = Create( enumItems[i].GetValue(null) ); } return arr; }
public static EnumProxy Create(object v) { lock (lockObject) { if (cache.ContainsKey(v)) return cache[v]; else { EnumProxy p = new EnumProxy(v); cache.Add(v, p); return p; } } }