Esempio n. 1
0
        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();
        }
Esempio n. 2
0
        public void ComputeTransLastHitGeometry()
        {
            switch (scMgr.GraphicsType)
            {
            case GraphicsType.GDIPLUS:

                if (hitGraphicsPath == null)
                {
                    return;
                }

                transLastHitGraphicsPath = (GraphicsPath)hitGraphicsPath.Clone();
                transLastHitGraphicsPath.Transform(globalMatrix);
                break;

            case GraphicsType.D2D:

                if (hitPathGeometry == null)
                {
                    return;
                }

                SharpDX.Direct2D1.Factory d2dFactory = D2DGraphics.d2dFactory;
                RawMatrix3x2 m32 = GDIDataD2DUtils.TransMatrixToRawMatrix3x2(globalMatrix);
                transLastHitPathGeometry = new TransformedGeometry(d2dFactory, hitPathGeometry, m32);
                break;
            }
        }
Esempio n. 3
0
        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);
            }
        }
Esempio n. 4
0
        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);
        }
Esempio n. 5
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);
        }
Esempio n. 6
0
        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));
            }
        }
Esempio n. 7
0
File: ScButton.cs Progetto: 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);
        }
Esempio n. 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);
        }
        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);
        }
Esempio n. 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();
        }
Esempio n. 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();
        }
Esempio n. 12
0
        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);
        }
Esempio n. 13
0
        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);
        }
Esempio n. 14
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);
        }
Esempio n. 15
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));
            }
        }
        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;
            }
        }
Esempio n. 17
0
        private void BtnLayer_MouseEnter(object sender, ScMouseEventArgs e)
        {
            RectangleF oldrc = DrawBox;

            Anchor = new PointF(Width / 2, Height / 2);

            ScaleX = maxZoom;
            ScaleY = maxZoom;

            RectangleF r = new RectangleF(btnLayer.Width - 30, btnLayer.Height - 30, 30, 30);

            gouPath = CreateGouPath(r);

            InvalidateGlobalRect(GDIDataD2DUtils.UnionRectF(oldrc, DrawBox));
        }
Esempio n. 18
0
        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));
            }
        }
Esempio n. 19
0
        private void GridViewContainer_ContentSizeChangedEvent()
        {
            if (Width == 0)
            {
                return;
            }

            SuspendLayout();

            PointF screenLoctain = gridViewCore.GetScreenLoaction();
            float  viewportWidth = gridViewCore.GetViewportWidth();
            float  screenEndPos  = screenLoctain.X + gridViewCore.GetContentSize().Width;

            if (gridViewCore.GetContentSize().Width < viewportWidth && screenLoctain.X < 0)
            {
                gridViewCore.MoveHeaderLoaction(0);
                gridViewCore.SetScreenLoactionX(0);
            }
            else if (screenEndPos <= viewportWidth)
            {
                float x = screenLoctain.X + viewportWidth - screenEndPos;

                if (x <= 0)
                {
                    gridViewCore.MoveHeaderLoaction(x);
                    gridViewCore.SetScreenLoactionX(x);
                }
            }


            if (shadow != null)
            {
                RectangleF oldShadowDrawBox = shadow.DrawBox;
                SetContentShowPos(gridViewCore.GetContentShowPos());
                ResumeLayout(true);
                InvalidateGlobalRect(GDIDataD2DUtils.UnionRectF(oldShadowDrawBox, DrawBox));
                Update();
            }
            else
            {
                SetContentShowPos(gridViewCore.GetContentShowPos());
                ResumeLayout(true);
                Refresh();
                Update();
            }
        }
Esempio n. 20
0
        /// <summary>
        /// 指示点是否包含在层的HitPathGeometry中
        /// </summary>
        /// <param name="pt"></param>
        /// <returns></returns>
        public bool FillContainsPoint(PointF pt)
        {
            if (isComputedStraight && IsUseOrgHitGeometry)
            {
                return(drawBox.Contains(pt));
            }

            switch (scMgr.GraphicsType)
            {
            case GraphicsType.GDIPLUS:
                return(transLastHitGraphicsPath.IsVisible(pt));

            case GraphicsType.D2D:
                return(transLastHitPathGeometry.FillContainsPoint(GDIDataD2DUtils.TransToRawVector2(pt)));
            }

            return(false);
        }
Esempio n. 21
0
        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);
            }
        }
Esempio n. 22
0
File: ScLabel.cs Progetto: 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();
            }
        }
Esempio n. 23
0
        public Layer PushLayer(D2DGraphics g, ScLayer sclayer)
        {
            Layer d2dLayer = new Layer(g.RenderTarget);

            LayerParameters layerParameters = new LayerParameters();

            layerParameters.ContentBounds     = GDIDataD2DUtils.TransToRawRectF(sclayer.DrawBox);
            layerParameters.LayerOptions      = LayerOptions.InitializeForCleartype;
            layerParameters.MaskAntialiasMode = AntialiasMode.PerPrimitive;

            //应用到GeometricMask上的变换,这个变换可能已经在计算布局的时候已经计算到了sclayer.TransLastHitPathGeometry上
            //所以不需要应用变换
            layerParameters.MaskTransform = identityMatrix;

            layerParameters.Opacity       = sclayer.Opacity;
            layerParameters.GeometricMask = sclayer.TransLastHitPathGeometry;

            g.RenderTarget.PushLayer(ref layerParameters, d2dLayer);
            return(d2dLayer);
        }
Esempio n. 24
0
        public void FixSize()
        {
            RectangleF totalRect = Rectangle.Empty;

            foreach (ScLayer control in controls)
            {
                if (totalRect == RectangleF.Empty)
                {
                    totalRect = new RectangleF(
                        control.Location.X, control.Location.Y,
                        control.Width, control.Height);
                    continue;
                }

                totalRect = GDIDataD2DUtils.UnionRectF(totalRect, control.DirectionRect);
            }

            Width  = totalRect.Right;
            Height = totalRect.Bottom;
        }
Esempio n. 25
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();
                }
            }
        }
Esempio n. 26
0
        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();
        }
Esempio n. 27
0
File: ScPanel.cs Progetto: 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);
        }
Esempio n. 28
0
        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();
        }
Esempio n. 29
0
        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();
        }
Esempio n. 30
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();
            }
        }