コード例 #1
0
ファイル: ScCheckBox.cs プロジェクト: zanderzhg/Sc
        void FillIn2(D2DGraphics g, Color boxColor)
        {
            RawRectangleF rect = new RawRectangleF(0, 0, Width, Height);
            RadialGradientBrushProperties props2 = new RadialGradientBrushProperties()
            {
                Center = new RawVector2((rect.Left + rect.Right) / 2, (rect.Top + rect.Bottom) / 2),
                GradientOriginOffset = new RawVector2(0, 0),
                RadiusX = Width / 2,
                RadiusY = Height / 2
            };

            GradientStop[] gradientStops2 = new GradientStop[2];

            gradientStops2[0].Color    = GDIDataD2DUtils.TransToRawColor4(Color.FromArgb(55, boxColor.R, boxColor.G, boxColor.B));
            gradientStops2[0].Position = 0f;


            //gradientStops2[1].Color = GDIDataD2DUtils.TransToRawColor4(Color.FromArgb(40, 0,0,255));
            //gradientStops2[1].Position = 0.5f;

            gradientStops2[1].Color    = GDIDataD2DUtils.TransToRawColor4(Color.FromArgb(55, boxColor.R, boxColor.G, boxColor.B));
            gradientStops2[1].Position = 1f;

            //
            GradientStopCollection gradientStopCollection2 = new GradientStopCollection(g.RenderTarget, gradientStops2, Gamma.StandardRgb, ExtendMode.Clamp);
            RadialGradientBrush    radialGradientBrush     = new RadialGradientBrush(g.RenderTarget, props2, gradientStopCollection2);

            g.RenderTarget.FillRectangle(rect, radialGradientBrush);

            gradientStopCollection2.Dispose();
            radialGradientBrush.Dispose();
        }
コード例 #2
0
ファイル: ScButton.cs プロジェクト: lypvc/Sc
        void FillItemGeometry(D2DGraphics g)
        {
            if (Enable == false)
            {
                color = Color.DarkGray;
            }

            g.RenderTarget.AntialiasMode = AntialiasMode.PerPrimitive;
            RawRectangleF    rect        = new RawRectangleF(1, 1, Width - 1, Height - 1);
            RoundedRectangle roundedRect = new RoundedRectangle()
            {
                RadiusX = this.RadiusX,
                RadiusY = this.RadiusY,
                Rect    = rect
            };

            RawColor4       rawColor = GDIDataD2DUtils.TransToRawColor4(color);
            SolidColorBrush brush    = new SolidColorBrush(g.RenderTarget, rawColor);

            g.RenderTarget.FillRoundedRectangle(roundedRect, brush);

            rawColor = GDIDataD2DUtils.TransToRawColor4(Color.FromArgb(SideShadowAlpha, 0, 0, 0));
            brush    = new SolidColorBrush(g.RenderTarget, rawColor);
            g.RenderTarget.DrawRoundedRectangle(roundedRect, brush);
        }
コード例 #3
0
ファイル: ScLayer.cs プロジェクト: zanderzhg/Sc
        public virtual void OnD2DPaint(ScGraphics g)
        {
            D2DGraphics d2dGraph = (D2DGraphics)g;

            if (d2dGraph == null)
            {
                return;
            }

            if (BackgroundColor != null && BackgroundColor.Value.A != 0)
            {
                if (BackgroundColor.Value.A == 255)
                {
                    RawColor4 color = GDIDataD2DUtils.TransToRawColor4(Color.FromArgb(BackgroundColor.Value.ToArgb()));
                    d2dGraph.RenderTarget.Clear(color);
                }
                else
                {
                    d2dGraph.RenderTarget.AntialiasMode = AntialiasMode.Aliased;
                    RawRectangleF   rect     = new RawRectangleF(0, 0, Width, Height);
                    RawColor4       rawColor = GDIDataD2DUtils.TransToRawColor4(BackgroundColor.Value);
                    SolidColorBrush brush    = new SolidColorBrush(d2dGraph.RenderTarget, rawColor);
                    d2dGraph.RenderTarget.FillRectangle(rect, brush);
                    brush.Dispose();
                }
            }

            if (D2DPaint != null)
            {
                D2DPaint(d2dGraph);
            }
        }
コード例 #4
0
        private void PrePlane_D2DPaint(D2DGraphics g)
        {
            RawRectangleF rect = new RawRectangleF(0, 0, prePlane.Width, prePlane.Height);

            Color color    = Color.Black;
            Color orgColor = Color.FromArgb(158, 105, 7);

            switch (preBtnMouseState)
            {
            case 0:
                color = Color.FromArgb(200, orgColor);
                break;

            case 1:
                color = Color.FromArgb(100, orgColor);
                break;

            case 2:
                color = Color.FromArgb(50, orgColor);
                break;
            }


            RawColor4 rawColor = GDIDataD2DUtils.TransToRawColor4(color);

            SharpDX.Direct2D1.Brush brush = new SolidColorBrush(g.RenderTarget, rawColor);
            g.RenderTarget.FillRectangle(rect, brush);
        }
