Ejemplo n.º 1
0
        private void TaskTerminated(object sender, BackgroundTaskTerminatedEventArgs args)
        {
            if (_dicomPrintSession != null)
            {
                _dicomPrintSession.Dispose();
                _dicomPrintSession = null;
            }

            if (_selectPresentationsInformations != null)
            {
                foreach (var item in _selectPresentationsInformations)
                {
                    IImageSopProvider   imageSopProvider = item.Image as IImageSopProvider;
                    ILocalSopDataSource localSource      = null;
                    if (imageSopProvider != null)
                    {
                        localSource = imageSopProvider.ImageSop.DataSource as ILocalSopDataSource;
                    }

                    item.Dispose();
                    if (localSource != null)
                    {
                        localSource.Dispose();
                    }
                }

                _dicomPrinter = null;
            }
        }
Ejemplo n.º 2
0
 // Methods
 public PrintItem(ISelectPresentationsInformation selectPresentation, CultureInfo cultureInfo)
 {
     _rectangle         = selectPresentation.DisplayRectangle;
     _mode              = selectPresentation.PresentationMode;
     _presentationImage = selectPresentation.Image;
     _exportOption      = DicomPrintSession.GetPresentationMode(_mode);
     _cultureInfo       = cultureInfo;
 }
Ejemplo n.º 3
0
        private ValidationResult GetValidtionResult(IApplicationComponent component)
        {
            string str;

            DicomPrinter.Configuration config = _dicomPrinter.Item.Config;
            bool success = DicomPrintSession.IsHaveModalityPixelSpacing(config, _selectPresentations, out str);

            return(new ValidationResult(success, str));
        }
Ejemplo n.º 4
0
        private void DoPrint(IBackgroundTaskContext context)
        {
            try
            {
                if (_selectPresentationsInformations == null || _selectPresentationsInformations.Count == 0)
                {
                    return;
                }
                Thread.Sleep(20);
                BackgroundTaskReportStatus(context, "Dicom打印开始", 0);
                Thread.Sleep(10);
                BackgroundTaskReportStatus(context, "开始处理图像...", 0);
                Thread.Sleep(10);
                //UISynchronizationContext.Send(DoImageProcess, null);
                DoImageProcess(null);
                if (_selectPresentationsInformations.Count == 0)
                {
                    BackgroundTaskReportStatus(context, "处理图像处理结果为0", 0);
                    return;
                }
                BackgroundTaskReportStatus(context, "开始向打印机发送图像", 0);
                Thread.Sleep(10);
                PrintScu scu = new PrintScu();
                DicomPrintProgressUpdate progressUpdate = new DicomPrintProgressUpdate();
                progressUpdate.dicomPrintManager = this;
                progressUpdate.printScu          = scu;
                progressUpdate.Task  = context;
                scu.ProgressUpdated += progressUpdate.Update;
                _dicomPrintSession   = new DicomPrintSession(DicomPrinter, new SelectPresentationsInformationsCollection(_selectPresentationsInformations));
                PrintScu.FilmSession filmSession = DicomPrintSession.GetFilmSession(_dicomPrintSession.SelectPresentationsCollection, _dicomPrintSession.DicomPrinter.Config);
                DicomState           dicomState  = scu.Print("MacroAETile", _dicomPrintSession.DicomPrinter.AETitle, _dicomPrintSession.DicomPrinter.Host, _dicomPrintSession.DicomPrinter.Port, filmSession);
                scu.Join();
                if (dicomState == DicomState.Success)
                {
                    //UpDicomPrintStatus(context);
                    if (_dicomPrintComponent != null)
                    {
                        UISynchronizationContext.Send(_dicomPrintComponent.PrintedDeleteImage, this);
                    }
                }
            }
            catch (Exception e)
            {
                Platform.Log(LogLevel.Debug, e);
                BackgroundTaskReportStatus(context, e.Message, 100);
            }

            if (_studyInstanceUid != null)
            {
                _studyInstanceUid.Clear();
                _studyInstanceUid = null;
            }
            GC.Collect();
        }
