Exemple #1
0
        NRadialGradientFill TwoGradientStops_Zoom()
        {
            NRadialGradientFill rgf = new NRadialGradientFill();

            rgf.GradientStops.Add(new NGradientStop(0, NColor.AliceBlue));
            rgf.GradientStops.Add(new NGradientStop(1, NColor.DarkSlateBlue));
            // FIX: Gradient Transform
            // rgf.MappingMode = ENGradientMappingMode.ZoomToFill;
            return(rgf);
        }
        void PaintEllipse(NPaintVisitor paintVisitor, double w, double h)
        {
            NRadialGradientFill rgf = new NRadialGradientFill();

            rgf.GradientStops.Add(new NGradientStop(0, NColor.Indigo));
            rgf.GradientStops.Add(new NGradientStop(0.6f, NColor.SlateBlue));
            rgf.GradientStops.Add(new NGradientStop(1, new NColor(NColor.Crimson, 30)));

            paintVisitor.SetStroke(NColor.Black, 1);
            paintVisitor.SetFill(rgf);

            paintVisitor.PaintEllipse(0.2 * w, 0.3 * h, 0.6 * w, 0.4 * h);
        }
Exemple #3
0
        NRadialGradientFill ShiftedFocus_Zoom()
        {
            NRadialGradientFill rgf = new NRadialGradientFill();

            rgf.GradientStops.Add(new NGradientStop(0.0f, NColor.White));
            rgf.GradientStops.Add(new NGradientStop(0.4f, NColor.Red));
            rgf.GradientStops.Add(new NGradientStop(1.0f, NColor.Black));
            rgf.FocusFactorX = -0.6f;
            rgf.FocusFactorY = -0.6f;
            // FIX: Radial Gradient
            // rgf.MappingMode = ENGradientMappingMode.ZoomToFill;
            return(rgf);
        }
Exemple #4
0
        NRadialGradientFill FiveGradientStops_Zoom()
        {
            NRadialGradientFill rgf = new NRadialGradientFill();

            rgf.GradientStops.Add(new NGradientStop(0.00f, NColor.Red));
            rgf.GradientStops.Add(new NGradientStop(0.25f, NColor.Yellow));
            rgf.GradientStops.Add(new NGradientStop(0.50f, NColor.LimeGreen));
            rgf.GradientStops.Add(new NGradientStop(0.75f, NColor.MediumBlue));
            rgf.GradientStops.Add(new NGradientStop(1.00f, NColor.DarkViolet));
            // FIX: Gradient Transform
            // rgf.MappingMode = ENGradientMappingMode.ZoomToFill;
            return(rgf);
        }
Exemple #5
0
        /// <summary>
        /// Static constructor.
        /// </summary>
        static NStyleNode()
        {
            defaultLinearGradientFill = new NLinearGradientFill();
            defaultLinearGradientFill.GradientStops.Add(new NGradientStop(0.0f, NColor.Red));
            defaultLinearGradientFill.GradientStops.Add(new NGradientStop(0.5f, NColor.Yellow));
            defaultLinearGradientFill.GradientStops.Add(new NGradientStop(1.0f, NColor.Indigo));

            defaultRadialGradientFill = new NRadialGradientFill();
            defaultRadialGradientFill.GradientStops.Add(new NGradientStop(0.0f, NColor.Red));
            defaultRadialGradientFill.GradientStops.Add(new NGradientStop(0.5f, NColor.Yellow));
            defaultRadialGradientFill.GradientStops.Add(new NGradientStop(1.0f, NColor.Indigo));

            defaultAdvancedGradientFill = new NAdvancedGradientFill();
            defaultAdvancedGradientFill.Points.Add(new NAdvancedGradientPoint(NColor.Red, NAngle.Zero, 0, 0, 1, ENAdvancedGradientPointShape.Circle));
            defaultAdvancedGradientFill.Points.Add(new NAdvancedGradientPoint(NColor.Blue, NAngle.Zero, 1, 1, 1, ENAdvancedGradientPointShape.Circle));

            NStyleNodeSchema = NSchema.Create(typeof(NStyleNode), NNode.NNodeSchema);

            // Properties - fill
            FillProperty                 = NStyleNodeSchema.AddSlot("Fill", typeof(NFill), defaultFill);
            ColorFillProperty            = NStyleNodeSchema.AddSlot("ColorFill", typeof(NColorFill), defaultColorFill);
            StockGradientFillProperty    = NStyleNodeSchema.AddSlot("StockGradientFill", typeof(NStockGradientFill), defaultStockGradientFill);
            LinearGradientFillProperty   = NStyleNodeSchema.AddSlot("LinearGradientFill", typeof(NLinearGradientFill), defaultLinearGradientFill);
            RadialGradientFillProperty   = NStyleNodeSchema.AddSlot("RadialGradientFill", typeof(NRadialGradientFill), defaultRadialGradientFill);
            AdvancedGradientFillProperty = NStyleNodeSchema.AddSlot("AdvancedGradientFill", typeof(NAdvancedGradientFill), defaultAdvancedGradientFill);
            HatchFillProperty            = NStyleNodeSchema.AddSlot("HatchFill", typeof(NHatchFill), defaultHatchFill);
            ImageFillProperty            = NStyleNodeSchema.AddSlot("ImageFill", typeof(NImageFill), defaultImageFill);

            // Broperties - border
            BorderProperty = NStyleNodeSchema.AddSlot("Border", typeof(NBorder), defaultBorder);

            // Broperties - stroke
            StrokeProperty = NStyleNodeSchema.AddSlot("Stroke", typeof(NStroke), defaultStroke);

            // Properties - font
            FontProperty = NStyleNodeSchema.AddSlot("Font", typeof(NFont), defaultFont);

            // Constants
            Designers = new NDesigner[] {
                new NStyleNodeHStackDesigner(),
                new NStyleNodeVStackDesigner(),
                new NStyleNodeTabDesigner(),
                new NStyleNodeMixedDesigner()
            };
        }