コード例 #5
0
ファイル: ScCheckBox.cs プロジェクト: zanderzhg/Sc
        void PaintState2(D2DGraphics g)
        {
            g.RenderTarget.AntialiasMode = AntialiasMode.Aliased;
            RawRectangleF rect = new RawRectangleF(1, 1, Width - 1, Height - 1);

            int a = Math.Min(BoxColor.A + 100, 255);
            int R = Math.Max(BoxColor.R - 130, 0);
            int G = Math.Max(BoxColor.G - 130, 0);
            int B = Math.Max(BoxColor.B - 130, 0);

            RawColor4       rawColor = GDIDataD2DUtils.TransToRawColor4(Color.FromArgb(a, R, G, B));
            SolidColorBrush brush    = new SolidColorBrush(g.RenderTarget, rawColor);

            g.RenderTarget.DrawRectangle(rect, brush, boxSideWidth);
            brush.Dispose();


            R = Math.Max(FillInBoxColor.R - 50, 0);
            G = Math.Max(FillInBoxColor.G - 50, 0);
            B = Math.Max(FillInBoxColor.B - 50, 0);

            if (IsUseInFill)
            {
                FillIn(g, Color.FromArgb(FillInBoxColor.A, R, G, B));
            }

            if (IsUseInFill2)
            {
                FillIn2(g, Color.FromArgb(FillInBoxColor.A, R, G, B));
            }
        }
コード例 #6
0
ファイル: ScTabHeadItem.cs プロジェクト: zanderzhg/Sc
        void FillItemGeometry(D2DGraphics g)
        {
            RectangleF rect = new RectangleF(0, 0, Width, Height);

            PathGeometry pathGeometry = new PathGeometry(D2DGraphics.d2dFactory);

            GeometrySink pSink = null;

            pSink = pathGeometry.Open();
            pSink.SetFillMode(SharpDX.Direct2D1.FillMode.Winding);

            pSink.BeginFigure(new RawVector2(rect.Left, rect.Bottom), FigureBegin.Filled);

            float len = gradientSize;

            RawVector2[] points =
            {
                new RawVector2(rect.Left + len,  rect.Top),
                new RawVector2(rect.Right - len, rect.Top),
                new RawVector2(rect.Right,       rect.Bottom),
            };

            pSink.AddLines(points);
            pSink.EndFigure(FigureEnd.Closed);
            pSink.Close();
            pSink.Dispose();

            RawColor4       rawColor = GDIDataD2DUtils.TransToRawColor4(color);
            SolidColorBrush brush    = new SolidColorBrush(g.RenderTarget, rawColor);

            g.RenderTarget.FillGeometry(pathGeometry, brush);
        }
コード例 #7
0
        private void Screen2_D2DPaint(D2DGraphics g)
        {
            g.RenderTarget.AntialiasMode = AntialiasMode.Aliased;

            RawRectangleF   rect     = new RawRectangleF(0, 0, (float)Math.Ceiling(screen2.Width - 1), (float)Math.Ceiling(screen2.Height - 1));
            RawColor4       rawColor = GDIDataD2DUtils.TransToRawColor4(Color.FromArgb(100, 0, 255, 0));
            SolidColorBrush brush    = new SolidColorBrush(g.RenderTarget, rawColor);

            g.RenderTarget.FillRectangle(rect, brush);
        }
コード例 #8
0
        private void TabBodyBox_D2DPaint(D2DGraphics g)
        {
            RawRectangleF rect    = new RawRectangleF(0, 0, tabBodyBox.Width, tabBodyBox.Height);
            PathGeometry  pathGeo = DrawUtils.CreateOutlineRoundRectGeometry(g, rect, 6);

            RawColor4       rawColor = GDIDataD2DUtils.TransToRawColor4(Color.FromArgb(255, 191, 152, 90));
            SolidColorBrush brush    = new SolidColorBrush(g.RenderTarget, rawColor);

            g.RenderTarget.FillGeometry(pathGeo, brush);
        }
コード例 #9
0
ファイル: ScLayer.cs プロジェクト: zanderzhg/Sc
        private void DebugLayer_D2DPaint(D2DGraphics g)
        {
            g.RenderTarget.AntialiasMode = AntialiasMode.PerPrimitive;
            RawRectangleF   rect     = new RawRectangleF(1, 1, Width - 1, Height - 1);
            RawColor4       rawColor = GDIDataD2DUtils.TransToRawColor4(Color.DarkBlue);
            SolidColorBrush brush    = new SolidColorBrush(g.RenderTarget, rawColor);


            //宽度
            TextFormat textFormat = new TextFormat(D2DGraphics.dwriteFactory, "微软雅黑", 12)
            {
                TextAlignment = TextAlignment.Center, ParagraphAlignment = ParagraphAlignment.Center
            };
            RawRectangleF rectw = new RawRectangleF(0, Height - 20, Width - 1, Height - 1);

            g.RenderTarget.DrawText(Width.ToString(), textFormat, rectw, brush);

            //高度
            TextFormat textFormat2 = new TextFormat(D2DGraphics.dwriteFactory, "微软雅黑", 12)
            {
                TextAlignment = TextAlignment.Center, ParagraphAlignment = ParagraphAlignment.Center, FlowDirection = SharpDX.DirectWrite.FlowDirection.TopToBottom
            };
            RawRectangleF recth = new RawRectangleF(Width - 10, 0, Width - 1, Height - 1);

            g.RenderTarget.DrawText(Height.ToString(), textFormat2, recth, brush);


            //全局坐标位置
            PointF pt = parent.TransLocalToGlobal(Location);

            textFormat.ParagraphAlignment = ParagraphAlignment.Near;
            textFormat.TextAlignment      = TextAlignment.Justified;
            RawRectangleF rectxy = new RawRectangleF(0, 0, Width - 1, 10);

            g.RenderTarget.DrawText(pt.ToString(), textFormat, rectxy, brush);


            //层类名称
            string mm = this.GetType().Name;

            if (!string.IsNullOrWhiteSpace(Name))
            {
                mm += "(" + Name + ")";
            }


            textFormat.ParagraphAlignment = ParagraphAlignment.Center;
            textFormat.TextAlignment      = TextAlignment.Center;
            RawRectangleF rectname = new RawRectangleF(0, 0, Width - 1, 10);

            g.RenderTarget.DrawText(mm, textFormat, rectxy, brush);

            g.RenderTarget.DrawRectangle(rect, brush, 1f);
        }
