/// <summary> /// Draws black in the areas outside the view. /// Assumes that controlBounds is starting at (0, 0) in upper left corner. /// </summary> /// <param name="context">A context to perform drawing.</param> /// <param name="controlBounds">Bounds of the control.</param> /// <param name="view">The bounds of the view.</param> public static void Draw(Graphics context, Rectangle controlBounds, RectangleD view) { context.Clear(Color.Black); context.FillRectangle(Brushes.White, (float)view.X, (float)view.Y, (float)view.Width, (float)view.Height); }
public static Matrix ViewToBufferMatrix(Rectangle controlBounds, RectangleD view, double settingsWidth, double settingsHeight) { var m = new Matrix (); m.Scale ((float)(view.Width / settingsWidth), (float)(view.Height / settingsHeight)); return m; }
public static Matrix ViewToControlMatrix(Rectangle controlBounds, RectangleD view, double settingsWidth, double settingsHeight) { var m = new Matrix (); m.Translate ((float)(view.X - controlBounds.X), (float)(view.Y - controlBounds.Y)); m.Scale ((float)(view.Width / settingsWidth), (float)(view.Height / settingsHeight)); return m; }