Example #1
0
        private void AppendSop(Sop sop, string ps = "")
        {
            try
            {
                Logger.LogFuncUp();

                //new a cell
                var cell = new MedViewerControlCell();


                //add display data to cell
                var    accessor  = new DataAccessor(medViewerControl.Configuration); //IViewerConfiguration config = null?
                var    imgSop    = sop as ImageSop;
                byte[] pixelData = null;
                //string ps = string.Empty;
                if (imgSop != null)
                {
                    pixelData = imgSop.GetNormalizedPixelData();
                    //ps = imgSop.PresentationState;
                }
                var displayData = accessor.CreateImageDataForFilming(sop.DicomSource, pixelData, ps);
                cell.Image.AddPage(displayData);

                //add cell to viewcontrol
                medViewerControl.LayoutManager.AddControlCell(cell);

                //2014-04-15 针对旋转后的图片做适合窗口处理
                if (displayData != null && displayData.PState != null)
                {
                    displayData.PState.SetRenderSize((int)medViewerControl.Width, (int)medViewerControl.Height);
                    displayData.FitWindow();
                }
                //2014-04-15 针对旋转后的图片做适合窗口处理

                //displayData.DeserializePSInfo();
                //_viewerControl.OnRaiseImageLoading(displayData);
                medViewerControl.Dispatcher.Invoke(new Action(() =>
                {
                    try
                    {
                        if (medViewerControl.CellCount > 0)
                        {
                            medViewerControl.LayoutManager.Refresh();
                        }
                        else
                        {
                            cell.Refresh();
                        }

                        //OnNewCellAdded
                    }
                    catch (Exception exp)
                    {
                        Logger.LogError(exp.Message);
                    }
                }));

                //cell.DeserializeGraphics();
                //_viewerControl.OnRaiseImageLoaded(displayData);

                Logger.LogFuncDown();
            }
            catch (Exception ex)
            {
                Logger.LogFuncException(ex.Message + ex.StackTrace);
                throw;
            }
        }