private void SetFsList(StringBuilder XmlFsList) { try { // InvokeRequired required compares the thread ID of the // calling thread to the thread ID of the creating thread. // If these threads are different, it returns true. if (listViewPckg.InvokeRequired) { SetFsListCallback d = new SetFsListCallback(SetFsList); listViewPckg.Invoke(d, XmlFsList); } else { //if(!VarGlobal.LessVerbose)Console.WriteLine(XmlFsList.ToString()); List <string> Result = ReadXml.GetAllFirstAttrValue(XmlFsList.ToString(), "binarylist", "filename"); listViewPckg.Items.Clear(); if (Result.Count > 0) { foreach (string item in Result) { if (backgroundWorkerBuildStatus.CancellationPending == true) { break; } Dictionary <string, string> SubResult = ReadXml.GetAllAttrValue(XmlFsList.ToString(), "binarylist", "filename", item); string name = string.Empty; int Size = 0; string FinalSize = string.Empty; string Time = string.Empty; foreach (string KeyName in SubResult.Keys) { switch (KeyName) { case "filename": name = SubResult[KeyName]; break; case "size": Size = Convert.ToInt32(SubResult[KeyName]); FsByteSize = Size; FinalSize = Size.ToString() + " Byte"; if (Size >= 1024) { FinalSize = (Size / 1024).ToString() + " Kb"; } if (Size >= (1024 * 1024)) { FinalSize = (Size / 1024 / 1024).ToString() + " Mo"; } break; case "mtime": try { DateTime Dt2 = Convert.ToDateTime("1970-01-01T01:00:00+01:00"); Time = Dt2.AddSeconds(Convert.ToInt64(SubResult[KeyName])).ToString(); } catch (ArgumentOutOfRangeException) { // fileCreationTime is not valid, so re-throw the exception. throw; } break; default: break; } } ListViewItem ToAdd = new ListViewItem(name); ToAdd.SubItems.AddRange(new string[] { FinalSize, Time }); ToAdd.Tag = FsByteSize; listViewPckg.Items.Add(ToAdd); } } _OperationStatusEnd = true; //FIXME : Yet another mono bug, it don't show the last item when there is an scrollbar listViewPckg.Items.Add(string.Empty); } } catch (Exception Ex) { if (!VarGlobal.LessVerbose) { Console.WriteLine(Ex.Message + Environment.NewLine + Ex.StackTrace); } } }
private void SetListFsPkg(StringBuilder XmlListFsPkg) { // InvokeRequired required compares the thread ID of the // calling thread to the thread ID of the creating thread. // If these threads are different, it returns true. if (TbCtrlFsList.InvokeRequired) { SetListFsPkgCallback d = new SetListFsPkgCallback(SetListFsPkg); TbCtrlFsList.Invoke(d, XmlListFsPkg); } else { //if(!VarGlobal.LessVerbose)Console.WriteLine(XmlListFsPkg.ToString()); List <string> Result = ReadXml.GetAllFirstAttrValue(XmlListFsPkg.ToString(), "directory", "name"); if (Result.Count > 0) { PanelFsList.Controls.Clear(); foreach (string item in Result) { if (backgroundWorkerAddFs.CancellationPending == true) { break; } Dictionary <string, string> SubResult = ReadXml.GetAllAttrValue(XmlListFsPkg.ToString(), "directory", "name", item); string name = string.Empty; int Size = 0; long Time = 0; foreach (string KeyName in SubResult.Keys) { switch (KeyName) { case "name": name = SubResult[KeyName]; break; case "size": Size = Convert.ToInt32(SubResult[KeyName]); break; case "mtime": Time = Convert.ToInt64(SubResult[KeyName]); break; default: break; } } PkgFiles TheCtrl = new PkgFiles(Package, name, Size, Time); TheCtrl.Dock = DockStyle.Top; PanelFsList.Controls.Add(TheCtrl); } //Mono have a damed bug who don't show ToolStrip2 since we rezise the control this.Height = this.Height + 1; this.Height = this.Height - 1; } VarGlobal.NetEvManager.DoSomething("List of files Done"); if (FromBtn == false && backgroundWorkerBuildStatus.IsBusy == false) { backgroundWorkerBuildStatus.RunWorkerAsync(); } } }