Пример #1
0
        public static void Run()
        {
            // ExStart:1
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_WorkingWithGradient();
            // Create new XPS Document
            XpsDocument doc = new XpsDocument();
            // Initialize List of XpsGradentStop
            List <XpsGradientStop> stops = new List <XpsGradientStop>();

            stops.Add(doc.CreateGradientStop(doc.CreateColor(253, 255, 12, 0), 0f));
            stops.Add(doc.CreateGradientStop(doc.CreateColor(252, 255, 154, 0), 0.359375f));
            stops.Add(doc.CreateGradientStop(doc.CreateColor(252, 255, 56, 0), 0.424805f));
            stops.Add(doc.CreateGradientStop(doc.CreateColor(253, 255, 229, 0), 0.879883f));
            stops.Add(doc.CreateGradientStop(doc.CreateColor(252, 255, 255, 234), 1f));
            // Create new path by defining geometery in abbreviation form
            XpsPath path = doc.AddPath(doc.CreatePathGeometry("M 10,110 L 228,110 228,200 10,200"));

            path.RenderTransform = doc.CreateMatrix(1f, 0f, 0f, 1f, 20f, 70f);
            path.Fill            = doc.CreateLinearGradientBrush(new PointF(10f, 110f), new PointF(10f, 200f));
            ((XpsGradientBrush)path.Fill).GradientStops.AddRange(stops);
            // Save resultant XPS document
            doc.Save(dataDir + "AddVerticalGradient_out.xps");
            // ExEnd:1
        }
Пример #2
0
        public static void Run()
        {
            // ExStart:1
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_WorkingWithShapes();
            // Create new XPS Document
            XpsDocument doc = new XpsDocument();
            // Radial gradient stroked ellipse in the lower left
            List<XpsGradientStop> stops = new List<XpsGradientStop>();
            stops.Add(doc.CreateGradientStop(doc.CreateColor(0, 0, 255), 0f));
            stops.Add(doc.CreateGradientStop(doc.CreateColor(255, 0, 0), .25f));
            stops.Add(doc.CreateGradientStop(doc.CreateColor(0, 255, 0), .5f));
            stops.Add(doc.CreateGradientStop(doc.CreateColor(255, 255, 0), .75f));
            stops.Add(doc.CreateGradientStop(doc.CreateColor(255, 0, 0), 1f));

            XpsPath path = doc.AddPath(doc.CreatePathGeometry("M 20,250 A 100,50 0 1 1 220,250 100,50 0 1 1 20,250"));
            path.Stroke = doc.CreateRadialGradientBrush(new PointF(575f, 125f), new PointF(575f, 100f), 75f, 50f);
            ((XpsGradientBrush)path.Stroke).SpreadMethod = XpsSpreadMethod.Reflect;
            ((XpsGradientBrush)path.Stroke).GradientStops.AddRange(stops);
            stops.Clear();
            path.StrokeThickness = 12f;
            // Save resultant XPS document
            doc.Save(dataDir + "AddEllipse_out.xps");
            // ExEnd:1
        }
        public static void Run()
        {
            // ExStart:1
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_WorkingWithGradient();
            // Create new XPS Document
            XpsDocument doc = new XpsDocument();
            // Initialize List of XpsGradentStop
            List <XpsGradientStop> stops = new List <XpsGradientStop>();

            // Add Colors to Gradient
            stops.Add(doc.CreateGradientStop(doc.CreateColor(0, 142, 4), 0f));
            stops.Add(doc.CreateGradientStop(doc.CreateColor(255, 202, 0), 0.144531f));
            stops.Add(doc.CreateGradientStop(doc.CreateColor(255, 250, 0), 0.264648f));
            stops.Add(doc.CreateGradientStop(doc.CreateColor(255, 0, 0), 0.414063f));
            stops.Add(doc.CreateGradientStop(doc.CreateColor(233, 0, 255), 0.544922f));
            stops.Add(doc.CreateGradientStop(doc.CreateColor(107, 27, 190), 0.694336f));
            stops.Add(doc.CreateGradientStop(doc.CreateColor(63, 0, 255), 0.844727f));
            stops.Add(doc.CreateGradientStop(doc.CreateColor(0, 199, 80), 1f));
            // Create new path by defining geometery in abbreviation form
            XpsPath path = doc.AddPath(doc.CreatePathGeometry("M 10,10 L 228,10 228,100 10,100"));

            path.RenderTransform = doc.CreateMatrix(1f, 0f, 0f, 1f, 20f, 70f);
            path.Fill            = doc.CreateLinearGradientBrush(new PointF(10f, 10f), new PointF(228f, 100f));
            ((XpsGradientBrush)path.Fill).GradientStops.AddRange(stops);
            // Save resultant XPS document
            doc.Save(dataDir + "AddLinearGradient_out.xps");
            // ExEnd:1
        }
