public CounterDisplay(MainWindow win, string cat, string counter, string instance) : base(string.Format("{0}/{1}", cat, counter)) { w = win; HBox hbox = new HBox(false, 6); VBox vbox = new VBox(false, 6); hbox.PackStart(vbox, false, false, 4); Label l = new Label(string.Format("Instance: {0}", instance)); l.Xalign = 0; vbox.PackStart(l, false, false, 0); rawval = new Label(""); rawval.Xalign = 0; vbox.PackStart(rawval, false, false, 0); error = new Label(""); error.Xalign = 0; vbox.PackStart(error, false, false, 0); type = new Label(""); type.Xalign = 0; vbox.PackStart(type, false, false, 0); draw = new CounterDrawing(); hbox.PackEnd(draw, true, true, 4); Add(hbox); Button rem = new Button("Remove"); vbox.PackStart(rem, false, false, 0); rem.Clicked += delegate { w.RemoveCounter(this); }; ShowAll(); try { if (instance == null) { countero = new PerformanceCounter(cat, counter); } else { countero = new PerformanceCounter(cat, counter, instance); } type.Text = countero.CounterType.ToString(); Update(); //Console.WriteLine ("{0}", countero.RawValue); //Console.WriteLine ("'{0}' '{1}' '{3}': {2}", cat, counter, countero.RawValue, instance); } catch (Exception e) { error.Text = e.Message; Console.WriteLine(e.StackTrace); } }
public CounterDisplay(MainWindow win, string cat, string counter, string instance) : base(string.Format ("{0}/{1}", cat, counter)) { w = win; HBox hbox = new HBox (false, 6); VBox vbox = new VBox (false, 6); hbox.PackStart (vbox, false, false, 4); Label l = new Label (string.Format ("Instance: {0}", instance)); l.Xalign = 0; vbox.PackStart (l, false, false, 0); rawval = new Label (""); rawval.Xalign = 0; vbox.PackStart (rawval, false, false, 0); error = new Label (""); error.Xalign = 0; vbox.PackStart (error, false, false, 0); type = new Label (""); type.Xalign = 0; vbox.PackStart (type, false, false, 0); draw = new CounterDrawing (); hbox.PackEnd (draw, true, true, 4); Add (hbox); Button rem = new Button ("Remove"); vbox.PackStart (rem, false, false, 0); rem.Clicked += delegate { w.RemoveCounter (this); }; ShowAll (); try { if (instance == null) countero = new PerformanceCounter (cat, counter); else countero = new PerformanceCounter (cat, counter, instance); type.Text = countero.CounterType.ToString (); Update (); //Console.WriteLine ("{0}", countero.RawValue); //Console.WriteLine ("'{0}' '{1}' '{3}': {2}", cat, counter, countero.RawValue, instance); } catch (Exception e) { error.Text = e.Message; Console.WriteLine (e.StackTrace); } }