Beispiel #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
        }
Beispiel #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
        }
Beispiel #4
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
        }