Free cookie consent management tool by TermsFeed Policy Generator

Changeset 1606


Ignore:
Timestamp:
04/18/09 13:41:01 (16 years ago)
Author:
bspisic
Message:

Exception handling for invalid coordinates (#589)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Visualization/3.2/Canvas.cs

    r1530 r1606  
    5050
    5151    public void Draw(Graphics graphics) {
    52       Stopwatch sw = new Stopwatch();
    53       sw.Start();
     52      try {
     53        Stopwatch sw = new Stopwatch();
     54        sw.Start();
    5455
    55       graphics.SmoothingMode = SmoothingMode.AntiAlias;
    56       graphics.FillRectangle(Brushes.White, Viewport);
     56        graphics.SmoothingMode = SmoothingMode.AntiAlias;
     57        graphics.FillRectangle(Brushes.White, Viewport);
    5758
    58       worldShape.Draw(graphics);
     59        worldShape.Draw(graphics);
    5960
    60       graphics.DrawRectangle(Pens.Black, 0, 0, Viewport.Width - 1, Viewport.Height - 1);
     61        graphics.DrawRectangle(Pens.Black, 0, 0, Viewport.Width - 1, Viewport.Height - 1);
    6162
    62       sw.Stop();
    63       Trace.WriteLine(string.Format("Drawing time: {0:0.0}ms", sw.Elapsed.TotalMilliseconds));
     63        sw.Stop();
     64        Trace.WriteLine(string.Format("Drawing time: {0:0.0}ms", sw.Elapsed.TotalMilliseconds));
     65      } catch (OverflowException e) {
     66        Trace.WriteLine(e);
     67
     68        graphics.FillRectangle(Brushes.White, graphics.ClipBounds);
     69
     70        using (Font font = new Font("Arial", 14)) {
     71          const string message = "Zoom level is too high!";
     72          graphics.DrawString(message, font, Brushes.Red, graphics.ClipBounds.X + 10, graphics.ClipBounds.Y + 10);
     73        }
     74      }
    6475    }
    6576  }
Note: See TracChangeset for help on using the changeset viewer.