Beispiel #1
0
        //--------------------------------------------------------------------------------------
        // 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));
            }
        }
Beispiel #2
0
        //--------------------------------------------------------------------------------------
        // SaveAsFunction: The saving function when an image doesnt have a saved file.
        //--------------------------------------------------------------------------------------
        private void SaveAsFunction()
        {
            // New save dialog
            SaveFileDialog save = new SaveFileDialog();

            // Filter which files can be saved.
            save.Filter = "PNG|*.png|BMP|*.bmp|GIF|*.gif|JPG|*.jpg|JPEG|*.jpeg|TIF|*.tif|TIFF|*.tiff";

            // Set image format
            ImageFormat format = ImageFormat.Png;

            // Show dialog box.
            if (save.ShowDialog() == DialogResult.OK)
            {
                //get filename extensions.
                string ext = System.IO.Path.GetExtension(save.FileName);

                switch (ext)
                {
                // png.
                case ".png":
                    format = ImageFormat.Png;
                    break;

                // bmp.
                case ".bmp":
                    format = ImageFormat.Bmp;
                    break;

                // gif.
                case ".gif":
                    format = ImageFormat.Gif;
                    break;

                // jpg.
                case ".jpg":
                    format = ImageFormat.Jpeg;
                    break;

                // jpeg.
                case ".jpeg":
                    format = ImageFormat.Jpeg;
                    break;

                // tif.
                case ".tif":
                    format = ImageFormat.Tiff;
                    break;

                // tiff.
                case ".tiff":
                    format = ImageFormat.Tiff;
                    break;
                }

                // Get the current tabview
                TabView tabview = ((TabView)tabControl1.SelectedTab.Controls[0]);

                // Get image and save image to save location.
                Image image = tabview.GetImage();
                image.Save(save.FileName, format);

                // Set altered and new to false
                tabview.SetAltered(false);
                tabview.SetNewFile(false);
                tabview.SetDirectory(save.FileName);

                // Set the tab name
                tabControl1.SelectedTab.Text = System.IO.Path.GetFileName(save.FileName);
            }
        }