/// <summary> /// Sets the value of the <c>Log</c> property for the specified control. /// </summary> /// <param name="counter">The control to set the property for.</param> /// <param name="value">The value of the property for the specified control.</param> /// <exception cref="ArgumentNullException"> /// <para><paramref name="counter"/> is <see langword="null"/>.</para> /// </exception> public void SetLog(INuGenCounter counter, Boolean value) { if (counter == null) { throw new ArgumentNullException("counter"); } if (!_logTargets.ContainsKey(counter)) { _logTargets.Add(counter, value); if (!base.DesignMode) { if (value) { counter.ValueChanged += this.counter_ValueChanged; } else { counter.ValueChanged -= this.counter_ValueChanged; } } } else { _logTargets[counter] = value; } }
private void SetShouldLog(INuGenCounter counter, bool value) { if (this.meters.ContainsKey(counter)) { this.meters[counter].ShouldLog = value; } }
/// <summary> /// Returns a collection of standard values for the data type this type converter is designed for when provided with a format context. /// </summary> /// <param name="context">An <see cref="T:System.ComponentModel.ITypeDescriptorContext"/> that provides a format context that can be used to extract additional information about the environment from which this converter is invoked. This parameter or properties of this parameter can be null.</param> /// <returns> /// A <see cref="T:System.ComponentModel.TypeConverter.StandardValuesCollection"/> that holds a standard set of valid values, or null if the data type does not support a standard set of values. /// </returns> public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { INuGenCounter counter = (context == null) ? null : (context.Instance as INuGenCounter); string machineName = "."; string categoryName = string.Empty; if (counter != null) { machineName = counter.MachineName; categoryName = counter.CategoryName; } try { PerformanceCounterCategory category = new PerformanceCounterCategory(categoryName, machineName); string[] instances = category.GetInstanceNames(); Array.Sort(instances, Comparer.Default); return(new TypeConverter.StandardValuesCollection(instances)); } catch { } return(null); }
/// <summary> /// Sets the value indicating whether to log the value changes on the meter. /// </summary> /// <param name="counter">The control to set the property for.</param> /// <param name="value">The value of the property for the specified control.</param> public void SetGraphLog(INuGenCounter counter, Boolean value) { if (_meters.ContainsKey(counter)) { this.SetShouldLog(counter, value); } else { GraphLineParams glp = new GraphLineParams(_id, value, this.GetLineColor(counter), this.GetIsBar(counter)); _PushGraph.SetIsBar(this.GetIndex(counter), this.GetIsBar(counter)); _PushGraph.Update(); _meters.Add(counter, glp); _id++; } if (value) { _PushGraph.AddLine(this.GetIndex(counter), this.GetLineColor(counter)); counter.Disposed += this.counter_Disposed; } else { _PushGraph.RemoveLine(this.GetIndex(counter)); counter.Disposed -= this.counter_Disposed; } }
private void SetShouldLog(INuGenCounter counter, Boolean value) { if (_meters.ContainsKey(counter)) { _meters[counter].ShouldLog = value; } }
/// <summary> /// Sets the graph line color used to log the value changes on the meter. /// </summary> /// <param name="counter">The control to set the property for.</param> /// <param name="lineColor">The value of the property for the specified control.</param> public void SetLineColor(INuGenCounter counter, Color lineColor) { if (_meters.ContainsKey(counter)) { _meters[counter].LineColor = lineColor; _PushGraph.SetLineColor(this.GetIndex(counter), lineColor); _PushGraph.Update(); } }
/// <summary> /// Sets the value indicating whether to draw the graph line as a set of bars. /// </summary> /// <param name="nuGenMeter">The control to set the property for.</param> /// <param name="value">The value of the property for the specified control.</param> public void SetIsBar(INuGenCounter nuGenMeter, Boolean value) { if (_meters.ContainsKey(nuGenMeter)) { _meters[nuGenMeter].IsBar = value; _PushGraph.SetIsBar(this.GetIndex(nuGenMeter), value); _PushGraph.Update(); } }
/// <summary> /// Sets the value indicating whether to draw the graph line as a set of bars. /// </summary> /// <param name="nuGenMeter">The control to set the property for.</param> /// <param name="value">The value of the property for the specified control.</param> public void SetIsBar(INuGenCounter nuGenMeter, bool value) { if (this.meters.ContainsKey(nuGenMeter)) { this.meters[nuGenMeter].IsBar = value; this.pushGraph.SetIsBar(this.GetIndex(nuGenMeter), value); this.pushGraph.Update(); } }
private void counter_Disposed(Object sender, EventArgs e) { if (sender is INuGenCounter) { INuGenCounter counter = (INuGenCounter)sender; _PushGraph.RemoveLine(this.GetIndex(counter)); _meters.Remove(counter); } }
private Int32 GetIndex(INuGenCounter counter) { if (_meters.ContainsKey(counter)) { return(_meters[counter].Index); } else { return(-1); } }
private Boolean GetShouldLog(INuGenCounter counter) { if (_meters.ContainsKey(counter)) { return(_meters[counter].ShouldLog); } else { return(false); } }
public Boolean GetIsBar(INuGenCounter counter) { if (_meters.ContainsKey(counter)) { return(_meters[counter].IsBar); } else { return(false); } }
private bool GetShouldLog(INuGenCounter counter) { if (this.meters.ContainsKey(counter)) { return(this.meters[counter].ShouldLog); } else { return(false); } }
public Color GetLineColor(INuGenCounter counter) { if (_meters.ContainsKey(counter)) { return(_meters[counter].LineColor); } else { return(Color.Yellow); } }
private int GetIndex(INuGenCounter counter) { if (this.meters.ContainsKey(counter)) { return(this.meters[counter].Index); } else { return(-1); } }
public bool GetIsBar(INuGenCounter counter) { if (this.meters.ContainsKey(counter)) { return(this.meters[counter].IsBar); } else { return(false); } }
/// <summary> /// Returns a collection of standard values for the data type this type converter is designed for when provided with a format context. /// </summary> /// <param name="context">An <see cref="T:System.ComponentModel.ITypeDescriptorContext"/> that provides a format context that can be used to extract additional information about the environment from which this converter is invoked. This parameter or properties of this parameter can be null.</param> /// <returns> /// A <see cref="T:System.ComponentModel.TypeConverter.StandardValuesCollection"/> that holds a standard set of valid values, or null if the data type does not support a standard set of values. /// </returns> public override System.ComponentModel.TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { INuGenCounter counter = (context == null) ? null : (context.Instance as INuGenCounter); string machineName = "."; string categoryName = string.Empty; if (counter != null) { machineName = counter.MachineName; categoryName = counter.CategoryName; } try { PerformanceCounterCategory category = new PerformanceCounterCategory(categoryName, machineName); string[] instances = category.GetInstanceNames(); PerformanceCounter[] counters = null; if (instances.Length == 0) { counters = category.GetCounters(); } else { counters = category.GetCounters(instances[0]); } string[] names = new string[counters.Length]; for (int nameIndex = 0; nameIndex < counters.Length; nameIndex++) { names[nameIndex] = counters[nameIndex].CounterName; } Array.Sort(names, Comparer.Default); return(new TypeConverter.StandardValuesCollection(names)); } catch { } return(null); }
/* * Log */ private void Log(StreamWriter sw, NuGenTargetEventArgs e) { Debug.Assert(sw != null, "sw != null"); Debug.Assert(e.Target is INuGenCounter, "e.Target is INuGenCounter"); Debug.Assert(e.TargetData is float, "e.TargetData is float"); if (e.Target is INuGenCounter && e.TargetData is float) { INuGenCounter counter = (INuGenCounter)e.Target; float counterValue = (float)e.TargetData; sw.WriteLine("\n------------- {0} -------------", counter.Name); sw.WriteLine("DATE: {0}", DateTime.Now.ToShortDateString()); sw.WriteLine("TIME: {0}.{1}", DateTime.Now.ToLongTimeString(), DateTime.Now.Millisecond.ToString()); sw.WriteLine("MACHINE: {0}", counter.MachineName); sw.WriteLine("CATEGORY: {0}", counter.CategoryName); sw.WriteLine("NAME: {0}", counter.CounterName); sw.WriteLine("INSTANCE: {0}", counter.InstanceName); sw.WriteLine("VALUE: {0}{1}", counterValue, counter.CounterFormat); } }
public override TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { INuGenCounter counter = (context == null) ? null : (context.Instance as INuGenCounter); String machineName = "."; if (context != null) { machineName = counter.MachineName; } if (machineName != _previousMachineName) { _previousMachineName = machineName; try { PerformanceCounter.CloseSharedResources(); PerformanceCounterCategory[] categories = PerformanceCounterCategory.GetCategories(machineName); String[] categoryNames = new String[categories.Length]; for (Int32 categoryIndex = 0; categoryIndex < categories.Length; categoryIndex++) { categoryNames[categoryIndex] = categories[categoryIndex].CategoryName; } Array.Sort(categoryNames, Comparer.Default); _previousStandardValues = new TypeConverter.StandardValuesCollection(categoryNames); } catch { _previousStandardValues = null; } } return(_previousStandardValues); }
public bool GetLog(INuGenCounter counter) { return this.logTargets.ContainsKey(counter); }
public Boolean GetLog(INuGenCounter counter) { return(_logTargets.ContainsKey(counter)); }
private bool GetShouldLog(INuGenCounter counter) { if (this.meters.ContainsKey(counter)) { return this.meters[counter].ShouldLog; } else { return false; } }
public Boolean GetGraphLog(INuGenCounter counter) { return(this.GetShouldLog(counter)); }
public bool GetLog(INuGenCounter counter) { return(this.logTargets.ContainsKey(counter)); }
public void RemoveGeneric(INuGenCounter item) { items.Remove(item); log.SetLog(item, false); }
public void LogGeneric(INuGenCounter item) { items.Add(item); log.SetLog(item, true); }
private Boolean GetShouldLog(INuGenCounter counter) { if (_meters.ContainsKey(counter)) { return _meters[counter].ShouldLog; } else { return false; } }
public Boolean GetGraphLog(INuGenCounter counter) { return this.GetShouldLog(counter); }
private int GetIndex(INuGenCounter counter) { if (this.meters.ContainsKey(counter)) { return this.meters[counter].Index; } else { return -1; } }
public Color GetLineColor(INuGenCounter counter) { if (_meters.ContainsKey(counter)) { return _meters[counter].LineColor; } else { return Color.Yellow; } }
/// <summary> /// Sets the value of the <c>Log</c> property for the specified control. /// </summary> /// <param name="counter">The control to set the property for.</param> /// <param name="value">The value of the property for the specified control.</param> /// <exception cref="ArgumentNullException"> /// <para><paramref name="counter"/> is <see langword="null"/>.</para> /// </exception> public void SetLog(INuGenCounter counter, bool value) { if (counter == null) { throw new ArgumentNullException("counter"); } if (!this.logTargets.ContainsKey(counter)) { this.logTargets.Add(counter, value); if (!base.DesignMode) { if (value) { counter.ValueChanged += this.counter_ValueChanged; } else { counter.ValueChanged -= this.counter_ValueChanged; } } } else { this.logTargets[counter] = value; } }
public Boolean GetIsBar(INuGenCounter counter) { if (_meters.ContainsKey(counter)) { return _meters[counter].IsBar; } else { return false; } }
public bool GetIsBar(INuGenCounter counter) { if (this.meters.ContainsKey(counter)) { return this.meters[counter].IsBar; } else { return false; } }
private Int32 GetIndex(INuGenCounter counter) { if (_meters.ContainsKey(counter)) { return _meters[counter].Index; } else { return -1; } }