public void MedicalViewerPropertiesExample() { MainForm2 form = new MainForm2(); form.ShowDialog(); } // MainForm1 will be the owner of the medical viewer control. class MainForm2 : Form { public MedicalViewer _medicalViewer; void MedicalViewerForm_SizeChanged(object sender, EventArgs e) { _medicalViewer.Size = new Size(this.ClientRectangle.Right, this.ClientRectangle.Bottom); } public MainForm2() { RasterCodecs.Startup(); RasterCodecs _codecs = new RasterCodecs(); RasterImage _image; // Create the medical viewer and adjust some properties. _medicalViewer = new MedicalViewer(); _medicalViewer.Rows = 2; _medicalViewer.Columns = 2; _medicalViewer.Location = new Point(0, 0); _medicalViewer.Size = new Size(this.ClientRectangle.Right, this.ClientRectangle.Bottom); _medicalViewer.ActiveBorderColor = Color.FromArgb(0, 0, 255); _medicalViewer.ActiveSubCellBorderColor = Color.FromArgb(0, 255, 0); _medicalViewer.AnnotationDefaultCursor = System.Windows.Forms.Cursors.Cross; _medicalViewer.AnnotationMoveCursor = System.Windows.Forms.Cursors.SizeNWSE; _medicalViewer.AnnotationSelectCursor = System.Windows.Forms.Cursors.SizeAll; _medicalViewer.AutoScroll = true; _medicalViewer.CellBackColor = Color.FromArgb(100, 100, 255); _medicalViewer.BorderStyle = MedicalViewerBorderStyle.DashDotDot; _medicalViewer.CellMaintenance = true; _medicalViewer.CustomSplitterColor = true; _medicalViewer.BackColor = Color.FromArgb(70, 70, 180); _medicalViewer.MeasurementUnit = MedicalViewerMeasurementUnit.Inches; _medicalViewer.NonActiveBorderColor = Color.FromArgb(0, 0, 0); _medicalViewer.PaintingMethod = MedicalViewerPaintingMethod.Normal; _medicalViewer.RegionDefaultCursor = System.Windows.Forms.Cursors.Cross; _medicalViewer.ResizeBoth = System.Windows.Forms.Cursors.SizeAll; _medicalViewer.ResizeHorizontalCursor = System.Windows.Forms.Cursors.SizeWE; _medicalViewer.ResizeVerticalCursor = System.Windows.Forms.Cursors.SizeNS; _medicalViewer.RulerInColor = Color.FromArgb(255, 255, 0); _medicalViewer.RulerOutColor = Color.FromArgb(255, 0, 0); _medicalViewer.RulerStyle = MedicalViewerRulerStyle.Bordered; _medicalViewer.ShowCellScroll = false; _medicalViewer.ShowFreezeText = true; _medicalViewer.SplitterColor = Color.FromArgb(128, 128, 128); _medicalViewer.SplitterStyle = MedicalViewerSplitterStyle.Thick; _medicalViewer.TextColor = Color.FromArgb(255, 255, 0); _medicalViewer.TextQuality = MedicalViewerTextQuality.Draft; _medicalViewer.TextShadowColor = Color.FromArgb(0, 0, 0); _medicalViewer.UseExtraSplitters = false; _medicalViewer.VisibleRow = 0; _medicalViewer.OverlayTextSize = 0; _medicalViewer.RegionBorderColor1 = Color.FromArgb(0, 0, 255); _medicalViewer.RegionBorderColor2 = Color.FromArgb(255, 255, 255); _medicalViewer.InteractiveInterpolation = true; // add some action that will be used to change the properties of the images inside the control. _medicalViewer.AddAction(MedicalViewerActionType.WindowLevel); _medicalViewer.AddAction(MedicalViewerActionType.Alpha); _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(); medicalKeys.MouseDown = Keys.Down; medicalKeys.MouseUp = Keys.Up; medicalKeys.MouseLeft = Keys.Left; medicalKeys.MouseRight = Keys.Right; _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); // Go through all the built in actions and remove the actions that have not been assigned to a mouse button, or a key. int index = 1; for (; index < 22; index++) { MedicalViewerActionType actionType = (MedicalViewerActionType)index; if (_medicalViewer.IsActionAdded(actionType)) { MedicalViewerMouseButtons mouseButton = _medicalViewer.GetActionButton(actionType); if (mouseButton == MedicalViewerMouseButtons.None) { MedicalViewerKeys keys = _medicalViewer.GetActionKeys(actionType); if (keys.MouseLeft == Keys.None && keys.MouseUp == Keys.None && keys.MouseDown == Keys.None && keys.MouseRight == Keys.None) _medicalViewer.RemoveAction(actionType); } } } // Makes the window level applies the effect on all selected cells at the same time. MedicalViewerActionFlags flags = _medicalViewer.GetActionFlags(MedicalViewerActionType.WindowLevel); flags |= MedicalViewerActionFlags.Selected; _medicalViewer.SetAction(MedicalViewerActionType.WindowLevel, MedicalViewerMouseButtons.Left, flags); // 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, true, 1, 1)); // 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 = 2; _medicalViewer.Cells[0].Columns = 2; _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"); MedicalViewerCell cell = new MedicalViewerCell(); cell.Image = _image; cell.Rows = 2; cell.Columns = 2; cell.Frozen = false; cell.DisplayRulers = MedicalViewerRulers.Both; cell.ApplyOnIndividualSubCell = false; cell.ApplyActionOnMove = true; cell.FitImageToCell = true; cell.Selected = true; cell.ShowTags = true; _medicalViewer.Cells.Add(cell); // 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); RasterCodecs.Shutdown(); Controls.Add(_medicalViewer); } } |