// For a derived class, it is recommended to override the event notifier rather // than subscribe to the event. protected override void OnPaint(Wimp.RedrawEventArgs e) { var local_matrix = (OS.Matrix)matrix.Clone(); // Matrix translation is used to position the drawfile on screen within // the window. local_matrix.Translate(e.Origin.X, e.Origin.Y); Drawfile.Render(0, draw_file, local_matrix, ref e.Redraw.Clip, 0); // Technically, we should call the base method to ensure that event subscribers // are also notified of this event, but I don't think that's necessary in this // case. // base.OnPaint (e); }
public DrawDocument(string name) : base("MainWindow") { using (var file = new BinaryReader(File.Open(name, FileMode.Open))) { draw_file = new byte [file.BaseStream.Length]; file.Read(draw_file, 0, (int)file.BaseStream.Length); // File is closed automatically at the end of the using scope. } OS.Rect bbox = Drawfile.GetBounds(0, draw_file, null); // Convert the bounding box from Draw units to OS units bbox.MinX >>= 8; bbox.MinY >>= 8; bbox.MaxX >>= 8; bbox.MaxY >>= 8; // Set the window extent to the size of the draw file. Extent = new OS.Rect(0, 0, bbox.MinX + bbox.MaxX, bbox.MinX + bbox.MaxY); Title = name; }