[561] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
| 3 | * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
| 4 | *
|
---|
| 5 | * This file is part of HeuristicLab.
|
---|
| 6 | *
|
---|
| 7 | * HeuristicLab is free software: you can redistribute it and/or modify
|
---|
| 8 | * it under the terms of the GNU General Public License as published by
|
---|
| 9 | * the Free Software Foundation, either version 3 of the License, or
|
---|
| 10 | * (at your option) any later version.
|
---|
| 11 | *
|
---|
| 12 | * HeuristicLab is distributed in the hope that it will be useful,
|
---|
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 15 | * GNU General Public License for more details.
|
---|
| 16 | *
|
---|
| 17 | * You should have received a copy of the GNU General Public License
|
---|
| 18 | * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
|
---|
| 19 | */
|
---|
| 20 | #endregion
|
---|
| 21 |
|
---|
| 22 | using System;
|
---|
| 23 | using System.Collections.Generic;
|
---|
| 24 | using System.Text;
|
---|
| 25 | using System.Drawing;
|
---|
| 26 | using System.Linq;
|
---|
| 27 | using HeuristicLab.Charting;
|
---|
[562] | 28 | using System.Windows.Forms;
|
---|
[1287] | 29 | using HeuristicLab.CEDMA.Core;
|
---|
| 30 | using HeuristicLab.PluginInfrastructure;
|
---|
| 31 | using HeuristicLab.Core;
|
---|
| 32 | using HeuristicLab.CEDMA.DB.Interfaces;
|
---|
[2131] | 33 | using System.Diagnostics;
|
---|
[561] | 34 |
|
---|
| 35 | namespace HeuristicLab.CEDMA.Charting {
|
---|
| 36 | public class BubbleChart : Chart {
|
---|
[1287] | 37 | private const string X_JITTER = "__X_JITTER";
|
---|
| 38 | private const string Y_JITTER = "__Y_JITTER";
|
---|
[561] | 39 | private const double maxXJitterPercent = 0.05;
|
---|
| 40 | private const double maxYJitterPercent = 0.05;
|
---|
| 41 | private const int minBubbleSize = 5;
|
---|
| 42 | private const int maxBubbleSize = 30;
|
---|
| 43 | private const int maxAlpha = 255;
|
---|
| 44 | private const int minAlpha = 50;
|
---|
| 45 | private static readonly Color defaultColor = Color.Blue;
|
---|
[562] | 46 | private static readonly Color selectionColor = Color.Red;
|
---|
[561] | 47 |
|
---|
| 48 | private double xJitterFactor = 0.0;
|
---|
| 49 | private double yJitterFactor = 0.0;
|
---|
| 50 | private string xDimension;
|
---|
| 51 | private string yDimension;
|
---|
| 52 | private string sizeDimension;
|
---|
| 53 | private bool invertSize;
|
---|
| 54 | private double minX = double.PositiveInfinity;
|
---|
| 55 | private double minY = double.PositiveInfinity;
|
---|
| 56 | private double maxX = double.NegativeInfinity;
|
---|
| 57 | private double maxY = double.NegativeInfinity;
|
---|
[2139] | 58 | private List<ResultsEntry> filteredEntries;
|
---|
[1287] | 59 | private Results results;
|
---|
| 60 | private Dictionary<IPrimitive, ResultsEntry> primitiveToEntryDictionary;
|
---|
[561] | 61 | private Random random = new Random();
|
---|
[562] | 62 | private Group points;
|
---|
[561] | 63 |
|
---|
[1287] | 64 | public BubbleChart(Results results, PointD lowerLeft, PointD upperRight)
|
---|
[561] | 65 | : base(lowerLeft, upperRight) {
|
---|
[1287] | 66 | primitiveToEntryDictionary = new Dictionary<IPrimitive, ResultsEntry>();
|
---|
[562] | 67 | this.results = results;
|
---|
[2139] | 68 | filteredEntries = new List<ResultsEntry>();
|
---|
[1287] | 69 |
|
---|
| 70 | foreach (var resultsEntry in results.GetEntries()) {
|
---|
| 71 | if (resultsEntry.Get(X_JITTER) == null)
|
---|
| 72 | resultsEntry.Set(X_JITTER, random.NextDouble() * 2.0 - 1.0);
|
---|
| 73 | if (resultsEntry.Get(Y_JITTER) == null)
|
---|
| 74 | resultsEntry.Set(Y_JITTER, random.NextDouble() * 2.0 - 1.0);
|
---|
| 75 | }
|
---|
[566] | 76 | results.Changed += new EventHandler(results_Changed);
|
---|
[561] | 77 | }
|
---|
[562] | 78 |
|
---|
[566] | 79 | void results_Changed(object sender, EventArgs e) {
|
---|
| 80 | Repaint();
|
---|
| 81 | EnforceUpdate();
|
---|
| 82 | }
|
---|
| 83 |
|
---|
[1287] | 84 | public BubbleChart(Results results, double x1, double y1, double x2, double y2)
|
---|
[562] | 85 | : this(results, new PointD(x1, y1), new PointD(x2, y2)) {
|
---|
[561] | 86 | }
|
---|
| 87 |
|
---|
| 88 | public void SetBubbleSizeDimension(string dimension, bool inverted) {
|
---|
| 89 | this.sizeDimension = dimension;
|
---|
| 90 | this.invertSize = inverted;
|
---|
| 91 | Repaint();
|
---|
| 92 | EnforceUpdate();
|
---|
| 93 | }
|
---|
| 94 |
|
---|
| 95 | public void ShowXvsY(string xDimension, string yDimension) {
|
---|
[1287] | 96 | if (this.xDimension != xDimension || this.yDimension != yDimension) {
|
---|
[561] | 97 | this.xDimension = xDimension;
|
---|
| 98 | this.yDimension = yDimension;
|
---|
[1287] | 99 |
|
---|
[561] | 100 | ResetViewSize();
|
---|
| 101 | Repaint();
|
---|
| 102 | ZoomToViewSize();
|
---|
| 103 | }
|
---|
| 104 | }
|
---|
| 105 |
|
---|
| 106 | internal void SetJitter(double xJitterFactor, double yJitterFactor) {
|
---|
| 107 | this.xJitterFactor = xJitterFactor * maxXJitterPercent * Size.Width;
|
---|
| 108 | this.yJitterFactor = yJitterFactor * maxYJitterPercent * Size.Height;
|
---|
| 109 | Repaint();
|
---|
| 110 | EnforceUpdate();
|
---|
| 111 | }
|
---|
| 112 |
|
---|
[2135] | 113 | public override void Render(Graphics graphics, int width, int height) {
|
---|
| 114 | graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
|
---|
| 115 | base.Render(graphics, width, height);
|
---|
| 116 | }
|
---|
| 117 |
|
---|
[561] | 118 | private void Repaint() {
|
---|
[1287] | 119 | if (xDimension == null || yDimension == null) return;
|
---|
| 120 | double maxSize = 1;
|
---|
| 121 | double minSize = 1;
|
---|
[1424] | 122 | if (sizeDimension != null && results.OrdinalVariables.Contains(sizeDimension)) {
|
---|
[2139] | 123 | var sizes = results.GetEntries()
|
---|
[1424] | 124 | .Select(x => Convert.ToDouble(x.Get(sizeDimension)))
|
---|
| 125 | .Where(size => !double.IsInfinity(size) && size != double.MaxValue && size != double.MinValue)
|
---|
| 126 | .OrderBy(r => r);
|
---|
| 127 | minSize = sizes.ElementAt((int)(sizes.Count() * 0.1));
|
---|
| 128 | maxSize = sizes.ElementAt((int)(sizes.Count() * 0.9));
|
---|
| 129 | } else {
|
---|
[1287] | 130 | minSize = 1;
|
---|
| 131 | maxSize = 1;
|
---|
| 132 | }
|
---|
| 133 | UpdateEnabled = false;
|
---|
| 134 | Group.Clear();
|
---|
| 135 | primitiveToEntryDictionary.Clear();
|
---|
| 136 | points = new Group(this);
|
---|
| 137 | Group.Add(new Axis(this, 0, 0, AxisType.Both));
|
---|
[2141] | 138 | UpdateViewSize(0, 0, TransformPixelToWorld(new Size(5, 0)).Width);
|
---|
[2139] | 139 | foreach (ResultsEntry r in results.GetEntries().Where(x => x.Visible)) {
|
---|
[2131] | 140 | List<double> xs = new List<double>();
|
---|
| 141 | List<double> ys = new List<double>();
|
---|
[2132] | 142 | List<object> actualXValues = new List<object>();
|
---|
| 143 | List<object> actualYValues = new List<object>();
|
---|
[1287] | 144 | int size;
|
---|
[2139] | 145 | if (results.OrdinalVariables.Contains(xDimension) && r.Get(xDimension) != null) {
|
---|
[2131] | 146 | xs.Add(Convert.ToDouble(r.Get(xDimension)) + (double)r.Get(X_JITTER) * xJitterFactor);
|
---|
[2132] | 147 | actualXValues.Add(r.Get(xDimension));
|
---|
[2139] | 148 | } else if (results.CategoricalVariables.Contains(xDimension) && r.Get(xDimension) != null) {
|
---|
[2131] | 149 | xs.Add(results.IndexOfCategoricalValue(xDimension, r.Get(xDimension)) + (double)r.Get(X_JITTER) * xJitterFactor);
|
---|
[2132] | 150 | actualXValues.Add(r.Get(xDimension));
|
---|
[2131] | 151 | } else if (results.MultiDimensionalCategoricalVariables.Contains(xDimension)) {
|
---|
| 152 | var path = xDimension.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim());
|
---|
| 153 | IEnumerable<ResultsEntry> subEntries = (IEnumerable<ResultsEntry>)r.Get(path.ElementAt(0));
|
---|
| 154 | foreach (ResultsEntry subEntry in subEntries) {
|
---|
[2139] | 155 | if (subEntry.Get(path.ElementAt(1)) != null) {
|
---|
| 156 | xs.Add(results.IndexOfCategoricalValue(xDimension, subEntry.Get(path.ElementAt(1))) + (double)r.Get(X_JITTER) * xJitterFactor);
|
---|
| 157 | actualXValues.Add(subEntry.Get(path.ElementAt(1)));
|
---|
| 158 | }
|
---|
[2131] | 159 | }
|
---|
| 160 | } else if (results.MultiDimensionalOrdinalVariables.Contains(xDimension)) {
|
---|
| 161 | var path = xDimension.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim());
|
---|
| 162 | IEnumerable<ResultsEntry> subEntries = (IEnumerable<ResultsEntry>)r.Get(path.ElementAt(0));
|
---|
| 163 | foreach (ResultsEntry subEntry in subEntries) {
|
---|
[2139] | 164 | if (subEntry.Get(path.ElementAt(1)) != null) {
|
---|
| 165 | xs.Add(Convert.ToDouble(subEntry.Get(path.ElementAt(1))) + (double)r.Get(X_JITTER) * xJitterFactor);
|
---|
| 166 | actualXValues.Add(subEntry.Get(path.ElementAt(1)));
|
---|
| 167 | }
|
---|
[2131] | 168 | }
|
---|
[1424] | 169 | }
|
---|
[2139] | 170 | if (results.OrdinalVariables.Contains(yDimension) && r.Get(yDimension) != null) {
|
---|
[2131] | 171 | ys.Add(Convert.ToDouble(r.Get(yDimension)) + (double)r.Get(Y_JITTER) * yJitterFactor);
|
---|
[2132] | 172 | actualYValues.Add(r.Get(yDimension));
|
---|
[2139] | 173 | } else if (results.CategoricalVariables.Contains(yDimension) && r.Get(yDimension) != null) {
|
---|
[2131] | 174 | ys.Add(results.IndexOfCategoricalValue(yDimension, r.Get(yDimension)) + (double)r.Get(Y_JITTER) * yJitterFactor);
|
---|
[2132] | 175 | actualYValues.Add(r.Get(yDimension));
|
---|
[2131] | 176 | } else if (results.MultiDimensionalCategoricalVariables.Contains(yDimension)) {
|
---|
| 177 | var path = yDimension.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim());
|
---|
| 178 | IEnumerable<ResultsEntry> subEntries = (IEnumerable<ResultsEntry>)r.Get(path.ElementAt(0));
|
---|
| 179 | foreach (ResultsEntry subEntry in subEntries) {
|
---|
[2139] | 180 | if (subEntry.Get(path.ElementAt(1)) != null) {
|
---|
| 181 | ys.Add(results.IndexOfCategoricalValue(yDimension, subEntry.Get(path.ElementAt(1))) + (double)r.Get(Y_JITTER) * yJitterFactor);
|
---|
| 182 | actualYValues.Add(subEntry.Get(path.ElementAt(1)));
|
---|
| 183 | }
|
---|
[2131] | 184 | }
|
---|
| 185 | } else if (results.MultiDimensionalOrdinalVariables.Contains(yDimension)) {
|
---|
| 186 | var path = yDimension.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim());
|
---|
| 187 | IEnumerable<ResultsEntry> subEntries = (IEnumerable<ResultsEntry>)r.Get(path.ElementAt(0));
|
---|
| 188 | foreach (ResultsEntry subEntry in subEntries) {
|
---|
[2139] | 189 | if (subEntry.Get(path.ElementAt(1)) != null) {
|
---|
| 190 | ys.Add(Convert.ToDouble(subEntry.Get(path.ElementAt(1))) + (double)r.Get(Y_JITTER) * yJitterFactor);
|
---|
| 191 | actualYValues.Add(subEntry.Get(path.ElementAt(1)));
|
---|
| 192 | }
|
---|
[2131] | 193 | }
|
---|
[2135] | 194 | }
|
---|
| 195 | if (xs.Count() == 0) {
|
---|
| 196 | xs.Add(double.NaN);
|
---|
| 197 | actualXValues.Add("NaN");
|
---|
| 198 | }
|
---|
| 199 | if (ys.Count() == 0) {
|
---|
[2131] | 200 | ys.Add(double.NaN);
|
---|
[2132] | 201 | actualYValues.Add("NaN");
|
---|
[1287] | 202 | }
|
---|
[1424] | 203 | size = CalculateSize(Convert.ToDouble(r.Get(sizeDimension)), minSize, maxSize);
|
---|
[2131] | 204 | Debug.Assert(xs.Count() == ys.Count() || xs.Count() == 1 || ys.Count() == 1);
|
---|
| 205 | int n = Math.Max(xs.Count(), ys.Count());
|
---|
| 206 | for (int i = 0; i < n; i++) {
|
---|
[2132] | 207 | double x = xs[Math.Min(i, xs.Count() - 1)];
|
---|
| 208 | double y = ys[Math.Min(i, ys.Count() - 1)];
|
---|
[2131] | 209 | if (double.IsInfinity(x) || x == double.MaxValue || x == double.MinValue) x = double.NaN;
|
---|
| 210 | if (double.IsInfinity(y) || y == double.MaxValue || y == double.MinValue) y = double.NaN;
|
---|
[2160] | 211 | if (!double.IsNaN(x) && !double.IsNaN(y) && IsReasonablePoint(new PointD(x,y))) {
|
---|
[2137] | 212 | string actualXValue = actualXValues[Math.Min(i, actualXValues.Count() - 1)].ToString();
|
---|
| 213 | string actualYValue = actualYValues[Math.Min(i, actualYValues.Count() - 1)].ToString();
|
---|
[2141] | 214 | UpdateViewSize(x, y, TransformPixelToWorld(new Size(size, 0)).Width);
|
---|
[2131] | 215 | int alpha = CalculateAlpha(size);
|
---|
| 216 | Pen pen = new Pen(Color.FromArgb(alpha, r.Selected ? selectionColor : defaultColor));
|
---|
| 217 | Brush brush = pen.Brush;
|
---|
| 218 | FixedSizeCircle c = new FixedSizeCircle(this, x, y, size, pen, brush);
|
---|
[2132] | 219 | c.ToolTipText = xDimension + " = " + actualXValue + Environment.NewLine +
|
---|
| 220 | yDimension + " = " + actualYValue + Environment.NewLine +
|
---|
| 221 | r.GetToolTipText();
|
---|
[2131] | 222 | points.Add(c);
|
---|
| 223 | if (!r.Selected) c.IntoBackground();
|
---|
| 224 | primitiveToEntryDictionary[c] = r;
|
---|
| 225 | }
|
---|
[1287] | 226 | }
|
---|
[561] | 227 | }
|
---|
[1287] | 228 | Group.Add(points);
|
---|
| 229 | UpdateEnabled = true;
|
---|
[561] | 230 | }
|
---|
| 231 |
|
---|
[2160] | 232 | private bool IsReasonablePoint(PointD pointD) {
|
---|
| 233 | return pointD.X > LowerLeft.X && pointD.X < UpperRight.X && pointD.Y > LowerLeft.Y && pointD.Y < UpperRight.Y;
|
---|
| 234 | }
|
---|
| 235 |
|
---|
[561] | 236 | private int CalculateSize(double size, double minSize, double maxSize) {
|
---|
[1287] | 237 | if (double.IsNaN(size) || double.IsInfinity(size) || size == double.MaxValue || size == double.MinValue) return minBubbleSize;
|
---|
| 238 | if (size > maxSize) size = maxSize;
|
---|
| 239 | if (size < minSize) size = minSize;
|
---|
| 240 | if (Math.Abs(maxSize - minSize) < 1.0E-10) return minBubbleSize;
|
---|
[561] | 241 | double sizeDifference = ((size - minSize) / (maxSize - minSize) * (maxBubbleSize - minBubbleSize));
|
---|
[1287] | 242 | if (invertSize) return maxBubbleSize - (int)sizeDifference;
|
---|
[561] | 243 | else return minBubbleSize + (int)sizeDifference;
|
---|
| 244 | }
|
---|
| 245 |
|
---|
| 246 | private int CalculateAlpha(int size) {
|
---|
[2135] | 247 | return (minAlpha + maxAlpha) / 2;
|
---|
[561] | 248 | }
|
---|
| 249 |
|
---|
| 250 | private void ZoomToViewSize() {
|
---|
[1287] | 251 | if (minX < maxX && minY < maxY) {
|
---|
[561] | 252 | // enlarge view by 5% on each side
|
---|
| 253 | double width = maxX - minX;
|
---|
| 254 | double height = maxY - minY;
|
---|
| 255 | minX = minX - width * 0.05;
|
---|
| 256 | maxX = maxX + width * 0.05;
|
---|
| 257 | minY = minY - height * 0.05;
|
---|
| 258 | maxY = maxY + height * 0.05;
|
---|
| 259 | ZoomIn(minX, minY, maxX, maxY);
|
---|
| 260 | }
|
---|
| 261 | }
|
---|
| 262 |
|
---|
| 263 | private void UpdateViewSize(double x, double y, double size) {
|
---|
[1287] | 264 | if (x - size < minX) minX = x - size;
|
---|
| 265 | if (x + size > maxX) maxX = x + size;
|
---|
| 266 | if (y - size < minY) minY = y + size;
|
---|
| 267 | if (y + size > maxY) maxY = y + size;
|
---|
[561] | 268 | }
|
---|
| 269 |
|
---|
| 270 | private void ResetViewSize() {
|
---|
| 271 | minX = double.PositiveInfinity;
|
---|
| 272 | maxX = double.NegativeInfinity;
|
---|
| 273 | minY = double.PositiveInfinity;
|
---|
| 274 | maxY = double.NegativeInfinity;
|
---|
| 275 | }
|
---|
[562] | 276 |
|
---|
[1287] | 277 | internal ResultsEntry GetResultsEntry(Point point) {
|
---|
| 278 | ResultsEntry r = null;
|
---|
[567] | 279 | IPrimitive p = points.GetPrimitive(TransformPixelToWorld(point));
|
---|
[1287] | 280 | if (p != null) {
|
---|
| 281 | primitiveToEntryDictionary.TryGetValue(p, out r);
|
---|
[567] | 282 | }
|
---|
| 283 | return r;
|
---|
[562] | 284 | }
|
---|
| 285 |
|
---|
[566] | 286 | public override void MouseDrag(Point start, Point end, MouseButtons button) {
|
---|
[1287] | 287 | if (button == MouseButtons.Left && Mode == ChartMode.Select) {
|
---|
[566] | 288 | PointD a = TransformPixelToWorld(start);
|
---|
| 289 | PointD b = TransformPixelToWorld(end);
|
---|
| 290 | double minX = Math.Min(a.X, b.X);
|
---|
| 291 | double minY = Math.Min(a.Y, b.Y);
|
---|
| 292 | double maxX = Math.Max(a.X, b.X);
|
---|
| 293 | double maxY = Math.Max(a.Y, b.Y);
|
---|
[569] | 294 | HeuristicLab.Charting.Rectangle rect = new HeuristicLab.Charting.Rectangle(this, minX, minY, maxX, maxY);
|
---|
[566] | 295 |
|
---|
| 296 | List<IPrimitive> primitives = new List<IPrimitive>();
|
---|
| 297 | primitives.AddRange(points.Primitives);
|
---|
| 298 |
|
---|
[1287] | 299 | foreach (FixedSizeCircle p in primitives) {
|
---|
| 300 | if (rect.ContainsPoint(p.Point)) {
|
---|
| 301 | ResultsEntry r;
|
---|
| 302 | primitiveToEntryDictionary.TryGetValue(p, out r);
|
---|
| 303 | if (r != null) r.ToggleSelected();
|
---|
[566] | 304 | }
|
---|
| 305 | }
|
---|
[1287] | 306 | if (primitives.Count() > 0) results.FireChanged();
|
---|
[566] | 307 | } else {
|
---|
| 308 | base.MouseDrag(start, end, button);
|
---|
| 309 | }
|
---|
| 310 | }
|
---|
[569] | 311 |
|
---|
| 312 | public override void MouseClick(Point point, MouseButtons button) {
|
---|
[1287] | 313 | if (button == MouseButtons.Left) {
|
---|
| 314 | ResultsEntry r = GetResultsEntry(point);
|
---|
[1424] | 315 | if (r != null) {
|
---|
| 316 | r.ToggleSelected();
|
---|
| 317 | results.FireChanged();
|
---|
| 318 | }
|
---|
[569] | 319 | } else {
|
---|
| 320 | base.MouseClick(point, button);
|
---|
| 321 | }
|
---|
| 322 | }
|
---|
| 323 |
|
---|
| 324 | public override void MouseDoubleClick(Point point, MouseButtons button) {
|
---|
[1287] | 325 | if (button == MouseButtons.Left) {
|
---|
| 326 | ResultsEntry entry = GetResultsEntry(point);
|
---|
| 327 | if (entry != null) {
|
---|
[2047] | 328 | string serializedData = (string)entry.Get(Ontology.SerializedData.Uri.Replace(Ontology.CedmaNameSpace, ""));
|
---|
[1287] | 329 | var model = (IItem)PersistenceManager.RestoreFromGZip(Convert.FromBase64String(serializedData));
|
---|
| 330 | PluginManager.ControlManager.ShowControl(model.CreateView());
|
---|
| 331 | }
|
---|
[569] | 332 | } else {
|
---|
| 333 | base.MouseDoubleClick(point, button);
|
---|
| 334 | }
|
---|
| 335 | }
|
---|
[2139] | 336 |
|
---|
| 337 | internal void ToggleSelected() {
|
---|
| 338 | foreach (ResultsEntry entry in results.GetEntries()) {
|
---|
| 339 | entry.ToggleSelected();
|
---|
| 340 | }
|
---|
| 341 | results.FireChanged();
|
---|
| 342 | }
|
---|
| 343 |
|
---|
| 344 | internal void ClearSelection() {
|
---|
| 345 | foreach (ResultsEntry entry in results.GetEntries().Where(x=>x.Selected)) {
|
---|
| 346 | entry.ToggleSelected();
|
---|
| 347 | }
|
---|
| 348 | results.FireChanged();
|
---|
| 349 | }
|
---|
| 350 |
|
---|
| 351 | internal void ApplyFilter(Func<ResultsEntry, bool> filterPred) {
|
---|
| 352 | foreach (ResultsEntry r in results.GetEntries()) {
|
---|
| 353 | if (filterPred(r)) {
|
---|
| 354 | r.Visible = false;
|
---|
| 355 | r.Selected = false;
|
---|
| 356 | filteredEntries.Add(r);
|
---|
| 357 | }
|
---|
| 358 | }
|
---|
| 359 | results.FireChanged();
|
---|
| 360 | }
|
---|
| 361 |
|
---|
| 362 | internal void ClearFilter() {
|
---|
| 363 | foreach (ResultsEntry r in filteredEntries) {
|
---|
| 364 | r.Visible = true;
|
---|
| 365 | }
|
---|
| 366 | filteredEntries.Clear();
|
---|
| 367 | results.FireChanged();
|
---|
| 368 | }
|
---|
[561] | 369 | }
|
---|
| 370 | }
|
---|