Пример #1
0
 void ApplyTransform()
 {
     if (transforms != null)
     {
         transforms.PushAll();
     }
 }
Пример #2
0
 public void SetClip(IGraphicsPath path)
 {
     TransformStack.PopAll();
     ResetClip();
     clipPath   = path.Clone().ToWpf();           // require a clone so changes to path don't affect current clip
     clipBounds = clipPath.Bounds.ToEtoF();
     ApplyClip();
     TransformStack.PushAll();
 }
Пример #3
0
 public void SetClip(RectangleF rectangle)
 {
     TransformStack.PopAll();
     ResetClip();
     clipBounds = rectangle;
     clipPath   = null;
     ApplyClip();
     TransformStack.PushAll();
 }
Пример #4
0
 void CreateGroup()
 {
     CloseGroup();
     if (baseContext == null)
     {
         baseContext = Control;
     }
     group   = new swm.DrawingGroup();
     Control = group.Open();
     TransformStack.PushAll();
     ApplyClip();
 }
Пример #5
0
 void CloseGroup()
 {
     if (group != null && baseContext != null)
     {
         TransformStack.PopAll();
         ResetClip();
         Control.Close();
         baseContext.DrawDrawing(group);
         Control = baseContext;
         group   = null;
         ApplyClip();
         TransformStack.PushAll();
     }
 }
Пример #6
0
        public void Clear(SolidBrush brush)
        {
            var rect = clipBounds ?? initialClip;

            if (drawingVisual != null)
            {
                // bitmap
                Control.Close();
                var newbmp = new swmi.RenderTargetBitmap((int)bounds.Width, (int)bounds.Height, 96, 96, swm.PixelFormats.Pbgra32);
                newbmp.Render(visual);

                swm.Geometry maskgeometry;
                if (clipPath != null)
                {
                    maskgeometry = clipPath.ToWpf();
                }
                else
                {
                    maskgeometry = new swm.RectangleGeometry(rect.ToWpf());
                }
                var boundsgeometry = new swm.RectangleGeometry(bounds);
                maskgeometry = swm.Geometry.Combine(boundsgeometry, maskgeometry, swm.GeometryCombineMode.Exclude, null);
                var dr = new swm.GeometryDrawing(swm.Brushes.Black, null, maskgeometry);
                var db = new swm.DrawingBrush(dr);
                //db.Transform = new swm.TranslateTransform (0.5, 0.5);

                Control = drawingVisual.RenderOpen();
                PushGuideLines(bounds.X, bounds.Y, bounds.Width, bounds.Height);
                Control.PushOpacityMask(db);
                Control.DrawImage(newbmp, bounds);
                Control.Pop();

                TransformStack.PushAll();
                ApplyClip();
            }
            else
            {
                // drawable
                if (brush == null || brush.Color.A < 1.0f)
                {
                    Widget.FillRectangle(Brushes.Black, rect);
                }
            }
            if (brush != null)
            {
                Widget.FillRectangle(brush, rect);
            }
        }