コード例 #10
0
        private void Selector_D2DPaint(D2DGraphics g)
        {
            if (!IsSelected)
            {
                return;
            }

            g.RenderTarget.AntialiasMode = AntialiasMode.Aliased;
            RawRectangleF   rect     = new RawRectangleF(1, 1, selector.Width - 2, selector.Height - 9);
            RawColor4       rawColor = GDIDataD2DUtils.TransToRawColor4(SelectorColor);
            SolidColorBrush brush    = new SolidColorBrush(g.RenderTarget, rawColor);

            RoundedRectangle rounderRect = new RoundedRectangle
            {
                RadiusX = 1,
                RadiusY = 1,
                Rect    = rect
            };

            g.RenderTarget.DrawRoundedRectangle(rounderRect, brush, 2f);
            brush.Dispose();


            //
            GradientStop[] gradientStops = new GradientStop[2];
            gradientStops[0].Color    = new RawColor4(0, 0, 0, 0.1f);
            gradientStops[0].Position = 0f;
            gradientStops[1].Color    = new RawColor4(0, 0, 0, 0);
            gradientStops[1].Position = 1f;

            //
            GradientStopCollection gradientStopCollection = new GradientStopCollection(g.RenderTarget, gradientStops, Gamma.StandardRgb, ExtendMode.Clamp);

            //
            rect = new RawRectangleF(0, selector.Height - 9, selector.Width - 1, selector.Height - 1);
            LinearGradientBrushProperties props = new LinearGradientBrushProperties()
            {
                StartPoint = new RawVector2(rect.Left, rect.Top),
                EndPoint   = new RawVector2(rect.Left, rect.Bottom)
            };

            SharpDX.Direct2D1.LinearGradientBrush linearGradientBrush = new SharpDX.Direct2D1.LinearGradientBrush(g.RenderTarget, props, gradientStopCollection);
            g.RenderTarget.FillRectangle(rect, linearGradientBrush);
            gradientStopCollection.Dispose();
            linearGradientBrush.Dispose();

            //Graphics gdiGraphics = g.CreateGdiGraphics();
            //gdiGraphics.SmoothingMode = SmoothingMode.HighQuality;
            //RectangleF rect1 = new RectangleF(0, 0, (float)Math.Ceiling(Width - 1), (float)Math.Ceiling(Height - 1));
            //Pen pen = new Pen(Color.FromArgb(255, 191, 152, 90), 1f);
            //DrawUtils.DrawRoundRectangle(gdiGraphics, Pens.Gold, rect1, 4);
            //g.RelaseGdiGraphics(gdiGraphics);
            //pen.Dispose();
        }
コード例 #11
0
        private void ScLayerLayoutViewerHeaderItem_D2DPaint(D2DGraphics g)
        {
            g.RenderTarget.AntialiasMode = AntialiasMode.Aliased;
            RawRectangleF   rect     = new RawRectangleF(0, 0, Width - 1, Height - 1);
            RawColor4       rawColor = GDIDataD2DUtils.TransToRawColor4(Color.FromArgb(55, 0, 0, 255));
            SolidColorBrush brush    = new SolidColorBrush(g.RenderTarget, rawColor);

            g.RenderTarget.FillRectangle(rect, brush);

            brush.Dispose();
        }
コード例 #12
0
ファイル: ScScrollBarSlider.cs プロジェクト: zanderzhg/Sc
        private void ScScrollBarSlider_D2DPaint(D2DGraphics g)
        {
            g.RenderTarget.AntialiasMode = AntialiasMode.Aliased;

            RawRectangleF rect = new RawRectangleF(2, 0, Width - 2, Height);

            RawColor4 color = GDIDataD2DUtils.TransToRawColor4(Color.FromArgb(alpha, 191, 152, 90));

            SharpDX.Direct2D1.Brush brush = new SolidColorBrush(g.RenderTarget, color);

            g.RenderTarget.FillRectangle(rect, brush);
        }
