namespace HalconTools { public class Counter { private int all; private int ng; private int ok; public Counter() { this.Reset(); } public string GetPercent() { if (this.all == 0) { return "100.0%"; } if (this.ok == this.all) { return "100.0%"; } if (this.ok == 0) { return "0.0%"; } double num = (((double) this.ok) / ((double) this.all)) * 100.0; return (num.ToString("#0.##") + "%"); } public string GetPercent(int alls, int ngs) { if (alls == 0) { return "100.0%"; } if ((alls - ngs) == alls) { return "100.0%"; } if ((alls - ngs) == 0) { return "0.0%"; } double num = (((double) (alls - ngs)) / ((double) alls)) * 100.0; return (num.ToString("#0.##") + "%"); } public void Reset() { this.ok = 0; this.ng = 0; this.all = 0; } public int All { get { return (this.ok + this.ng); } } public int NG { get { return this.ng; } set { this.ng = value; } } public int OK { get { return this.ok; } set { this.ok = value; } } } }