示例#1
0
        AnnAutomationObject CreateZoneAutomationObject()
        {
            AnnAutomationObject  automationObj        = new AnnAutomationObject();
            ZoneAnnotationObject zoneAnnotationObject = new ZoneAnnotationObject();

            AnnAutomationObject rectAutomationObject = GetAutomationObject(_annAutomationManager, AnnObject.RectangleObjectId);
            AnnRectangleObject  rectObject           = rectAutomationObject.ObjectTemplate as AnnRectangleObject;

            zoneAnnotationObject.Stroke = rectObject.Stroke != null?rectObject.Stroke.Clone() as AnnStroke : null;

            zoneAnnotationObject.Fill = rectObject.Fill != null?rectObject.Fill.Clone() as AnnBrush : null;

            zoneAnnotationObject.CellPen = AnnStroke.Create(AnnSolidColorBrush.Create("Blue"), new LeadLengthD(1));

            automationObj.Id               = AnnObject.UserObjectId;
            automationObj.Name             = zoneAnnotationObject.FriendlyName;
            automationObj.ObjectTemplate   = zoneAnnotationObject;
            automationObj.DrawDesignerType = rectAutomationObject.DrawDesignerType;
            automationObj.EditDesignerType = typeof(ZoneAnnotationObjectEditDesigner);
            automationObj.RunDesignerType  = rectAutomationObject.RunDesignerType;
            automationObj.DrawCursor       = rectAutomationObject.DrawCursor;

            // Disable the rotation points
            automationObj.UseRotateThumbs = false;
            return(automationObj);
        }
示例#2
0
        private void AdjustFusionImage_Edit(object sender, AnnRectangleObject fusionEditRect)
        {
            int subCellIndex = _cell.ActiveSubCell;
            int index        = _cmbFusedIndex.SelectedIndex;

            MedicalViewerFusion fusion = _cell.SubCells[subCellIndex].Fusion[index];

            AnnContainer _Container = GetContainer(_cell, fusionEditRect);

            fusion.Rotation = (float)fusionEditRect.Angle;

            LeadPointD[] pt = new LeadPointD[1];


            LeadRectD rect = _Container.Mapper.RectFromContainerCoordinates(fusionEditRect.Rect, AnnFixedStateOperations.None);

            Rectangle displayRect = _cell.GetDisplayedImageRectangle();

            rect.Offset(-displayRect.Left, -displayRect.Top);


            pt[0].X = (float)(rect.X + rect.Width / 2);
            pt[0].Y = (float)(rect.Y + rect.Height / 2);

            LeadPointD point = LeadPointD.Create(pt[0].X, pt[0].Y);


            _cell.AutomationContainer.Mapper.Transform.TransformPoints(pt);

            float normalizedXPosition = (float)(((float)point.X - (float)displayRect.Width / 2) / fusion.FusedImage.Width * 100 / _cell.GetScale(subCellIndex));
            float normalizedYPosition = (float)(((float)point.Y - (float)displayRect.Height / 2) / fusion.FusedImage.Height * 100 / _cell.GetScale(subCellIndex));

            float scaleX = (float)((rect.Width / fusion.FusedImage.Width) * 100 / _cell.GetScale(subCellIndex));
            float scaleY = (float)((rect.Height / fusion.FusedImage.Height) * 100 / _cell.GetScale(subCellIndex));

            if (scaleX == 0)
            {
                scaleX = 0.1F;
            }

            if (scaleY == 0)
            {
                scaleY = 0.1F;
            }

            RectangleF rectangle = new RectangleF(normalizedXPosition, normalizedYPosition, Math.Abs(scaleX), Math.Abs(scaleY));

            fusion.DisplayRectangle = rectangle;

            UpdateFusionUI(index);

            CellData cellData = (CellData)_cell.Tag;

            if (cellData.SyncCellFusion)
            {
                UpdateCellFusions(fusion, subCellIndex, index);
            }

            _cell.Invalidate();
        }
示例#3
0
        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);
        }