コード例 #13
0
        private void ScTextBoxEx_D2DPaint(D2DGraphics g)
        {
            g.RenderTarget.AntialiasMode = AntialiasMode.Aliased;

            RawRectangleF rect = new RawRectangleF(2, 2, Width - 1, Height - 1);

            // PathGeometry pathGeometry = new PathGeometry(D2DGraphics.d2dFactory);

            // PathGeometry pathGeometry = DrawUtils.CreateOutlineRoundRectGeometry(g, rect, 4);

            //ID2D1StrokeStyle* g_stroke_style; // 声明线条风格接口
            //g_pD2DFactory->CreateStrokeStyle(D2D1::StrokeStyleProperties(
            //                D2D1_CAP_STYLE_ROUND,
            //                D2D1_CAP_STYLE_ROUND,
            //                D2D1_CAP_STYLE_ROUND,
            //                D2D1_LINE_JOIN_MITER,
            //                1.0f,
            //                D2D1_DASH_STYLE_SOLID, // 有多种风格可以设置(dash,dot....)
            //                10.0f),
            //            NULL,
            //            0,
            //            &g_stroke_style);


            RoundedRectangle roundedRect = new RoundedRectangle()
            {
                RadiusX = 4,
                RadiusY = 4,
                Rect    = rect
            };



            RawColor4       rawColor = GDIDataD2DUtils.TransToRawColor4(Color.FromArgb(255, 200, 200, 200));
            SolidColorBrush brush    = new SolidColorBrush(g.RenderTarget, rawColor);

            g.RenderTarget.DrawRectangle(rect, brush, 1f);

            //Graphics gdiGraphics = g.CreateGdiGraphics();

            //gdiGraphics.SmoothingMode = SmoothingMode.HighQuality;
            //RectangleF rect1 = new RectangleF(0, 0, (float)Math.Ceiling(Width - 1), (float)Math.Ceiling(Height - 1));
            //Pen pen = new Pen(Color.FromArgb(255, 191, 152, 90), 1f);
            //DrawUtils.DrawRoundRectangle(gdiGraphics, Pens.Gold, rect1, 4);

            //g.RelaseGdiGraphics(gdiGraphics);



            // g.RenderTarget.DrawGeometry(pathGeometry, brush);
        }
コード例 #14
0
        private void RootScControl_D2DPaint(D2DGraphics g)
        {
            RawRectangleF rect = new RawRectangleF(0, 0, rootScLayer.Width, rootScLayer.Height);

            if (BackgroundColor != null)
            {
                RawColor4 color = GDIDataD2DUtils.TransToRawColor4(BackgroundColor.Value);
                g.RenderTarget.Clear(color);
            }
            else if (controlType == ControlType.UPDATELAYERFORM)
            {
                g.RenderTarget.Clear(new RawColor4(0, 0, 0, 0));
            }
        }
コード例 #15
0
        private void ScLayerLayoutViewerHeaderItemContainer_D2DPaint(D2DGraphics g)
        {
            switch (StyleIdx)
            {
            case 1:
                g.RenderTarget.AntialiasMode = AntialiasMode.Aliased;
                RawRectangleF   rect     = new RawRectangleF(0, 0, Width, Height);
                RawColor4       rawColor = GDIDataD2DUtils.TransToRawColor4(BackGroundColor);
                SolidColorBrush brush    = new SolidColorBrush(g.RenderTarget, rawColor);
                g.RenderTarget.FillRectangle(rect, brush);

                brush.Dispose();
                break;
            }
        }
コード例 #16
0
ファイル: ScCheckBox.cs プロジェクト: zanderzhg/Sc
        void PaintState0(D2DGraphics g)
        {
            g.RenderTarget.AntialiasMode = AntialiasMode.Aliased;

            RawRectangleF   rect     = new RawRectangleF(1, 1, Width - 1, Height - 1);
            RawColor4       rawColor = GDIDataD2DUtils.TransToRawColor4(BoxColor);
            SolidColorBrush brush    = new SolidColorBrush(g.RenderTarget, rawColor);

            g.RenderTarget.DrawRectangle(rect, brush, boxSideWidth);
            brush.Dispose();

            if (IsUseInFill)
            {
                FillIn(g, Color.FromArgb(50, BoxColor.R, BoxColor.G, BoxColor.B));
            }
        }
コード例 #17
0
ファイル: ScTitleButton.cs プロジェクト: zanderzhg/Sc
        void DrawString(D2DGraphics g)
        {
            if (!string.IsNullOrWhiteSpace(Text))
            {
                g.RenderTarget.AntialiasMode = AntialiasMode.PerPrimitive;
                RawRectangleF rect = new RawRectangleF(0, 0, Width - 1, Height - 1);


                SolidColorBrush brush      = new SolidColorBrush(g.RenderTarget, GDIDataD2DUtils.TransToRawColor4(fontColor));
                TextFormat      textFormat = new TextFormat(D2DGraphics.dwriteFactory, foreFont.FamilyName, foreFont.Weight, foreFont.Style, foreFont.Size)
                {
                    TextAlignment = TextAlignment.Center, ParagraphAlignment = ParagraphAlignment.Center
                };

                textFormat.WordWrapping = WordWrapping.Wrap;

                g.RenderTarget.DrawText(Text, textFormat, rect, brush, DrawTextOptions.Clip);
            }
        }
