Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/14/08 22:31:37 (16 years ago)
Author:
gkronber
Message:

minor code improvements

Location:
trunk/sources/HeuristicLab.CEDMA.Charting
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.CEDMA.Charting/BubbleChart.cs

    r570 r573  
    6464      foreach(Record r in results.Records) {
    6565        records.Add(r);
    66         r.OnSelectionChanged += new EventHandler(Record_OnSelectionChanged);
    67       }
     66     }
    6867      results.OnRecordAdded += new EventHandler<RecordAddedEventArgs>(results_OnRecordAdded);
    6968      results.Changed += new EventHandler(results_Changed);
     
    8180    void results_OnRecordAdded(object sender, RecordAddedEventArgs e) {
    8281      lock(records) {
    83         e.Record.OnSelectionChanged += new EventHandler(Record_OnSelectionChanged);
    8482        records.Add(e.Record);
    85       }
    86     }
    87 
    88     void Record_OnSelectionChanged(object sender, EventArgs e) {
    89       Record r = (Record)sender;
    90       IPrimitive primitive;
    91       recordToPrimitiveDictionary.TryGetValue(r, out primitive);
    92       if(primitive != null) {
    93         ((FixedSizeCircle)primitive).UpdateEnabled = false;
    94         points.UpdateEnabled = false;
    95         if(r.Selected) {
    96           int alpha = primitive.Pen.Color.A;
    97           primitive.Pen.Color = Color.FromArgb(alpha, selectionColor);
    98           primitive.Brush = primitive.Pen.Brush;
    99           primitive.IntoForeground();
    100         } else {
    101           int alpha = primitive.Pen.Color.A;
    102           primitive.Pen.Color = Color.FromArgb(alpha, defaultColor);
    103           primitive.Brush = primitive.Pen.Brush;
    104           primitive.IntoBackground();
    105         }
    106         ((FixedSizeCircle)primitive).UpdateEnabled = true;
    107         points.UpdateEnabled = true;
    10883      }
    10984    }
     
    165140            c.ToolTipText = r.GetToolTipText();
    166141            points.Add(c);
     142            if(!r.Selected) c.IntoBackground();
    167143            primitiveToRecordDictionary[c] = r;
    168144            recordToPrimitiveDictionary[r] = c;
  • trunk/sources/HeuristicLab.CEDMA.Charting/Histogram.cs

    r572 r573  
    8787
    8888    private void Repaint() {
    89       if(dimension == null) return;
    90       UpdateEnabled = false;
    91       Group.Clear();
    92       primitiveToRecordsDictionary.Clear();
    93       recordToPrimitiveDictionary.Clear();
    94       bars = new Group(this);
    95       Group.Add(new Axis(this, 0, 0, AxisType.Both));
    96       UpdateViewSize(0, 0);
    97       Pen defaultPen = new Pen(defaultColor);
    98       Brush defaultBrush = defaultPen.Brush;
    99       PaintHistogram(records, defaultPen, defaultBrush);
    100       Pen selectionPen = new Pen(selectionColor);
    101       Brush selectionBrush = selectionPen.Brush;
    102       PaintHistogram(records.Where(r => r.Selected), selectionPen, selectionBrush);
    103       Group.Add(bars);
    104       UpdateEnabled = true;
     89      lock(records) {
     90        if(dimension == null) return;
     91        UpdateEnabled = false;
     92        Group.Clear();
     93        primitiveToRecordsDictionary.Clear();
     94        recordToPrimitiveDictionary.Clear();
     95        bars = new Group(this);
     96        Group.Add(new Axis(this, 0, 0, AxisType.Both));
     97        UpdateViewSize(0, 0);
     98        Pen defaultPen = new Pen(defaultColor);
     99        Brush defaultBrush = defaultPen.Brush;
     100        PaintHistogram(records, defaultPen, defaultBrush);
     101        Pen selectionPen = new Pen(selectionColor);
     102        Brush selectionBrush = selectionPen.Brush;
     103        PaintHistogram(records.Where(r => r.Selected), selectionPen, selectionBrush);
     104        Group.Add(bars);
     105        UpdateEnabled = true;
     106      }
    105107    }
    106108
     
    168170    public override void MouseClick(Point point, MouseButtons button) {
    169171      if(button == MouseButtons.Left) {
    170         List<Record> rs = GetRecords(point);
    171         UpdateEnabled = false;
    172         if(rs != null) rs.ForEach(r => r.ToggleSelected());
    173         UpdateEnabled = true;
     172        lock(records) {
     173          List<Record> rs = GetRecords(point);
     174          UpdateEnabled = false;
     175          if(rs != null) rs.ForEach(r => r.ToggleSelected());
     176          UpdateEnabled = true;
     177        }
    174178        results.FireChanged();
    175179      } else {
  • trunk/sources/HeuristicLab.CEDMA.Charting/Record.cs

    r569 r573  
    6868    public const string Y_JITTER = "__Y_JITTER";
    6969
    70     public event EventHandler OnSelectionChanged;
    71 
    7270    private Dictionary<string, double> values = new Dictionary<string, double>();
    7371    private ResultList resultList;
     
    9492    public void ToggleSelected() {
    9593      selected = !selected;
    96       if(OnSelectionChanged != null) OnSelectionChanged(this, new EventArgs());     
    9794    }
    9895
Note: See TracChangeset for help on using the changeset viewer.