Exemple #6
0
        NRadialGradientFill ShiftedCenter_Zoom()
        {
            NRadialGradientFill rgf = new NRadialGradientFill();

            rgf.GradientStops.Add(new NGradientStop(0.0f, NColor.Crimson));
            rgf.GradientStops.Add(new NGradientStop(0.5f, NColor.Goldenrod));
            rgf.GradientStops.Add(new NGradientStop(0.6f, NColor.Indigo));
            rgf.GradientStops.Add(new NGradientStop(1.0f, NColor.Thistle));
            // FIX: Gradient Transform
            // rgf.MappingMode = ENGradientMappingMode.ZoomToFill;

            // The center coordinates are specified with values between 0 and 1
            // FIX: Radial Gradient
            // rgf.CenterFactorX = 0.0f;
            // rgf.CenterFactorY = 1.0f;

            return(rgf);
        }
Exemple #7
0
        protected override NWidget CreateExampleContent()
        {
            // Create a table panel to hold the canvases and the labels
            m_Table = new NTableFlowPanel();
            m_Table.HorizontalPlacement = ENHorizontalPlacement.Left;
            m_Table.VerticalPlacement   = ENVerticalPlacement.Top;
            m_Table.Padding             = new NMargins(30);
            m_Table.HorizontalSpacing   = 30;
            m_Table.VerticalSpacing     = 30;
            m_Table.MaxOrdinal          = 2;

            string[] texts = new string[]
            {
                "Two Gradient Stops (Stretch Mapping)",
                "Two Gradient Stops (ZoomToFill Mapping)",
                "Five Gradient Stops (Stretch Mapping)",
                "Five Gradient Stops (ZoomToFill Mapping)",
                "Shifted Gradient Center (Stretch Mapping)",
                "Shifted Gradient Center (ZoomToFill Mapping)",
                "Shifted Gradient Focus (Stretch Mapping)",
                "Shifted Gradient Focus (ZoomToFill Mapping)",
            };

            NRadialGradientFill[] fills = new NRadialGradientFill[]
            {
                TwoGradientStops_Stretch(),
                TwoGradientStops_Zoom(),
                FiveGradientStops_Stretch(),
                FiveGradientStops_Zoom(),
                ShiftedCenter_Stretch(),
                ShiftedCenter_Zoom(),
                ShiftedFocus_Stretch(),
                ShiftedFocus_Zoom()
            };

            // Add a canvas for each demonstrated gradient
            for (int i = 0; i < fills.Length; i++)
            {
                NStackPanel stack = new NStackPanel();
                m_Table.Add(stack);
                stack.Direction = ENHVDirection.TopToBottom;
                stack.FillMode  = ENStackFillMode.First;
                stack.FitMode   = ENStackFitMode.First;

                // Create a widget with the proper filling
                NCanvas canvas = new NCanvas();
                canvas.PreferredSize = new NSize(defaultCanvasWidth, defaultCanvasHeight);
                canvas.Tag           = fills[i];
                stack.Add(canvas);
                canvas.PrePaint += new Function <NCanvasPaintEventArgs>(OnCanvasPrePaint);

                // Create a label with the corresponding name
                NLabel label = new NLabel(texts[i]);
                stack.Add(label);
                label.HorizontalPlacement = ENHorizontalPlacement.Center;
            }

            // The table must be scrollable
            NScrollContent scroll = new NScrollContent();

            scroll.Content = m_Table;
            return(scroll);
        }