コード例 #18
0
ファイル: ScLabel.cs プロジェクト: lypvc/Sc
        private void ScLabel_D2DPaint(D2DGraphics g)
        {
            RawRectangleF rect = new RawRectangleF(TextPadding.left, TextPadding.top, Width - TextPadding.left - TextPadding.right, Height - TextPadding.top - TextPadding.bottom);

            if (!string.IsNullOrWhiteSpace(Text))
            {
                SolidColorBrush brush      = new SolidColorBrush(g.RenderTarget, GDIDataD2DUtils.TransToRawColor4(ForeColor));
                TextFormat      textFormat = new TextFormat(D2DGraphics.dwriteFactory, foreFont.FamilyName, foreFont.Weight, foreFont.Style, foreFont.Size)
                {
                    TextAlignment = Alignment, ParagraphAlignment = ParagraphAlignment.Center
                };

                textFormat.WordWrapping = WordWrapping.Wrap;

                g.RenderTarget.DrawText(Text, textFormat, rect, brush, DrawTextOptions.Clip);
                brush.Dispose();
                textFormat.Dispose();
            }
        }
コード例 #19
0
ファイル: ScCheckBox.cs プロジェクト: zanderzhg/Sc
        void DrawCheck(D2DGraphics g)
        {
            g.RenderTarget.AntialiasMode = AntialiasMode.PerPrimitive;
            Geometry checkGeometry = null;

            switch (CheckType)
            {
            case 0: checkGeometry = CreateCheckGeometry0(g); break;

            case 1: checkGeometry = CreateCheckGeometry1(g); break;

            default: checkGeometry = CreateCheckGeometry0(g); break;
            }

            RawColor4       rawColor = GDIDataD2DUtils.TransToRawColor4(CheckColor);
            SolidColorBrush brush    = new SolidColorBrush(g.RenderTarget, rawColor);

            g.RenderTarget.FillGeometry(checkGeometry, brush);
            brush.Dispose();
            checkGeometry.Dispose();
        }
コード例 #20
0
ファイル: ScPanel.cs プロジェクト: lypvc/Sc
        private void ScPanel_D2DPaint(D2DGraphics g)
        {
            g.RenderTarget.AntialiasMode = AntialiasMode.Aliased;

            RawRectangleF   rect     = new RawRectangleF(0, 1, Width - 1, Height - 1);
            RawColor4       rawColor = GDIDataD2DUtils.TransToRawColor4(Color.FromArgb(255, 241, 251, 253));
            SolidColorBrush brush    = new SolidColorBrush(g.RenderTarget, rawColor);

            g.RenderTarget.FillRectangle(rect, brush);

            rect     = new RawRectangleF(0, 0, Width - 1, 10 - 1);
            rawColor = GDIDataD2DUtils.TransToRawColor4(Color.FromArgb(255, 122, 151, 207));
            brush    = new SolidColorBrush(g.RenderTarget, rawColor);
            g.RenderTarget.FillRectangle(rect, brush);


            rect     = new RawRectangleF(1, 1, Width - 1, Height - 1);
            rawColor = GDIDataD2DUtils.TransToRawColor4(Color.FromArgb(255, 214, 215, 220));
            brush    = new SolidColorBrush(g.RenderTarget, rawColor);
            g.RenderTarget.DrawRectangle(rect, brush);
        }
コード例 #21
0
        private void RootScControl_D2DPaint(D2DGraphics g)
        {
            RawRectangleF rect = new RawRectangleF(0, 0, rootScLayer.Width, rootScLayer.Height);

            if (BackgroundColor != null)
            {
                if (BackgroundColor.Value.A == 255)
                {
                    RawColor4 color = GDIDataD2DUtils.TransToRawColor4(Color.FromArgb(BackgroundColor.Value.ToArgb()));
                    g.RenderTarget.Clear(color);
                }
                else
                {
                    g.RenderTarget.AntialiasMode = AntialiasMode.Aliased;
                    RawColor4       rawColor = GDIDataD2DUtils.TransToRawColor4(BackgroundColor.Value);
                    SolidColorBrush brush    = new SolidColorBrush(g.RenderTarget, rawColor);
                    g.RenderTarget.FillRectangle(rect, brush);
                    brush.Dispose();
                }
            }
        }
