コード例 #1
0
ファイル: FormImageViewer.cs プロジェクト: royedwards/DRDNet
        ///<summary>This form will get the necessary images off disk or from the cloud so that it can control layout.</summary>
        public void SetImage(Document thisDocument, string displayTitle)
        {
            //for now, the document is single. Later, it will get groups for composite images/mounts.
            Text         = displayTitle;
            displayedDoc = thisDocument;
            List <long> docNums = new List <long>();

            docNums.Add(thisDocument.DocNum);
            string fileName = CloudStorage.PathTidy(Documents.GetPaths(docNums, ImageStore.GetPreferredAtoZpath())[0]);

            if (!FileAtoZ.Exists(fileName))
            {
                MessageBox.Show(fileName + " +" + Lan.g(this, "could not be found."));
                return;
            }
            ImageCurrent = (Bitmap)FileAtoZ.GetImage(fileName);
            DisplayImage();
        }
コード例 #2
0
 private void PaintPreviewPicture()
 {
     try {
         Document doc       = GetSelectedDocument();
         string   imagePath = FileAtoZ.CombinePaths(_patFolder, doc.FileName);
         if (!FileAtoZ.Exists(imagePath))
         {
             throw new Exception("File not found");
         }
         Image tmpImg   = FileAtoZ.GetImage(imagePath);
         float imgScale = 1;                                                                                                   //will be between 0 and 1
         if (tmpImg.PhysicalDimension.Height > picturePreview.Height || tmpImg.PhysicalDimension.Width > picturePreview.Width) //image is too large
         //Image is larger than PictureBox, resize to fit.
         {
             if (tmpImg.PhysicalDimension.Width / picturePreview.Width > tmpImg.PhysicalDimension.Height / picturePreview.Height)               //resize image based on width
             {
                 imgScale = picturePreview.Width / tmpImg.PhysicalDimension.Width;
             }
             else                      //resize image based on height
             {
                 imgScale = picturePreview.Height / tmpImg.PhysicalDimension.Height;
             }
         }
         if (picturePreview.Image != null)
         {
             picturePreview.Image.Dispose();
             picturePreview.Image = null;
         }
         picturePreview.Image = new Bitmap(tmpImg, (int)(tmpImg.PhysicalDimension.Width * imgScale), (int)(tmpImg.PhysicalDimension.Height * imgScale));
         //labelDescription.Text=Lan.g(this,"Description")+": "+doc.Description;
         picturePreview.Invalidate();
         if (tmpImg != null)
         {
             tmpImg.Dispose();
         }
         tmpImg = null;
     }
     catch (Exception e) {
         e.DoNothing();
         picturePreview.Image = null;
         picturePreview.Invalidate();
     }
 }
コード例 #3
0
        private void paintPreviewPicture()
        {
            if (gridMain.GetSelectedIndex() == -1)
            {
                return;
            }
            string imagePath = ImageNamesList[gridMain.GetSelectedIndex()];
            Image  tmpImg    = FileAtoZ.GetImage(imagePath);                                                                      //Could throw an exception if someone deletes the image right after this window loads.
            float  imgScale  = 1;                                                                                                 //will be between 0 and 1

            if (tmpImg.PhysicalDimension.Height > picturePreview.Height || tmpImg.PhysicalDimension.Width > picturePreview.Width) //image is too large
            //Image is larger than PictureBox, resize to fit.
            {
                if (tmpImg.PhysicalDimension.Width / picturePreview.Width > tmpImg.PhysicalDimension.Height / picturePreview.Height)           //resize image based on width
                {
                    imgScale = picturePreview.Width / tmpImg.PhysicalDimension.Width;
                }
                else                  //resize image based on height
                {
                    imgScale = picturePreview.Height / tmpImg.PhysicalDimension.Height;
                }
            }
            if (picturePreview.Image != null)
            {
                picturePreview.Image.Dispose();
                picturePreview.Image = null;
            }
            picturePreview.Image = new Bitmap(tmpImg, (int)(tmpImg.PhysicalDimension.Width * imgScale), (int)(tmpImg.PhysicalDimension.Height * imgScale));
            labelImageSize.Text  = Lan.g(this, "Image Size") + ": " + (int)tmpImg.PhysicalDimension.Width + " x " + (int)tmpImg.PhysicalDimension.Height;
            picturePreview.Invalidate();
            if (tmpImg != null)
            {
                tmpImg.Dispose();
            }
            tmpImg = null;
        }