Example #1
0
        private void butPickRxListImage_Click(object sender, EventArgs e)
        {
            if (!PrefC.AtoZfolderUsed)
            {
                MsgBox.Show(this, "This option is not supported with images stored in the database.");
                return;
            }
            FormImageSelect formIS = new FormImageSelect();

            formIS.PatNum = PatCur.PatNum;
            formIS.ShowDialog();
            if (formIS.DialogResult != DialogResult.OK)
            {
                return;
            }
            string   patFolder = ImageStore.GetPatientFolder(PatCur, ImageStore.GetPreferredAtoZpath());
            Document doc       = Documents.GetByNum(formIS.SelectedDocNum);

            if (!ImageStore.HasImageExtension(doc.FileName))
            {
                MsgBox.Show(this, "The selected file is not a supported image type.");
                return;
            }
            textDocDateDesc.Text = doc.DateTStamp.ToShortDateString() + " - " + doc.Description.ToString();
            if (BitmapOriginal != null)
            {
                BitmapOriginal.Dispose();
            }
            BitmapOriginal = ImageStore.OpenImage(doc, patFolder);
            Bitmap bitmap = ImageHelper.ApplyDocumentSettingsToImage(doc, BitmapOriginal, ImageSettingFlags.ALL);

            pictBox.BackgroundImage = bitmap;
            resizePictBox();
        }
		///<summary>Accepts a list of MimeEntity and parses it for paths, htmls and other key factors. It will test that the resulting parts
		///have a valid image extension. If they do, they are saved to a temporary web page for presentation to the user. If they are not
		///then they are disreguarded an a message is sent to the user warning them of potentially malicious content.</summary>
		private string ParseAndSaveAttachement(string htmlFolderPath,string html,List<MimeEntity> listParts) {
				bool hasDangerousAttachment=false;
				foreach(MimeEntity entity in listParts) {
					string contentId=EmailMessages.GetMimeImageContentId(entity);
					string fileName=EmailMessages.GetMimeImageFileName(entity);
					//Only show image types.  Otherwise, prompt user that potentially dangerous code is attached to the email and will not be shown.
					if(!ImageStore.HasImageExtension(fileName)) {//Check file format against known image format extensions.
						hasDangerousAttachment=true;
						continue;
					}
					html=html.Replace("cid:"+contentId,fileName);
					EmailAttach attachment=_listEmailAttachDisplayed.FirstOrDefault(x => x.DisplayedFileName.ToLower().Trim()==fileName.ToLower().Trim());
					//The path and filename must be directly accessed from the EmailAttach object in question, otherwise subsequent code would have accessed
					//an empty bodied message and never shown an image.
					EmailMessages.SaveMimeImageToFile(entity,htmlFolderPath,attachment?.ActualFileName);
				}
				if(hasDangerousAttachment) {
					//Since the extension is not within the image formats it may contain mallware and we will not parse or present it.
					MsgBox.Show("This message contains some elements that may not be safe and will not be loaded.");
				}
				return html;
		}
Example #3
0
 private void gridMain_CellClick(object sender, ODGridClickEventArgs e)
 {
     //Determine if it's a folder or a file that was clicked
     //If a folder, do nothing
     //If a file, download a thumbnail and display it
     if (ImageStore.HasImageExtension(gridMain.ListGridRows[gridMain.GetSelectedIndex()].Cells[0].Text))
     {
         try {
             //Place thumbnail within odPictureox to display
             OpenDentalCloud.Core.TaskStateThumbnail state = CloudStorage.GetThumbnail(textPath.Text, gridMain.ListGridRows[gridMain.GetSelectedIndex()].Cells[0].Text);
             if (state == null || state.FileContent == null || state.FileContent.Length < 2)
             {
                 labelThumbnail.Visible = true;
                 odPictureBox.Visible   = false;
             }
             else
             {
                 labelThumbnail.Visible = false;
                 odPictureBox.Visible   = true;
                 using (MemoryStream stream = new MemoryStream(state.FileContent)) {
                     _thumbnail = new Bitmap(Image.FromStream(stream));
                 }
                 odPictureBox.Image = _thumbnail;
                 odPictureBox.Invalidate();
             }
         }
         catch (Exception ex) {
             labelThumbnail.Visible = false;
             odPictureBox.Visible   = false;
             ex.DoNothing();
         }
     }
     else
     {
         labelThumbnail.Visible = false;
         odPictureBox.Visible   = false;
     }
 }
        private void butPickRxListImage_Click(object sender, EventArgs e)
        {
            if (PrefC.AtoZfolderUsed == DataStorageType.InDatabase)
            {
                MsgBox.Show(this, "This option is not supported with images stored in the database.");
                return;
            }
            FormImageSelect formIS = new FormImageSelect();

            formIS.PatNum = PatCur.PatNum;
            formIS.ShowDialog();
            if (formIS.DialogResult != DialogResult.OK)
            {
                return;
            }
            string   patFolder = ImageStore.GetPatientFolder(PatCur, ImageStore.GetPreferredAtoZpath());
            Document doc       = Documents.GetByNum(formIS.SelectedDocNum);

            if (!ImageStore.HasImageExtension(doc.FileName))
            {
                MsgBox.Show(this, "The selected file is not a supported image type.");
                return;
            }
            textDocDateDesc.Text = doc.DateTStamp.ToShortDateString() + " - " + doc.Description.ToString();
            if (BitmapOriginal != null)
            {
                BitmapOriginal.Dispose();
            }
            if (PrefC.AtoZfolderUsed == DataStorageType.LocalAtoZ)
            {
                BitmapOriginal = ImageStore.OpenImage(doc, patFolder);
            }
            else
            {
                FormProgress FormP = new FormProgress();
                FormP.DisplayText          = "Downloading Image...";
                FormP.NumberFormat         = "F";
                FormP.NumberMultiplication = 1;
                FormP.MaxVal = 100;              //Doesn't matter what this value is as long as it is greater than 0
                FormP.TickMS = 1000;
                OpenDentalCloud.Core.TaskStateDownload state = CloudStorage.DownloadAsync(patFolder
                                                                                          , doc.FileName
                                                                                          , new OpenDentalCloud.ProgressHandler(FormP.OnProgress));
                FormP.ShowDialog();
                if (FormP.DialogResult == DialogResult.Cancel)
                {
                    state.DoCancel = true;
                    return;
                }
                else
                {
                    using (MemoryStream ms = new MemoryStream(state.FileContent)) {
                        BitmapOriginal = new Bitmap(ms);
                    }
                }
            }
            Bitmap bitmap = ImageHelper.ApplyDocumentSettingsToImage(doc, BitmapOriginal, ImageSettingFlags.ALL);

            pictBox.BackgroundImage = bitmap;
            resizePictBox();
        }