Form1.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. //using SvgNet;
  11. // This is the code for your desktop app.
  12. // Press Ctrl+F5 (or go to Debug > Start Without Debugging) to run your app.
  13. namespace SketchAssistant
  14. {
  15. public partial class Form1 : Form
  16. {
  17. public Form1()
  18. {
  19. InitializeComponent();
  20. }
  21. //Dialog to select a file.
  22. OpenFileDialog openFileDialogLeft = new OpenFileDialog();
  23. //Image loaded on the left
  24. Image leftImage = null;
  25. private void Form1_Load(object sender, EventArgs e)
  26. {
  27. this.DoubleBuffered = true;
  28. //Connect the Paint event of the left picture box to the event handler method.
  29. pictureBoxLeft.Paint += new System.Windows.Forms.PaintEventHandler(this.pictureBoxLeft_Paint);
  30. }
  31. private void pictureBoxLeft_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
  32. {
  33. //Draw the left image
  34. if(leftImage != null)
  35. {
  36. pictureBoxLeft.Image = leftImage;
  37. }
  38. }
  39. //TODO: Remove this placeholder when real buttons are in place
  40. private void toolStripLabel1_Click(object sender, EventArgs e)
  41. {
  42. }
  43. // A Table Layout with one row and two columns.
  44. // Columns are 50% so that the window is evenly split.
  45. // The size is manually set relative to the window size.
  46. // TODO: Maybe change this to automatically be the size of a parent container...
  47. private void tableLayoutPanel1_Paint(object sender, PaintEventArgs e)
  48. {
  49. }
  50. private void fileToolStripMenuItem_Click(object sender, EventArgs e)
  51. {
  52. }
  53. //Load button, will open an OpenFileDialog
  54. private void loadToolStripMenuItem_Click(object sender, EventArgs e)
  55. {
  56. openFileDialogLeft.Filter = "Image|*.jpg;*.png;*.jpeg";
  57. if(openFileDialogLeft.ShowDialog() == DialogResult.OK)
  58. {
  59. toolStripLoadStatus.Text = openFileDialogLeft.SafeFileName;
  60. leftImage = Image.FromFile(openFileDialogLeft.FileName);
  61. //The following line is needed, as else on first image load
  62. //the image will only be shown after resizing the window.
  63. this.Refresh();
  64. }
  65. }
  66. private void toolStripStatusLabel1_Click(object sender, EventArgs e)
  67. {
  68. }
  69. private void statusStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
  70. {
  71. }
  72. //Timer that refreshes the picture box, so that it will always show the right contents in the right size
  73. private void timer1_Tick(object sender, EventArgs e)
  74. {
  75. pictureBoxLeft.Update();
  76. }
  77. private void pictureBoxLeft_Click(object sender, EventArgs e)
  78. {
  79. }
  80. }
  81. }