//this method notify all of the observers protected void OnFinish(object sender) { if (Finished != null) { DiscoverFinishEventArgs args = new DiscoverFinishEventArgs(); args.DescoverResult = DescoverResult; Finished(sender, args); } }
public override void UpdateDraw(object sender, DiscoverFinishEventArgs e) { listView.BeginUpdate(); listView.Items.Clear(); // Get the enumerator to iterate the collection IDictionaryEnumerator listEnumerator = e.DescoverResult.GetEnumerator(); // Sum all the files size. The total will be used // to calculate the files size in percent long totalSize = 0; while (listEnumerator.MoveNext()) { totalSize += (long)listEnumerator.Value; } // Loop to fill ListView with ListViewItem ListViewItem listItem; listEnumerator.Reset(); while (listEnumerator.MoveNext()) { string itemName = listEnumerator.Key.ToString(); //Console.WriteLine("itemName " + itemName); listItem = new ListViewItem(itemName); // Set item icon. This operation needs to be overriden SetIcon(listItem); // The file size in kilobytes string sizeInfo = ((long)listEnumerator.Value / 1024).ToString ("#,##0") + " KB"; listItem.SubItems.Add(sizeInfo); // Calculate & display the size in percentage float percent = (totalSize > 0) ? (long)listEnumerator.Value * 100 / (float)totalSize : 0; listItem.SubItems.Add(percent.ToString("#,##0.00") + " %"); // Add the ListViewItem to the listView listView.Items.Add(listItem); } listView.EndUpdate(); }
public override void UpdateDraw(object sender, DiscoverFinishEventArgs e) { // Draw the chart using the given data barGraph.Data = e.DescoverResult; barGraph.Draw(); }
public abstract void UpdateDraw(object sender, DiscoverFinishEventArgs e);