//-------------------------------------------------------------------------------------- // openToolStripMenuItem_Click: What to do when the open button is pressed under the menu bar. // // Param: // sender: object type, Supports all classes in the .NET Framework class hierarchy. // e: EventArgs type, represents the base class for classes that cotain event data. //-------------------------------------------------------------------------------------- private void openToolStripMenuItem_Click(object sender, EventArgs e) { // New open file dialog. OpenFileDialog dlg = new OpenFileDialog(); string filename = ""; // Filter which files can be opened. dlg.Filter = "BMP|*.bmp|GIF|*.gif|JPG|*.jpg;*.jpeg|PNG|*.png|TIFF|*.tif;*.tiff|" + "All Files|*.*"; // Present the open dialog if (dlg.ShowDialog() == DialogResult.OK) { // store the file path. filename = dlg.SafeFileName; // Create a new tab TabView tabview = NewTab(filename); // Set image to the new tabview. Bitmap bitm = new Bitmap(Image.FromFile(dlg.FileName)); tabview.SetImage(bitm); tabview.SetDirectory(dlg.FileName); tabview.SetNewFile(true); } }
//-------------------------------------------------------------------------------------- // newToolStripMenuItem_Click: What to do when the new button is pressed under the menu bar. // // Param: // sender: object type, Supports all classes in the .NET Framework class hierarchy. // e: EventArgs type, represents the base class for classes that cotain event data. //-------------------------------------------------------------------------------------- private void newToolStripMenuItem_Click(object sender, EventArgs e) { // Create and display a new forms for options on creating the new project. var form2 = new Form2(); form2.StartPosition = FormStartPosition.CenterParent; form2.ShowDialog(); // If the okay button is pressed. if (form2.GetOkayPressed()) { // Create new tab TabView tabview = NewTab("New Image"); // Create new bitmap Bitmap bitm = new Bitmap(form2.GetImageWidth(), form2.GetImageHeight(), PixelFormat.Format32bppArgb); // Let the user pick a width and hieght in a seperate form. // Set the background of the picturebox. tabview.SetBackgroundColor(form2.GetImageColor()); // Set image on the tabview tabview.SetImage(bitm); // Set the new file to true. tabview.SetNewFile(true); } }
//-------------------------------------------------------------------------------------- // Form1_DragDrop: Function for what to do when something is drag dropped. // // Param: // sender: object type, Supports all classes in the .NET Framework class hierarchy. // e: DragEventArgs type, represents the base class for classes that cotain event data. //-------------------------------------------------------------------------------------- private void Form1_DragDrop(object sender, DragEventArgs e) { // if a valid file has been dropped. if (isDataValid) { // while the thread is still running. while (imageThread.IsAlive) { Application.DoEvents(); // Block the current thread Thread.Sleep(0); } // Create a new tab TabView tabview = NewTab(System.IO.Path.GetFileName(filepath)); // Set image to the new tabview. tabview.SetImage(image); tabview.SetDirectory(System.IO.Path.GetFileName(filepath)); } }