public void MedicalViewerExample() { MainForm1 form = new MainForm1(); form.ShowDialog(); } // MainForm1 will be the owner of the medical viewer control. class MainForm1 : Form { private MedicalViewer _medicalViewer; void MedicalViewerForm_SizeChanged(object sender, EventArgs e) { _medicalViewer.Size = new Size(this.ClientRectangle.Right, this.ClientRectangle.Bottom); } public MainForm1() { RasterCodecs.Startup(); RasterCodecs _codecs = new RasterCodecs(); RasterImage _image; // Create the medical viewer and adjust the size and the location. _medicalViewer = new MedicalViewer(1, 2); _medicalViewer.Location = new Point(0, 0); _medicalViewer.Size = new Size(this.ClientRectangle.Right, this.ClientRectangle.Bottom); // add some action that will be used to change the properties of the images inside the control. _medicalViewer.AddAction(MedicalViewerActionType.WindowLevel); _medicalViewer.AddAction(MedicalViewerActionType.Scale); _medicalViewer.AddAction(MedicalViewerActionType.Offset); _medicalViewer.AddAction(MedicalViewerActionType.Stack); // assign the added actions to a mouse button, meaning that when the user click and drag the mouse button, the associted action will be activated. _medicalViewer.SetAction(MedicalViewerActionType.WindowLevel, MedicalViewerMouseButtons.Left, MedicalViewerActionFlags.Active | MedicalViewerActionFlags.RealTime); _medicalViewer.SetAction(MedicalViewerActionType.Offset, MedicalViewerMouseButtons.Right, MedicalViewerActionFlags.Active | MedicalViewerActionFlags.RealTime); _medicalViewer.SetAction(MedicalViewerActionType.Scale, MedicalViewerMouseButtons.Middle, MedicalViewerActionFlags.Active | MedicalViewerActionFlags.RealTime); _medicalViewer.SetAction(MedicalViewerActionType.Stack, MedicalViewerMouseButtons.Wheel, MedicalViewerActionFlags.Active | MedicalViewerActionFlags.RealTime); // 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); _medicalViewer.SetActionKeys(MedicalViewerActionType.Offset, medicalKeys); medicalKeys.Modifiers = MedicalViewerModifiers.Ctrl; _medicalViewer.SetActionKeys(MedicalViewerActionType.WindowLevel, medicalKeys); medicalKeys.MouseDown = Keys.PageDown; medicalKeys.MouseUp = Keys.PageUp; _medicalViewer.SetActionKeys(MedicalViewerActionType.Stack, medicalKeys); medicalKeys.MouseDown = Keys.Subtract; medicalKeys.MouseUp = Keys.Add; _medicalViewer.SetActionKeys(MedicalViewerActionType.Scale, medicalKeys); // Load an image and then add it to the control. _image = _codecs.Load(LeadtoolsExamples.Common.ImagesPath.Path + "image3.cmp"); _medicalViewer.Cells.Add(new MedicalViewerCell(_image, true)); // adjust some properties to the cell and add some tags. _medicalViewer.Cells[0].SetTag(2, MedicalViewerTagAlignment.TopLeft, MedicalViewerTagType.UserData, "EX. ID 230-36-5448"); _medicalViewer.Cells[0].SetTag(4, MedicalViewerTagAlignment.TopLeft, MedicalViewerTagType.Frame); _medicalViewer.Cells[0].SetTag(6, MedicalViewerTagAlignment.TopLeft, MedicalViewerTagType.Scale); _medicalViewer.Cells[0].SetTag(2, MedicalViewerTagAlignment.BottomLeft, MedicalViewerTagType.WindowLevelData); _medicalViewer.Cells[0].SetTag(1, MedicalViewerTagAlignment.BottomLeft, MedicalViewerTagType.FieldOfView); _medicalViewer.Cells[0].SetTag(1, MedicalViewerTagAlignment.TopRight, MedicalViewerTagType.UserData, "Good, Guy"); _medicalViewer.Cells[0].SetTag(2, MedicalViewerTagAlignment.TopRight, MedicalViewerTagType.UserData, "PID 125-98-445"); _medicalViewer.Cells[0].SetTag(3, MedicalViewerTagAlignment.TopRight, MedicalViewerTagType.UserData, "DOB 08/02/1929"); _medicalViewer.Cells[0].SetTag(5, MedicalViewerTagAlignment.TopRight, MedicalViewerTagType.UserData, "03/16/1999"); _medicalViewer.Cells[0].SetTag(0, MedicalViewerTagAlignment.BottomLeft, MedicalViewerTagType.RulerUnit); _medicalViewer.Cells[0].Rows = 1; _medicalViewer.Cells[0].Columns = 1; _medicalViewer.Cells[0].Frozen = false; _medicalViewer.Cells[0].DisplayRulers = MedicalViewerRulers.Both; _medicalViewer.Cells[0].ApplyOnIndividualSubCell = false; _medicalViewer.Cells[0].ApplyActionOnMove = true; _medicalViewer.Cells[0].FitImageToCell = true; _medicalViewer.Cells[0].Selected = true; _medicalViewer.Cells[0].ShowTags = true; // Load an image and then add it to the control. _image = _codecs.Load(LeadtoolsExamples.Common.ImagesPath.Path + "image2.cmp"); _medicalViewer.Cells.Add(new MedicalViewerCell(_image)); // adjust some properties to the cell and add some tags. _medicalViewer.Cells[1].SetTag(2, MedicalViewerTagAlignment.TopLeft, MedicalViewerTagType.UserData, "EX. ID 230-36-5448"); _medicalViewer.Cells[1].SetTag(4, MedicalViewerTagAlignment.TopLeft, MedicalViewerTagType.Frame); _medicalViewer.Cells[1].SetTag(6, MedicalViewerTagAlignment.TopLeft, MedicalViewerTagType.Scale); _medicalViewer.Cells[1].SetTag(2, MedicalViewerTagAlignment.BottomLeft, MedicalViewerTagType.WindowLevelData); _medicalViewer.Cells[1].SetTag(1, MedicalViewerTagAlignment.BottomLeft, MedicalViewerTagType.FieldOfView); _medicalViewer.Cells[1].SetTag(1, MedicalViewerTagAlignment.TopRight, MedicalViewerTagType.UserData, "Good, Guy"); _medicalViewer.Cells[1].SetTag(2, MedicalViewerTagAlignment.TopRight, MedicalViewerTagType.UserData, "PID 125-98-445"); _medicalViewer.Cells[1].SetTag(3, MedicalViewerTagAlignment.TopRight, MedicalViewerTagType.UserData, "DOB 08/02/1929"); _medicalViewer.Cells[1].SetTag(5, MedicalViewerTagAlignment.TopRight, MedicalViewerTagType.UserData, "03/16/1999"); _medicalViewer.Cells[1].SetTag(0, MedicalViewerTagAlignment.BottomLeft, MedicalViewerTagType.RulerUnit); _medicalViewer.Cells[1].Rows = 2; _medicalViewer.Cells[1].Columns = 2; _medicalViewer.Cells[1].Frozen = false; _medicalViewer.Cells[1].DisplayRulers = MedicalViewerRulers.Both; _medicalViewer.Cells[1].ApplyOnIndividualSubCell = false; _medicalViewer.Cells[1].ApplyActionOnMove = true; _medicalViewer.Cells[1].FitImageToCell = true; _medicalViewer.Cells[1].Selected = true; _medicalViewer.Cells[1].ShowTags = true; RasterCodecs.Shutdown(); Controls.Add(_medicalViewer); } } |