Advertisement
Guest User

Untitled

a guest
Oct 1st, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.18 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10.  
  11.  
  12. namespace GraphicsPictureHouse
  13. {
  14. public partial class Form1 : Form
  15. {
  16. private Graphics gScreen;
  17. private Graphics gBitmap;
  18. private Bitmap bitmap;
  19. private int zoom = 1;
  20. private bool mouseDown = false;
  21. private int xCentre = 300;
  22. private int yCentre = 300;
  23. private int xRoute = 0;
  24. private int yRoute = 0;
  25. int xStart;
  26. int yStart;
  27.  
  28. public Form1()
  29. {
  30. InitializeComponent();
  31. gBitmap = this.CreateGraphics();
  32. }
  33.  
  34. private void Form1_Load(object sender, EventArgs e)
  35. {
  36. gScreen = CreateGraphics();
  37. bitmap = new Bitmap(ClientRectangle.Width, ClientRectangle.Height);
  38. gBitmap = Graphics.FromImage(bitmap); //?
  39. }
  40.  
  41. private void Form1_Paint(object sender, PaintEventArgs e)
  42. {
  43.  
  44. MyClass.Draw(e.Graphics, Convert.ToInt32(numericUpDown.Value), zoom, xCentre+xRoute, yCentre+yRoute);
  45. gScreen.DrawImage(bitmap, ClientRectangle);
  46. }
  47.  
  48. private void Mouse_Move(object sender, MouseEventArgs e)
  49. {
  50. this.Text = " " + e.X + " " + e.Y;
  51. if (mouseDown)
  52. {
  53. xRoute = xStart - xCentre;
  54. yStart = yStart - yCentre;
  55. this.Refresh();
  56. }
  57. }
  58.  
  59. private void paint_Btn_Click(object sender, EventArgs e)
  60. {
  61. this.Refresh();
  62. }
  63.  
  64. private void Mouse_Down(object sender, MouseEventArgs e)
  65. {
  66. mouseDown = true;
  67. xStart = e.X;
  68. yStart = e.X;
  69.  
  70.  
  71.  
  72. }
  73.  
  74. private void Mouse_Wheel(object sender, MouseEventArgs e)
  75. {
  76. zoom++;
  77. this.Refresh();
  78. }
  79.  
  80. private void Mouse_Up(object sender, MouseEventArgs e)
  81. {
  82. mouseDown = false;
  83. }
  84. }
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement