All pastes #196469 Raw Edit

dmoonfire

public text v1 · immutable
·published 2006-10-10 16:42 UTC
rendered paste body
		#region Properties
		/// <summary>
		/// Sets or gets the current source selected.
		/// </summary>
		public Source CurrentSource
		{
			get
			{
				// Get the active metric
				TreeIter iter;

				if (!GetActiveIter(out iter))
					return Source.CustomSource;

				// Return this value
				ListStore store = (ListStore) Model;
				return store.GetValue(iter, 0) as Source;
			}
    
			set
			{
				// Go through the rows. If they match, set it and stop
				ListStore store = (ListStore) Model;
				TreeIter iter;
				store.GetIterFirst(out iter);

				// Check for null
				if (value == null)
				{
					SetActiveIter(iter);
					return;
				}

				// Go through the others
				while (store.IterNext(ref iter))
				{
					// Get the metric for this iter
					Source bm = (Source) store.GetValue(iter, 0);

					if (value.Name == bm.Name)
					{
						SetActiveIter(iter);
						return;
					}
				}

				// Set the first value
				Active = 0;
			}
		}
		#endregion