Esempio n. 1
0
        /**********************************************************************************
         * 1.图像在cell中的位置应该由RenderCenter 来决定,offset是通过RenderCenter和cell
         * 的weight&height 计算出来的, Offset只是用于在cell中渲染显示图像,
         * 不是用来决定图像在cell中的位置.
         * Edit by Duyaojun,2013.12.30
         * *********************************************************************************/
        private void PanCell(MedViewerControlCell cell, double renderCenterX, double renderCenterY, bool needRefresh)
        {
            Point  renderCenterPoint = new Point((renderCenterX - 0.5), (renderCenterY - 0.5));
            Matrix matrix            = new Matrix(cell.Image.CurrentPage.PState.TransformMatrix.M11,
                                                  cell.Image.CurrentPage.PState.TransformMatrix.M12,
                                                  cell.Image.CurrentPage.PState.TransformMatrix.M21,
                                                  cell.Image.CurrentPage.PState.TransformMatrix.M22, 0, 0);

            matrix.Invert();
            Point transformRenderCenterPoint = matrix.Transform(renderCenterPoint);

            cell.Image.CurrentPage.PState.CanRaiseValueChangedEvent = false;
            cell.Image.CurrentPage.PState.RenderCenterX             = (transformRenderCenterPoint.X + 0.5);
            cell.Image.CurrentPage.PState.RenderCenterY             = (transformRenderCenterPoint.Y + 0.5);
            cell.Image.CurrentPage.PState.UpdateOffset();
            cell.Image.CurrentPage.PState.CanRaiseValueChangedEvent = true;
            if (needRefresh)
            {
                cell.Refresh(CellRefreshType.Image);
            }
            else
            {
                cell.Image.CurrentPage.IsDirty = true;
            }
        }
Esempio n. 2
0
 private void WindowingCell(MedViewerControlCell cell, WindowLevel winLevel, bool needRefresh)
 {
     cell.Image.CurrentPage.PState.CanRaiseValueChangedEvent = false;
     cell.Image.CurrentPage.PState.WindowLevel = winLevel;
     cell.Image.CurrentPage.PState.CanRaiseValueChangedEvent = true;
     if (needRefresh)
     {
         cell.Refresh(CellRefreshType.Image);
         if (cell.ActualWidth >= FilmingUtility.FilmingPageSyncBoundary && cell.ActualHeight >= FilmingUtility.FilmingPageSyncBoundary)
         {
             cell.Refresh(CellRefreshType.ImageText);
         }
     }
     else
     {
         cell.Image.CurrentPage.IsDirty = true;
     }
 }
Esempio n. 3
0
        private void Button_Rotate_Confirm_Click(object sender, RoutedEventArgs e)
        {
            try{
                if (rotateAngle.Text == "非数字" || !Double.TryParse(rotateAngle.Text, out _value))
                {
                    return;
                }
                else
                {
                    if (true == ccw.IsChecked)
                    {
                        _value = -(_value % 360);
                    }
                    else
                    {
                        _value = _value % 360;
                    }
                }
                Logger.Instance.LogPerformanceRecord("[Action][CustomRotate][Begin]");
                foreach (var filmingPage in _activeFilmingPageList)
                {
                    foreach (var selectedCell in filmingPage.SelectedCells())
                    {
                        var cmd = new CmdRotateCustom(_value);
                        selectedCell.ExecuteCommand(cmd);

                        //selectedCell.Refresh();
                    }
                }

                if (_zoomViewerCell != null)
                {
                    var cmd = new CmdRotateCustom(_value);
                    _zoomViewerCell.ExecuteCommand(cmd);
                    _zoomViewerCell.Refresh();
                }
                Logger.Instance.LogPerformanceRecord("[Action][CustomRotate][End]");
            }
            catch (Exception exp)
            {
                Logger.LogFuncException("Exception: " + exp.ToString());
            }
        }
 public static void ColorInverse(this MedViewerControlCell cell)
 {
     try
     {
         foreach (var dd in cell.Image.Pages)
         {
             dd.PState.IsPaletteReversed = !dd.PState.IsPaletteReversed;
         }
         cell.Refresh();
     }
     catch (Exception ex)
     {
         Logger.LogError(ex.Message + ex.StackTrace);
         throw;
     }
 }
Esempio n. 5
0
        public static void ZoomCell(MedViewerControlCell cell, double scaleX, double scaleY, bool needRefresh)
        {
            double scaleXNew = Math.Abs(scaleX / cell.Image.CurrentPage.PState.ScaleX);
            double scaleYNew = Math.Abs(scaleY / cell.Image.CurrentPage.PState.ScaleY);

            cell.Image.CurrentPage.PState.CanRaiseValueChangedEvent = false;
            cell.Image.CurrentPage.PState.ScaleByRenderCenter(scaleXNew, scaleYNew);
            cell.Image.CurrentPage.PState.CanRaiseValueChangedEvent = true;
            if (needRefresh)
            {
                cell.Refresh();
            }
            else
            {
                cell.Image.CurrentPage.IsDirty = true;
            }
        }
Esempio n. 6
0
 public static void SetSUVTypeForCell(MedViewerControlCell cell, string SUVType)
 {
     try
     {
         Logger.LogFuncUp();
         if (CellModality(cell) != Modality.PT)
         {
             return;
         }
         cell.Image.SetDataUnit(SUVType);
         cell.Refresh();
         Logger.LogFuncDown();
     }
     catch (Exception ex)
     {
         Logger.LogWarning(ex.StackTrace);
     }
 }
 public static void FitToWindowByShort(this MedViewerControlCell cell)
 {
     try
     {
         if (cell.Image != null && cell.Image.Pages.Any())
         {
             foreach (var dd in cell.Image.Pages)
             {
                 dd.FitAndFillWindow();
             }
             cell.Refresh();
         }
     }
     catch (Exception ex)
     {
         Logger.LogError(ex.Message + ex.StackTrace);
         throw;
     }
 }
Esempio n. 8
0
 public static void SetEnhancementCell(MedViewerControlCell cell, string enhanceTag, bool needRefresh)
 {
     if (null != cell &&
         null != cell.Image &&
         null != cell.Image.CurrentPage &&
         (Modality.CT == cell.Image.CurrentPage.Modality || Modality.MG == cell.Image.CurrentPage.Modality))
     {
         if (!cell.Image.CurrentPage.PState.EnhancePara.Equals(Convert.ToDouble(enhanceTag)))
         {
             cell.Image.CurrentPage.PState.EnhancePara = Convert.ToDouble(enhanceTag);
             if (needRefresh)
             {
                 cell.Refresh();
             }
             else
             {
                 cell.Image.CurrentPage.IsDirty = true;
             }
         }
     }
 }
Esempio n. 9
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;
            }
        }