示例#4
0
        private LeadRectD BoundsToAnnotations(AnnRectangleObject rectObject, LeadRect rect, AnnContainer container)
        {
            // Convert a rectangle from logical (top-left) to annotation object coordinates
            LeadRectD rc = rect.ToLeadRectD();

            rc = _rasterImageViewer.ConvertRect(null, ImageViewerCoordinateType.Image, ImageViewerCoordinateType.Control, rc);
            rc = container.Mapper.RectToContainerCoordinates(rc);
            return(rc);
        }
示例#5
0
        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;
        }
示例#6
0
        AnnRectangleObject CreateRectangle(LeadRectD rect, AnnBrush brush, AnnLayer layer)
        {
            AnnRectangleObject annRectObject = new AnnRectangleObject();

            annRectObject.Rect          = rect;
            annRectObject.Fill          = brush;
            annRectObject.Stroke.Stroke = AnnSolidColorBrush.Create("yellow");
            _automation.Container.Children.Add(annRectObject);
            layer.Children.Add(annRectObject);

            return(annRectObject);
        }
示例#7
0
        private LeadRect BoundsFromAnnotations(AnnRectangleObject rectObject, AnnContainer container)
        {
            // Convert a rectangle from annotation object to logical coordinates (top-left)
            LeadRectD temp = container.Mapper.RectFromContainerCoordinates(rectObject.Rect, AnnFixedStateOperations.None);

            if (temp.IsEmpty)
            {
                return(LeadRect.Empty);
            }

            temp = _rasterImageViewer.ConvertRect(null, ImageViewerCoordinateType.Control, ImageViewerCoordinateType.Image, temp);
            LeadRect rect = temp.ToLeadRect();

            return(rect);
        }
示例#8
0
        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();
        }
示例#9
0
        void cell_AnnotationCreated(object sender, MedicalViewerAnnotationCreatedEventArgs e)
        {
            AnnRectangleObject rectangle = e.Object as AnnRectangleObject;

            rectangle.RotateGripper = new LeadLengthD();


            _Container = GetContainer((MedicalViewerMultiCell)sender, rectangle);


            for (int i = 0; i < Cell.SubCells.Count; i++)
            {
                AnnContainer container = Cell.SubCells[i].AnnotationContainer;

                if (container != null && container != _Container)
                {
                    container.Children.Add(rectangle);
                }
            }
        }
示例#10
0
        private void ViewDatasetDialog_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (loaderThread != null)
            {
                loaderThread.Abort();
            }

            if (DialogResult == DialogResult.OK)
            {
                AnnContainer container = Cell.GetAnnotationContainer();

                foreach (AnnRectangleObject rectangle in container.Children)
                {
                    //AnnTransformer transform = new AnnTransformer(container.UnitConverter, rectangle.Transform);
                    //AnnRectangleObject imageRectangle = transform.RectangleToPhysical(rectangle.BoundingRectangle);

                    AnnRectangleObject imageRectangle = new AnnRectangleObject(container.Mapper.RectFromContainerCoordinates(rectangle.Bounds, AnnFixedStateOperations.None));

                    _BlackoutRects.Add(new LeadRect((int)imageRectangle.Bounds.Left, (int)imageRectangle.Bounds.Top, (int)imageRectangle.Bounds.Width, (int)imageRectangle.Bounds.Height));
                }
            }
        }