Ejemplo n.º 5
0
 public void Accept()
 {
     if (this._dicomPrinter == null)
     {
         base.Host.DesktopWindow.ShowMessageBox("请选择打印机", MessageBoxActions.Ok);
     }
     else
     {
         if (this.HasValidationErrors || this._dicomPrinterConfigurationEditorComponent.HasValidationErrors)
         {
             this.ShowValidation(true);
             this._dicomPrinterConfigurationEditorComponent.ShowValidation(true);
         }
         else
         {
             IApplicationComponentHost host          = base.Host;
             DesktopWindow             desktopWindow = host.DesktopWindow;
             _dicomPrintSession = new DicomPrintSession(_dicomPrinter.Item, _selectPresentations);
             // Platform.Log(LogLevel.Info, _dicomPrinter.Item.Config.ToString());
             base.Exit(ApplicationComponentExitCode.Accepted);
         }
     }
 }
Ejemplo n.º 6
0
 public DciomPrintApplicationComponent(SelectPresentationsInformationsCollection selectPresentations)
 {
     this._selectPresentations = selectPresentations;
     this._dicomPrinterTable   = new DicomPrinterTable(true);
     _dicomPrintSession        = null;
 }
Ejemplo n.º 7
0
 public PrintScu.FilmBox GetFilmBox(IList <PrintScu.IPrintItem> pirntItemList)
 {
     return(DicomPrintSession.GetFilmBox(config, pirntItemList));
 }
Ejemplo n.º 8
0
        private static PrintScu.FilmBox GetFilmBox(DicomPrinter.Configuration config, IList <PrintScu.IPrintItem> itemList)
        {
            // This item is obfuscated and can not be translated.
            PrintScu.FilmBox box;
            if (config.FilmBox.FilmSize != PrinterFilmSize.AutoSelect)
            {
                box = new PrintScu.FilmBox(config.StandardResolutionDPI, config.HighResolutionDPI)
                {
                    FilmSizeId         = config.FilmBox.FilmSize.ToFilmSize(),
                    ImageDisplayFormat = config.FilmBox.ImageDisplayFormat.ToImageDisplayFormat()
                };

                if (config.FilmBox.FilmOrientation != FilmOrientation.None)
                {
                    box.FilmOrientation = config.FilmBox.FilmOrientation;
                }

                if (config.FilmBox.BorderDensity != BorderDensity.None)
                {
                    box.BorderDensity = config.FilmBox.BorderDensity;
                }

                if (config.FilmBox.EmptyImageDensity != EmptyImageDensity.None)
                {
                    box.EmptyImageDensity = config.FilmBox.EmptyImageDensity;
                }

                if (config.FilmBox.MagnificationType != MagnificationType.None)
                {
                    box.MagnificationType = config.FilmBox.MagnificationType;
                }

                if (!string.IsNullOrEmpty(config.FilmBox.ConfigurationInformation))
                {
                    box.ConfigurationInformation = config.FilmBox.ConfigurationInformation;
                }

                if (config.FilmBox.RequestedResolution != RequestedResolution.None)
                {
                    box.RequestedResolutionId = config.FilmBox.RequestedResolution;
                }
            }
            else
            {
                box = new PrintScu.FilmBox(config.StandardResolutionDPI, config.HighResolutionDPI)
                {
                    FilmSizeId         = config.FilmBox.FilmSize.ToFilmSize(),
                    ImageDisplayFormat = config.FilmBox.ImageDisplayFormat.ToImageDisplayFormat()
                };

                if (config.FilmBox.RequestedResolution == RequestedResolution.High)
                {
                    int numberOfCopies = config.Session.NumberOfCopies;
                    AutomaticFilmSizeConfiguration automaticFilmSizeConfiguration = config.FilmBox.AutomaticFilmSizeConfiguration;
                    PrintScu.IPrintItem            printItem             = DicomPrintSession.GetT <PrintScu.IPrintItem>(itemList);
                    FilmConfigInformation          fileConfigInformation = FilmConfigInformation.GetFilmInformation(automaticFilmSizeConfiguration, (ISelectPresentationsInformation)printItem, numberOfCopies);
                    box.ImageDisplayFormat = ImageDisplayFormat.Standard_1x1;
                    box.FilmSizeId         = fileConfigInformation.FilmSize;
                    box.FilmOrientation    = fileConfigInformation.FilmOrientation;
                }
            }
            return(box);
        }