コード例 #22
0
ファイル: ScCheckBox.cs プロジェクト: zanderzhg/Sc
        void FillIn(D2DGraphics g, Color boxColor)
        {
            RawRectangleF   rect     = new RawRectangleF(FillMargin.left + 1, FillMargin.top + 1, Width - FillMargin.right, Height - FillMargin.bottom);
            RawColor4       rawColor = GDIDataD2DUtils.TransToRawColor4(boxColor);
            SolidColorBrush brush    = new SolidColorBrush(g.RenderTarget, rawColor);

            g.RenderTarget.DrawRectangle(rect, brush, 1);
            brush.Dispose();

            //
            RawRectangleF fillRect = new RawRectangleF(FillMargin.left, FillMargin.top, Width - FillMargin.right, Height - FillMargin.bottom);

            g.RenderTarget.AntialiasMode = AntialiasMode.PerPrimitive;
            GradientStop[] gradientStops = new GradientStop[3];


            gradientStops[0].Color    = GDIDataD2DUtils.TransToRawColor4(Color.FromArgb(255, boxColor.R, boxColor.G, boxColor.B));
            gradientStops[0].Position = 0f;


            gradientStops[1].Color    = GDIDataD2DUtils.TransToRawColor4(Color.FromArgb(20, boxColor.R, boxColor.G, boxColor.B));
            gradientStops[1].Position = 0.5f;

            gradientStops[2].Color    = GDIDataD2DUtils.TransToRawColor4(Color.FromArgb(0, boxColor.R, boxColor.G, boxColor.B));
            gradientStops[2].Position = 1f;

            //
            GradientStopCollection gradientStopCollection = new GradientStopCollection(g.RenderTarget, gradientStops, Gamma.StandardRgb, ExtendMode.Clamp);

            LinearGradientBrushProperties props = new LinearGradientBrushProperties()
            {
                StartPoint = new RawVector2(fillRect.Left, fillRect.Top),
                EndPoint   = new RawVector2(fillRect.Right, fillRect.Bottom)
            };

            SharpDX.Direct2D1.LinearGradientBrush linearGradientBrush = new SharpDX.Direct2D1.LinearGradientBrush(g.RenderTarget, props, gradientStopCollection);
            g.RenderTarget.FillRectangle(fillRect, linearGradientBrush);
            gradientStopCollection.Dispose();
            linearGradientBrush.Dispose();
        }
コード例 #23
0
        private void ScGridView_D2DPaint(D2DGraphics g)
        {
            g.RenderTarget.AntialiasMode = AntialiasMode.Aliased;

            RawRectangleF   rect     = new RawRectangleF(1, 1, Width, Height);
            RawColor4       rawColor = GDIDataD2DUtils.TransToRawColor4(OutsideLineColor);
            SolidColorBrush brush    = new SolidColorBrush(g.RenderTarget, rawColor);

            g.RenderTarget.DrawRectangle(rect, brush);
            brush.Dispose();


            rect = new RawRectangleF(gridViewPack.DirectionRect.Left + 1, gridViewPack.DirectionRect.Top + 1, gridViewPack.DirectionRect.Right + 1, gridViewPack.DirectionRect.Bottom + 1);

            if (rect.Left <= rect.Right && rect.Top <= rect.Bottom)
            {
                rawColor = GDIDataD2DUtils.TransToRawColor4(InsideLineColor);
                brush    = new SolidColorBrush(g.RenderTarget, rawColor);
                g.RenderTarget.DrawRectangle(rect, brush);
                brush.Dispose();
            }
        }
コード例 #24
0
ファイル: ScScrollBarSliderEx.cs プロジェクト: zanderzhg/Sc
        private void ScScrollBarSlider_D2DPaint(D2DGraphics g)
        {
            RawRectangleF rect = new RawRectangleF();

            switch (ScrollOrientation)
            {
            case ScScrollOrientation.HORIZONTAL_SCROLL:
                rect = new RawRectangleF(0, 2, Width, Height - 2);
                break;

            case ScScrollOrientation.VERTICAL_SCROLL:
                rect = new RawRectangleF(2, 0, Width - 2, Height);
                break;
            }

            g.RenderTarget.AntialiasMode = AntialiasMode.Aliased;
            RawColor4 color = GDIDataD2DUtils.TransToRawColor4(Color.FromArgb(alpha, SliderColor.R, SliderColor.G, SliderColor.B));

            SharpDX.Direct2D1.Brush brush = new SolidColorBrush(g.RenderTarget, color);
            g.RenderTarget.FillRectangle(rect, brush);
            brush.Dispose();
        }
コード例 #25
0
ファイル: ScTab.cs プロジェクト: lypvc/Sc
        private void TabBodyBox_D2DPaint(D2DGraphics g)
        {
            g.RenderTarget.AntialiasMode = AntialiasMode.Aliased;
            //RawRectangleF rect = new RawRectangleF(0, 0, Width - 1, Height - 1);
            //RawColor4 rawColor = GDIDataD2DUtils.TransToRawColor4(Color.FromArgb(255, 255, 255, 255));
            //SolidColorBrush brush = new SolidColorBrush(g.RenderTarget, rawColor);
            //g.RenderTarget.FillRectangle(rect, brush);

            RawRectangleF   rect     = new RawRectangleF(1, 1, tabBodyBox.Width - 1, tabBodyBox.Height - 1);
            RawColor4       rawColor = GDIDataD2DUtils.TransToRawColor4(Color.FromArgb(255, 222, 226, 230));
            SolidColorBrush brush    = new SolidColorBrush(g.RenderTarget, rawColor);

            g.RenderTarget.DrawRectangle(rect, brush, 2);



            //RawRectangleF rect = new RawRectangleF(0, 0, tabBodyBox.Width, tabBodyBox.Height);
            //PathGeometry pathGeo = DrawUtils.CreateOutlineRoundRectGeometry(g, rect, 6);

            //RawColor4 rawColor = GDIDataD2DUtils.TransToRawColor4(Color.FromArgb(255, 191, 152, 90));
            //SolidColorBrush brush = new SolidColorBrush(g.RenderTarget, rawColor);
            //g.RenderTarget.FillGeometry(pathGeo, brush);
        }
