void TerminateAdjustFusionImageForm() { HideAllFusionEditRectangles(); if (_currentAnnDesigner != null) { _currentAnnDesigner.End(); } this.FormClosing -= new FormClosingEventHandler(AdjustFusionImage_FormClosing); if (_cell != null && !_cell.IsDisposed) { MedicalViewerSubCell subCell = _cell.SubCells[_cell.ActiveSubCell]; _cell.Paint -= new PaintEventHandler(_cell_Paint); _cell.DesignerCreated -= new EventHandler <MedicalViewerDesignerCreatedEventArgs>(_cell_DesignerCreated); _cell.DeleteAnnotation -= new EventHandler <MedicalViewerDeleteEventArgs>(_cell_DeleteAnnotation); _cell.ActiveSubCellChanged -= new EventHandler <MedicalViewerActiveSubCellChangedEventArgs>(_cell_ActiveSubCellChanged); } if (_palettePreview.Image != null) { _palettePreview.Image.Dispose(); _palettePreview.Image = null; } if (_orgImagePalettePreview.Image != null) { _orgImagePalettePreview.Image.Dispose(); _orgImagePalettePreview.Image = null; } }
void InitializeAdjustFusionImageForm() { _currentAnnDesigner = null; int cellIndex = _form.GetFirstSelectedMultiCellIndex(); if (cellIndex == -1) { return; } _cell = (MedicalViewerMultiCell)_viewer.Cells[cellIndex]; if (_cell == null) { return; } _cell.Automation.Edit += new EventHandler <AnnEditDesignerEventArgs>(Automation_Edit); _cell.Automation.SetCursor += new EventHandler <AnnCursorEventArgs>(Automation_SetCursor); _cell.Automation.RestoreCursor += Automation_RestoreCursor; _cellFusionNames = _form.FusionListNames[cellIndex]; UpdateFusionUI(0); UpdateFusionComboBox(); MedicalViewerSubCell subCell = _cell.SubCells[_cell.ActiveSubCell]; this.FormClosing += new FormClosingEventHandler(AdjustFusionImage_FormClosing); _cell.Paint += new PaintEventHandler(_cell_Paint); _cell.DesignerCreated += new EventHandler <MedicalViewerDesignerCreatedEventArgs>(_cell_DesignerCreated); _cell.ActiveSubCellChanged += new EventHandler <MedicalViewerActiveSubCellChangedEventArgs>(_cell_ActiveSubCellChanged); _cell.DeleteAnnotation += new EventHandler <MedicalViewerDeleteEventArgs>(_cell_DeleteAnnotation); }
private void AddAnnotationRectangle(MedicalViewerSubCell subCell) { AnnRectangleObject rect = new AnnRectangleObject(); rect.IsVisible = false; rect.Stroke = AnnStroke.Create(AnnSolidColorBrush.Create("Red"), LeadLengthD.Create(5)); subCell.AnnotationContainer.Children.Add(rect); }
private void RemoveFusionEditRectangle(MedicalViewerSubCell subCell, int removeIndex) { if (subCell.AnnotationContainer.Children.Count != 0) { subCell.AnnotationContainer.Children.RemoveAt(removeIndex); _cell.RefreshAnnotation(); } }
private void AddFusionEditRectangle(MedicalViewerSubCell subCell) { AnnRectangleObject rect = new AnnRectangleObject(); rect.IsVisible = false; rect.Stroke = AnnStroke.Create(AnnSolidColorBrush.Create("Red"), LeadLengthD.Create(5)); subCell.AnnotationContainer.Children.Add(rect); //rect.RotateGripper = new LeadLengthD(1); _cell.AnnotationPrecedency = true; }
private void _btnReset_Click(object sender, EventArgs e) { int subCellIndex = _cell.ActiveSubCell; int index = _cmbFusedIndex.SelectedIndex; _cmbOrgImagePalette.SelectedIndex = 0; UpdatePalettePreview(_cmbOrgImagePalette, _orgImagePalettePreview); if (index >= 0 && _cell.SubCells[subCellIndex].Fusion.Count > index) { MedicalViewerSubCell subCell = _cell.SubCells[subCellIndex]; MedicalViewerFusion fusion = subCell.Fusion[index]; MedicalViewerFusion tmpFusion = new MedicalViewerFusion(); tmpFusion.FusedImage = fusion.FusedImage; SuspendUpdate(); _txtWLWidth.Text = tmpFusion.Width.ToString(); _txtWLCenter.Text = tmpFusion.Center.ToString(); _txtScaleX.Text = "100.000"; _txtScaleY.Text = "100.000"; _txtOffsetX.Text = "0.000"; _txtOffsetY.Text = "0.000"; _txtRotate.Text = "0.000"; _chkFit.Checked = true; _cmbPalette.SelectedIndex = 0; ResumeUpdate(); UpdateFusion(); _txtRotate.Refresh(); _txtOffsetX.Refresh(); _txtOffsetY.Refresh(); _txtScaleX.Refresh(); _txtScaleY.Refresh(); _chkFit.Refresh(); _cmbPalette.Refresh(); resetOffset(); } }
private void ShowFusionEditRectangle(int index) { int subCellIndex = _cell.ActiveSubCell; MedicalViewerSubCell subCell = _cell.SubCells[subCellIndex]; for (int i = 0; i < subCell.AnnotationContainer.Children.Count; i++) { subCell.AnnotationContainer.Children[i].IsVisible = false; } AddAnnotationRectangle(subCell); UpdateFusionEditRectangle(index); subCell.AnnotationContainer.Children[index].IsVisible = true; _cell.RefreshAnnotation(); }
private void UpdateFusionEditRectangle(int index) { int subCellIndex = _cell.ActiveSubCell; MedicalViewerSubCell subCell = _cell.SubCells[subCellIndex]; MedicalViewerFusion fusion = _cell.SubCells[subCellIndex].Fusion[index]; AnnRectangleObject fusionEditRect = ((AnnRectangleObject)subCell.AnnotationContainer.Children[index]); double scaleRatio = _cell.GetScale(subCellIndex) / 100; Point location = _cell.GetDisplayedImageRectangle().Location; AnnContainer container = subCell.AnnotationContainer; double scale = _cell.GetScale(subCellIndex); LeadSizeD fusionEditRectSize = new LeadSizeD(); fusionEditRectSize.Width = fusion.FusedImage.Width * fusion.DisplayRectangle.Width * scale / 100; fusionEditRectSize.Height = fusion.FusedImage.Height * fusion.DisplayRectangle.Height * scale / 100; fusionEditRectSize = container.Mapper.SizeToContainerCoordinates(fusionEditRectSize); LeadPointD fusionEditRectPos = new LeadPointD(); fusionEditRectPos.X = (subCell.AnnotationContainer.Size.Width - fusionEditRectSize.Width) / 2; fusionEditRectPos.Y = (subCell.AnnotationContainer.Size.Height - fusionEditRectSize.Height) / 2; //container.Bounds fusionEditRect.Rect = new LeadRectD(fusionEditRectPos, fusionEditRectSize); AnnContainer _Container = GetContainer(_cell, fusionEditRect); fusionEditRect.Rotate(fusion.Rotation, new LeadPointD(_Container.Size.Width / 2, _Container.Size.Height / 2)); LeadPointD point = LeadPointD.Create(fusion.DisplayRectangle.X * fusion.FusedImage.Width * scaleRatio + location.X, fusion.DisplayRectangle.Y * fusion.FusedImage.Height * scaleRatio + location.Y); point = _Container.Mapper.PointToContainerCoordinates(point); fusionEditRect.Translate(point.X, point.Y); fusionEditRect.RotateCenter = new LeadPointD(fusionEditRect.Rect.Left + (fusionEditRect.Rect.Width / 2), fusionEditRect.Rect.Top + (fusionEditRect.Rect.Height / 2)); _cell.RefreshAnnotation(); _cell.Automation.Invalidate(LeadRectD.Empty); _cell.Invalidate(); }
private void UpdateFusionUI(int index) { SuspendUpdate(); int subCellIndex = _cell.ActiveSubCell; _cmbOrgImagePalette.SelectedIndex = (int)_cell.SubCells[subCellIndex].PaletteType; if (index >= 0 && _cell.SubCells[subCellIndex].Fusion.Count > index) { MedicalViewerSubCell subCell = _cell.SubCells[subCellIndex]; MedicalViewerFusion fusion = subCell.Fusion[index]; _cmbPalette.SelectedIndex = (int)fusion.ColorPalette; _txtWLWidth.Text = fusion.Width.ToString(); _txtWLCenter.Text = fusion.Center.ToString(); UpdatePalettePreview(_cmbPalette, _palettePreview); _txtOffsetX.Text = (fusion.DisplayRectangle.X * fusion.FusedImage.Width).ToString("#0.000"); _txtOffsetY.Text = (fusion.DisplayRectangle.Y * fusion.FusedImage.Height).ToString("#0.000"); _chkFit.Checked = (Math.Abs(fusion.DisplayRectangle.Width - 1) < 0.0001 && Math.Abs(fusion.DisplayRectangle.Height - 1) < 0.0001); _txtScaleX.Text = (fusion.DisplayRectangle.Width * 100).ToString("#0.000"); _txtScaleX.Enabled = !_chkFit.Checked; _txtScaleY.Text = (fusion.DisplayRectangle.Height * 100).ToString("#0.000"); _txtScaleY.Enabled = !_chkFit.Checked; _txtRotate.Text = fusion.Rotation.ToString("#0.000"); _txtRotate.Refresh(); _txtOffsetX.Refresh(); _txtOffsetY.Refresh(); _txtScaleX.Refresh(); _txtScaleY.Refresh(); _chkFit.Refresh(); } ResumeUpdate(); }
private void UpdateFusion() { if (!_update) { return; } int subCellIndex = _cell.ActiveSubCell; int index = _cmbFusedIndex.SelectedIndex; MedicalViewerSubCell subCell = _cell.SubCells[subCellIndex]; MedicalViewerFusion fusion = subCell.Fusion[index]; UpdatePalettePreview(_cmbPalette, _palettePreview); if (_txtWLWidth.Text == "") { fusion.Width = 1; } else { fusion.Width = Convert.ToInt32(_txtWLWidth.Text); } if (_txtWLCenter.Text == "") { fusion.Center = 0; } else { fusion.Center = Convert.ToInt32(_txtWLCenter.Text); } fusion.ColorPalette = (MedicalViewerPaletteType)_cmbPalette.SelectedIndex; if (_txtOffsetX.Text == "") { fusion.DisplayRectangle = new RectangleF(0, fusion.DisplayRectangle.Y, fusion.DisplayRectangle.Width, fusion.DisplayRectangle.Height); } else { try { float offsetX = float.Parse(_txtOffsetX.Text) / fusion.FusedImage.Width; fusion.DisplayRectangle = new RectangleF(offsetX, fusion.DisplayRectangle.Y, fusion.DisplayRectangle.Width, fusion.DisplayRectangle.Height); } catch { } } if (_txtOffsetY.Text == "") { fusion.DisplayRectangle = new RectangleF(fusion.DisplayRectangle.X, 0, fusion.DisplayRectangle.Width, fusion.DisplayRectangle.Height); } else { try { float offsetY = float.Parse(_txtOffsetY.Text) / fusion.FusedImage.Height; fusion.DisplayRectangle = new RectangleF(fusion.DisplayRectangle.X, offsetY, fusion.DisplayRectangle.Width, fusion.DisplayRectangle.Height); } catch { } } RasterImage image = _cell.VirtualImage[subCellIndex].Image; float fitScaleX = image.Width * 1.0f / fusion.FusedImage.Width; float fitScaleY = image.Height * 1.0f / fusion.FusedImage.Height; float xScale = 0.001f; if (_txtScaleX.Text != "") { xScale = Math.Max(xScale, float.Parse(_txtScaleX.Text)); } float yScale = 0.001f; if (_txtScaleY.Text != "") { yScale = Math.Max(yScale, float.Parse(_txtScaleY.Text)); } if (_txtScaleX.Text == "") { fusion.DisplayRectangle = new RectangleF(fusion.DisplayRectangle.X, fusion.DisplayRectangle.Y, 1, fusion.DisplayRectangle.Height); } else { fusion.DisplayRectangle = new RectangleF(fusion.DisplayRectangle.X, fusion.DisplayRectangle.Y, _chkFit.Checked ? fitScaleX : xScale / 100.0f, fusion.DisplayRectangle.Height); } if (_txtScaleY.Text == "") { fusion.DisplayRectangle = new RectangleF(fusion.DisplayRectangle.X, fusion.DisplayRectangle.Y, fusion.DisplayRectangle.Width, 1); } else { fusion.DisplayRectangle = new RectangleF(fusion.DisplayRectangle.X, fusion.DisplayRectangle.Y, fusion.DisplayRectangle.Width, _chkFit.Checked ? fitScaleY : yScale / 100.0f); } if (_txtRotate.Text == "") { fusion.Rotation = 0; } else { try { fusion.Rotation = float.Parse(_txtRotate.Text); } catch { } } UpdateFusionEditRectangle(index); CellData cellData = (CellData)_cell.Tag; if (cellData.SyncCellFusion) { UpdateCellFusions(fusion, subCellIndex, index); } }