public IEnumerator <IXLRange> GetEnumerator() { return(Ranges .OrderBy(r => r.Worksheet.Position) .ThenBy(r => r.RangeAddress.FirstAddress.RowNumber) .ThenBy(r => r.RangeAddress.FirstAddress.ColumnNumber) .Cast <IXLRange>() .GetEnumerator()); }
//private void CreateLabels() //{ // double max = Maximum; // double min = Minimum; // for (double v = min; v <= max; v += MajorTickStep) // { // Tick tick = new Tick() { Value = v, TickType = TickType.Label }; // labels.Add(tick); // //also set the content and template for the label // tick.ContentTemplate = GetTickTemplate(TickType.Label, v); // tick.Content = v; // Children.Insert(0, tick); // } //} //private void CreateTicks() //{ // double max = Maximum; // double min = Minimum; // int num = 0;//the tick index // double val = min;//the value of the tick // while (val <= max) // { // DataTemplate template = null; // Tick tick = new Tick(); // tick.Value = val; // if (num % MinorTickStep == 0) // { // tick.TickType = TickType.Minor; // template = GetTickTemplate(TickType.Minor, val); // } // if (num % MajorTickStep == 0) // { // tick.TickType = TickType.Major; // template = GetTickTemplate(TickType.Major, val); // } // tick.ContentTemplate = template; // tick.Content = val; // ticks.Add(tick); // Children.Insert(0, tick); // val += MinorTickStep; // num += MinorTickStep; // } //} //private void ClearLabels() //{ // for (int i = 0; i < labels.Count; i++) // { // Children.Remove(labels[i]); // } // labels.Clear(); //} //private void ClearTicks() //{ // for (int i = 0; i < ticks.Count; i++) // { // Children.Remove(ticks[i]); // } // ticks.Clear(); //} protected Color GetRangeColorForValue(double val) { // The value can be in more than 1 range since if it is in a range and // we might have another range with a bigger offset. // Ex: a value of 10 will be in ranges with offsets of 15, 20, etc // This is why I order the ranges and return the first match var rngs = Ranges.OrderBy(p => p.Offset).ToList(); for (int i = 0; i < rngs.Count; i++) { if (val <= rngs[i].Offset) { return(rngs[i].Color); } } return(DefaultRangeColor); }
private void ConcatenateRanges() { var concatenatedRanges = new List <RangeOfValues>(); var indexesToRemove = new List <int>(); var sortedRanges = Ranges.OrderBy(k => k.Start).ToList(); for (int idx = sortedRanges.Count() - 1; idx > 0;) { if (sortedRanges[idx].Start == sortedRanges[idx - 1].End || sortedRanges[idx].Start - sortedRanges[idx - 1].End == 1) { concatenatedRanges.Add(new RangeOfValues(sortedRanges[idx - 1].Start, sortedRanges[idx].End)); indexesToRemove.Add(idx); indexesToRemove.Add(idx - 1); idx = -1; } idx--; } //rebuild _ranges retaining the original order placing the concatenated ranges at the end if (concatenatedRanges.Any()) { int idx = 0; var allRanges = new Dictionary <int, RangeOfValues>(); foreach (var range in Ranges) { allRanges.Add(idx++, range); } indexesToRemove.ForEach(id => sortedRanges.RemoveAt(id)); var tRanges = new List <RangeOfValues>(); sortedRanges.ForEach(sr => tRanges.Add(sr)); concatenatedRanges.ForEach(sr => tRanges.Add(new RangeOfValues(sr.Start, sr.End))); Ranges.Clear(); var removalKeys = allRanges.Keys.Where(k => tRanges.Contains(allRanges[k])); foreach (var nk in removalKeys) { Ranges.Add(allRanges[nk]); tRanges.Remove(allRanges[nk]); } tRanges.ForEach(tr => Ranges.Add(tr)); } }
private void BindRepeater() { rRanges.DataSource = Ranges.OrderBy(item => item.OrderPrice); rRanges.DataBind(); }
public IQueryable <Range> FindRanges() { return(Ranges.OrderBy(pr => pr.Id)); }