public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (((UInt64)value) == 0) { return(""); } return(FileOps.FormatSize((UInt64)value) + "/s"); }
public void DoUpdate(ProgramSet progSet) { this.progSet = progSet; SuspendChange++; ImgFunc.GetIconAsync(progSet.GetIcon(), icon.Width, (ImageSource src) => { if (Application.Current != null) { Application.Current.Dispatcher.Invoke(new Action(() => { icon.Source = src; })); } return(0); }); //name.Content = process.Name; name.Text = progSet.config.Name; int blockedConnections = 0; int allowedConnections = 0; int socketCount = 0; UInt64 uploadRate = 0; UInt64 downloadRate = 0; foreach (Program prog in progSet.Programs.Values) { blockedConnections += prog.BlockedCount; allowedConnections += prog.AllowedCount; socketCount += prog.SocketCount; uploadRate += prog.UploadRate; downloadRate += prog.DownloadRate; } info.Content = Translate.fmt("lbl_prog_info", blockedConnections, allowedConnections, socketCount, FileOps.FormatSize((decimal)uploadRate), FileOps.FormatSize((decimal)downloadRate)); WpfFunc.CmbSelect(category, progSet.config.Category == null ? "" : progSet.config.Category); WpfFunc.CmbSelect(cmbAccess, progSet.config.GetAccess().ToString()); if (progSet.config.NetAccess != ProgramSet.Config.AccessLevels.Unconfigured && progSet.config.NetAccess != progSet.config.CurAccess) { cmbAccess.Background /*grid.Background*/ = FindResource("Stripes") as DrawingBrush; } else { cmbAccess.Background = GetAccessColor(progSet.config.GetAccess()); } chkNotify.IsChecked = progSet.config.GetNotify(); progGrid.Items.Clear(); foreach (Program prog in progSet.Programs.Values) { progGrid.Items.Insert(0, new ProgEntry(prog)); } btnSplit.IsEnabled = progSet.Programs.Count > 1; SuspendChange--; }
void LoadList(List <MsUpdate> List) { updateView.Items.Clear(); ListViewItem[] items = new ListViewItem[List.Count]; for (int i = 0; i < List.Count; i++) { MsUpdate Update = List[i]; string State = ""; switch (Update.State) { case MsUpdate.UpdateState.History: switch ((OperationResultCode)Update.ResultCode) { case OperationResultCode.orcNotStarted: State = "Not Started"; break; case OperationResultCode.orcInProgress: State = "In Progress"; break; case OperationResultCode.orcSucceeded: State = "Succeeded"; break; case OperationResultCode.orcSucceededWithErrors: State = "Succeeded with Errors"; break; case OperationResultCode.orcFailed: State = "Failed"; break; case OperationResultCode.orcAborted: State = "Aborted"; break; } State += " (0x" + String.Format("{0:X8}", Update.HResult) + ")"; break; default: if ((Update.Attributes & (int)MsUpdate.UpdateAttr.Beta) != 0) { State = "Beta "; } if ((Update.Attributes & (int)MsUpdate.UpdateAttr.Installed) != 0) { State += "Installed"; if ((Update.Attributes & (int)MsUpdate.UpdateAttr.Uninstallable) != 0) { State += " Removable"; } } else if ((Update.Attributes & (int)MsUpdate.UpdateAttr.Hidden) != 0) { State += "Hidden"; if ((Update.Attributes & (int)MsUpdate.UpdateAttr.Downloaded) != 0) { State += " Downloaded"; } } else { if ((Update.Attributes & (int)MsUpdate.UpdateAttr.Downloaded) != 0) { State += "Downloaded"; } else { State += "Pending"; } if ((Update.Attributes & (int)MsUpdate.UpdateAttr.AutoSelect) != 0) { State += " (!)"; } if ((Update.Attributes & (int)MsUpdate.UpdateAttr.Mandatory) != 0) { State += " Manatory"; } } if ((Update.Attributes & (int)MsUpdate.UpdateAttr.Exclusive) != 0) { State += ", Exclusive"; } if ((Update.Attributes & (int)MsUpdate.UpdateAttr.Reboot) != 0) { State += ", Needs Reboot"; } break; } items[i] = new ListViewItem(new string[] { Update.Title, Update.Category, Update.KB, FileOps.FormatSize(Update.Size), Update.Date.ToString("dd.MM.yyyy"), State }); items[i].Tag = Update; ListViewGroup lvg = updateView.Groups[Update.Category]; if (lvg == null) { lvg = updateView.Groups.Add(Update.Category, Update.Category); ListViewExtended.setGrpState(lvg, ListViewGroupState.Collapsible); } items[i].Group = lvg; } updateView.Items.AddRange(items); // Note: this has caused issues in the past //updateView.SetGroupState(ListViewGroupState.Collapsible); }