private void InitializeMedicalViewer() { try { MedicalViewerMultiCell cell = new MedicalViewerMultiCell(); cell.KeepDrawingAnnotation = true; cell.AddAction(MedicalViewerActionType.Stack); cell.SetAction(MedicalViewerActionType.Stack, MedicalViewerMouseButtons.Wheel, MedicalViewerActionFlags.Active); cell.AddAction(MedicalViewerActionType.AnnotationRedaction); cell.SetAction(MedicalViewerActionType.AnnotationRedaction, MedicalViewerMouseButtons.Left, MedicalViewerActionFlags.Active); cell.AddAction(MedicalViewerActionType.Scale); cell.SetAction(MedicalViewerActionType.Scale, MedicalViewerMouseButtons.Right, MedicalViewerActionFlags.Active); cell.AnnotationCreated += new EventHandler <MedicalViewerAnnotationCreatedEventArgs>(cell_AnnotationCreated); cell.DesignerCreated += new EventHandler <MedicalViewerDesignerCreatedEventArgs>(cell_DesignerCreated); _MedicalViewer = new MedicalViewer(1, 1); _MedicalViewer.Dock = DockStyle.Fill; _MedicalViewer.SplitterStyle = MedicalViewerSplitterStyle.None; _MedicalViewer.Cells.Add(cell); _MedicalViewer.Dock = DockStyle.Fill; panelView.Controls.Add(_MedicalViewer); } catch (Exception e) { Messager.ShowError(this, e); Close(); } }
private void _btnApply_Click(object sender, EventArgs e) { MedicalViewerActionFlags applyingOperation = (MedicalViewerActionFlags)0; switch (_cmbNudgeApplyTo.SelectedIndex) { case 0: applyingOperation = MedicalViewerActionFlags.Active; break; case 1: applyingOperation = MedicalViewerActionFlags.Selected; break; case 2: applyingOperation = MedicalViewerActionFlags.AllCells; break; } if (_cmbNudgeApplyTo.SelectedIndex > 0) { if (_cmbNudgeApplyingMethod.SelectedIndex == 1) { applyingOperation ^= MedicalViewerActionFlags.OnRelease; } else { applyingOperation ^= MedicalViewerActionFlags.RealTime; } } if ((MedicalViewerMouseButtons)_cmbNudgeMouseButton.SelectedIndex == MedicalViewerMouseButtons.Left) { _owner.CurrentAction = MedicalViewerActionType.NudgeTool; _owner.LeftButtonAction = MedicalViewerActionType.NudgeTool; _owner.CheckMoveMarkersAction(false); _owner.CheckSelectPoints(false); } if ((MedicalViewerMouseButtons)_cmbNudgeMouseButton.SelectedIndex == MedicalViewerMouseButtons.Right) { _owner.RightButtonAction = MedicalViewerActionType.NudgeTool; } cell.SetAction(MedicalViewerActionType.NudgeTool, (MedicalViewerMouseButtons)_cmbNudgeMouseButton.SelectedIndex, applyingOperation); foreach (MedicalViewerBaseCell viewerCell in viewer.Cells) { viewerCell.SetAction(MedicalViewerActionType.NudgeTool, (MedicalViewerMouseButtons)_cmbNudgeMouseButton.SelectedIndex, applyingOperation); } applyingOperation = (MedicalViewerActionFlags)0; switch (_cmbShrinkApplyTo.SelectedIndex) { case 0: applyingOperation = MedicalViewerActionFlags.Active; break; case 1: applyingOperation = MedicalViewerActionFlags.Selected; break; case 2: applyingOperation = MedicalViewerActionFlags.AllCells; break; } if (_cmbShrinkApplyTo.SelectedIndex > 0) { if (_cmbShrinkApplyingMethod.SelectedIndex == 1) { applyingOperation ^= MedicalViewerActionFlags.OnRelease; } else { applyingOperation ^= MedicalViewerActionFlags.RealTime; } } if ((MedicalViewerMouseButtons)_cmbShrinkMouseButton.SelectedIndex == MedicalViewerMouseButtons.Left) { _owner.CurrentAction = MedicalViewerActionType.ShrinkTool; _owner.LeftButtonAction = MedicalViewerActionType.ShrinkTool; _owner.CheckMoveMarkersAction(false); _owner.CheckSelectPoints(false); } if ((MedicalViewerMouseButtons)_cmbShrinkMouseButton.SelectedIndex == MedicalViewerMouseButtons.Right) { _owner.RightButtonAction = MedicalViewerActionType.ShrinkTool; } cell.SetAction(MedicalViewerActionType.ShrinkTool, (MedicalViewerMouseButtons)_cmbShrinkMouseButton.SelectedIndex, applyingOperation); foreach (MedicalViewerBaseCell viewerCell in viewer.Cells) { viewerCell.SetAction(MedicalViewerActionType.ShrinkTool, (MedicalViewerMouseButtons)_cmbShrinkMouseButton.SelectedIndex, applyingOperation); } }
public Form1() { RasterSupport.SetLicense(@"C:\LEADTOOLS 20\Common\License\LEADTOOLS.LIC", System.IO.File.ReadAllText(@"C:\LEADTOOLS 20\Common\License\LEADTOOLS.LIC.KEY")); InitializeComponent(); RasterCodecs _codecs = new RasterCodecs(); RasterImage _image; string dicomFileName = @"C:\Users\Public\Documents\LEADTOOLS Images\IMAGE3.dcm"; // Create the medical viewer and adjust the size and the location. _medicalViewer = new MedicalViewer(1, 1); _medicalViewer.Location = new Point(0, 0); _medicalViewer.Size = new Size(this.ClientRectangle.Right, this.ClientRectangle.Bottom); // Load an image and then add it to the control. _image = _codecs.Load(dicomFileName); DicomEngine.Startup(); using (DicomDataSet ds = new DicomDataSet()) { MedicalViewerMultiCell cell = new MedicalViewerMultiCell(_image, true, 1, 1); ds.Load(dicomFileName, DicomDataSetLoadFlags.None); string dpatientID = GetDicomTag(ds, DicomTag.PatientID); string dpatientName = GetDicomTag(ds, DicomTag.PatientName); string dpatientAge = GetDicomTag(ds, DicomTag.PatientAge); string dpatientBirthDate = GetDicomTag(ds, DicomTag.PatientBirthDate); string dpatientSex = GetDicomTag(ds, DicomTag.PatientSex); // add some actions that will be used to change the properties of the images inside the control. cell.AddAction(MedicalViewerActionType.WindowLevel); cell.AddAction(MedicalViewerActionType.Offset); cell.AddAction(MedicalViewerActionType.Stack); // assign the added actions to a mouse button, meaning that when the user clicks and drags the mouse button, the associated action will be activated. cell.SetAction(MedicalViewerActionType.Offset, MedicalViewerMouseButtons.Right, MedicalViewerActionFlags.Active); cell.SetAction(MedicalViewerActionType.WindowLevel, MedicalViewerMouseButtons.Left, MedicalViewerActionFlags.Active); cell.SetAction(MedicalViewerActionType.Stack, MedicalViewerMouseButtons.Wheel, MedicalViewerActionFlags.Active); // assign the added actions to a keyboard keys that will work like the mouse. MedicalViewerKeys medicalKeys = new MedicalViewerKeys(Keys.Down, Keys.Up, Keys.Left, Keys.Right, MedicalViewerModifiers.None); cell.SetActionKeys(MedicalViewerActionType.Offset, medicalKeys); medicalKeys.Modifiers = MedicalViewerModifiers.Ctrl; cell.SetActionKeys(MedicalViewerActionType.WindowLevel, medicalKeys); medicalKeys.MouseDown = Keys.PageDown; medicalKeys.MouseUp = Keys.PageUp; cell.SetActionKeys(MedicalViewerActionType.Stack, medicalKeys); medicalKeys.MouseDown = Keys.Subtract; medicalKeys.MouseUp = Keys.Add; cell.SetActionKeys(MedicalViewerActionType.Scale, medicalKeys); _medicalViewer.Cells.Add(cell); // adjust some properties of the cell and add some tags. cell.SetTag(1, MedicalViewerTagAlignment.TopRight, MedicalViewerTagType.UserData, "Name: " + dpatientName); cell.SetTag(2, MedicalViewerTagAlignment.TopRight, MedicalViewerTagType.UserData, "ID: " + dpatientID); cell.SetTag(3, MedicalViewerTagAlignment.TopRight, MedicalViewerTagType.UserData, "DOB: " + dpatientBirthDate); cell.SetTag(4, MedicalViewerTagAlignment.TopRight, MedicalViewerTagType.UserData, "Age: " + dpatientAge); cell.SetTag(5, MedicalViewerTagAlignment.TopRight, MedicalViewerTagType.UserData, "Sex: " + dpatientSex); cell.SetTag(4, MedicalViewerTagAlignment.TopLeft, MedicalViewerTagType.Frame); cell.SetTag(6, MedicalViewerTagAlignment.TopLeft, MedicalViewerTagType.Scale); cell.SetTag(2, MedicalViewerTagAlignment.BottomLeft, MedicalViewerTagType.WindowLevelData); cell.SetTag(1, MedicalViewerTagAlignment.BottomLeft, MedicalViewerTagType.FieldOfView); cell.SetTag(0, MedicalViewerTagAlignment.BottomLeft, MedicalViewerTagType.RulerUnit); cell.Rows = 1; cell.Columns = 1; cell.Frozen = false; cell.DisplayRulers = MedicalViewerRulers.Both; cell.ApplyOnIndividualSubCell = false; cell.ApplyActionOnMove = true; cell.FitImageToCell = true; cell.Selected = true; cell.ShowTags = true; } string GetDicomTag(DicomDataSet ds, long tag) { DicomElement patientElement = ds.FindFirstElement(null, tag, true); if (patientElement != null) { return(ds.GetConvertValue(patientElement)); } return(null); } Controls.Add(_medicalViewer); _medicalViewer.Dock = DockStyle.Fill; }