public DynamicPropertyScaleDescriptor(IPowerShellDataSource dataSource, string name) { _dataSource = dataSource; _name = name; Color = ColorManager.AssignColor(); _dataSource.Data.CollectionChanged += OnData; _ranges = new ObservableCollection <IRangeDescriptor>(RangeDescriptorFactory.Create(Color, new object[] { _minimum, "?", _maximum }).ToList()); }
public IScaleDescriptor ForPropertyName(string propertyName) { if (_color.HasValue) { return(this); } if (!_propertyColorMap.ContainsKey(propertyName)) { _propertyColorMap.Add(propertyName, ColorManager.AssignColor()); } var color = _propertyColorMap[propertyName]; var descriptor = new ScaleDescriptor(this, color); return(descriptor); }
IRangeDescriptor Next() { /* * int?, Color?, int? * 80, Red, 100 * Red, 100 * 80, Red * 80, 100 */ var descriptor = new RangeDescriptor(); double?v1 = null; double?v2 = null; Color? clr = null; if (_index >= _values.Count - 1) { return(null); } var first = _values[_index]; clr = first.ToColor(); if (null == clr) { if (first is int || first is double || first is string) { v1 = Convert.ToDouble(first); } else { throw new InvalidRangeDescriptorException("Expected number or color at value [" + first.ToString() + "]"); } } ++_index; if (_index < _values.Count) { var second = _values[_index]; if (null != second) { Color?clr2 = second.ToColor(); if (null == clr2) { if ("?" == (second as string)) { clr2 = ColorManager.AssignColor(_index, _values.Count, _rangeBaseColor); } } if (null == clr2) { if (second is int || second is double || second is string) { v2 = Convert.ToDouble(second); } else { throw new InvalidRangeDescriptorException("Expected number or color at value [" + second.ToString() + "]"); } } else if (null != clr) { throw new InvalidRangeDescriptorException("Expected number at value [" + second.ToString() + "]"); } else { clr = clr2; ++_index; } } } if (v1.HasValue && clr.HasValue && _index < _values.Count) { var third = _values[_index]; if (!(third is int || third is double || third is string)) { throw new InvalidRangeDescriptorException("Expected number at value [" + third.ToString() + "]"); } v2 = Convert.ToDouble(third); } if (v1.HasValue && v2.HasValue) { if (v1.Value > v2.Value) { double v = v1.Value; v1 = v2; v2 = v; } } descriptor.Color = clr; if (v1.HasValue) { descriptor.Minimum = v1.Value; } if (v2.HasValue) { descriptor.Maximum = v2.Value; } return(descriptor); }
private bool ConfigureAxes(SolidPSObjectBase o) { if (!CanConfigureAxes) { return(false); } if (SeriesType.IsCategorical()) { ConfigureCategoricalAxes(o); } else if (SeriesType.IsCategoricalRange()) { ConfigureCategoricalRange(o); } else if (SeriesType.IsScatter()) { ConfigureScatterAxes(o); } else if (SeriesType.IsPolar()) { ConfigurePolarAxis(o); } else if (SeriesType.IsRadial()) { ConfigureRadialAxis(o); } else { throw new InvalidOperationException("Unanticipated series type encountered during axis determination: " + SeriesType); } VerifyAxisTypes(o); var sdx = GetScaleForProperty(XAxis.ValueMemberPath); var sdy = GetScaleForProperty(YAxis.ValueMemberPath); if (null == sdx) { sdx = new ScaleDescriptor(XAxis.ValueMemberPath, ColorManager.AssignColor()); } XAxis.AxisScaleDescriptors.Add(new ScaleDescriptorAssignment { PropertyName = sdx.Name, Scale = sdx }); if (null != sdy) { var sdym = new[] { sdy }.Union(DataSource.Scales.Select(s => s.Scale)) .Where(s => s.Name == sdy.Name) .ToList() .ConvertAll(a => new ScaleDescriptorAssignment { PropertyName = a.Name, Scale = a }); sdym.ToList().ForEach(YAxis.AxisScaleDescriptors.Add); } var ev = AxesUpdated; if (null != ev) { ev(this, EventArgs.Empty); } return(true); }