Пример #4
0
        public static void Run()
        {
            // ExStart:1
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_WorkingWithVisualBrush();

            XpsDocument doc = new XpsDocument();
            // Geometry for magenta grid VisualBrush
            XpsPathGeometry pathGeometry = doc.CreatePathGeometry();

            pathGeometry.AddSegment(doc.CreatePolyLineSegment(
                                        new PointF[] { new PointF(240f, 5f), new PointF(240f, 310f), new PointF(0f, 310f) }));
            pathGeometry[0].StartPoint = new PointF(0f, 5f);

            // Canvas for magenta grid VisualBrush
            XpsCanvas visualCanvas = doc.CreateCanvas();

            XpsPath visualPath = visualCanvas.AddPath(
                doc.CreatePathGeometry("M 0,4 L 4,4 4,0 6,0 6,4 10,4 10,6 6,6 6,10 4,10 4,6 0,6 Z"));

            visualPath.Fill = doc.CreateSolidColorBrush(doc.CreateColor(1f, .61f, 0.1f, 0.61f));

            XpsPath gridPath = doc.CreatePath(pathGeometry);

            //Create Visual Brush, it is specified by some XPS fragment (vector graphics and glyphs)
            gridPath.Fill = doc.CreateVisualBrush(visualCanvas,
                                                  new RectangleF(0f, 0f, 10f, 10f), new RectangleF(0f, 0f, 10f, 10f));
            ((XpsVisualBrush)gridPath.Fill).TileMode = XpsTileMode.Tile;
            // New canvas
            XpsCanvas canvas = doc.AddCanvas();

            canvas.RenderTransform = doc.CreateMatrix(1f, 0f, 0f, 1f, 268f, 70f);
            // Add grid
            canvas.AddPath(gridPath);
            // Red transparent rectangle in the middle top
            XpsPath path = canvas.AddPath(doc.CreatePathGeometry("M 30,20 l 258.24,0 0,56.64 -258.24,0 Z"));

            path         = canvas.AddPath(doc.CreatePathGeometry("M 10,10 L 228,10 228,100 10,100"));
            path.Fill    = doc.CreateSolidColorBrush(doc.CreateColor(1.0f, 0.0f, 0.0f));
            path.Opacity = 0.7f;
            // Save resultant XPS document
            doc.Save(dataDir + "AddGrid_out.xps");
            // ExEnd:1
        }
Пример #5
0
        public static void Run()
        {
            // ExStart:1
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_WorkingWithGradient();
            // Create new XPS Document
            XpsDocument doc = new XpsDocument();
            // Initialize List of XpsGradentStop
            List <XpsGradientStop> stops = new List <XpsGradientStop>();

            stops.Add(doc.CreateGradientStop(doc.CreateColor(255, 244, 253, 225), 0.0673828f));
            stops.Add(doc.CreateGradientStop(doc.CreateColor(255, 251, 240, 23), 0.314453f));
            stops.Add(doc.CreateGradientStop(doc.CreateColor(255, 252, 209, 0), 0.482422f));
            stops.Add(doc.CreateGradientStop(doc.CreateColor(255, 241, 254, 161), 0.634766f));
            stops.Add(doc.CreateGradientStop(doc.CreateColor(255, 53, 253, 255), 0.915039f));
            stops.Add(doc.CreateGradientStop(doc.CreateColor(255, 12, 91, 248), 1f));
            // Create new path by defining geometery in abbreviation form
            XpsPath path = doc.AddPath(doc.CreatePathGeometry("M 10,210 L 228,210 228,300 10,300"));

            path.RenderTransform = doc.CreateMatrix(1f, 0f, 0f, 1f, 20f, 70f);
            path.Fill            = doc.CreateLinearGradientBrush(new PointF(10f, 0f), new PointF(228f, 0f));
            ((XpsGradientBrush)path.Fill).GradientStops.AddRange(stops);
            // Save resultant XPS document
            doc.Save(dataDir + "AddHorizontalGradient_out.xps");
            // ExEnd:1
        }
        public static void Run()
        {
            // ExStart:1
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_WorkingWithShapes();
            // Create new XPS Document
            XpsDocument doc = new XpsDocument();
            // CMYK (blue) solid color stroked rectangle in the lower left
            XpsPath path = doc.AddPath(doc.CreatePathGeometry("M 20,10 L 220,10 220,100 20,100 Z"));

            path.Stroke = doc.CreateSolidColorBrush(
                doc.CreateColor(dataDir + "uswebuncoated.icc", 1.0f, 1.000f, 0.000f, 0.000f, 0.000f));
            path.StrokeThickness = 12f;
            // Save resultant XPS document
            doc.Save(dataDir + "AddRectangle_out.xps");
            // ExEnd:1
        }
        public static void Run()
        {
            // ExStart:1
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_WorkingWithTransparency();
            // Create new XPS Document
            XpsDocument doc = new XpsDocument();
            //Add Canvas to XpsDocument instance
            XpsCanvas canvas = doc.AddCanvas();
            // Rectangle with opacity masked by ImageBrush
            XpsPath path = canvas.AddPath(doc.CreatePathGeometry("M 10,180 L 228,180 228,285 10,285"));

            path.Fill        = doc.CreateSolidColorBrush(doc.CreateColor(1.0f, 0.0f, 0.0f));
            path.OpacityMask = doc.CreateImageBrush(dataDir + "R08SY_NN.tif", new RectangleF(0f, 0f, 128f, 192f),
                                                    new RectangleF(0f, 0f, 64f, 96f));
            ((XpsImageBrush)path.OpacityMask).TileMode = XpsTileMode.Tile;
            // Save resultant XPS document
            doc.Save(dataDir + "OpacityMask_out.xps");
            // ExEnd:1
        }