示例#11
0
文件: DROC.cs 项目: khaha2210/radio
        /// <summary>
        /// Xử lý sự kiện Mouseup để vẽ đối tượng cắt ảnh
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void cell_MouseUp(object sender, MouseEventArgs e)
        {
            try
            {
                if (!blnhasJustCreated) return;
                Rectangle Rec = _CurrCell.GetDisplayedImageRectangle();
                X2 = e.X - Rec.X;
                Y2 = e.Y - Rec.Y;
                ImgRec = Rec;
                Leadtools.Annotations.AnnContainer _AnnContainer;
                lastRecObj = null;
                bool bHasRecObj = false;
                if (_DicomMedicalViewer._IsCropping)
                {
                    _AnnContainer = _CurrCell.GetAnnotationContainer();
                    _CurrCell.SetAnnotationContainer(new AnnContainer());
                    AnnContainer _newAnn = new AnnContainer();
                    foreach (AnnObject AnnObj in _AnnContainer.Objects)
                        if (AnnObj.GetType().Equals(new AnnRectangleObject().GetType()) || (AnnObj.GetType().Equals(new AnnTextObject().GetType()) && ((AnnTextObject)AnnObj).Text != null && (((AnnTextObject)AnnObj).Text.ToString() == "L" || ((AnnTextObject)AnnObj).Text.ToString() == "R")))
                        {
                            if (AnnObj.GetType().Equals(new AnnRectangleObject().GetType()))
                            {
                                lastRecObj = (AnnRectangleObject)AnnObj;
                            }
                            else
                                _newAnn.Objects.Add(AnnObj);
                        }


                    if (lastRecObj != null)
                    {
                        lastRecObj.Tag = 2100;// MultiLanguage.GetText(globalVariables.DisplayLanguage, "Cắt ảnh", "CROP");
                        lastRecObj.NameFont = new AnnFont("Arial", new AnnLength(50), FontStyle.Bold);
                        lastRecObj.Pen = new AnnPen(Color.Red, new AnnLength(GetWidthOfCrop()));

                        _newAnn.Objects.Add(lastRecObj);


                    }
                    _CurrCell.SetAnnotationContainer(_newAnn);
                    _CurrCell.Invalidate();
                    //SaveAnnotation(CurrCellFileName);
                    //LoadAnnotation(_CurrCell, GetAnnPath(CurrCellFileName), false);


                }
            }
            catch
            {
            }
            finally
            {
                blnhasJustCreated = false;
            }
        }
示例#12
0
文件: DROC.cs 项目: khaha2210/radio
        void CropX()
        {
            try
            {
                Leadtools.Annotations.AnnContainer _AnnContainer;
                AnnTextObject lastRecObj = null;

                _AnnContainer = _CurrCell.GetAnnotationContainer();

                AnnContainer _newAnn = (AnnContainer)_AnnContainer.Clone();
                _newAnn.Objects.Clear();
                foreach (AnnObject AnnObj in _AnnContainer.Objects)

                        if (AnnObj.GetType().Equals(new AnnTextObject().GetType()))
                        {
                            lastRecObj = (AnnTextObject)AnnObj;
                        }
                       


                if (lastRecObj != null)
                {
                    lastRecObj.Tag = 2100;// MultiLanguage.GetText(globalVariables.DisplayLanguage, "Cắt ảnh", "CROP");
                    lastRecObj.NameFont = new AnnFont("Arial", new AnnLength(_CurrCell.OverlayTextSize), FontStyle.Bold);
                    lastRecObj.Pen = new AnnPen(Color.Green, new AnnLength(GetWidthOfCrop()));
                    lastRecObj.SetFixedState(false, false);
                    lastRecObj.UseBrushAsTextBackground = true;
                    lastRecObj.Brush = new AnnSolidBrush(Color.White);
                    lastRecObj.Text = "";
                    
                    _newAnn.Objects.Add(lastRecObj);
                    
                }
                _CurrCell.SetAnnotationContainer(_newAnn);
                _CurrCell.SubCells[0].SelectObject(_CurrCell.SubCells[0].AnnotationContainer.Objects[0], true);
                _CurrCell.ShowRotationHandle = false;
                _DicomMedicalViewer._medicalViewer.Invalidate();
                _AnnContainer =_CurrCell.GetAnnotationContainer();

            }
            catch
            {
            }
            finally
            {
                blnhasJustCreated = false;
            }
        }