コード例 #26
0
        private void InitTextFormatLayout()
        {
            if (d2d == null)
            {
                return;
            }

            TextMetrics metrics;
            SizeF       minSize;

            CurrentTextFormat = new TextFormat(D2DGraphics.dwriteFactory, foreFont.FamilyName, foreFont.Size);
            //{ TextAlignment = TextAlignment.Center, ParagraphAlignment = ParagraphAlignment.Center};

            CurrentTextFormat.WordWrapping = WordWrapping.NoWrap;

            CurrentTextLayout = new TextLayout(D2DGraphics.dwriteFactory, txt, CurrentTextFormat, 0, 0);

            metrics = CurrentTextLayout.Metrics;
            minSize = new SizeF(metrics.WidthIncludingTrailingWhitespace, metrics.Height);

            float w = (float)Math.Ceiling(minSize.Width);

            if (w > boxWidth)
            {
                Width = w;
            }
            else
            {
                Width = boxWidth;
            }

            Height = (float)Math.Ceiling(minSize.Height);



            RawColor4 rawColor = GDIDataD2DUtils.TransToRawColor4(foreColor);
            //RedDrawingeffect = new ColorDrawingEffect(rawColor);
            //CurrentTextLayout.SetDrawingEffect(RedDrawingeffect, new TextRange(0, txt.Count() - 1));

            SolidColorBrush brush = new SolidColorBrush(d2d.renderTarget, rawColor);

            CurrentTextLayout.SetDrawingEffect(brush, new TextRange(0, txt.Count()));



            //BlueDrawingEffect = new ColorDrawingEffect(SharpDX.Color.Blue);
            //GreenDrawingEffect = new ColorDrawingEffect(SharpDX.Color.Green);

            //CurrentTextLayout.SetFontSize(10.0f, new TextRange(6, 14));

            //CurrentTextLayout.SetDrawingEffect(BlueDrawingEffect, new TextRange(14, 7));
            //CurrentTextLayout.SetDrawingEffect(GreenDrawingEffect, new TextRange(21, 8));
            //CurrentTextLayout.SetUnderline(true, new TextRange(0, 20));
            //CurrentTextLayout.SetStrikethrough(true, new TextRange(22, 7));


            //SolidColorBrush greenBrush = new SolidColorBrush(d2d.renderTarget, SharpDX.Color.Black);
            //CurrentTextLayout.SetDrawingEffect(greenBrush, new TextRange(10, 1));

            /*
             * // Set a stylistic typography
             * using (var typo = new Typography(d2d.dwriteFactory))
             * {
             *  typo.AddFontFeature(new FontFeature(FontFeatureTag.StylisticSet7, 1));
             *  CurrentTextLayout.SetTypography(typo, CurrentTextRange);
             * }
             */
        }
コード例 #27
0
        private void TxtView_D2DPaint(D2DGraphics g)
        {
            if (!string.IsNullOrWhiteSpace(BackGroundText) && !isHideBackGroundText)
            {
                g.RenderTarget.AntialiasMode = AntialiasMode.PerPrimitive;
                SolidColorBrush brush      = new SolidColorBrush(g.RenderTarget, GDIDataD2DUtils.TransToRawColor4(BackGroundTextColor));
                TextFormat      textFormat = new TextFormat(D2DGraphics.dwriteFactory, foreFont.FamilyName, foreFont.Weight, foreFont.Style, foreFont.Size)
                {
                    TextAlignment = TextAlignment.Leading, ParagraphAlignment = ParagraphAlignment.Center
                };

                textFormat.WordWrapping = WordWrapping.Wrap;

                SharpDX.RectangleF textRegionRect =
                    new SharpDX.RectangleF(0, 0, Width - 1, Height - 1);

                g.RenderTarget.DrawText(BackGroundText, textFormat, textRegionRect, brush, DrawTextOptions.Clip);
            }


            if (metricsList != null)
            {
                g.RenderTarget.AntialiasMode = AntialiasMode.Aliased;


                SharpDX.Direct2D1.Brush brush = new SolidColorBrush(g.RenderTarget, SharpDX.Color.SkyBlue);

                foreach (HitTestMetrics m in metricsList)
                {
                    SharpDX.RectangleF textRegionRect =
                        new SharpDX.RectangleF((float)Math.Ceiling(m.Left), (float)Math.Ceiling(m.Top), (float)Math.Ceiling(m.Width), (float)Math.Ceiling(m.Height));

                    g.RenderTarget.FillRectangle(textRegionRect, brush);
                }
            }

            g.RenderTarget.AntialiasMode = AntialiasMode.PerPrimitive;

            if (CurrentTextLayout != null && scTextRenderer != null)
            {
                CurrentTextLayout.Draw(scTextRenderer, 0, 0);
            }


            if (cursorState == 1)
            {
                g.RenderTarget.AntialiasMode = AntialiasMode.Aliased;

                RawRectangleF rect =
                    new RawRectangleF(
                        hitTestMetrics[cursorIdx].Left,
                        hitTestMetrics[cursorIdx].Top,
                        hitTestMetrics[cursorIdx].Left + hitTestMetrics[cursorIdx].Width,
                        hitTestMetrics[cursorIdx].Top + hitTestMetrics[cursorIdx].Height);

                RawVector2 pt0;
                RawVector2 pt1;

                if (isTrailingHit[cursorIdx] == false)
                {
                    pt0 = new RawVector2((float)Math.Ceiling(rect.Left), (float)Math.Ceiling(rect.Top));
                    pt1 = new RawVector2((float)Math.Ceiling(rect.Left), (float)Math.Ceiling(rect.Bottom));
                }
                else
                {
                    pt0 = new RawVector2((float)Math.Ceiling(rect.Right), (float)Math.Ceiling(rect.Top));
                    pt1 = new RawVector2((float)Math.Ceiling(rect.Right), (float)Math.Ceiling(rect.Bottom));
                }

                RawColor4 color = GDIDataD2DUtils.TransToRawColor4(Color.FromArgb(255, 255, 0, 0));
                SharpDX.Direct2D1.Brush brushx = new SolidColorBrush(g.RenderTarget, color);

                if (pt0.X == 0 && pt1.X == 0)
                {
                    pt1.X = pt0.X = 1;
                }

                g.RenderTarget.DrawLine(pt0, pt1, brushx);
            }
        }
