Esempio n. 1
0
        public void LoadImage(Stream stream)
        {
            try
            {                
                ImageLoader imgLoader = new ImageLoader();
                imgLoader.Stream = stream;
                imgLoader.Load(_codec);
                RasterImage _image = imgLoader.Image;
                imageViewer.Image = null;
                if (_image != null)
                {
                    imageViewer.Image = _image;
                    ImageSizing sizing = new ImageSizing(imageViewer);
                    sizing.SetScale(scaleFactor);
                    _codec.Options.Load.XResolution = imageViewer.Image.XResolution;
                    _codec.Options.Load.YResolution = imageViewer.Image.YResolution;
                    _annAutomation.Container.UnitConverter.DpiX = imageViewer.Image.XResolution;
                    _annAutomation.Container.UnitConverter.DpiY = imageViewer.Image.YResolution;

                    if (imageViewer.Image.XResolution == 204 && imageViewer.Image.YResolution == 196)
                    {
                        imageViewer.UseDpi = true;
                    }
                    else
                    {
                        imageViewer.UseDpi = false;
                    }

                    annotation.LoadFromStream(stream);
                    annotation.LoadFromMemory(1);
                }

                _annAutomation.ObjectsDirty = false;
                _annAutomation.ImageDirty = false;

                imageToolBar.UpdateToolBar();

                saveAsFileName = null; // always user has to set it.
                Edit = false;
            }
            catch (Exception ex)
            {
                imageViewer.Image = null;
                _annAutomation.ObjectsDirty = false;
                _annAutomation.ImageDirty = false;
                imageToolBar.UpdateToolBar();
                throw new Exception("An error occurred while loading the image." + Environment.NewLine +
                     "Error CNF-392 in " + FORM_NAME + ".LoadImage(): " + ex.Message);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Loads the images in view mode.
        /// </summary>
        public void LoadImage()
        {
            try
            {               
                ImageLoader imgLoader = new ImageLoader();

                imgLoader.FileName = newFileName;
                imgLoader.Load(_codec);
                RasterImage _image = imgLoader.Image;
                this.imageViewer.Image = null;
                imageFileName = newFileName;
                if (_image != null)
                {
                    this.imageViewer.Image = _image;
                    ImageSizing sizing = new ImageSizing(imageViewer);
                    sizing.SetScale(scaleFactor);
                    _codec.Options.Load.XResolution = imageViewer.Image.XResolution;
                    _codec.Options.Load.YResolution = imageViewer.Image.YResolution;
                    _annAutomation.Container.UnitConverter.DpiX = imageViewer.Image.XResolution;
                    _annAutomation.Container.UnitConverter.DpiY = imageViewer.Image.YResolution;
                    
                    if (imageViewer.Image.XResolution == 204 && imageViewer.Image.YResolution == 196)
                    {
                        imageViewer.UseDpi = true;
                    }
                    else
                    {
                        imageViewer.UseDpi = false;
                    }
                    
                    annotation.LoadFromFile(imageFileName);
                    annotation.LoadFromMemory(1);
                    imageToolBar.setFileName(newFileName);
                }

                _annAutomation.ObjectsDirty = false;
                _annAutomation.ImageDirty = false;

                imageToolBar.UpdateToolBar();
                
                saveAsFileName = null; // always user has to set it.
//                this.Edit = false;
            }
            catch (Exception e)
            {
                imageViewer.Image = null;
                _annAutomation.ObjectsDirty = false;
                _annAutomation.ImageDirty = false;
                imageToolBar.UpdateToolBar();
                XtraMessageBox.Show("An error occurred while loading the image for file: " + newFileName  + "." + Environment.NewLine +
                        "Error CNF-391 in " + FORM_NAME + ".LoadImage(): " + e.Message,
                     FORM_ERROR_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }