private void GridMeasures_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {

                if (e.RowIndex < 0 || e.ColumnIndex < 0)
                    return;

                ImageForm frm;

                if (GridMeasures.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.GetType().Equals(typeof(Image)) ||
                    GridMeasures.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.GetType().Equals(typeof(Bitmap))
                    )
                {
                    frm = new ImageForm((Image)GridMeasures.Rows[e.RowIndex].Cells[e.ColumnIndex].Value);
                    frm.MdiParent = MdiParent;
                    frm.Show();
                }
                else if (GridMeasures.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.GetType().Equals(typeof(WeakImage)))
                {
                    frm = new ImageForm(((WeakImage)GridMeasures.Rows[e.RowIndex].Cells[e.ColumnIndex].Value).Image);
                    frm.MdiParent = MdiParent;
                    frm.Show();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.GetType().FullName, ex.Message);
            }
        }
        public ImageForm(ImageForm iFormImageSrc)
            : this()
        {
            // Inherit settings also ...
            Mode = iFormImageSrc.Mode;

            // Copy the image, pixel-by-pixel ...
            SetImage((Image)iFormImageSrc.pictureBoxImage.Image.Clone());
        }
        private void backToSpatialDomainToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                FourierTransform t = new FourierTransform();

                ImageForm frmImg = new ImageForm(Facilities.ToImage(Facilities.ToBitmap(t.ApplyReverseTransform(_complex))));
                frmImg.MdiParent = this.MdiParent;
                frmImg.Show();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.GetType().FullName, ex.Message);
            }
        }
        private void GridResults_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex < 0 || e.ColumnIndex < 0)
                return;

            RowResults tuple = (RowResults)GridResults.Rows[e.RowIndex].DataBoundItem;
            ImageForm frm;

            if (GridResults.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.GetType().Equals(typeof(Image)) ||
                GridResults.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.GetType().Equals(typeof(Bitmap))
                )
            {
                frm = new ImageForm((Image)GridResults.Rows[e.RowIndex].Cells[e.ColumnIndex].Value);
                frm.MdiParent = MdiParent;
                frm.Show();
            }
            else
            {
                switch (e.ColumnIndex)
                {
                    case 3:

                        MeasuresViewerForm m = new MeasuresViewerForm(tuple.Item4);
                        m.MdiParent = MdiParent;
                        m.Show();

                        break;
                }
            }
        }
        private void GridReferences_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex < 0 || e.ColumnIndex < 0)
                return;

            RowImage tuple = (RowImage)GridReferences.Rows[e.RowIndex].DataBoundItem;
            ImageForm frm;

            if (GridReferences.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.GetType().Equals(typeof(Image)) ||
                GridReferences.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.GetType().Equals(typeof(Bitmap))
                )
            {
                frm = new ImageForm((Image)GridReferences.Rows[e.RowIndex].Cells[e.ColumnIndex].Value);
                frm.MdiParent = MdiParent;
                frm.Show();
            }
        }
        private void ExecuteFilter(Type t, Image img)
        {
            try
            {
                // Initialize instance
                FilterCore filter = (FilterCore)System.Activator.CreateInstance(t);

                // Setup instance (if necessary ...)
                SortedDictionary<string, object> configs = filter.GetDefaultConfigs();
                if (null != configs)
                {
                    ConfigurationsForm conf = new ConfigurationsForm(ref configs);
                    if (conf.ShowDialog() == System.Windows.Forms.DialogResult.Cancel)
                        return;
                }

                // Execute filter, get new image ...
                Image ret = filter.ApplyFilter(img, configs);

                ret.Tag = Facilities.CloneTag(img);
                Facilities.AddFilterExecution(ref ret, filter, configs);

                ImageForm ret_form = new ImageForm(ret);
                ret_form.MdiParent = MdiParent;
                ret_form.Mode = Mode;
                ret_form.Show();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, e.GetType().FullName);
            }
        }
 private void cloneToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         ImageForm img = new ImageForm(this);
         img.MdiParent = MdiParent;
         img.Show();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.GetType().FullName, ex.Message);
     }
 }
 private void openNormalImageFormToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         ImageForm imForm = new ImageForm(pictureFilteredImage.Image);
         imForm.MdiParent = MdiParent;
         imForm.Show();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.GetType().FullName, ex.Message);
     }
 }
        private void gridResults_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (e.RowIndex < 0 || e.ColumnIndex < 0)
                    return;

                RowResults tuple = (RowResults)gridResults.Rows[e.RowIndex].DataBoundItem;
                ImageForm frm;

                if (gridResults.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.GetType().Equals(typeof(Image)) ||
                    gridResults.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.GetType().Equals(typeof(Bitmap)))
                {
                    frm = new ImageForm((Image)(gridResults.Rows[e.RowIndex].Cells[e.ColumnIndex].Value));
                    frm.MdiParent = MdiParent;
                    frm.Show();
                }
                else if (gridResults.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.GetType().Equals(typeof(WeakImage)))
                {
                    frm = new ImageForm(((WeakImage)gridResults.Rows[e.RowIndex].Cells[e.ColumnIndex].Value).Image);
                    frm.MdiParent = MdiParent;
                    frm.Show();
                }
                else
                {
                    switch (e.ColumnIndex)
                    {
                        case 3:

                            MeasuresViewerForm m = new MeasuresViewerForm(tuple.Item4);
                            m.MdiParent = MdiParent;
                            m.Show();

                            break;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.GetType().FullName, ex.Message);
            }
        }
        private void gridImages_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                DataGridView wrkGrid = (DataGridView)sender;

                if (e.RowIndex < 0 || e.ColumnIndex < 0)
                    return;

                RowImage tuple = (RowImage)wrkGrid.Rows[e.RowIndex].DataBoundItem;
                ImageForm frm;

                if (wrkGrid.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.GetType().Equals(typeof(Image)) ||
                    wrkGrid.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.GetType().Equals(typeof(Bitmap))
                    )
                {
                    frm = new ImageForm((Image)wrkGrid.Rows[e.RowIndex].Cells[e.ColumnIndex].Value);
                    frm.MdiParent = MdiParent;
                    frm.Show();
                }
                else if (wrkGrid.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.GetType().Equals(typeof(WeakImage)))
                {
                    frm = new ImageForm(((WeakImage)wrkGrid.Rows[e.RowIndex].Cells[e.ColumnIndex].Value).Image);
                    frm.MdiParent = MdiParent;
                    frm.Show();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.GetType().FullName, ex.Message);
            }
        }
        private void openFileDialog1_FileOk(object sender, CancelEventArgs e)
        {
            try
            {
                OpenFileDialog wrkSender = sender as OpenFileDialog;

                if (wrkSender != null)
                {
                    foreach (String fn in wrkSender.FileNames)
                    {
                        try
                        {
                            ImageForm img = new ImageForm(fn);
                            img.MdiParent = this;
                            img.Show();
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message, ex.GetType().FullName);
                        }
                    }

                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.GetType().FullName, ex.Message);
            }
        }