2
// InstrumentationViewerDialog.cs
5
// Lluis Sanchez Gual <lluis@novell.com>
7
// Copyright (c) 2010 Novell, Inc (http://www.novell.com)
9
// Permission is hereby granted, free of charge, to any person obtaining a copy
10
// of this software and associated documentation files (the "Software"), to deal
11
// in the Software without restriction, including without limitation the rights
12
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
// copies of the Software, and to permit persons to whom the Software is
14
// furnished to do so, subject to the following conditions:
16
// The above copyright notice and this permission notice shall be included in
17
// all copies or substantial portions of the Software.
19
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
28
using System.Collections.Generic;
29
using MonoDevelop.Core.Instrumentation;
30
using MonoDevelop.Core.Serialization;
31
using MonoDevelop.Components.Chart;
32
using MonoDevelop.Components;
34
namespace Mono.Instrumentation.Monitor
45
// public string Color;
47
[ItemProperty (DefaultValue=true)]
48
public bool Visible = true;
50
DateTime lastUpdateTime = DateTime.MinValue;
52
public void Init (Counter counter)
54
this.counter = counter;
58
public void CopyFrom (ChartSerieInfo other)
61
Visible = other.Visible;
63
counter = other.counter;
66
public Counter Counter {
68
if (counter == null && Name != null)
69
counter = App.Service.GetCounter (Name);
77
serie = new Serie (Name);
80
if (Counter.DisplayMode == CounterDisplayMode.Block) {
81
serie.ExtendBoundingValues = true;
82
serie.InitialValue = 0;
83
serie.DisplayMode = DisplayMode.BlockLine;
85
serie.DisplayMode = DisplayMode.Line;
86
serie.Color = GdkColor.ToCairoColor ();
87
foreach (CounterValue val in Counter.GetValues ()) {
88
serie.AddData (val.TimeStamp.Ticks, val.Value);
89
lastUpdateTime = val.TimeStamp;
91
serie.Visible = Visible;
97
public bool UpdateCounter ()
99
if (!Counter.Disposed)
103
lastUpdateTime = DateTime.MinValue;
107
public void UpdateSerie ()
109
if (serie == null || Counter == null)
111
foreach (CounterValue val in Counter.GetValuesAfter (lastUpdateTime)) {
112
serie.AddData (val.TimeStamp.Ticks, val.Value);
113
lastUpdateTime = val.TimeStamp;
117
public Gdk.Color GdkColor {
119
return Counter.GetColor ();
123
public Gdk.Pixbuf ColorIcon {
125
return Counter.GetIcon ();