Example #1
0
		public void CopyFrom (ChartView other)
		{
			Name = other.Name;
			Series.Clear ();
			foreach (ChartSerieInfo si in other.Series) {
				ChartSerieInfo c = new ChartSerieInfo ();
				c.CopyFrom (si);
				Series.Add (c);
			}
		}
		public void SetView (ChartView v)
		{
			originalView = v;
			view = new ChartView ();
			
			if (v.EditedView != null)
				view = v.EditedView;
			else {
				view.CopyFrom (v);
				v.EditedView = view;
			}
			FillSelectedSeries ();
			UpdateCharts ();
			UpdateButtonStatus ();
		}
		public void ShowAllTimers ()
		{
			hboxChartBar.Visible = hboxSeriesBar.Visible = false;
			
			view = new ChartView ();
			foreach (Counter c in App.Service.GetCounters ()) {
				if (c is TimerCounter)
					view.Add (c);
			}
			
			FillSelectedSeries ();
			toggleListView.Active = true;
		}
		void LoadViews ()
		{
			try {
				XmlDataSerializer ser = new XmlDataSerializer (new DataContext ());
				FilePath file = ConfigFile;
				if (System.IO.File.Exists (file)) {
					views = (List<ChartView>) ser.Deserialize (file, typeof (List<ChartView>));
					UpdateViews ();
					return;
				}
			} catch (Exception ex) {
				LoggingService.LogError ("Error while loading monitor-views.xml", ex);
			}
			views = new List<ChartView> ();
			ChartView v = new ChartView ();
			v.Name = "Default";
			views.Add (v);
			UpdateViews ();
		}
		internal void DeleteView (ChartView view)
		{
			string msg = string.Format ("Are you sure you want to delete the profile '{0}'?", view.Name);
			MessageDialog dlg = new MessageDialog (this, DialogFlags.Modal, MessageType.Question, ButtonsType.OkCancel, msg);
			if (dlg.Run () == (int) ResponseType.Ok) {
				views.Remove (view);
				SaveViews ();
				UpdateViews ();
			}
			dlg.Destroy ();
		}
		internal void NewView (ChartView source)
		{
			string name;
			do {
				NewProfile dlg = new NewProfile ();
				if (dlg.Run () == (int) Gtk.ResponseType.Cancel)
					return;
				name = dlg.ViewName;
				dlg.Destroy ();
			} while (name == string.Empty);
			
			if (name == null)
				return;
			
			ChartView v = new ChartView ();
			v.CopyFrom (source);
			v.Name = name;
			views.Add (v);
			SaveViews ();
			
			TreeIter it = store.AppendValues (iterViews, name, v);
			treeCounters.Selection.SelectIter (it);
		}