private void SubGridFactory(ImageDisplayFormat displayFormat, ref TileCollection collection, IPrintViewTile parentTile) { if (RootImageBox == null || displayFormat == null) { return; } foreach (PrintViewTile tile in collection) { float x = parentTile.NormalizedRectangle.X + parentTile.NormalizedRectangle.Width * tile.NormalizedRectangle.X; float y = parentTile.NormalizedRectangle.Y + parentTile.NormalizedRectangle.Height * tile.NormalizedRectangle.Y; float w = parentTile.NormalizedRectangle.Width * tile.NormalizedRectangle.Width; float h = parentTile.NormalizedRectangle.Height * tile.NormalizedRectangle.Height; tile.NormalizedRectangle = new RectangleF(x, y, w, h); } }
private void SubGrid(object sender, EventArgs rArgs) { Button button = sender as Button; if (button == null) { return; } string imageDisplaySet = (string)button.Tag; if (imageDisplaySet == null || imageDisplaySet == "") { return; } if (imageDisplaySet == "CUSTOM") { int row = int.Parse(this.RowNumeric.Text); int col = int.Parse(this.ColumnNumeric.Text); if (row == 0 || col == 0) { return; } displayFormat = LayoutFactory.TileFactory(row, col); } else { displayFormat = ImageDisplayFormat.FromDicomString(imageDisplaySet); } if (this.fenge.Checked) { _component.SetTileGrid(displayFormat); if (printComponent != null) { printComponent.DicomPrinterConfigurationEditorComponent.ImageDisplayFormat = new PrinterImageDisplayFormat() { Value = displayFormat.DicomString };; } } else { _component.SubGrid(displayFormat); } }
public void SetTileGrid(ImageDisplayFormat displayFormat) { TileCollection collection = SetTileGridFactory(displayFormat); if (collection == null) { return; } ClearSelectTiles(); foreach (var item in RootImageBox.Tiles) { item.Dispose(); } RootImageBox.Tiles.Clear(); RootImageBox.Tiles.AddRange(collection); EventsHelper.Fire(_layoutCompletedEvent, this, EventArgs.Empty); this.RootImageBox.TopLeftPresentationImageIndex = 0; this.RootImageBox.Draw(); PropertyValueChanged(); }
/// <summary> /// Get the rowIndex and columnIndex of the specified imageBoxPosition for this ImageDisplayType. /// </summary> private static void GetRowColumnIndex(ImageDisplayFormat imageDisplayFormat, int imageBoxPosition, out int rowIndex, out int columnIndex) { rowIndex = 0; columnIndex = 0; switch (imageDisplayFormat.Format) { case ImageDisplayFormat.FormatEnum.STANDARD: { var numberOfColumns = imageDisplayFormat.Modifiers[0]; var numberOfRows = imageDisplayFormat.Modifiers[1]; var imageBoxIndex = imageBoxPosition - 1; rowIndex = imageBoxIndex / numberOfRows; columnIndex = imageBoxIndex % numberOfColumns; break; } case ImageDisplayFormat.FormatEnum.ROW: { // Major row order: left-to-right and top-to-bottom GetIndexForRowColumnFormat(imageDisplayFormat.Modifiers, imageBoxPosition, out rowIndex, out columnIndex); break; } case ImageDisplayFormat.FormatEnum.COL: { // Major column order: top-to-bottom and left-to-right GetIndexForRowColumnFormat(imageDisplayFormat.Modifiers, imageBoxPosition, out columnIndex, out rowIndex); break; } case ImageDisplayFormat.FormatEnum.SLIDE: case ImageDisplayFormat.FormatEnum.SUPERSLIDE: case ImageDisplayFormat.FormatEnum.CUSTOM: default: throw new NotSupportedException(string.Format("{0} image display format is not supported", imageDisplayFormat.Format)); } }
public void Row_Format_Test() { var simpleRowFormat = ImageDisplayFormat.FromDicomString(@"ROW\1,2"); Assert.AreEqual(simpleRowFormat.DicomString, @"ROW\1,2"); Assert.AreEqual(simpleRowFormat.Format, ImageDisplayFormat.FormatEnum.ROW); Assert.AreEqual(simpleRowFormat.MaximumImageBoxes, 1 + 2); Assert.AreEqual(simpleRowFormat.Modifiers.Count, 2); Assert.AreEqual(simpleRowFormat.Modifiers[0], 1); Assert.AreEqual(simpleRowFormat.Modifiers[1], 2); var complexRowformat = ImageDisplayFormat.FromDicomString(@"ROW\1,2,3,4,5"); Assert.AreEqual(complexRowformat.DicomString, @"ROW\1,2,3,4,5"); Assert.AreEqual(complexRowformat.Format, ImageDisplayFormat.FormatEnum.ROW); Assert.AreEqual(complexRowformat.MaximumImageBoxes, 1 + 2 + 3 + 4 + 5); Assert.AreEqual(complexRowformat.Modifiers.Count, 5); Assert.AreEqual(complexRowformat.Modifiers[0], 1); Assert.AreEqual(complexRowformat.Modifiers[1], 2); Assert.AreEqual(complexRowformat.Modifiers[2], 3); Assert.AreEqual(complexRowformat.Modifiers[3], 4); Assert.AreEqual(complexRowformat.Modifiers[4], 5); }
public void Unrecognized_Format_Test() { ImageDisplayFormat.FromDicomString(@"Test"); }
public void Invalid_Column_Format_Test() { ImageDisplayFormat.FromDicomString(@"COL\1"); }
public void Invalid_Row_Format_Test() { ImageDisplayFormat.FromDicomString(@"ROW"); }
public void Invalid_Standard_Format_Test() { ImageDisplayFormat.FromDicomString(@"STANDARD\1"); }
/// <summary> /// Iniitalize the film box dataset attributes to defaults /// </summary> /// <returns></returns> public bool Initialize() { //initialization Add(new DicomSequence(DicomTag.ReferencedImageBoxSequence)); if (!Contains(DicomTag.FilmOrientation)) { FilmOrientation = "PORTRAIT"; } if (!Contains(DicomTag.FilmSizeID)) { FilmSizeID = "A4"; } if (!Contains(DicomTag.MagnificationType)) { MagnificationType = "BILINEAR"; } if (!Contains(DicomTag.MaxDensity)) { MaxDensity = 0; } if (!Contains(DicomTag.MinDensity)) { MinDensity = 0; } if (!Contains(DicomTag.BorderDensity)) { BorderDensity = "BLACK"; } if (!Contains(DicomTag.Trim)) { Trim = "NO"; } if (!Contains(DicomTag.RequestedResolutionID)) { RequestedResolutionID = "STANDARD"; } try { if (string.IsNullOrEmpty(ImageDisplayFormat)) { return(false); } var parts = ImageDisplayFormat.Split('\\'); if (parts[0] == "STANDARD" && parts.Length == 2) { parts = parts[1].Split(','); if (parts.Length == 2) { int row = int.Parse(parts[0]); int col = int.Parse(parts[1]); for (int r = 0; r < row; r++) { for (int c = 0; c < col; c++) { CreateImageBox(); } } return(true); } } else if ((parts[0] == "ROW" || parts[0] == "COL") && parts.Length == 2) { parts = parts[1].Split(','); foreach (var part in parts) { int count = int.Parse(part); for (int i = 0; i < count; i++) { CreateImageBox(); } } return(true); } } // ReSharper disable once EmptyGeneralCatchClause catch (Exception ex) { //Core.Logger.Error("FilmBox.Initialize", ex); } //Core.Logger.Error("Unsupported image display format \"{0}\"", ImageDisplayFormat); return(false); }
public void SubGrid(ImageDisplayFormat displayFormat) { if (RootImageBox.SelectedTile == null) { return; } var printViewTile = RootImageBox.SelectedTile as PrintViewTile; var memorableCommand = new MemorableUndoableCommand(RootImageBox) { BeginState = RootImageBox.CreateMemento() }; List <PrintViewTile> selectTiles; if (RootImageBox.DisplaySet != null && RootImageBox.DisplaySet.PresentationImages.Count != 0) { selectTiles = new List <PrintViewTile>(); foreach (var selectPresentationImage in RootImageBox.SelectPresentationImages) { if (selectPresentationImage.Tile == null) { continue; } var tile = selectPresentationImage.Tile as PrintViewTile; if (!selectTiles.Contains(tile) && !tile.isSubTile) { selectTiles.Add(tile); } } if (!selectTiles.Contains(printViewTile) && !printViewTile.isSubTile) { selectTiles.Add(printViewTile); } } else { selectTiles = new List <PrintViewTile>(); foreach (var selectTile in RootImageBox.SelectTiles) { if (!selectTiles.Contains(selectTile) && !selectTile.isSubTile) { selectTiles.Add(selectTile); } } } if (selectTiles.Count == 0) { return; } foreach (var tile in selectTiles) { TileCollection collection = SetTileGridFactory(displayFormat); if (collection == null) { continue; } SubGridFactory(displayFormat, ref collection, tile); int index = RootImageBox.Tiles.IndexOf(tile); RootImageBox.Tiles.Remove(tile); for (int i = collection.Count - 1; i >= 0; i--) { var item = collection[i] as PrintViewTile; item.isSubTile = true; item.ParentPrintViewTile = tile; RootImageBox.Tiles.Insert(index, item); tile.SubTiles.Add(item); } } EventsHelper.Fire(_layoutCompletedEvent, this, EventArgs.Empty); this.RootImageBox.TopLeftPresentationImageIndex = 0; this.RootImageBox.Draw(); ClearSelectTiles(); this.RootImageBox.SelectDefaultTile(); memorableCommand.EndState = RootImageBox.CreateMemento(); var historyCommand = new DrawableUndoableCommand(RootImageBox) { Name = "RootImageBoxSubGrid" }; historyCommand.Enqueue(memorableCommand); CommandHistory.AddCommand(historyCommand); PropertyValueChanged(); }
/// <summary> /// 获得打印格式的列 /// </summary> public static int GetColumnNumber(ImageDisplayFormat imageDisplayFormat) { return(imageDisplayFormat.Modifiers[0]); }
/// <summary> /// 获得打印格式的行 /// </summary> public static int GetRowNumber(ImageDisplayFormat imageDisplayFormat) { return(imageDisplayFormat.Modifiers[1]); }
/// <summary> /// 构造一个ImageDisplayFormat实例 /// </summary> /// <param name="row">行</param> /// <param name="column">列</param> public static ImageDisplayFormat TileFactory(int row, int column) { ImageDisplayFormat imageDisplayFormat = ImageDisplayFormat.FromDicomString(string.Format(@"STANDARD\{0},{1}", column, row)); return(imageDisplayFormat); }
public void Null_DicomString_Test() { var format = ImageDisplayFormat.FromDicomString(null); Assert.IsNull(format); }
public void Empty_DicomString_Test() { var format = ImageDisplayFormat.FromDicomString(string.Empty); Assert.IsNull(format); }
private TileCollection SetTileGridFactory(ImageDisplayFormat displayFormat) { TileCollection tiles = null; if (RootImageBox == null || displayFormat == null) { return(null); } int row = displayFormat.Modifiers[1]; int col = displayFormat.Modifiers[0]; switch (displayFormat.Format) { case ImageDisplayFormat.FormatEnum.STANDARD: tiles = SetTileGrid(row, col); break; case ImageDisplayFormat.FormatEnum.ROW: tiles = new TileCollection(); double tileWidth = 1.0d / 2; double tileHeight = 1.0d / 2; RectangleF rect1 = new RectangleF(0, 0, 1, (float)tileHeight); PrintViewTile tile1 = new PrintViewTile(); tile1.NormalizedRectangle = rect1; tiles.Add(tile1); for (int r = 1; r == 1; r++) { for (int column = 0; column < 2; column++) { double x = column * tileWidth; double y = r * tileHeight; RectangleF rect = new RectangleF((float)x, (float)y, (float)tileWidth, (float)tileHeight); PrintViewTile tile = new PrintViewTile(); tile.NormalizedRectangle = rect; tiles.Add(tile); } } break; case ImageDisplayFormat.FormatEnum.COL: tiles = new TileCollection(); double ColtileWidth = 1.0d / 2; double ColtileHeight = 1.0d / 2; RectangleF Colrect = new RectangleF(0, 0, (float)ColtileWidth, 1); PrintViewTile Coltile = new PrintViewTile(); Coltile.NormalizedRectangle = Colrect; tiles.Add(Coltile); for (int r = 0; r < 2; r++) { for (int column = 1; column == 1; column++) { double x = column * ColtileWidth; double y = r * ColtileHeight; RectangleF rect = new RectangleF((float)x, (float)y, (float)ColtileWidth, (float)ColtileHeight); PrintViewTile tile = new PrintViewTile(); tile.NormalizedRectangle = rect; tiles.Add(tile); } } break; } return(tiles); }
/// <summary> /// Initalize the film box dataset attributes to defaults /// </summary> /// <returns>True if film box attributes could be initialized, false otherwise.</returns> public bool Initialize() { //initialization this.AddOrUpdate(new DicomSequence(DicomTag.ReferencedImageBoxSequence)); if (!this.Contains(DicomTag.FilmOrientation)) { FilmOrientation = "PORTRAIT"; } if (!this.Contains(DicomTag.FilmSizeID)) { FilmSizeID = "A4"; } if (!this.Contains(DicomTag.MagnificationType)) { MagnificationType = "BILINEAR"; } if (!this.Contains(DicomTag.MaxDensity)) { MaxDensity = 0; } if (!this.Contains(DicomTag.MinDensity)) { MinDensity = 0; } if (!this.Contains(DicomTag.BorderDensity)) { BorderDensity = "BLACK"; } if (!this.Contains(DicomTag.EmptyImageDensity)) { EmptyImageDensity = "BLACK"; } if (!this.Contains(DicomTag.Trim)) { Trim = "NO"; } if (!this.Contains(DicomTag.RequestedResolutionID)) { RequestedResolutionID = "STANDARD"; } try { if (string.IsNullOrEmpty(ImageDisplayFormat)) { Logger.Error("No display format present in N-CREATE Basic Film Box dataset"); return(false); } Logger.Info("Applying display format {0} for film box {1}", ImageDisplayFormat, SOPInstanceUID); var parts = ImageDisplayFormat.Split('\\'); if (parts[0] == "STANDARD" && parts.Length == 2) { parts = parts[1].Split(','); if (parts.Length == 2) { int row = int.Parse(parts[0]); int col = int.Parse(parts[1]); for (int r = 0; r < row; r++) { for (int c = 0; c < col; c++) { CreateImageBox(); } } return(true); } } else if ((parts[0] == "ROW" || parts[0] == "COL") && parts.Length == 2) { parts = parts[1].Split(','); foreach (var part in parts) { int count = int.Parse(part); for (int i = 0; i < count; i++) { CreateImageBox(); } } return(true); } } catch (Exception ex) { Logger.Error("FilmBox.Initialize, exception message: {0}", ex.Message); } return(false); }
public void SuperSlide_Format_Test() { ImageDisplayFormat.FromDicomString(@"SUPERSLIDE"); }
/// <summary> /// Get the rowIndex and columnIndex of the specified imageBoxPosition for this ImageDisplayType. /// </summary> private static void GetRowColumnIndex(ImageDisplayFormat imageDisplayFormat, int imageBoxPosition, out int rowIndex, out int columnIndex) { rowIndex = 0; columnIndex = 0; switch (imageDisplayFormat.Format) { case ImageDisplayFormat.FormatEnum.STANDARD: { var numberOfColumns = imageDisplayFormat.Modifiers[0]; var numberOfRows = imageDisplayFormat.Modifiers[1]; var imageBoxIndex = imageBoxPosition - 1; rowIndex = imageBoxIndex / numberOfRows; columnIndex = imageBoxIndex % numberOfColumns; break; } case ImageDisplayFormat.FormatEnum.ROW: { // Major row order: left-to-right and top-to-bottom GetIndexForRowColumnFormat(imageDisplayFormat.Modifiers, imageBoxPosition, out rowIndex, out columnIndex); break; } case ImageDisplayFormat.FormatEnum.COL: { // Major column order: top-to-bottom and left-to-right GetIndexForRowColumnFormat(imageDisplayFormat.Modifiers, imageBoxPosition, out columnIndex, out rowIndex); break; } case ImageDisplayFormat.FormatEnum.SLIDE: case ImageDisplayFormat.FormatEnum.SUPERSLIDE: case ImageDisplayFormat.FormatEnum.CUSTOM: default: throw new NotSupportedException(string.Format("{0} image display format is not supported", imageDisplayFormat.Format)); } }
public void Custom_Format_Test() { ImageDisplayFormat.FromDicomString(@"CUSTOM\1"); }