Example #1
0
        public void UpdateControls()
        {
            ViewerForm activeForm = ActiveViewerForm;

            // Update File menu items...
            EnableAndVisibleMenu(_miFileSave, activeForm != null);
            EnableAndVisibleMenu(_miFileClose, activeForm != null);

            // Update Edit menu items...
            EnableAndVisibleMenu(_miEditUndo, activeForm != null);
            EnableAndVisibleMenu(_miEditRedo, activeForm != null);
            _miEditSeperator1.Visible = (activeForm != null);
            EnableAndVisibleMenu(_miEditCopy, activeForm != null);
            _miEditPaste.Enabled = RasterClipboard.IsReady;

            // Update Analysis menu items...
            EnableAndVisibleMenu(_miAnalysis, activeForm != null);
            EnableAndVisibleMenu(_miAnalysisInteractiveHistogram, activeForm != null);

            if (activeForm != null)
            {
                if (activeForm.UndoList.Index <= 0)
                {
                    _miEditUndo.Enabled = false;
                }
                else
                {
                    _miEditUndo.Enabled = true;
                }

                if (activeForm.UndoList.Index >= activeForm.UndoList.Counter - 1)
                {
                    _miEditRedo.Enabled = false;
                }
                else
                {
                    _miEditRedo.Enabled = true;
                }

                _menuItemMagGlassStart.Checked = activeForm.IsMagGlass;
                _menuItemMagGlassStop.Checked  = !activeForm.IsMagGlass;
            }

            // Update Window menu items...
            EnableAndVisibleMenu(_miWindow, activeForm != null);
        }
Example #2
0
 public void LoadDropFiles(ViewerForm viewer, string[] files)
 {
     try
     {
         if (files != null)
         {
             for (int i = 0; i < files.Length; i++)
             {
                 try
                 {
                     RasterImage      image = _codecs.Load(files[i]);
                     ImageInformation info  = new ImageInformation(image, files[i]);
                     if (i == 0 && viewer != null)
                     {
                         viewer.Initialize(info, _paintProperties, false);
                     }
                     else
                     {
                         NewImage(info);
                     }
                 }
                 catch (Exception ex)
                 {
                     Messager.ShowFileOpenError(this, files[i], ex);
                 }
             }
         }
     }
     catch (Exception ex)
     {
         Messager.ShowError(this, ex);
     }
     finally
     {
         UpdateControls();
     }
 }
Example #3
0
        private void _miEditPaste_Click(object sender, EventArgs e)
        {
            try
            {
                using (WaitCursor wait = new WaitCursor())
                {
                    RasterImage image = RasterClipboard.Paste(this.Handle);
                    if (image != null)
                    {
                        ViewerForm activeForm = ActiveViewerForm;

                        if (image.HasRegion && activeForm == null)
                        {
                            image.MakeRegionEmpty();
                        }

                        if (image.HasRegion)
                        {
                            // make sure the images have the same BitsPerPixel and Palette
                            if (activeForm.Viewer.Image.BitsPerPixel > 8)
                            {
                                if (image.BitsPerPixel != activeForm.Viewer.Image.BitsPerPixel)
                                {
                                    try
                                    {
                                        ColorResolutionCommand colorRes = new ColorResolutionCommand();
                                        colorRes.BitsPerPixel = activeForm.Viewer.Image.BitsPerPixel;
                                        colorRes.Order        = activeForm.Viewer.Image.Order;
                                        colorRes.Mode         = Leadtools.ImageProcessing.ColorResolutionCommandMode.InPlace;
                                        colorRes.Run(image);
                                    }
                                    catch (Exception ex)
                                    {
                                        Messager.ShowError(this, ex);
                                    }
                                }
                            }
                            else
                            {
                                try
                                {
                                    ColorResolutionCommand colorRes = new ColorResolutionCommand();
                                    colorRes.BitsPerPixel = activeForm.Viewer.Image.BitsPerPixel;
                                    colorRes.SetPalette(activeForm.Viewer.Image.GetPalette());
                                    colorRes.PaletteFlags = Leadtools.ImageProcessing.ColorResolutionCommandPaletteFlags.UsePalette;
                                    colorRes.Mode         = Leadtools.ImageProcessing.ColorResolutionCommandMode.InPlace;
                                    colorRes.Run(image);
                                }
                                catch (Exception ex)
                                {
                                    Messager.ShowError(this, ex);
                                }
                            }
                        }
                        else
                        {
                            NewImage(new ImageInformation(image));
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Messager.ShowError(this, ex);
            }
            finally
            {
                UpdateControls();
            }
        }