示例#13
0
文件: DROC.cs 项目: khaha2210/radio
        /// <summary>
        /// Load Annotation của một ảnh để hiển thị cho người dùng xem
        /// </summary>
        /// <param name="cell"></param>
        /// <param name="fileName"></param>
        /// <param name="AutoIgnoreCropObject"></param>
        private void LoadAnnotation(MedicalViewerMultiCell cell, string fileName, bool AutoIgnoreCropObject)
        {
            return;
            int count = 1;
            #region 17.5
            //try
            //{
            //    if (fileName != null)
            //    {
            //        AnnCodecs _annCodecs = new AnnCodecs();
            //        _annCodecs.Load(fileName, cell.GetAnnotationContainer(0), 1);

            //        if (AutoIgnoreCropObject)
            //        {
            //            Leadtools.Annotations.AnnContainer _AnnContainer;
            //            lastRecObj = null;
            //            bool bHasRecObj = false;
            //            _AnnContainer = ((MedicalViewerMultiCell)_DicomMedicalViewer._medicalViewer.Cells[_DicomMedicalViewer._medicalViewerCellIndex]).GetAnnotationContainer(0);
            //            ((MedicalViewerMultiCell)_DicomMedicalViewer._medicalViewer.Cells[_DicomMedicalViewer._medicalViewerCellIndex]).SetAnnotationContainer(new AnnContainer());
            //            AnnContainer _newAnn = new AnnContainer();
            //            foreach (AnnObject AnnObj in _AnnContainer.Objects)
            //                if (AnnObj.GetType().Equals(new AnnRectangleObject().GetType()) || (AnnObj.GetType().Equals(new AnnTextObject().GetType()) && ((AnnTextObject)AnnObj).Text != null && (((AnnTextObject)AnnObj).Text.ToString() == "L" || ((AnnTextObject)AnnObj).Text.ToString() == "R")))
            //                {
            //                    if (AnnObj.GetType().Equals(new AnnRectangleObject().GetType()) && ((AnnRectangleObject)AnnObj).Name.ToUpper() == "CẮT ẢNH")
            //                    {
            //                        lastRecObj = (AnnRectangleObject)AnnObj;
            //                    }
            //                    else
            //                        _newAnn.Objects.Add(AnnObj);
            //                }



            //            ((MedicalViewerMultiCell)_DicomMedicalViewer._medicalViewer.Cells[_DicomMedicalViewer._medicalViewerCellIndex]).SetAnnotationContainer(_newAnn);
            //            ((MedicalViewerMultiCell)_DicomMedicalViewer._medicalViewer.Cells[_DicomMedicalViewer._medicalViewerCellIndex]).Invalidate();
            //        }

            //        //count += cell.Image.PageCount;
            //    }
            //}
            //catch (Exception ex)
            //{
            //}
            #endregion
            #region 17.0

            try
            {
                if (fileName != null)
                {
                    FileStream f = new FileStream(fileName, FileMode.OpenOrCreate);
                   
                    cell.LoadAnnotations(f);
                    f.Flush();
                    f.Close();
                    return;
                    if (AutoIgnoreCropObject)
                    {
                        Leadtools.Annotations.AnnContainer _AnnContainer;
                        lastRecObj = null;
                        bool bHasRecObj = false;
                        _AnnContainer = ((MedicalViewerMultiCell)_DicomMedicalViewer._medicalViewer.Cells[_DicomMedicalViewer._medicalViewerCellIndex]).GetAnnotationContainer(0);
                        ((MedicalViewerMultiCell)_DicomMedicalViewer._medicalViewer.Cells[_DicomMedicalViewer._medicalViewerCellIndex]).SetAnnotationContainer(new AnnContainer());
                        AnnContainer _newAnn = new AnnContainer();
                        foreach (AnnObject AnnObj in _AnnContainer.Objects)
                            if (AnnObj.GetType().Equals(new AnnRectangleObject().GetType()) || (AnnObj.GetType().Equals(new AnnTextObject().GetType()) && ((AnnTextObject)AnnObj).Text != null && (((AnnTextObject)AnnObj).Text.ToString() == "L" || ((AnnTextObject)AnnObj).Text.ToString() == "R")))
                            {
                                if (AnnObj.GetType().Equals(new AnnRectangleObject().GetType()) && ((AnnRectangleObject)AnnObj).Tag != null && ((AnnRectangleObject)AnnObj).Tag.ToString().ToUpper() == "2100")
                                {
                                    lastRecObj = (AnnRectangleObject)AnnObj;
                                }
                                else
                                    _newAnn.Objects.Add(AnnObj);
                            }
                        ((MedicalViewerMultiCell)_DicomMedicalViewer._medicalViewer.Cells[_DicomMedicalViewer._medicalViewerCellIndex]).SetAnnotationContainer(_newAnn);
                        ((MedicalViewerMultiCell)_DicomMedicalViewer._medicalViewer.Cells[_DicomMedicalViewer._medicalViewerCellIndex]).Invalidate();
                    }

                    //count += cell.Image.PageCount;
                }
            }
            catch (Exception ex)
            {
            }
            #endregion
        }