コード例 #28
0
ファイル: ScTitleButton.cs プロジェクト: zanderzhg/Sc
        void FillItemGeometry(D2DGraphics g)
        {
            g.RenderTarget.AntialiasMode = AntialiasMode.PerPrimitive;

            RawRectangleF    rect        = new RawRectangleF(1, 1, Width - 1, Height - 1);
            RoundedRectangle roundedRect = new RoundedRectangle()
            {
                RadiusX = this.RadiusX,
                RadiusY = this.RadiusY,
                Rect    = rect
            };

            GradientStop[] gradientStops = new GradientStop[5];

            gradientStops[0].Color    = GDIDataD2DUtils.TransToRawColor4(colors[0]);
            gradientStops[0].Position = 0f;

            gradientStops[1].Color    = GDIDataD2DUtils.TransToRawColor4(colors[1]);
            gradientStops[1].Position = 0.4f;

            gradientStops[2].Color    = GDIDataD2DUtils.TransToRawColor4(colors[2]);
            gradientStops[2].Position = 0.5f;

            gradientStops[3].Color    = GDIDataD2DUtils.TransToRawColor4(colors[1]);
            gradientStops[3].Position = 0.6f;

            gradientStops[4].Color    = GDIDataD2DUtils.TransToRawColor4(colors[0]);
            gradientStops[4].Position = 1f;

            //
            GradientStopCollection gradientStopCollection = new GradientStopCollection(g.RenderTarget, gradientStops, Gamma.StandardRgb, ExtendMode.Clamp);

            //
            LinearGradientBrushProperties props = new LinearGradientBrushProperties()
            {
                StartPoint = new RawVector2(rect.Left, rect.Top),
                EndPoint   = new RawVector2(rect.Left, rect.Bottom)
            };

            SharpDX.Direct2D1.LinearGradientBrush linearGradientBrush = new SharpDX.Direct2D1.LinearGradientBrush(g.RenderTarget, props, gradientStopCollection);
            g.RenderTarget.FillRoundedRectangle(roundedRect, linearGradientBrush);

            //
            gradientStops = new GradientStop[5];

            gradientStops[0].Color    = GDIDataD2DUtils.TransToRawColor4(colors[2]);
            gradientStops[0].Position = 0f;

            gradientStops[1].Color    = GDIDataD2DUtils.TransToRawColor4(colors[1]);
            gradientStops[1].Position = 0.1f;

            gradientStops[2].Color    = GDIDataD2DUtils.TransToRawColor4(colors[0]);
            gradientStops[2].Position = 0.5f;

            gradientStops[3].Color    = GDIDataD2DUtils.TransToRawColor4(colors[1]);
            gradientStops[3].Position = 0.9f;


            gradientStops[4].Color    = GDIDataD2DUtils.TransToRawColor4(colors[2]);
            gradientStops[4].Position = 1f;

            //
            gradientStopCollection = new GradientStopCollection(g.RenderTarget, gradientStops, Gamma.StandardRgb, ExtendMode.Clamp);

            //
            props = new LinearGradientBrushProperties()
            {
                StartPoint = new RawVector2(rect.Left, rect.Top),
                EndPoint   = new RawVector2(rect.Right, rect.Top)
            };

            linearGradientBrush = new SharpDX.Direct2D1.LinearGradientBrush(g.RenderTarget, props, gradientStopCollection);
            g.RenderTarget.FillRoundedRectangle(roundedRect, linearGradientBrush);



            RawColor4       rawColor = GDIDataD2DUtils.TransToRawColor4(Color.FromArgb(SideShadowAlpha, 0, 0, 0));
            SolidColorBrush brush    = new SolidColorBrush(g.RenderTarget, rawColor);

            g.RenderTarget.DrawRoundedRectangle(roundedRect, brush);
        }