Beispiel #1
0
        /// <summary>
        /// Description: If the child is closing, create a dialog that will handle how the user wants the child to close.
        /// The dialog will allow the form to save, save as, close, or cancel closing.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void childClosing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            FormChild     child  = (FormChild)sender;
            DialogClosing dialog = new DialogClosing();

            switch (dialog.ShowDialog())
            {
            case DialogResult.OK:       // Save
                saveToolStripMenuItem_Click(sender, e);
                break;

            case DialogResult.Yes:      // Save-As
                saveAsToolStripMenuItem_Click(sender, e);
                break;

            case DialogResult.No:     // No
                break;

            case DialogResult.Cancel:
                e.Cancel = true;
                break;
            }

            // Checks if there are still child forms, if there is not disable the toolstrips
            if (this.MdiChildren.Length - 1 <= 0)
            {
                saveToolStripMenuItem.Enabled   = false;
                saveAsToolStripMenuItem.Enabled = false;
            }
        }
Beispiel #2
0
        /// <summary>
        /// Description: Open a file from the web
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void openFromWebToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DialogOpenWeb dialog = new DialogOpenWeb();

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    WebRequest  request  = WebRequest.Create(dialog.Url);
                    WebResponse response = request.GetResponse();

                    Image     image = Image.FromStream(response.GetResponseStream());
                    FormChild child = new FormChild();
                    child.Image                     = image;
                    child.MdiParent                 = this;
                    child.FormClosing              += new System.Windows.Forms.FormClosingEventHandler(childClosing);
                    saveToolStripMenuItem.Enabled   = true;
                    saveAsToolStripMenuItem.Enabled = true;
                    child.Show();
                }
                catch (Exception exception)
                {
                    MessageBox.Show(exception.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// Description: Save the image to a specified location
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FormChild child = (FormChild)this.ActiveMdiChild;

            saveFileDialog1.Filter = "JPeg Image| *.jpg; *.jpeg|Bitmap Image|*.bmp|Gif Image|*.gif";
            saveFileDialog1.Title  = "Save an Image File";

            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                child.save(saveFileDialog1.FileName);
            }
        }
Beispiel #4
0
 /// <summary>
 /// Description: Open a file from the file explorer
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void openFromFileToolStripMenuItem_Click(object sender, EventArgs e)
 {
     openFileDialog1.Filter      = "Image Files (*.jpg, *.jpeg, *.bmp, *.gif)|*.jpg; *.jpeg; *.bmp; *.gif|All Files (*.*)|*.*";
     openFileDialog1.FilterIndex = 1;
     if (openFileDialog1.ShowDialog() == DialogResult.OK)
     {
         FormChild child = new FormChild(openFileDialog1.FileName);
         child.Url                       = openFileDialog1.FileName;
         child.MdiParent                 = this;
         child.FormClosing              += new System.Windows.Forms.FormClosingEventHandler(childClosing);
         saveToolStripMenuItem.Enabled   = true;
         saveAsToolStripMenuItem.Enabled = true;
         child.Show();
     }
 }
Beispiel #5
0
 /// <summary>
 /// Description: When the new accelerator is clicked, call a dialog to specify the size of the new childform.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void newToolStripMenuItem_Click(object sender, EventArgs e)
 {
     using (DialogNew dialog = new DialogNew())
     {
         if (dialog.ShowDialog() == DialogResult.OK)
         {
             FormChild child = new FormChild(dialog.Resolution);
             child.MdiParent                 = this;
             child.FormClosing              += new System.Windows.Forms.FormClosingEventHandler(childClosing);
             saveToolStripMenuItem.Enabled   = true;
             saveAsToolStripMenuItem.Enabled = true;
             child.Show();
         }
     }
 }