示例#14
0
 static AnnParallelLinesDrawer()
 {
     _objectTemplate = new AnnRectangleObject();
     _objectTemplate.Stroke.Stroke          = AnnSolidColorBrush.Create("blue");
     _objectTemplate.Stroke.StrokeDashArray = new double[] { 4, 2, 2, 2, 2, 2 };
 }
示例#15
0
 static AnnNorbergDrawer()
 {
     _objectTemplate = new AnnRectangleObject();
     _objectTemplate.Stroke.Stroke          = AnnSolidColorBrush.Create("black");
     _objectTemplate.Stroke.StrokeThickness = LeadLengthD.Create(2);
 }
        public override void Render(AnnContainerMapper mapper, AnnObject annObject)
        {
            if (mapper == null)
            {
                ExceptionHelper.ArgumentNullException("mapper");
            }
            if (annObject == null)
            {
                ExceptionHelper.ArgumentNullException("annObject");
            }

            base.Render(mapper, annObject);
            AnnRichTextObject annRichTextObject = annObject as AnnRichTextObject;

            if (annRichTextObject != null && !String.IsNullOrEmpty(annRichTextObject.Rtf))
            {
                AnnWinFormsRenderingEngine engine = RenderingEngine as AnnWinFormsRenderingEngine;
                if (engine != null && engine.Context != null)
                {
                    AnnRectangleObject tempRect = new AnnRectangleObject();
                    tempRect.Points.Clear();
                    foreach (LeadPointD pt in GetRenderPoints(mapper, annRichTextObject))
                    {
                        tempRect.Points.Add(pt);
                    }

                    double rotation = tempRect.Angle;
                    if (rotation == 180)
                    {
                        rotation = 0;
                    }

                    LeadRectD          boundsPixels   = tempRect.Rect.Clone();
                    AnnContainerMapper identityMapper = mapper.Clone();
                    identityMapper.UpdateTransform(LeadMatrix.Identity);
                    identityMapper.MapResolutions(mapper.SourceDpiX, mapper.SourceDpiY, mapper.SourceDpiX, mapper.SourceDpiY);
                    boundsPixels = identityMapper.RectFromContainerCoordinates(boundsPixels, annRichTextObject.FixedStateOperations);
                    if (tempRect.Stroke != null)
                    {
                        boundsPixels.Inflate(-tempRect.Stroke.StrokeThickness.Value, -tempRect.Stroke.StrokeThickness.Value);
                    }

                    string rtf = annRichTextObject.Rtf;
                    IntPtr hemfDC;
                    if (_richTextBox == null)
                    {
                        _richTextBox = new InternalRichTextEdit();
                    }

                    try
                    {
                        _richTextBox.Rtf = rtf;
                    }
                    catch
                    {
                        using (RichTextBox richTextBox = new RichTextBox())
                        {
                            richTextBox.Text      = rtf;
                            annRichTextObject.Rtf = richTextBox.Rtf;
                            _richTextBox.Rtf      = richTextBox.Rtf;
                        }
                    }

                    Graphics graphics = engine.Context;
                    double   dpiX     = 96;
                    double   dpiY     = 96;

                    _richTextBox.Location = new Point((int)boundsPixels.Location.X, (int)boundsPixels.Location.Y);
                    _richTextBox.Size     = new Size((int)boundsPixels.Size.Width, (int)boundsPixels.Size.Height);
                    IntPtr hdc = graphics.GetHdc();

                    Win32.RECT rc = new Win32.RECT();

                    rc.left   = _richTextBox.ClientRectangle.Left;
                    rc.top    = _richTextBox.ClientRectangle.Top;
                    rc.right  = (int)boundsPixels.Width;
                    rc.bottom = (int)boundsPixels.Height;

                    int iWidthMM    = SafeNativeMethods.GetDeviceCaps(hdc, Win32.HORZSIZE);
                    int iHeightMM   = SafeNativeMethods.GetDeviceCaps(hdc, Win32.VERTSIZE);
                    int iWidthPels  = SafeNativeMethods.GetDeviceCaps(hdc, Win32.HORZRES);
                    int iHeightPels = SafeNativeMethods.GetDeviceCaps(hdc, Win32.VERTRES);

                    rc.left   = (rc.left * iWidthMM * 100) / iWidthPels;
                    rc.top    = (rc.top * iHeightMM * 100) / iHeightPels;
                    rc.right  = (rc.right * iWidthMM * 100) / iWidthPels;
                    rc.bottom = (rc.bottom * iHeightMM * 100) / iHeightPels;

                    hemfDC = SafeNativeMethods.CreateEnhMetaFile(hdc, null, ref rc, null);

                    Win32.RECT emfRect = new Win32.RECT();
                    emfRect.right  = (int)boundsPixels.Width;
                    emfRect.bottom = (int)boundsPixels.Height;

                    IntPtr brush = SafeNativeMethods.GetStockObject(5);
                    SafeNativeMethods.SetBkMode(hemfDC, 1);
                    SafeNativeMethods.FillRect(hemfDC, ref emfRect, brush);
                    SafeNativeMethods.DeleteObject(brush);

                    Print(_richTextBox, _richTextBox.ClientRectangle, hemfDC, (int)dpiX, (int)dpiY, false);
                    IntPtr hemf = SafeNativeMethods.CloseEnhMetaFile(hemfDC);

                    using (Metafile metaFile = new Metafile(hemf, true))
                    {
                        graphics.ReleaseHdc();
                        GraphicsState state = graphics.Save();

                        //the mapper transform dosent contain dpi effect so we will add dpi effect .
                        LeadMatrix matrix = mapper.Transform;
                        //add dpi effect to the transform
                        matrix.Scale((float)(mapper.TargetDpiX / mapper.SourceDpiX), (float)(mapper.TargetDpiY / mapper.SourceDpiY));

                        if ((annRichTextObject.FixedStateOperations & AnnFixedStateOperations.Scrolling) == AnnFixedStateOperations.Scrolling)
                        {
                            matrix.Translate(-matrix.OffsetX, -matrix.OffsetY);
                        }

                        if ((annRichTextObject.FixedStateOperations & AnnFixedStateOperations.Zooming) == AnnFixedStateOperations.Zooming)
                        {
                            double offsetX = matrix.OffsetX;
                            double offsetY = matrix.OffsetY;
                            double scaleX  = 1.0;
                            double scaleY  = 1.0;
                            if (matrix.M11 != 0 && matrix.M22 != 0)
                            {
                                scaleX = 1.0 / Math.Abs(matrix.M11);
                                scaleY = 1.0 / Math.Abs(matrix.M22);
                            }

                            matrix.Scale(scaleX, scaleY);
                        }

                        using (Matrix transform = new Matrix((float)matrix.M11, (float)matrix.M12, (float)matrix.M21, (float)matrix.M22, (float)matrix.OffsetX, (float)matrix.OffsetY))
                        {
                            graphics.MultiplyTransform(transform);
                            graphics.DrawImage(metaFile, new Point((int)boundsPixels.Left, (int)boundsPixels.Top));
                        }
                        graphics.Restore(state);
                    }
                }

                //EndDraw(graphics, gState);
            }
        }