コード例 #1
0
ファイル: ConnectionItem.cs プロジェクト: kevinxw/CIS681-Pr4
        /// <summary>
        /// Re-generate the path
        /// </summary>
        public void Draw()
        {
            if (Points.Count < 2)
            {
                pathGeometry = null;
            }
            else
            {
                PathFigure figure = new PathFigure();
                figure.StartPoint = contentObject.SourcePosition; figure.IsFilled = false; figure.IsClosed = false;
#if DEBUG_ON
                System.Console.WriteLine("{0} connection drawing lines ", System.DateTime.Now.Millisecond);
                foreach (Point p in contentObject.Stops)
                {
                    System.Console.Write("{0} ", p.ToString());
                }
#endif
                figure.Segments.Add(new PolyLineSegment(contentObject.Stops, true));
                PathGeometry geometry = new System.Windows.Media.PathGeometry();
                geometry.Figures.Add(figure);
                // draw different head for different types
                geometry.Figures.Add(DrawHead());
                geometry.Freeze();  // improve the performance
                pathGeometry = geometry;
                if (IsLoaded)
                {
                    InvalidateVisual();
                }
            }
        }
コード例 #2
0
        // Create the pen and triangle in a static constructor and freeze them to improve performance.
        static InsertionAdorner()
        {
            pen = new Pen
            {
                Brush = Brushes.Gray,
                Thickness = 2
            };
            pen.Freeze();

            LineSegment firstLine = new LineSegment(new Point(0, -5), false);
            firstLine.Freeze();
            LineSegment secondLine = new LineSegment(new Point(0, 5), false);
            secondLine.Freeze();

            PathFigure figure = new PathFigure
            {
                StartPoint = new Point(5, 0)
            };
            figure.Segments.Add(firstLine);
            figure.Segments.Add(secondLine);
            figure.Freeze();

            triangle = new PathGeometry();
            triangle.Figures.Add(figure);
            triangle.Freeze();
        }
コード例 #3
0
        ///<summary>
        /// Creates a <see cref="WpfGeometry"/> representing a <see cref="IGeometry"/>, according to the specified PointTransformation and PointShapeFactory (if relevant).
        ///</summary>
        public WpfGeometry ToShape(IGeometry geometry)
        {
            if (geometry.IsEmpty)
            {
                return(new WpfPathGeometry());
            }

            var p = new WpfPathGeometry();

            AddShape(p, geometry);

            p.Freeze();
            return(p);
        }
コード例 #4
0
 /// <summary>
 /// Create the pen and triangle in a static constructor and freeze them to improve performance.
 /// </summary>
 static InsertionAdorner()
 {
     Pen = new Pen { Brush = Brushes.SkyBlue, Thickness = LineThickness };
     Pen.Freeze();
     var firstLine = new LineSegment(new Point(0, -TriangleWidth), false);
     firstLine.Freeze();
     var secondLine = new LineSegment(new Point(0, TriangleWidth), false);
     secondLine.Freeze();
     var figure = new PathFigure {StartPoint = new Point(TriangleWidth, 0)};
     figure.Segments.Add(firstLine);
     figure.Segments.Add(secondLine);
     figure.Freeze();
     Triangle = new PathGeometry();
     Triangle.Figures.Add(figure);
     Triangle.Freeze();
 }
コード例 #5
0
		static InsertionAdorner()
		{
			Pen = new Pen { Brush = new SolidColorBrush(Color.FromRgb(48, 48, 48)), Thickness = 2 };
			Pen.Freeze();

			var firstLine = new LineSegment(new Point(0, -5), false);
			firstLine.Freeze();
			
			var secondLine = new LineSegment(new Point(0, 5), false);
			secondLine.Freeze();

			var figure = new PathFigure { StartPoint = new Point(5, 0) };
			figure.Segments.Add(firstLine);
			figure.Segments.Add(secondLine);
			figure.Freeze();

			Triangle = new PathGeometry();
			Triangle.Figures.Add(figure);
			Triangle.Freeze();
		}
コード例 #6
0
        /// <summary>
        /// Initializes static members of the <see cref="InsertionAdorner" /> class.
        /// </summary>
        static InsertionAdorner()
        {
            // Create the pen and triangle in a static constructor and freeze them to improve performance.
            Pen = new Pen { Brush = Brushes.Gray, Thickness = 2 };
            Pen.Freeze();

            var firstLine = new LineSegment(new Point(0, -5), false);
            firstLine.Freeze();
            var secondLine = new LineSegment(new Point(0, 5), false);
            secondLine.Freeze();

            var figure = new PathFigure { StartPoint = new Point(5, 0) };
            figure.Segments.Add(firstLine);
            figure.Segments.Add(secondLine);
            figure.Freeze();

            Triangle = new PathGeometry();
            Triangle.Figures.Add(figure);
            Triangle.Freeze();
        }
コード例 #7
0
        static DropTargetInsertionAdorner()
        {
            // Create the pen and triangle in a static constructor and freeze them to improve performance.
            const int triangleSize = 3;

            m_Pen = new Pen(Brushes.Gray, 2);
            m_Pen.Freeze();

            LineSegment firstLine = new LineSegment(new Point(0, -triangleSize), false);
            firstLine.Freeze();
            LineSegment secondLine = new LineSegment(new Point(0, triangleSize), false);
            secondLine.Freeze();

            PathFigure figure = new PathFigure { StartPoint = new Point(triangleSize, 0) };
            figure.Segments.Add(firstLine);
            figure.Segments.Add(secondLine);
            figure.Freeze();

            m_Triangle = new PathGeometry();
            m_Triangle.Figures.Add(figure);
            m_Triangle.Freeze();
        }
コード例 #8
0
        static DropTargetMetroInsertionAdorner()
        {
            // Create the pen and triangle in a static constructor and freeze them to improve performance.
            const int triangleSize = 5;

            var color = (Color) ThemeManager.DetectAppStyle(Application.Current).Item2.Resources["AccentColor"];
            m_Pen = new Pen(new SolidColorBrush(color), 2);
            m_Pen.Freeze();

            var firstLine = new LineSegment(new Point(0, -triangleSize), false);
            firstLine.Freeze();
            var secondLine = new LineSegment(new Point(0, triangleSize), false);
            secondLine.Freeze();

            var figure = new PathFigure {StartPoint = new Point(triangleSize, 0)};
            figure.Segments.Add(firstLine);
            figure.Segments.Add(secondLine);
            figure.Freeze();

            m_Triangle = new PathGeometry();
            m_Triangle.Figures.Add(figure);
            m_Triangle.Freeze();
        }
コード例 #9
0
        ///<summary>
        /// Creates a <see cref="WpfGeometry"/> representing a <see cref="IGeometry"/>, according to the specified PointTransformation and PointShapeFactory (if relevant).
        ///</summary>
        public WpfGeometry ToShape(IGeometry geometry)
        {
            if (geometry.IsEmpty)
                return new WpfPathGeometry();

            var p = new WpfPathGeometry();
            AddShape(p, geometry);

            p.Freeze();
            return p;
        }
コード例 #10
0
        /// <summary>
        /// 描画処理をおこないます。
        /// </summary>
        /// <param name="dc">描画するコンテキスト</param>
        protected override void OnRender(DrawingContext dc)
        {
            //base.OnRender(dc);

            if (XAxisData == null)
            {
                IsDataEnabled = false;
                return;
            }
            if (YAxisData == null)
            {
                IsDataEnabled = false;
                return;
            }

            var xArray = XAxisData.OfType<double>().ToArray();
            var yArray = YAxisData.OfType<double>().ToArray();
            var length = xArray.Length < yArray.Length ? xArray.Length : yArray.Length;
            Point? pt0 = null;
            var isLineFirst = true;
            var pathfigure = new PathFigure();
            var pen = new Pen(this.Color != null ? new SolidColorBrush(this.Color.Value) : this.Stroke, this.Thickness);
            pen.Freeze();
            Pen markerPen = null;
            if (this.MarkerPen != null)
            {
                markerPen = this.Color != null ? new Pen(new SolidColorBrush(this.Color.Value), this.MarkerPen.Thickness) : this.MarkerPen;
                markerPen.Freeze();
            }
            var markerFill = this.Color != null ? new SolidColorBrush(this.Color.Value) : this.Fill;
            if (markerFill != null)
                markerFill.Freeze();
            for (var i = 0; i < length; i++)
            {
                if (IsStrokeEnabled)
                {
                    #region 線の描画
                    if (pt0 != null)
                    {

                        if ((pt0.Value.Y >= this.YMax) && (yArray[i] >= this.YMax))
                        {
                            // 絶対に線の描画があり得ないパターン
                        }
                        else if ((pt0.Value.Y <= this.YMin) && (yArray[i] <= this.YMin))
                        {
                            // 絶対に線の描画があり得ないパターン
                        }
                        else
                        {
                            Point? ptLine0 = null;
                            Point? ptLine1 = null;

                            // 以前の点が右端より左側にあって
                            // 今回の点が左端より右側にある場合のみ
                            // 線を描画する可能性がある
                            if ((pt0.Value.X < this.XMax) && (xArray[i] > this.XMin))
                            {
                                // 以前の点が範囲内ならこれを左端の点とする
                                if ((this.XMin <= pt0.Value.X) && (pt0.Value.X <= this.XMax) && (this.YMin <= pt0.Value.Y) && (pt0.Value.Y <= this.YMax))
                                {
                                    ptLine0 = GetControlPointFromGraphPoint(pt0.Value);
                                }
                                // 今回の点が範囲内ならこれを右端の点とする
                                if ((this.XMin <= xArray[i]) && (xArray[i] <= this.XMax) && (this.YMin <= yArray[i]) && (yArray[i] <= this.YMax))
                                {
                                    ptLine1 = GetControlPointFromGraphPoint(xArray[i], yArray[i]);
                                }

                                // 左端または右端の点が確定していない場合はグラフ表示範囲の境界線との交点を調べる
                                if ((ptLine0 == null) || (ptLine1 == null))
                                {
                                    // y = ax + b
                                    // 傾き
                                    double? a = xArray[i] != pt0.Value.X ? (yArray[i] - pt0.Value.Y) / (xArray[i] - pt0.Value.X) : (double?)null;
                                    if (a != null)
                                    {
                                        // 切片
                                        double b = pt0.Value.Y - a.Value * pt0.Value.X;

                                        // 左端縦軸との交点
                                        var yLeft = a.Value * this.XMin + b;
                                        // 右端縦軸との交点
                                        var yRight = a.Value * this.XMax + b;
                                        // 上端横軸との交点
                                        var xTop = (this.YMax - b) / a.Value;
                                        // 下端横軸との交点
                                        var xBottom = (this.YMin - b) / a.Value;

                                        #region 左端の点を確定する
                                        if (ptLine0 == null)
                                        {
                                            // 左端縦軸交点の確認
                                            if ((this.YMin <= yLeft) && (yLeft <= this.YMax))
                                            {
                                                ptLine0 = GetControlPointFromGraphPoint(this.XMin, yLeft);
                                            }
                                            else
                                            {
                                                // 下から上への線の場合
                                                if (pt0.Value.Y < yArray[i])
                                                {
                                                    // 交わり得るのは下端横軸交点
                                                    if ((this.XMin <= xBottom) && (xBottom <= this.XMax))
                                                    {
                                                        ptLine0 = GetControlPointFromGraphPoint(xBottom, this.YMin);
                                                    }
                                                }
                                                else
                                                {
                                                    // 上から下への線の場合は
                                                    // 交わり得るのは上端横軸交点
                                                    if ((this.XMin <= xTop) && (xTop <= this.XMax))
                                                    {
                                                        ptLine0 = GetControlPointFromGraphPoint(xTop, this.YMax);
                                                    }
                                                }
                                            }

                                            if (ptLine0 != null)
                                            {
                                                pathfigure.Segments.Add(new LineSegment(ptLine0.Value, false));
                                            }
                                        }
                                        #endregion 左端の点を確定する

                                        #region 右端の点を確定する
                                        if (ptLine1 == null)
                                        {
                                            // 右端縦軸交点の確認
                                            if ((this.YMin <= yRight) && (yRight <= this.YMax))
                                            {
                                                ptLine1 = GetControlPointFromGraphPoint(this.XMax, yRight);
                                            }
                                            else
                                            {
                                                // 下から上への線の場合
                                                if (pt0.Value.Y < yArray[i])
                                                {
                                                    // 交わり得るのは上端横軸交点
                                                    if ((this.XMin <= xTop) && (xTop <= this.XMax))
                                                    {
                                                        ptLine1 = GetControlPointFromGraphPoint(xTop, this.YMax);
                                                    }
                                                }
                                                else
                                                {
                                                    // 上から下への線の場合は
                                                    // 交わり得るのは下端横軸交点
                                                    if ((this.XMin <= xBottom) && (xBottom <= this.XMax))
                                                    {
                                                        ptLine1 = GetControlPointFromGraphPoint(xBottom, this.YMin);
                                                    }
                                                }
                                            }
                                        }
                                        #endregion 右端の点を確定する
                                    }
                                }

                                // 線の開始点を確定する
                                if (isLineFirst && ptLine0 != null)
                                {
                                    pathfigure.StartPoint = ptLine0.Value;
                                    isLineFirst = false;
                                }

                                // 右端の点が確定したら線を結ぶ
                                if ((ptLine0 != null) && (ptLine1 != null))
                                {
                                    pathfigure.Segments.Add(new LineSegment(ptLine1.Value, true));
                                }
                            }
                        }
                    }
                    #endregion 線の描画
                }

                if (this.IsMarkerEnabled)
                {
                    #region データ点の描画
                    if (pt0 != null)
                    {
                        // 線の上にデータ点を描画するために
                        // ひとつ前のデータ点を描画する
                        DrawingDataPoint(dc, markerFill, MarkerPen, pt0.Value);
                    }
                    if (i == length - 1)
                    {
                        // ひとつ前のデータ点を描画していたので
                        // 最後のデータ点をここで描画する
                        DrawingDataPoint(dc, markerFill, MarkerPen, new Point(xArray[i], yArray[i]));
                    }
                    #endregion データ点の描画
                }

                // 以前の点として保持
                pt0 = new Point(xArray[i], yArray[i]);
            }

            if (!pathfigure.IsFrozen)
                pathfigure.Freeze();
            var geometry = new PathGeometry();
            geometry.Figures.Add(pathfigure);
            geometry.Freeze();
            dc.DrawGeometry(null, pen, geometry);

            // 強調表示するデータ点
            if (this.HighlightPoint != null)
            {
                DrawingDataPoint(dc, markerFill, MarkerPen, this.HighlightPoint.Value, true);
            }

            // データ表示確認
            IsDataEnabled = length > 0;
        }
コード例 #11
0
        /// <summary>
        /// Render callback.  
        /// </summary>
        protected override void OnRender(DrawingContext drawingContext)
        {
            CornerRadius cornerRadius = CornerRadius;

            Rect shadowBounds = new Rect(new Point(ShadowDepth, ShadowDepth),
                             new Size(RenderSize.Width, RenderSize.Height));
            Color color = Color;

            if (shadowBounds.Width > 0 && shadowBounds.Height > 0 && color.A > 0)
            {
                // The shadow is drawn with a dark center the size of the shadow bounds
                // deflated by shadow depth on each side.
                double centerWidth = shadowBounds.Right - shadowBounds.Left - 2 * ShadowDepth;
                double centerHeight = shadowBounds.Bottom - shadowBounds.Top - 2 * ShadowDepth;

                // Clamp corner radii to be less than 1/2 the side of the inner shadow bounds 
                double maxRadius = Math.Min(centerWidth * 0.5, centerHeight * 0.5);
                cornerRadius.TopLeft = Math.Min(cornerRadius.TopLeft, maxRadius);
                cornerRadius.TopRight = Math.Min(cornerRadius.TopRight, maxRadius);
                cornerRadius.BottomLeft = Math.Min(cornerRadius.BottomLeft, maxRadius);
                cornerRadius.BottomRight = Math.Min(cornerRadius.BottomRight, maxRadius);

                // Get the brushes for the 9 regions
                Brush[] brushes = GetBrushes(color, cornerRadius);

                // Snap grid to device pixels
                double centerTop = shadowBounds.Top + ShadowDepth;
                double centerLeft = shadowBounds.Left + ShadowDepth;
                double centerRight = shadowBounds.Right - ShadowDepth;
                double centerBottom = shadowBounds.Bottom - ShadowDepth;

                // Because of different corner radii there are 6 potential x (or y) lines to snap to
                double[] guidelineSetX = new double[] { centerLeft,
                                                        centerLeft + cornerRadius.TopLeft,
                                                        centerRight - cornerRadius.TopRight,
                                                        centerLeft + cornerRadius.BottomLeft,
                                                        centerRight - cornerRadius.BottomRight,
                                                        centerRight};

                double[] guidelineSetY = new double[] { centerTop,
                                                        centerTop + cornerRadius.TopLeft,
                                                        centerTop + cornerRadius.TopRight,
                                                        centerBottom - cornerRadius.BottomLeft,
                                                        centerBottom - cornerRadius.BottomRight,
                                                        centerBottom};
                
                drawingContext.PushGuidelineSet(new GuidelineSet(guidelineSetX, guidelineSetY));

                // The corner rectangles are drawn drawn ShadowDepth pixels bigger to 
                // account for the blur
                cornerRadius.TopLeft = cornerRadius.TopLeft + ShadowDepth;
                cornerRadius.TopRight = cornerRadius.TopRight + ShadowDepth;
                cornerRadius.BottomLeft = cornerRadius.BottomLeft + ShadowDepth;
                cornerRadius.BottomRight = cornerRadius.BottomRight + ShadowDepth;


                // Draw Top row
                Rect topLeft = new Rect(shadowBounds.Left, shadowBounds.Top, cornerRadius.TopLeft, cornerRadius.TopLeft);
                drawingContext.DrawRectangle(brushes[TopLeft], null, topLeft);

                double topWidth = guidelineSetX[2] - guidelineSetX[1];
                if (topWidth > 0)
                {
                    Rect top = new Rect(guidelineSetX[1], shadowBounds.Top, topWidth, ShadowDepth);
                    drawingContext.DrawRectangle(brushes[Top], null, top);
                }

                Rect topRight = new Rect(guidelineSetX[2], shadowBounds.Top, cornerRadius.TopRight, cornerRadius.TopRight);
                drawingContext.DrawRectangle(brushes[TopRight], null, topRight);

                // Middle row
                double leftHeight = guidelineSetY[3] - guidelineSetY[1];
                if (leftHeight > 0)
                {
                    Rect left = new Rect(shadowBounds.Left, guidelineSetY[1], ShadowDepth, leftHeight);
                    drawingContext.DrawRectangle(brushes[Left], null, left);
                }

                double rightHeight = guidelineSetY[4] - guidelineSetY[2];
                if (rightHeight > 0)
                {
                    Rect right = new Rect(guidelineSetX[5], guidelineSetY[2], ShadowDepth, rightHeight);
                    drawingContext.DrawRectangle(brushes[Right], null, right);
                }

                // Bottom row
                Rect bottomLeft = new Rect(shadowBounds.Left, guidelineSetY[3], cornerRadius.BottomLeft, cornerRadius.BottomLeft);
                drawingContext.DrawRectangle(brushes[BottomLeft], null, bottomLeft);

                double bottomWidth = guidelineSetX[4] - guidelineSetX[3];
                if (bottomWidth > 0)
                {
                    Rect bottom = new Rect(guidelineSetX[3], guidelineSetY[5], bottomWidth, ShadowDepth);
                    drawingContext.DrawRectangle(brushes[Bottom], null, bottom);
                }

                Rect bottomRight = new Rect(guidelineSetX[4], guidelineSetY[4], cornerRadius.BottomRight, cornerRadius.BottomRight);
                drawingContext.DrawRectangle(brushes[BottomRight], null, bottomRight);


                // Fill Center

                // Because the heights of the top/bottom rects and widths of the left/right rects are fixed
                // and the corner rects are drawn with the size of the corner, the center 
                // may not be a square.  In this case, create a path to fill the area

                // When the target object's corner radius is 0, only need to draw one rect
                if (cornerRadius.TopLeft == ShadowDepth &&
                    cornerRadius.TopLeft == cornerRadius.TopRight &&
                    cornerRadius.TopLeft == cornerRadius.BottomLeft &&
                    cornerRadius.TopLeft == cornerRadius.BottomRight)
                {
                    // All corners of target are 0, render one large rectangle
                    Rect center = new Rect(guidelineSetX[0], guidelineSetY[0], centerWidth, centerHeight);
                    drawingContext.DrawRectangle(brushes[Center], null, center);
                }
                else
                {
                    // If the corner radius is TL=2, TR=1, BL=0, BR=2 the following shows the shape that needs to be created.
                    //             _________________
                    //            |                 |_
                    //         _ _|                   |
                    //        |                       |
                    //        |                    _ _|
                    //        |                   |   
                    //        |___________________| 
                    // The missing corners of the shape are filled with the radial gradients drawn above

                    // Define shape counter clockwise
                    PathFigure figure = new PathFigure();

                    if (cornerRadius.TopLeft > ShadowDepth)
                    {
                        figure.StartPoint = new Point(guidelineSetX[1], guidelineSetY[0]);
                        figure.Segments.Add(new LineSegment(new Point(guidelineSetX[1], guidelineSetY[1]), true));
                        figure.Segments.Add(new LineSegment(new Point(guidelineSetX[0], guidelineSetY[1]), true));
                    }
                    else
                    {
                        figure.StartPoint = new Point(guidelineSetX[0], guidelineSetY[0]);
                    }

                    if (cornerRadius.BottomLeft > ShadowDepth)
                    {
                        figure.Segments.Add(new LineSegment(new Point(guidelineSetX[0], guidelineSetY[3]), true));
                        figure.Segments.Add(new LineSegment(new Point(guidelineSetX[3], guidelineSetY[3]), true));
                        figure.Segments.Add(new LineSegment(new Point(guidelineSetX[3], guidelineSetY[5]), true));
                    }
                    else
                    {
                        figure.Segments.Add(new LineSegment(new Point(guidelineSetX[0], guidelineSetY[5]), true));
                    }

                    if (cornerRadius.BottomRight > ShadowDepth)
                    {
                        figure.Segments.Add(new LineSegment(new Point(guidelineSetX[4], guidelineSetY[5]), true));
                        figure.Segments.Add(new LineSegment(new Point(guidelineSetX[4], guidelineSetY[4]), true));
                        figure.Segments.Add(new LineSegment(new Point(guidelineSetX[5], guidelineSetY[4]), true));
                    }
                    else
                    {
                        figure.Segments.Add(new LineSegment(new Point(guidelineSetX[5], guidelineSetY[5]), true));
                    }


                    if (cornerRadius.TopRight > ShadowDepth)
                    {
                        figure.Segments.Add(new LineSegment(new Point(guidelineSetX[5], guidelineSetY[2]), true));
                        figure.Segments.Add(new LineSegment(new Point(guidelineSetX[2], guidelineSetY[2]), true));
                        figure.Segments.Add(new LineSegment(new Point(guidelineSetX[2], guidelineSetY[0]), true));
                    }
                    else
                    {
                        figure.Segments.Add(new LineSegment(new Point(guidelineSetX[5], guidelineSetY[0]), true));
                    }
                    
                    figure.IsClosed = true;
                    figure.Freeze();

                    PathGeometry geometry = new PathGeometry();
                    geometry.Figures.Add(figure);
                    geometry.Freeze();

                    drawingContext.DrawGeometry(brushes[Center], null, geometry);
                }

                drawingContext.Pop();
            }
        }
コード例 #12
0
ファイル: TabItemBorder.cs プロジェクト: kekekeks/PerspexVS
        private static Geometry ApplyTransform(Geometry geometry, double bt, Size renderSize)
        {
            var pathGeometry = new PathGeometry();
            pathGeometry.AddGeometry(geometry);

            var hbt = bt * 0.5;
            //var scaleY = ((hbt * 100) / renderSize.Height) / 100;
            var scaleY = hbt / renderSize.Height;
            pathGeometry.Transform = new ScaleTransform(1, scaleY + 1, renderSize.Width * 0.5, 0);
            pathGeometry.Freeze();
            return pathGeometry;
        }
コード例 #13
0
ファイル: DataGridHeaderBorder.cs プロジェクト: JianwenSun/cc
        private void RenderTheme(DrawingContext dc)
        {
            Size size = RenderSize;
            bool isClickable = IsClickable && IsEnabled;
            bool isPressed = isClickable && IsPressed;
            ListSortDirection? sortDirection = SortDirection;
            bool isSorted = sortDirection != null;
            bool horizontal = Orientation == Orientation.Horizontal;
            Brush background = EnsureControlBrush();
            Brush light = SystemColors.ControlLightBrush;
            Brush dark = SystemColors.ControlDarkBrush;
            bool shouldDrawRight = true;
            bool shouldDrawBottom = true;
            bool usingSeparatorBrush = false;

            Brush darkDarkRight = null;
            if (!horizontal)
            {
                if (SeparatorVisibility == Visibility.Visible && SeparatorBrush != null)
                {
                    darkDarkRight = SeparatorBrush;
                    usingSeparatorBrush = true;
                }
                else
                {
                    shouldDrawRight = false;
                }
            }
            else
            {
                darkDarkRight = SystemColors.ControlDarkDarkBrush;
            }

            Brush darkDarkBottom = null;
            if (horizontal)
            {
                if (SeparatorVisibility == Visibility.Visible && SeparatorBrush != null)
                {
                    darkDarkBottom = SeparatorBrush;
                    usingSeparatorBrush = true;
                }
                else
                {
                    shouldDrawBottom = false;
                }
            }
            else
            {
                darkDarkBottom = SystemColors.ControlDarkDarkBrush;
            }

            EnsureCache((int)ClassicFreezables.NumFreezables);

            // Draw the background
            dc.DrawRectangle(background, null, new Rect(0.0, 0.0, size.Width, size.Height));

            if ((size.Width > 3.0) && (size.Height > 3.0))
            {
                // Draw the border
                if (isPressed)
                {
                    dc.DrawRectangle(dark, null, new Rect(0.0, 0.0, size.Width, 1.0));
                    dc.DrawRectangle(dark, null, new Rect(0.0, 0.0, 1.0, size.Height));
                    dc.DrawRectangle(dark, null, new Rect(0.0, Max0(size.Height - 1.0), size.Width, 1.0));
                    dc.DrawRectangle(dark, null, new Rect(Max0(size.Width - 1.0), 0.0, 1.0, size.Height));
                }
                else
                {
                    dc.DrawRectangle(light, null, new Rect(0.0, 0.0, 1.0, Max0(size.Height - 1.0)));
                    dc.DrawRectangle(light, null, new Rect(0.0, 0.0, Max0(size.Width - 1.0), 1.0));

                    if (shouldDrawRight)
                    {
                        if (!usingSeparatorBrush)
                        {
                            dc.DrawRectangle(dark, null, new Rect(Max0(size.Width - 2.0), 1.0, 1.0, Max0(size.Height - 2.0)));
                        }

                        dc.DrawRectangle(darkDarkRight, null, new Rect(Max0(size.Width - 1.0), 0.0, 1.0, size.Height));
                    }

                    if (shouldDrawBottom)
                    {
                        if (!usingSeparatorBrush)
                        {
                            dc.DrawRectangle(dark, null, new Rect(1.0, Max0(size.Height - 2.0), Max0(size.Width - 2.0), 1.0));
                        }

                        dc.DrawRectangle(darkDarkBottom, null, new Rect(0.0, Max0(size.Height - 1.0), size.Width, 1.0));
                    }
                }
            }

            if (isSorted && (size.Width > 14.0) && (size.Height > 10.0))
            {
                // If sorted, draw an arrow on the right
                TranslateTransform positionTransform = new TranslateTransform(size.Width - 15.0, (size.Height - 5.0) * 0.5);
                positionTransform.Freeze();
                dc.PushTransform(positionTransform);

                bool ascending = (sortDirection == ListSortDirection.Ascending);
                PathGeometry arrowGeometry = (PathGeometry)GetCachedFreezable(ascending ? (int)ClassicFreezables.ArrowUpGeometry : (int)ClassicFreezables.ArrowDownGeometry);
                if (arrowGeometry == null)
                {
                    arrowGeometry = new PathGeometry();
                    PathFigure arrowFigure = new PathFigure();

                    if (ascending)
                    {
                        arrowFigure.StartPoint = new Point(0.0, 5.0);

                        LineSegment line = new LineSegment(new Point(5.0, 0.0), false);
                        line.Freeze();
                        arrowFigure.Segments.Add(line);

                        line = new LineSegment(new Point(10.0, 5.0), false);
                        line.Freeze();
                        arrowFigure.Segments.Add(line);
                    }
                    else
                    {
                        arrowFigure.StartPoint = new Point(0.0, 0.0);

                        LineSegment line = new LineSegment(new Point(10.0, 0.0), false);
                        line.Freeze();
                        arrowFigure.Segments.Add(line);

                        line = new LineSegment(new Point(5.0, 5.0), false);
                        line.Freeze();
                        arrowFigure.Segments.Add(line);
                    }

                    arrowFigure.IsClosed = true;
                    arrowFigure.Freeze();

                    arrowGeometry.Figures.Add(arrowFigure);
                    arrowGeometry.Freeze();

                    CacheFreezable(arrowGeometry, ascending ? (int)ClassicFreezables.ArrowUpGeometry : (int)ClassicFreezables.ArrowDownGeometry);
                }

                dc.DrawGeometry(SystemColors.GrayTextBrush, null, arrowGeometry);

                dc.Pop(); // Position Transform
            }
        }
コード例 #14
0
ファイル: MainWindow.xaml.cs プロジェクト: HarelM/Set-Game
        private void AnimateMoveCard(int iLocationFrom, int iLocationTo)
        {
            Canvas canvesFrom = GetCanvas(iLocationFrom);
            Point pointCanvasCornerFrom = canvesFrom.PointToScreen(new Point(0, 0));
            Canvas canvesTo = GetCanvas(iLocationTo);
            Point pointCanvasCornerTo = canvesTo.PointToScreen(new Point(0, 0));

            // Create the animation path.
            PathGeometry animationPath = new PathGeometry();
            PathFigure pFigure = new PathFigure();

            PolyLineSegment pLineSegment = new PolyLineSegment();
            pFigure.StartPoint = new Point(0, 0);
            pLineSegment.Points.Add(pFigure.StartPoint);
            pLineSegment.Points.Add(new Point(pointCanvasCornerTo.X - pointCanvasCornerFrom.X, pointCanvasCornerTo.Y - pointCanvasCornerFrom.Y));

            // Create a MatrixTransform. This transform will be used to move the button.
            MatrixTransform matrixTransform = new MatrixTransform();

            pFigure.Segments.Add(pLineSegment);
            animationPath.Figures.Add(pFigure);

            // Freeze the PathGeometry for performance benefits.
            animationPath.Freeze();

            // Create a MatrixAnimationUsingPath to move the
            // button along the path by animating its MatrixTransform.
            MatrixAnimationUsingPath matrixAnimation = new MatrixAnimationUsingPath();
            matrixAnimation.PathGeometry = animationPath;
            matrixAnimation.Duration = TimeSpan.FromSeconds(iAnimationRemoveCardTime);

            canvesFrom.Children[0].RenderTransform = matrixTransform;
            matrixAnimation.Completed += delegate
            {
                MoveCard(iLocationFrom, iLocationTo);
            };

            matrixTransform.BeginAnimation(MatrixTransform.MatrixProperty, matrixAnimation);
        }
コード例 #15
0
        public static DrawingImage CreateImage(PointPattern[] pointPatterns, Size size, Color color)
        {
            if (pointPatterns == null)
                throw new Exception("You must provide a gesture before trying to generate a thumbnail");

            DrawingGroup drawingGroup = new DrawingGroup();
            for (int i = 0; i < pointPatterns.Length; i++)
            {
                PathGeometry pathGeometry = new PathGeometry();

                color.A = (byte)(0xFF - i * 0x55);
                SolidColorBrush brush = new SolidColorBrush(color);
                Pen drawingPen = new Pen(brush, 3 + i * 2) { StartLineCap = PenLineCap.Round, EndLineCap = PenLineCap.Round };

                if (pointPatterns[i].Points == null) return null;
                for (int j = 0; j < pointPatterns[i].Points.Count; j++)
                {
                    if (pointPatterns[i].Points[j].Count == 1)
                    {
                        Geometry ellipse = new EllipseGeometry(new Point(size.Width * j + size.Width / 2, size.Height / 2),
                            drawingPen.Thickness / 2, drawingPen.Thickness / 2);
                        pathGeometry.AddGeometry(ellipse);
                        continue;
                    }
                    StreamGeometry sg = new StreamGeometry { FillRule = FillRule.EvenOdd };
                    using (StreamGeometryContext sgc = sg.Open())
                    {
                        // Create new size object accounting for pen width
                        Size szeAdjusted = new Size(size.Width - drawingPen.Thickness - 1,
                            (size.Height - drawingPen.Thickness - 1));

                        Size scaledSize;
                        Point[] scaledPoints = ScaleGesture(pointPatterns[i].Points[j], szeAdjusted.Width - 10, szeAdjusted.Height - 10,
                            out scaledSize);

                        // Define size that will mark the offset to center the gesture
                        double iLeftOffset = (size.Width / 2) - (scaledSize.Width / 2);
                        double iTopOffset = (size.Height / 2) - (scaledSize.Height / 2);
                        Vector sizOffset = new Vector(iLeftOffset + j * size.Width, iTopOffset);
                        sgc.BeginFigure(Point.Add(scaledPoints[0], sizOffset), false, false);
                        foreach (Point p in scaledPoints)
                        {
                            sgc.LineTo(Point.Add(p, sizOffset), true, true);
                        }
                        DrawArrow(sgc, scaledPoints, sizOffset, drawingPen.Thickness);
                    }
                    sg.Freeze();
                    pathGeometry.AddGeometry(sg);
                }
                pathGeometry.Freeze();
                GeometryDrawing drawing = new GeometryDrawing(null, drawingPen, pathGeometry);
                drawing.Freeze();
                drawingGroup.Children.Add(drawing);
            }
            //  myPath.Data = sg;
            drawingGroup.Freeze();
            DrawingImage drawingImage = new DrawingImage(drawingGroup);
            drawingImage.Freeze();

            return drawingImage;
        }
コード例 #16
0
ファイル: Trapezoid.cs プロジェクト: CensoredHF/Snappie
        private static PathGeometry CreateGeometry(Size contentDesiredSize)
        {
            //TODO Make better :)  do some funky beziers or summit
            const double cheapRadiusBig = 6.0;
            const double cheapRadiusSmall = cheapRadiusBig/2;
            
            const int angle = 20;
            const double radians = angle * (Math.PI / 180);

            var startPoint = new Point(0, contentDesiredSize.Height + cheapRadiusSmall + cheapRadiusSmall);

            //clockwise starting at bottom left
            var bottomLeftSegment = new ArcSegment(new Point(startPoint.X + cheapRadiusSmall, startPoint.Y - cheapRadiusSmall),
                new Size(cheapRadiusSmall, cheapRadiusSmall), 315, false, SweepDirection.Counterclockwise, true);
            var triangleX = Math.Tan(radians) * (contentDesiredSize.Height);
            var leftSegment = new LineSegment(new Point(bottomLeftSegment.Point.X + triangleX, bottomLeftSegment.Point.Y - contentDesiredSize.Height), true);
            var topLeftSegment = new ArcSegment(new Point(leftSegment.Point.X + cheapRadiusBig, leftSegment.Point.Y - cheapRadiusSmall), new Size(cheapRadiusBig, cheapRadiusBig), 120, false, SweepDirection.Clockwise, true);
            var topSegment = new LineSegment(new Point(contentDesiredSize.Width + cheapRadiusBig + cheapRadiusBig, 0), true);
            var topRightSegment = new ArcSegment(new Point(contentDesiredSize.Width + cheapRadiusBig + cheapRadiusBig + cheapRadiusBig, cheapRadiusSmall), new Size(cheapRadiusBig, cheapRadiusBig), 40, false, SweepDirection.Clockwise, true);

            triangleX = Math.Tan(radians) * (contentDesiredSize.Height);
            //triangleX = Math.Tan(radians)*(contentDesiredSize.Height - topRightSegment.Point.Y);
            var rightSegment =
                new LineSegment(new Point(topRightSegment.Point.X + triangleX,
                    topRightSegment.Point.Y + contentDesiredSize.Height), true);

            var bottomRightPoint = new Point(rightSegment.Point.X + cheapRadiusSmall,
                rightSegment.Point.Y + cheapRadiusSmall);
            var bottomRightSegment = new ArcSegment(bottomRightPoint,
                new Size(cheapRadiusSmall, cheapRadiusSmall), 25, false, SweepDirection.Counterclockwise, true);
            var bottomLeftPoint = new Point(0, bottomRightSegment.Point.Y);
            var bottomSegment = new LineSegment(bottomLeftPoint, true);            

            var pathSegmentCollection = new PathSegmentCollection
            {
                bottomLeftSegment, leftSegment, topLeftSegment, topSegment, topRightSegment, rightSegment, bottomRightSegment, bottomSegment
            };
            var pathFigure = new PathFigure(startPoint, pathSegmentCollection, true)
            {
                IsFilled = true
            };
            var pathFigureCollection = new PathFigureCollection
            {
                pathFigure
            };
            var geometryGroup = new PathGeometry(pathFigureCollection);            
            geometryGroup.Freeze();                        

            return geometryGroup;
        }
コード例 #17
0
		/// <summary>
		/// </summary>
		/// <exception cref="ArgumentNullException">
		/// <para><paramref name="span"/> is <see langword="null"/>.</para>
		/// </exception>
		/// <exception cref="ArgumentOutOfRangeException">
		/// <para><paramref name="span"/> is less than zero or greater than the buffer length for the associated <see cref="ISourceEditorView"/>.</para>
		/// </exception>
		public Geometry GetMarkerGeometry(Span span)
		{
			if (span == null)
			{
				throw new ArgumentNullException("span");
			}
			if ((span.Start < 0) || (span.End > _editorView.TextBuffer.Length))
			{
				throw new ArgumentOutOfRangeException("span");
			}
			if (span.IsEmpty)
			{
				return null;
			}
			PathGeometry geometry = new PathGeometry();
			geometry.FillRule = FillRule.Nonzero;
			IList<ITextLine> textLines = _editorView.TextLines;
			if (textLines.Count == 0)
			{
				return null;
			}
			if ((span.Start > base.LastRenderedCharacter) || (span.End < base.FirstRenderedCharacter))
			{
				return null;
			}
			ITextLine item = null;
			ITextLine textLineClosestTo = null;
			if (span.Start < base.FirstRenderedCharacter)
			{
				item = textLines[0];
			}
			if (span.End > base.LastRenderedCharacter)
			{
				textLineClosestTo = textLines[textLines.Count - 1];
			}
			if (item == null)
			{
				item = base.GetTextLineClosestTo(span.Start);
			}
			if (textLineClosestTo == null)
			{
				textLineClosestTo = base.GetTextLineClosestTo(span.End);
			}
			if (item == textLineClosestTo)
			{
				foreach (TextBounds bounds in item.GetTextBounds(span))
				{
					RectangleGeometry geometry2 = new RectangleGeometry(new Rect(bounds.Left - 0.2, bounds.Top - 1, bounds.Width + 0.4, bounds.Height + 1), 0.6, 0.6);
					geometry2.Freeze();
					geometry.AddGeometry(geometry2);
				}
			}
			else
			{
				foreach (TextBounds bounds2 in item.GetTextBounds(span))
				{
					RectangleGeometry geometry3 = new RectangleGeometry(new Rect(bounds2.Left - 0.2, bounds2.Top - 1, bounds2.Width + 0.4, bounds2.Height + 1), 0.6, 0.6);
					geometry3.Freeze();
					geometry.AddGeometry(geometry3);
				}
				Int32 num = textLines.IndexOf(item) + 1;
				Int32 index = textLines.IndexOf(textLineClosestTo);
				for (Int32 i = num; i < index; i++)
				{
					ITextLine line3 = textLines[i];
					RectangleGeometry geometry4 = new RectangleGeometry(new Rect(-0.2, line3.VerticalOffset - 0.2, line3.Width, line3.Height + 0.4), 0.6, 0.6);
					geometry4.Freeze();
					geometry.AddGeometry(geometry4);
				}
				foreach (TextBounds bounds3 in textLineClosestTo.GetTextBounds(span))
				{
					RectangleGeometry geometry5 = new RectangleGeometry(new Rect(bounds3.Left - 0.2, bounds3.Top - 1, bounds3.Width + 0.4, bounds3.Height + 1), 0.6, 0.6);
					geometry5.Freeze();
					geometry.AddGeometry(geometry5);
				}
			}
			geometry.Freeze();
			return geometry.GetOutlinedPathGeometry();
		}
コード例 #18
0
ファイル: DataGridHeaderBorder.cs プロジェクト: JianwenSun/cc
        private void RenderTheme(DrawingContext dc)
        {
            Size size = RenderSize;
            bool horizontal = Orientation == Orientation.Horizontal;
            bool isClickable = IsClickable && IsEnabled;
            bool isHovered = isClickable && IsHovered;
            bool isPressed = isClickable && IsPressed;
            ListSortDirection? sortDirection = SortDirection;
            bool isSorted = sortDirection != null;
            bool isSelected = IsSelected;

            EnsureCache((int)RoyaleFreezables.NumFreezables);

            if (horizontal)
            {
                // When horizontal, rotate the rendering by -90 degrees
                Matrix m1 = new Matrix();
                m1.RotateAt(-90.0, 0.0, 0.0);
                Matrix m2 = new Matrix();
                m2.Translate(0.0, size.Height);

                MatrixTransform horizontalRotate = new MatrixTransform(m1 * m2);
                horizontalRotate.Freeze();
                dc.PushTransform(horizontalRotate);

                double temp = size.Width;
                size.Width = size.Height;
                size.Height = temp;
            }

            // Draw the background
            RoyaleFreezables backgroundType = isPressed ? RoyaleFreezables.PressedBackground : isHovered ? RoyaleFreezables.HoveredBackground : RoyaleFreezables.NormalBackground;
            LinearGradientBrush background = (LinearGradientBrush)GetCachedFreezable((int)backgroundType);
            if (background == null)
            {
                background = new LinearGradientBrush();
                background.StartPoint = new Point();
                background.EndPoint = new Point(0.0, 1.0);

                if (isPressed)
                {
                    background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xB9, 0xB9, 0xC8), 0.0));
                    background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xEC, 0xEC, 0xF3), 0.1));
                    background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xEC, 0xEC, 0xF3), 1.0));
                }
                else if (isHovered || isSelected)
                {
                    background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xFE, 0xFE, 0xFE), 0.0));
                    background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xFE, 0xFE, 0xFE), 0.85));
                    background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xBD, 0xBE, 0xCE), 1.0));
                }
                else
                {
                    background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xF9, 0xFA, 0xFD), 0.0));
                    background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xF9, 0xFA, 0xFD), 0.85));
                    background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xBD, 0xBE, 0xCE), 1.0));
                }

                background.Freeze();
                CacheFreezable(background, (int)backgroundType);
            }

            dc.DrawRectangle(background, null, new Rect(0.0, 0.0, size.Width, size.Height));

            if (isHovered && !isPressed && (size.Width >= 6.0) && (size.Height >= 4.0))
            {
                // When hovered, there is a colored tab at the bottom
                TranslateTransform positionTransform = new TranslateTransform(0.0, size.Height - 3.0);
                positionTransform.Freeze();
                dc.PushTransform(positionTransform);

                PathGeometry tabGeometry = new PathGeometry();
                PathFigure tabFigure = new PathFigure();

                tabFigure.StartPoint = new Point(0.5, 0.5);

                LineSegment line = new LineSegment(new Point(size.Width - 0.5, 0.5), true);
                line.Freeze();
                tabFigure.Segments.Add(line);

                ArcSegment arc = new ArcSegment(new Point(size.Width - 2.5, 2.5), new Size(2.0, 2.0), 90.0, false, SweepDirection.Clockwise, true);
                arc.Freeze();
                tabFigure.Segments.Add(arc);

                line = new LineSegment(new Point(2.5, 2.5), true);
                line.Freeze();
                tabFigure.Segments.Add(line);

                arc = new ArcSegment(new Point(0.5, 0.5), new Size(2.0, 2.0), 90.0, false, SweepDirection.Clockwise, true);
                arc.Freeze();
                tabFigure.Segments.Add(arc);

                tabFigure.IsClosed = true;
                tabFigure.Freeze();

                tabGeometry.Figures.Add(tabFigure);
                tabGeometry.Freeze();

                Pen tabStroke = (Pen)GetCachedFreezable((int)RoyaleFreezables.TabStroke);
                if (tabStroke == null)
                {
                    SolidColorBrush tabStrokeBrush = new SolidColorBrush(Color.FromArgb(0xFF, 0xF8, 0xA9, 0x00));
                    tabStrokeBrush.Freeze();

                    tabStroke = new Pen(tabStrokeBrush, 1.0);
                    tabStroke.Freeze();

                    CacheFreezable(tabStroke, (int)RoyaleFreezables.TabStroke);
                }

                LinearGradientBrush tabFill = (LinearGradientBrush)GetCachedFreezable((int)RoyaleFreezables.TabFill);
                if (tabFill == null)
                {
                    tabFill = new LinearGradientBrush();
                    tabFill.StartPoint = new Point();
                    tabFill.EndPoint = new Point(1.0, 0.0);

                    tabFill.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xFC, 0xE0, 0xA6), 0.0));
                    tabFill.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xF6, 0xC4, 0x56), 0.1));
                    tabFill.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xF6, 0xC4, 0x56), 0.9));
                    tabFill.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xDF, 0x97, 0x00), 1.0));

                    tabFill.Freeze();
                    CacheFreezable(tabFill, (int)RoyaleFreezables.TabFill);
                }

                dc.DrawGeometry(tabFill, tabStroke, tabGeometry);

                dc.Pop(); // Translate Transform
            }

            if (isPressed && (size.Width >= 2.0) && (size.Height >= 2.0))
            {
                // When pressed, there is a border on the left and bottom
                SolidColorBrush border = (SolidColorBrush)GetCachedFreezable((int)RoyaleFreezables.PressedBorder);
                if (border == null)
                {
                    border = new SolidColorBrush(Color.FromArgb(0xFF, 0x80, 0x80, 0x99));
                    border.Freeze();
                    CacheFreezable(border, (int)RoyaleFreezables.PressedBorder);
                }

                dc.DrawRectangle(border, null, new Rect(0.0, 0.0, 1.0, size.Height));
                dc.DrawRectangle(border, null, new Rect(0.0, Max0(size.Height - 1.0), size.Width, 1.0));
            }

            if (!isPressed && !isHovered && (size.Width >= 4.0))
            {
                if (SeparatorVisibility == Visibility.Visible)
                {
                    Brush sideBrush;
                    if (SeparatorBrush != null)
                    {
                        sideBrush = SeparatorBrush;
                    }
                    else
                    {
                        // When not pressed or hovered, draw the resize gripper
                        LinearGradientBrush gripper = (LinearGradientBrush)GetCachedFreezable((int)(horizontal ? RoyaleFreezables.HorizontalGripper : RoyaleFreezables.VerticalGripper));
                        if (gripper == null)
                        {
                            gripper = new LinearGradientBrush();
                            gripper.StartPoint = new Point();
                            gripper.EndPoint = new Point(1.0, 0.0);

                            Color highlight = Color.FromArgb(0xFF, 0xFF, 0xFF, 0xFF);
                            Color shadow = Color.FromArgb(0xFF, 0xC7, 0xC5, 0xB2);

                            if (horizontal)
                            {
                                gripper.GradientStops.Add(new GradientStop(highlight, 0.0));
                                gripper.GradientStops.Add(new GradientStop(highlight, 0.25));
                                gripper.GradientStops.Add(new GradientStop(shadow, 0.75));
                                gripper.GradientStops.Add(new GradientStop(shadow, 1.0));
                            }
                            else
                            {
                                gripper.GradientStops.Add(new GradientStop(shadow, 0.0));
                                gripper.GradientStops.Add(new GradientStop(shadow, 0.25));
                                gripper.GradientStops.Add(new GradientStop(highlight, 0.75));
                                gripper.GradientStops.Add(new GradientStop(highlight, 1.0));
                            }

                            gripper.Freeze();
                            CacheFreezable(gripper, (int)(horizontal ? RoyaleFreezables.HorizontalGripper : RoyaleFreezables.VerticalGripper));
                        }

                        sideBrush = gripper;
                    }

                    dc.DrawRectangle(sideBrush, null, new Rect(horizontal ? 0.0 : Max0(size.Width - 2.0), 4.0, 2.0, Max0(size.Height - 8.0)));
                }
            }

            if (isSorted && (size.Width > 14.0) && (size.Height > 10.0))
            {
                // When sorted, draw an arrow on the right
                TranslateTransform positionTransform = new TranslateTransform(size.Width - 15.0, (size.Height - 5.0) * 0.5);
                positionTransform.Freeze();
                dc.PushTransform(positionTransform);

                bool ascending = (sortDirection == ListSortDirection.Ascending);
                PathGeometry arrowGeometry = (PathGeometry)GetCachedFreezable(ascending ? (int)RoyaleFreezables.ArrowUpGeometry : (int)RoyaleFreezables.ArrowDownGeometry);
                if (arrowGeometry == null)
                {
                    arrowGeometry = new PathGeometry();
                    PathFigure arrowFigure = new PathFigure();

                    if (ascending)
                    {
                        arrowFigure.StartPoint = new Point(0.0, 5.0);

                        LineSegment line = new LineSegment(new Point(5.0, 0.0), false);
                        line.Freeze();
                        arrowFigure.Segments.Add(line);

                        line = new LineSegment(new Point(10.0, 5.0), false);
                        line.Freeze();
                        arrowFigure.Segments.Add(line);
                    }
                    else
                    {
                        arrowFigure.StartPoint = new Point(0.0, 0.0);

                        LineSegment line = new LineSegment(new Point(10.0, 0.0), false);
                        line.Freeze();
                        arrowFigure.Segments.Add(line);

                        line = new LineSegment(new Point(5.0, 5.0), false);
                        line.Freeze();
                        arrowFigure.Segments.Add(line);
                    }

                    arrowFigure.IsClosed = true;
                    arrowFigure.Freeze();

                    arrowGeometry.Figures.Add(arrowFigure);
                    arrowGeometry.Freeze();

                    CacheFreezable(arrowGeometry, ascending ? (int)RoyaleFreezables.ArrowUpGeometry : (int)RoyaleFreezables.ArrowDownGeometry);
                }

                SolidColorBrush arrowFill = (SolidColorBrush)GetCachedFreezable((int)RoyaleFreezables.ArrowFill);
                if (arrowFill == null)
                {
                    arrowFill = new SolidColorBrush(Color.FromArgb(0xFF, 0xAC, 0xA8, 0x99));
                    arrowFill.Freeze();
                    CacheFreezable(arrowFill, (int)RoyaleFreezables.ArrowFill);
                }

                dc.DrawGeometry(arrowFill, null, arrowGeometry);

                dc.Pop(); // Position Transform
            }

            if (horizontal)
            {
                dc.Pop(); // Horizontal Rotate
            }
        }
コード例 #19
0
ファイル: SelectionLayer.cs プロジェクト: lovebanyi/dnSpy
        protected override void OnRender(DrawingContext drawingContext)
        {
            base.OnRender(drawingContext);
            if (hexBox.Selection == null || hexBox.VisibleBytesPerLine < 1)
                return;

            ulong selStart = hexBox.Selection.Value.StartOffset;
            ulong selEnd = hexBox.Selection.Value.EndOffset;
            int lines = hexBox.VisibleLinesPerPage;
            ulong bpl = (ulong)hexBox.VisibleBytesPerLine;
            ulong visibleStart = hexBox.TopOffset;
            ulong visibleEnd = NumberUtils.AddUInt64(NumberUtils.AddUInt64(visibleStart, NumberUtils.MulUInt64(bpl, NumberUtils.SubUInt64((ulong)lines, 1))), NumberUtils.SubUInt64(bpl, 1));
            if (selStart > visibleEnd || selEnd < visibleStart)
                return;

            ulong offset = Math.Max(selStart, visibleStart);
            ulong endOffset = Math.Min(selEnd, visibleEnd);
            double x = -hexBox.CharacterWidth * hexBox.LeftColumn;
            double y = (offset - hexBox.TopOffset) / bpl * hexBox.CharacterHeight;
            var path = new PathGeometry();
            double hexByteX = hexBox.GetHexByteColumnIndex() * hexBox.CharacterWidth;
            double asciiX = hexBox.GetAsciiColumnIndex() * hexBox.CharacterWidth;
            while (offset <= endOffset) {
                ulong byteIndex = hexBox.GetLineByteIndex(offset);
                ulong count = Math.Min(bpl - byteIndex, endOffset - offset + 1);

                double dx = byteIndex * hexBox.CharacterWidth;
                var rectGeo = new RectangleGeometry(new Rect(x + dx * 3 + hexByteX + hexBox.CharacterWidth, y, count * hexBox.CharacterWidth * 3 - hexBox.CharacterWidth, hexBox.CharacterHeight));
                rectGeo.Freeze();
                path.AddGeometry(rectGeo);

                if (hexBox.ShowAscii) {
                    rectGeo = new RectangleGeometry(new Rect(x + dx + asciiX, y, count * hexBox.CharacterWidth, hexBox.CharacterHeight));
                    rectGeo.Freeze();
                    path.AddGeometry(rectGeo);
                }

                if (offset + bpl - byteIndex < offset)
                    break;
                offset += bpl - byteIndex;
                y += hexBox.CharacterHeight;
            }

            path.Freeze();
            drawingContext.DrawGeometry(Background, null, path);
        }
コード例 #20
0
        private void RenderAeroNormalColor(DrawingContext dc)
        {
            Size size = RenderSize;
            bool horizontal = Orientation == Orientation.Horizontal;
            bool isClickable = IsClickable && IsEnabled;
            bool isHovered = isClickable && IsHovered;
            bool isPressed = isClickable && IsPressed;
            ListSortDirection? sortDirection = SortDirection;
            bool isSorted = sortDirection != null;
            bool isSelected = IsSelected;
            bool hasBevel = (!isHovered && !isPressed && !isSorted && !isSelected);

            EnsureCache((int)AeroFreezables.NumFreezables);

            if (horizontal)
            {
                // When horizontal, rotate the rendering by -90 degrees
                Matrix m1 = new Matrix();
                m1.RotateAt(-90.0, 0.0, 0.0);
                Matrix m2 = new Matrix();
                m2.Translate(0.0, size.Height);

                MatrixTransform horizontalRotate = new MatrixTransform(m1 * m2);
                horizontalRotate.Freeze();
                dc.PushTransform(horizontalRotate);

                double temp = size.Width;
                size.Width = size.Height;
                size.Height = temp;
            }

            if (hasBevel)
            {
                // This is a highlight that can be drawn by just filling the background with the color.
                // It will be seen through the gab between the border and the background.
                LinearGradientBrush bevel = (LinearGradientBrush)GetCachedFreezable((int)AeroFreezables.NormalBevel);
                if (bevel == null)
                {
                    bevel = new LinearGradientBrush();
                    bevel.StartPoint = new Point();
                    bevel.EndPoint = new Point(0.0, 1.0);
                    bevel.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xFF, 0xFF, 0xFF), 0.0));
                    bevel.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xFF, 0xFF, 0xFF), 0.4));
                    bevel.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xFC, 0xFC, 0xFD), 0.4));
                    bevel.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xFB, 0xFC, 0xFC), 1.0));
                    bevel.Freeze();

                    CacheFreezable(bevel, (int)AeroFreezables.NormalBevel);
                }

                dc.DrawRectangle(bevel, null, new Rect(0.0, 0.0, size.Width, size.Height));
            }

            // Fill the background
            AeroFreezables backgroundType = AeroFreezables.NormalBackground;
            if (isPressed)
            {
                backgroundType = AeroFreezables.PressedBackground;
            }
            else if (isHovered)
            {
                backgroundType = AeroFreezables.HoveredBackground;
            }
            else if (isSorted || isSelected)
            {
                backgroundType = AeroFreezables.SortedBackground;
            }

            LinearGradientBrush background = (LinearGradientBrush)GetCachedFreezable((int)backgroundType);
            if (background == null)
            {
                background = new LinearGradientBrush();
                background.StartPoint = new Point();
                background.EndPoint = new Point(0.0, 1.0);

                switch (backgroundType)
                {
                    case AeroFreezables.NormalBackground:
                        background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xFF, 0xFF, 0xFF), 0.0));
                        background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xFF, 0xFF, 0xFF), 0.4));
                        background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xF7, 0xF8, 0xFA), 0.4));
                        background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xF1, 0xF2, 0xF4), 1.0));
                        break;

                    case AeroFreezables.PressedBackground:
                        background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xBC, 0xE4, 0xF9), 0.0));
                        background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xBC, 0xE4, 0xF9), 0.4));
                        background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0x8D, 0xD6, 0xF7), 0.4));
                        background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0x8A, 0xD1, 0xF5), 1.0));
                        break;

                    case AeroFreezables.HoveredBackground:
                        background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xE3, 0xF7, 0xFF), 0.0));
                        background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xE3, 0xF7, 0xFF), 0.4));
                        background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xBD, 0xED, 0xFF), 0.4));
                        background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xB7, 0xE7, 0xFB), 1.0));
                        break;

                    case AeroFreezables.SortedBackground:
                        background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xF2, 0xF9, 0xFC), 0.0));
                        background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xF2, 0xF9, 0xFC), 0.4));
                        background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xE1, 0xF1, 0xF9), 0.4));
                        background.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xD8, 0xEC, 0xF6), 1.0));
                        break;
                }

                background.Freeze();

                CacheFreezable(background, (int)backgroundType);
            }

            dc.DrawRectangle(background, null, new Rect(0.0, 0.0, size.Width, size.Height));

            if (size.Width >= 2.0)
            {
                // Draw the borders on the sides
                AeroFreezables sideType = AeroFreezables.NormalSides;
                if (isPressed)
                {
                    sideType = AeroFreezables.PressedSides;
                }
                else if (isHovered)
                {
                    sideType = AeroFreezables.HoveredSides;
                }
                else if (isSorted || isSelected)
                {
                    sideType = AeroFreezables.SortedSides;
                }

                if (SeparatorVisibility == Visibility.Visible)
                {
                    Brush sideBrush;
                    if (SeparatorBrush != null)
                    {
                        sideBrush = SeparatorBrush;
                    }
                    else
                    {
                        sideBrush = (Brush)GetCachedFreezable((int)sideType);
                        if (sideBrush == null)
                        {
                            LinearGradientBrush lgBrush = null;
                            if (sideType != AeroFreezables.SortedSides)
                            {
                                lgBrush = new LinearGradientBrush();
                                lgBrush.StartPoint = new Point();
                                lgBrush.EndPoint = new Point(0.0, 1.0);
                                sideBrush = lgBrush;
                            }

                            switch (sideType)
                            {
                                case AeroFreezables.NormalSides:
                                    lgBrush.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xF2, 0xF2, 0xF2), 0.0));
                                    lgBrush.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xEF, 0xEF, 0xEF), 0.4));
                                    lgBrush.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xE7, 0xE8, 0xEA), 0.4));
                                    lgBrush.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xDE, 0xDF, 0xE1), 1.0));
                                    break;

                                case AeroFreezables.PressedSides:
                                    lgBrush.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0x7A, 0x9E, 0xB1), 0.0));
                                    lgBrush.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0x7A, 0x9E, 0xB1), 0.4));
                                    lgBrush.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0x50, 0x91, 0xAF), 0.4));
                                    lgBrush.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0x4D, 0x8D, 0xAD), 1.0));
                                    break;

                                case AeroFreezables.HoveredSides:
                                    lgBrush.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0x88, 0xCB, 0xEB), 0.0));
                                    lgBrush.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0x88, 0xCB, 0xEB), 0.4));
                                    lgBrush.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0x69, 0xBB, 0xE3), 0.4));
                                    lgBrush.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0x69, 0xBB, 0xE3), 1.0));
                                    break;

                                case AeroFreezables.SortedSides:
                                    sideBrush = new SolidColorBrush(Color.FromArgb(0xFF, 0x96, 0xD9, 0xF9));
                                    break;
                            }

                            sideBrush.Freeze();

                            CacheFreezable(sideBrush, (int)sideType);
                        }
                    }

                    dc.DrawRectangle(sideBrush, null, new Rect(0.0, 0.0, 1.0, Max0(size.Height - 0.95)));
                    dc.DrawRectangle(sideBrush, null, new Rect(size.Width - 1.0, 0.0, 1.0, Max0(size.Height - 0.95)));
                }
            }

            if (isPressed && (size.Width >= 4.0) && (size.Height >= 4.0))
            {
                // When pressed, there are added borders on the left and top
                LinearGradientBrush topBrush = (LinearGradientBrush)GetCachedFreezable((int)AeroFreezables.PressedTop);
                if (topBrush == null)
                {
                    topBrush = new LinearGradientBrush();
                    topBrush.StartPoint = new Point();
                    topBrush.EndPoint = new Point(0.0, 1.0);
                    topBrush.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0x86, 0xA3, 0xB2), 0.0));
                    topBrush.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0x86, 0xA3, 0xB2), 0.1));
                    topBrush.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xAA, 0xCE, 0xE1), 0.9));
                    topBrush.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xAA, 0xCE, 0xE1), 1.0));
                    topBrush.Freeze();

                    CacheFreezable(topBrush, (int)AeroFreezables.PressedTop);
                }

                dc.DrawRectangle(topBrush, null, new Rect(0.0, 0.0, size.Width, 2.0));

                LinearGradientBrush pressedBevel = (LinearGradientBrush)GetCachedFreezable((int)AeroFreezables.PressedBevel);
                if (pressedBevel == null)
                {
                    pressedBevel = new LinearGradientBrush();
                    pressedBevel.StartPoint = new Point();
                    pressedBevel.EndPoint = new Point(0.0, 1.0);
                    pressedBevel.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xA2, 0xCB, 0xE0), 0.0));
                    pressedBevel.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xA2, 0xCB, 0xE0), 0.4));
                    pressedBevel.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0x72, 0xBC, 0xDF), 0.4));
                    pressedBevel.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0x6E, 0xB8, 0xDC), 1.0));
                    pressedBevel.Freeze();

                    CacheFreezable(pressedBevel, (int)AeroFreezables.PressedBevel);
                }

                dc.DrawRectangle(pressedBevel, null, new Rect(1.0, 0.0, 1.0, size.Height - 0.95));
                dc.DrawRectangle(pressedBevel, null, new Rect(size.Width - 2.0, 0.0, 1.0, size.Height - 0.95));
            }

            if (size.Height >= 2.0)
            {
                // Draw the bottom border
                AeroFreezables bottomType = AeroFreezables.NormalBottom;
                if (isPressed)
                {
                    bottomType = AeroFreezables.PressedOrHoveredBottom;
                }
                else if (isHovered)
                {
                    bottomType = AeroFreezables.PressedOrHoveredBottom;
                }
                else if (isSorted || isSelected)
                {
                    bottomType = AeroFreezables.SortedBottom;
                }

                SolidColorBrush bottomBrush = (SolidColorBrush)GetCachedFreezable((int)bottomType);
                if (bottomBrush == null)
                {
                    switch (bottomType)
                    {
                        case AeroFreezables.NormalBottom:
                            bottomBrush = new SolidColorBrush(Color.FromArgb(0xFF, 0xD5, 0xD5, 0xD5));
                            break;

                        case AeroFreezables.PressedOrHoveredBottom:
                            bottomBrush = new SolidColorBrush(Color.FromArgb(0xFF, 0x93, 0xC9, 0xE3));
                            break;

                        case AeroFreezables.SortedBottom:
                            bottomBrush = new SolidColorBrush(Color.FromArgb(0xFF, 0x96, 0xD9, 0xF9));
                            break;
                    }

                    bottomBrush.Freeze();

                    CacheFreezable(bottomBrush, (int)bottomType);
                }

                dc.DrawRectangle(bottomBrush, null, new Rect(0.0, size.Height - 1.0, size.Width, 1.0));
            }

            if (isSorted && (size.Width > 14.0) && (size.Height > 10.0))
            {
                // Draw the sort arrow
                TranslateTransform positionTransform = new TranslateTransform((size.Width - 8.0) * 0.5, 1.0);
                positionTransform.Freeze();
                dc.PushTransform(positionTransform);

                bool ascending = (sortDirection == ListSortDirection.Ascending);
                PathGeometry arrowGeometry = (PathGeometry)GetCachedFreezable(ascending ? (int)AeroFreezables.ArrowUpGeometry : (int)AeroFreezables.ArrowDownGeometry);
                if (arrowGeometry == null)
                {
                    arrowGeometry = new PathGeometry();
                    PathFigure arrowFigure = new PathFigure();

                    if (ascending)
                    {
                        arrowFigure.StartPoint = new Point(0.0, 4.0);

                        LineSegment line = new LineSegment(new Point(4.0, 0.0), false);
                        line.Freeze();
                        arrowFigure.Segments.Add(line);

                        line = new LineSegment(new Point(8.0, 4.0), false);
                        line.Freeze();
                        arrowFigure.Segments.Add(line);
                    }
                    else
                    {
                        arrowFigure.StartPoint = new Point(0.0, 0.0);

                        LineSegment line = new LineSegment(new Point(8.0, 0.0), false);
                        line.Freeze();
                        arrowFigure.Segments.Add(line);

                        line = new LineSegment(new Point(4.0, 4.0), false);
                        line.Freeze();
                        arrowFigure.Segments.Add(line);
                    }

                    arrowFigure.IsClosed = true;
                    arrowFigure.Freeze();

                    arrowGeometry.Figures.Add(arrowFigure);
                    arrowGeometry.Freeze();

                    CacheFreezable(arrowGeometry, ascending ? (int)AeroFreezables.ArrowUpGeometry : (int)AeroFreezables.ArrowDownGeometry);
                }

                // Draw two arrows, one inset in the other. This is to achieve a double gradient over both the border and the fill.
                LinearGradientBrush arrowBorder = (LinearGradientBrush)GetCachedFreezable((int)AeroFreezables.ArrowBorder);
                if (arrowBorder == null)
                {
                    arrowBorder = new LinearGradientBrush();
                    arrowBorder.StartPoint = new Point();
                    arrowBorder.EndPoint = new Point(1.0, 1.0);
                    arrowBorder.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0x3C, 0x5E, 0x72), 0.0));
                    arrowBorder.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0x3C, 0x5E, 0x72), 0.1));
                    arrowBorder.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xC3, 0xE4, 0xF5), 1.0));
                    arrowBorder.Freeze();
                    CacheFreezable(arrowBorder, (int)AeroFreezables.ArrowBorder);
                }

                dc.DrawGeometry(arrowBorder, null, arrowGeometry);

                LinearGradientBrush arrowFill = (LinearGradientBrush)GetCachedFreezable((int)AeroFreezables.ArrowFill);
                if (arrowFill == null)
                {
                    arrowFill = new LinearGradientBrush();
                    arrowFill.StartPoint = new Point();
                    arrowFill.EndPoint = new Point(1.0, 1.0);
                    arrowFill.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0x61, 0x96, 0xB6), 0.0));
                    arrowFill.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0x61, 0x96, 0xB6), 0.1));
                    arrowFill.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xCA, 0xE6, 0xF5), 1.0));
                    arrowFill.Freeze();
                    CacheFreezable(arrowFill, (int)AeroFreezables.ArrowFill);
                }

                // Inset the fill arrow inside the border arrow
                ScaleTransform arrowScale = (ScaleTransform)GetCachedFreezable((int)AeroFreezables.ArrowFillScale);
                if (arrowScale == null)
                {
                    arrowScale = new ScaleTransform(0.75, 0.75, 3.5, 4.0);
                    arrowScale.Freeze();
                    CacheFreezable(arrowScale, (int)AeroFreezables.ArrowFillScale);
                }

                dc.PushTransform(arrowScale);

                dc.DrawGeometry(arrowFill, null, arrowGeometry);

                dc.Pop(); // Scale Transform
                dc.Pop(); // Position Transform
            }

            if (horizontal)
            {
                dc.Pop(); // Horizontal Rotate
            }
        }
コード例 #21
0
ファイル: MainWindow.xaml.cs プロジェクト: HarelM/Set-Game
        private void AnimatePutCard(int iLocationIndex)
        {
            Canvas targetCanves = GetCanvas(iLocationIndex);
            Point pointCanvasCorner = targetCanves.PointToScreen(new Point(0, 0));
            Point pointWindowCorner = PointToScreen(new Point(0, 0));

            // Create the animation path.
            PathGeometry animationPath = new PathGeometry();
            PathFigure pFigure = new PathFigure();

            PolyLineSegment pLineSegment = new PolyLineSegment();
            Point pointStart = new Point();
            pointStart.X = pointWindowCorner.X - pointCanvasCorner.X + this.ActualWidth / 2 - targetCanves.ActualHeight / 4;
            pointStart.Y = pointWindowCorner.Y - pointCanvasCorner.Y - targetCanves.ActualWidth;
            pFigure.StartPoint = pointStart;
            pLineSegment.Points.Add(pFigure.StartPoint);
            pLineSegment.Points.Add(new Point(0, 0));

            // Create a MatrixTransform. This transform will be used to move the button.
            MatrixTransform matrixTransform = new MatrixTransform();
            targetCanves.RenderTransform = matrixTransform;

            pFigure.Segments.Add(pLineSegment);
            animationPath.Figures.Add(pFigure);

            // Freeze the PathGeometry for performance benefits.
            animationPath.Freeze();

            // Create a MatrixAnimationUsingPath to move the
            // button along the path by animating its MatrixTransform.
            MatrixAnimationUsingPath matrixAnimation = new MatrixAnimationUsingPath();
            matrixAnimation.PathGeometry = animationPath;
            matrixAnimation.Duration = TimeSpan.FromSeconds(iAnimationPutCardTime);

            DoubleAnimation doubleAnimation = new DoubleAnimation(90, 360, TimeSpan.FromSeconds(iAnimationPutCardTime));
            RotateTransform renderTransform = new RotateTransform(0, targetCanves.ActualWidth / 2, targetCanves.ActualHeight / 2);//targetCanves.ActualHeight);
            targetCanves.Children[0].RenderTransform = renderTransform;
            renderTransform.BeginAnimation(RotateTransform.AngleProperty, doubleAnimation);

            //matrixAnimation.DoesRotateWithTangent = true;
            matrixTransform.BeginAnimation(MatrixTransform.MatrixProperty, matrixAnimation);
        }
コード例 #22
0
        /*
         * Animation Helper Methods
         */
        private void moveCard(Image cardImage, int absoluteX, int absoluteY)
        {
            string transformName = "theTransform";
                int x = absoluteX - (int)cardImage.Margin.Left;
                int y = absoluteY - (int)cardImage.Margin.Top;

                if (x != 0 && y != 0)
                {
                    //create translateTransform
                    TranslateTransform moveCard9 = new TranslateTransform();
                    this.RegisterName(transformName, moveCard9);
                    cardImage.RenderTransform = moveCard9;

                    //create the path
                    PathGeometry animationPath9 = new PathGeometry();
                    PathFigure pFigure9 = new PathFigure();
                    pFigure9.StartPoint = new Point(0, 0);
                    PolyBezierSegment pBezierSegment9 = new PolyBezierSegment();
                    pBezierSegment9.Points.Add(new Point(x, y));
                    pBezierSegment9.Points.Add(new Point(x, y));
                    pBezierSegment9.Points.Add(new Point(x, y));
                    pFigure9.Segments.Add(pBezierSegment9);
                    animationPath9.Figures.Add(pFigure9);

                    //freeze path for performance benefits
                    animationPath9.Freeze();

                    //create the animation to move the card horizontally
                    DoubleAnimationUsingPath translateXAnimation9 = new DoubleAnimationUsingPath();
                    translateXAnimation9.PathGeometry = animationPath9;
                    translateXAnimation9.Duration = TimeSpan.FromSeconds(1);
                    translateXAnimation9.Source = PathAnimationSource.X;

                    Storyboard.SetTargetName(translateXAnimation9, transformName);
                    Storyboard.SetTargetProperty(translateXAnimation9, new PropertyPath(TranslateTransform.XProperty));

                    //create the animation to move the card vertically
                    DoubleAnimationUsingPath translateYAnimation9 = new DoubleAnimationUsingPath();
                    translateYAnimation9.PathGeometry = animationPath9;
                    translateYAnimation9.Duration = TimeSpan.FromSeconds(1);
                    translateYAnimation9.Source = PathAnimationSource.Y;

                    Storyboard.SetTargetName(translateYAnimation9, transformName);
                    Storyboard.SetTargetProperty(translateYAnimation9, new PropertyPath(TranslateTransform.YProperty));

                    //create a storyboard
                    Storyboard pathAnimationStoryboard = new Storyboard();
                    pathAnimationStoryboard.Children.Add(translateXAnimation9);
                    pathAnimationStoryboard.Children.Add(translateYAnimation9);

                    //begin the storyboard
                    pathAnimationStoryboard.Begin(this);
                    this.UnregisterName(transformName);
                }
        }
コード例 #23
0
ファイル: MainWindow.xaml.cs プロジェクト: HarelM/Set-Game
        private void AnimatePutCardMiddleOrRight(int iLocationIndex)
        {
            Canvas targetCanves = GetCanvas(iLocationIndex);
            Point pointCanvasCorner = targetCanves.PointToScreen(new Point(0, 0));

            // Create the animation path.
            PathGeometry animationPath = new PathGeometry();
            PathFigure pFigure = new PathFigure();

            PolyBezierSegment pBezierSegment = new PolyBezierSegment();

            pFigure.StartPoint = new Point(-pointCanvasCorner.X + this.ActualWidth / 2, -pointCanvasCorner.Y);
            pBezierSegment.Points.Add(pFigure.StartPoint);
            pBezierSegment.Points.Add(new Point(-targetCanves.ActualWidth, 0));
            pBezierSegment.Points.Add(new Point(0, 0));

            // Create a MatrixTransform. This transform will be used to move the button.
            MatrixTransform matrixTransform = new MatrixTransform();
            targetCanves.RenderTransform = matrixTransform;

            pFigure.Segments.Add(pBezierSegment);
            animationPath.Figures.Add(pFigure);

            // Freeze the PathGeometry for performance benefits.
            animationPath.Freeze();

            // Create a MatrixAnimationUsingPath to move the
            // button along the path by animating its MatrixTransform.
            MatrixAnimationUsingPath matrixAnimation =
                new MatrixAnimationUsingPath();
            matrixAnimation.PathGeometry = animationPath;
            matrixAnimation.Duration = TimeSpan.FromSeconds(iAnimationPutCardTime);

            // Set the animation's DoesRotateWithTangent property
            // to true so that rotates the card in addition to moving it.
            matrixAnimation.DoesRotateWithTangent = true;
            matrixTransform.BeginAnimation(MatrixTransform.MatrixProperty, matrixAnimation);
        }
コード例 #24
0
ファイル: MainWindow.xaml.cs プロジェクト: HarelM/Set-Game
        private void AnimatePutCardLeft(int iLocationIndex)
        {
            Canvas targetCanves = GetCanvas(iLocationIndex);
            Point pointCanvasCorner = targetCanves.PointToScreen(new Point(0, 0));

            // Create the animation path.
            PathGeometry animationPath = new PathGeometry();
            PathFigure pFigure = new PathFigure();

            PolyBezierSegment pBezierSegment = new PolyBezierSegment();
            pFigure.StartPoint = new Point(-pointCanvasCorner.X + this.ActualWidth / 2, -pointCanvasCorner.Y);
            pBezierSegment.Points.Add(pFigure.StartPoint);
            pBezierSegment.Points.Add(new Point(targetCanves.ActualWidth * 2, targetCanves.ActualHeight));
            pBezierSegment.Points.Add(new Point(targetCanves.ActualWidth, targetCanves.ActualHeight));

            // Create a MatrixTransform. This transform will be used to move the button.
            MatrixTransform matrixTransform = new MatrixTransform();
            targetCanves.RenderTransform = matrixTransform;

            pFigure.Segments.Add(pBezierSegment);
            animationPath.Figures.Add(pFigure);

            // Freeze the PathGeometry for performance benefits.
            animationPath.Freeze();

            // Create a MatrixAnimationUsingPath to move the
            // button along the path by animating its MatrixTransform.
            MatrixAnimationUsingPath matrixAnimation =
                new MatrixAnimationUsingPath();
            matrixAnimation.PathGeometry = animationPath;
            matrixAnimation.Duration = TimeSpan.FromSeconds(2 * iAnimationPutCardTime / 3);

            matrixAnimation.Completed += delegate
            {
                // the cards get reversed - there for need animation to flip it...
                DoubleAnimation doubleAnimation = new DoubleAnimation(180, 0, TimeSpan.FromSeconds(iAnimationPutCardTime / 3));
                RotateTransform rotareTransform = new RotateTransform(0, targetCanves.ActualWidth / 2, targetCanves.ActualHeight / 2);//targetCanves.ActualHeight);
                targetCanves.RenderTransform = rotareTransform;
                rotareTransform.BeginAnimation(RotateTransform.AngleProperty, doubleAnimation);
            };

            // Set the animation's DoesRotateWithTangent property
            // to true so that rotates the card in addition to moving it.
            matrixAnimation.DoesRotateWithTangent = true;
            matrixTransform.BeginAnimation(MatrixTransform.MatrixProperty, matrixAnimation);
        }
コード例 #25
0
        private void dealcards()
        {
            ////////////////////////////////////////////////
            //////// Deal card 1 ///////////////////////////
            ////////////////////////////////////////////////
            TranslateTransform moveCard9 = new TranslateTransform();
            this.RegisterName("AnimatedTranslateTransform", moveCard9);
            card9.RenderTransform = moveCard9;

            //create the path
            PathGeometry animationPath9 = new PathGeometry();
            PathFigure pFigure9 = new PathFigure();
            pFigure9.StartPoint = new Point(0, 0);
            PolyBezierSegment pBezierSegment9 = new PolyBezierSegment();
            pBezierSegment9.Points.Add(new Point(30, 350));
            pBezierSegment9.Points.Add(new Point(30, 350));
            pBezierSegment9.Points.Add(new Point(30, 350));
            pFigure9.Segments.Add(pBezierSegment9);
            animationPath9.Figures.Add(pFigure9);

            //freeze path for performance benefits
            animationPath9.Freeze();

            //create the animation to move the card horizontally
            DoubleAnimationUsingPath translateXAnimation9 = new DoubleAnimationUsingPath();
            translateXAnimation9.PathGeometry = animationPath9;
            translateXAnimation9.PathGeometry = animationPath9;
            translateXAnimation9.Duration = TimeSpan.FromSeconds(.5);

            //set source property to x
            translateXAnimation9.Source = PathAnimationSource.X;

            Storyboard.SetTargetName(translateXAnimation9, "AnimatedTranslateTransform");
            Storyboard.SetTargetProperty(translateXAnimation9, new PropertyPath(TranslateTransform.XProperty));

            DoubleAnimationUsingPath translateYAnimation9 = new DoubleAnimationUsingPath();
            translateYAnimation9.PathGeometry = animationPath9;
            translateYAnimation9.Duration = TimeSpan.FromSeconds(.5);

            translateYAnimation9.Source = PathAnimationSource.Y;

            Storyboard.SetTargetName(translateYAnimation9, "AnimatedTranslateTransform");
            Storyboard.SetTargetProperty(translateYAnimation9, new PropertyPath(TranslateTransform.YProperty));

            //create a storyboard
            Storyboard.SetTargetName(translateYAnimation9, "AnimatedTranslateTransform");
            Storyboard.SetTargetProperty(translateYAnimation9, new PropertyPath(TranslateTransform.YProperty));

            ////////////////////////////////////////////////
            //////// Deal card 2 ///////////////////////////
            ////////////////////////////////////////////////
            TranslateTransform moveCard8 = new TranslateTransform();
            this.RegisterName("AnimatedTranslateTransform8", moveCard8);
            card8.RenderTransform = moveCard8;

            //create the path
            PathGeometry animationPath8 = new PathGeometry();
            PathFigure pFigure8 = new PathFigure();
            pFigure8.StartPoint = new Point(0, 0);
            PolyBezierSegment pBezierSegment8 = new PolyBezierSegment();
            pBezierSegment8.Points.Add(new Point(130, 350));
            pBezierSegment8.Points.Add(new Point(130, 350));
            pBezierSegment8.Points.Add(new Point(130, 350));
            pFigure8.Segments.Add(pBezierSegment8);
               // animationPath8.Figures.Add(pFigure7);
            animationPath8.Figures.Add(pFigure8);

            //freeze path for performance benefits
            animationPath8.Freeze();

            //create the animation to move the card horizontally
            DoubleAnimationUsingPath translateXAnimation8 = new DoubleAnimationUsingPath();
            translateXAnimation8.PathGeometry = animationPath8;
            translateXAnimation8.PathGeometry = animationPath8;
            translateXAnimation8.Duration = TimeSpan.FromSeconds(.5);

            //set source property to x
            translateXAnimation8.Source = PathAnimationSource.X;

            Storyboard.SetTargetName(translateXAnimation8, "AnimatedTranslateTransform8");
            Storyboard.SetTargetProperty(translateXAnimation8, new PropertyPath(TranslateTransform.XProperty));

            DoubleAnimationUsingPath translateYAnimation8 = new DoubleAnimationUsingPath();
            translateYAnimation8.PathGeometry = animationPath8;
            translateYAnimation8.Duration = TimeSpan.FromSeconds(.5);

            translateYAnimation8.Source = PathAnimationSource.Y;

            Storyboard.SetTargetName(translateYAnimation8, "AnimatedTranslateTransform8");
            Storyboard.SetTargetProperty(translateYAnimation8, new PropertyPath(TranslateTransform.YProperty));

            //create a storyboard
            Storyboard.SetTargetName(translateYAnimation8, "AnimatedTranslateTransform8");
            Storyboard.SetTargetProperty(translateYAnimation8, new PropertyPath(TranslateTransform.YProperty));

            ////////////////////////////////////////////////
            //////// Deal card 3 ///////////////////////////
            ////////////////////////////////////////////////
            TranslateTransform moveCard7 = new TranslateTransform();
            this.RegisterName("AnimatedTranslateTransform7", moveCard7);
            card7.RenderTransform = moveCard7;

            //create the path
            PathGeometry animationPath7 = new PathGeometry();
            PathFigure pFigure7 = new PathFigure();
            pFigure7.StartPoint = new Point(0, 0);
            PolyBezierSegment pBezierSegment7 = new PolyBezierSegment();
            pBezierSegment7.Points.Add(new Point(710, 350));
            pBezierSegment7.Points.Add(new Point(710, 350));
            pBezierSegment7.Points.Add(new Point(710, 350));
            pFigure7.Segments.Add(pBezierSegment7);
            animationPath7.Figures.Add(pFigure7);

            //freeze path for performance benefits
            animationPath7.Freeze();

            //create the animation to move the card horizontally
            DoubleAnimationUsingPath translateXAnimation7 = new DoubleAnimationUsingPath();
            translateXAnimation7.PathGeometry = animationPath7;
            translateXAnimation7.PathGeometry = animationPath7;
            translateXAnimation7.Duration = TimeSpan.FromSeconds(.7);

            //set source property to x
            translateXAnimation7.Source = PathAnimationSource.X;

            Storyboard.SetTargetName(translateXAnimation7, "AnimatedTranslateTransform7");
            Storyboard.SetTargetProperty(translateXAnimation7, new PropertyPath(TranslateTransform.XProperty));

            DoubleAnimationUsingPath translateYAnimation7 = new DoubleAnimationUsingPath();
            translateYAnimation7.PathGeometry = animationPath7;
            translateYAnimation7.Duration = TimeSpan.FromSeconds(.7);

            translateYAnimation7.Source = PathAnimationSource.Y;

            Storyboard.SetTargetName(translateYAnimation7, "AnimatedTranslateTransform7");
            Storyboard.SetTargetProperty(translateYAnimation7, new PropertyPath(TranslateTransform.YProperty));

            //create a storyboard
            Storyboard.SetTargetName(translateYAnimation7, "AnimatedTranslateTransform7");
            Storyboard.SetTargetProperty(translateYAnimation7, new PropertyPath(TranslateTransform.YProperty));

            ////////////////////////////////////////////////
            //////// Deal card 4 ///////////////////////////
            ////////////////////////////////////////////////
            TranslateTransform moveCard6 = new TranslateTransform();
            this.RegisterName("AnimatedTranslateTransform6", moveCard6);
            card6.RenderTransform = moveCard6;

            //create the path
            PathGeometry animationPath6 = new PathGeometry();
            PathFigure pFigure6 = new PathFigure();
            pFigure6.StartPoint = new Point(0, 0);
            PolyBezierSegment pBezierSegment6 = new PolyBezierSegment();
            pBezierSegment6.Points.Add(new Point(810, 350));
            pBezierSegment6.Points.Add(new Point(810, 350));
            pBezierSegment6.Points.Add(new Point(810, 350));
            pFigure6.Segments.Add(pBezierSegment6);
            animationPath6.Figures.Add(pFigure6);

            //freeze path for performance benefits
            animationPath6.Freeze();

            //create the animation to move the card horizontally
            DoubleAnimationUsingPath translateXAnimation6 = new DoubleAnimationUsingPath();
            translateXAnimation6.PathGeometry = animationPath6;
            translateXAnimation6.PathGeometry = animationPath6;
            translateXAnimation6.Duration = TimeSpan.FromSeconds(.6);

            //set source property to x
            translateXAnimation6.Source = PathAnimationSource.X;

            Storyboard.SetTargetName(translateXAnimation6, "AnimatedTranslateTransform6");
            Storyboard.SetTargetProperty(translateXAnimation6, new PropertyPath(TranslateTransform.XProperty));

            DoubleAnimationUsingPath translateYAnimation6 = new DoubleAnimationUsingPath();
            translateYAnimation6.PathGeometry = animationPath6;
            translateYAnimation6.Duration = TimeSpan.FromSeconds(.6);

            translateYAnimation6.Source = PathAnimationSource.Y;

            Storyboard.SetTargetName(translateYAnimation6, "AnimatedTranslateTransform6");
            Storyboard.SetTargetProperty(translateYAnimation6, new PropertyPath(TranslateTransform.YProperty));

            //create a storyboard
            Storyboard.SetTargetName(translateYAnimation6, "AnimatedTranslateTransform6");
            Storyboard.SetTargetProperty(translateYAnimation6, new PropertyPath(TranslateTransform.YProperty));

            ////////////////////////////////////////////////
            //////// Deal card 5 ///////////////////////////
            ////////////////////////////////////////////////
            TranslateTransform moveCard5 = new TranslateTransform();
            this.RegisterName("AnimatedTranslateTransform5", moveCard5);
            card5.RenderTransform = moveCard5;

            //create the path
            PathGeometry animationPath5 = new PathGeometry();
            PathFigure pFigure5 = new PathFigure();
            pFigure5.StartPoint = new Point(0, 0);
            PolyBezierSegment pBezierSegment5 = new PolyBezierSegment();
            pBezierSegment5.Points.Add(new Point(240, -10));
            pBezierSegment5.Points.Add(new Point(240, -10));
            pBezierSegment5.Points.Add(new Point(240, -10));
            pFigure5.Segments.Add(pBezierSegment5);
            animationPath5.Figures.Add(pFigure5);

            //freeze path for performance benefits
            animationPath5.Freeze();

            //create the animation to move the card horizontally
            DoubleAnimationUsingPath translateXAnimation5 = new DoubleAnimationUsingPath();
            translateXAnimation5.PathGeometry = animationPath5;
            translateXAnimation5.PathGeometry = animationPath5;
            translateXAnimation5.Duration = TimeSpan.FromSeconds(.5);

            //set source property to x
            translateXAnimation5.Source = PathAnimationSource.X;

            Storyboard.SetTargetName(translateXAnimation5, "AnimatedTranslateTransform5");
            Storyboard.SetTargetProperty(translateXAnimation5, new PropertyPath(TranslateTransform.XProperty));

            DoubleAnimationUsingPath translateYAnimation5 = new DoubleAnimationUsingPath();
            translateYAnimation5.PathGeometry = animationPath5;
            translateYAnimation5.Duration = TimeSpan.FromSeconds(.5);

            translateYAnimation5.Source = PathAnimationSource.Y;

            Storyboard.SetTargetName(translateYAnimation5, "AnimatedTranslateTransform5");
            Storyboard.SetTargetProperty(translateYAnimation5, new PropertyPath(TranslateTransform.YProperty));

            //create a storyboard
            Storyboard.SetTargetName(translateYAnimation5, "AnimatedTranslateTransform5");
            Storyboard.SetTargetProperty(translateYAnimation5, new PropertyPath(TranslateTransform.YProperty));

            ////////////////////////////////////////////////
            //////// Deal card 6 ///////////////////////////
            ////////////////////////////////////////////////
            TranslateTransform moveCard4 = new TranslateTransform();
            this.RegisterName("AnimatedTranslateTransform4", moveCard4);
            card4.RenderTransform = moveCard4;

            //create the path
            PathGeometry animationPath4 = new PathGeometry();
            PathFigure pFigure4 = new PathFigure();
            pFigure4.StartPoint = new Point(0, 0);
            PolyBezierSegment pBezierSegment4 = new PolyBezierSegment();
            pBezierSegment4.Points.Add(new Point(340, -10));
            pBezierSegment4.Points.Add(new Point(340, -10));
            pBezierSegment4.Points.Add(new Point(340, -10));
            pFigure4.Segments.Add(pBezierSegment4);
            animationPath4.Figures.Add(pFigure4);

            //freeze path for performance benefits
            animationPath4.Freeze();

            //create the animation to move the card horizontally
            DoubleAnimationUsingPath translateXAnimation4 = new DoubleAnimationUsingPath();
            translateXAnimation4.PathGeometry = animationPath4;
            translateXAnimation4.PathGeometry = animationPath4;
            translateXAnimation4.Duration = TimeSpan.FromSeconds(.4);

            //set source property to x
            translateXAnimation4.Source = PathAnimationSource.X;

            Storyboard.SetTargetName(translateXAnimation4, "AnimatedTranslateTransform4");
            Storyboard.SetTargetProperty(translateXAnimation4, new PropertyPath(TranslateTransform.XProperty));

            DoubleAnimationUsingPath translateYAnimation4 = new DoubleAnimationUsingPath();
            translateYAnimation4.PathGeometry = animationPath4;
            translateYAnimation4.Duration = TimeSpan.FromSeconds(.4);

            translateYAnimation4.Source = PathAnimationSource.Y;

            Storyboard.SetTargetName(translateYAnimation4, "AnimatedTranslateTransform4");
            Storyboard.SetTargetProperty(translateYAnimation4, new PropertyPath(TranslateTransform.YProperty));

            //create a storyboard
            Storyboard.SetTargetName(translateYAnimation4, "AnimatedTranslateTransform4");
            Storyboard.SetTargetProperty(translateYAnimation4, new PropertyPath(TranslateTransform.YProperty));

            ////////////////////////////////////////////////
            //////// Deal card 7 ///////////////////////////
            ////////////////////////////////////////////////
            TranslateTransform moveCard3 = new TranslateTransform();
            this.RegisterName("AnimatedTranslateTransform3", moveCard3);
            card3.RenderTransform = moveCard3;

            //create the path
            PathGeometry animationPath3 = new PathGeometry();
            PathFigure pFigure3 = new PathFigure();
            pFigure3.StartPoint = new Point(0, 0);
            PolyBezierSegment pBezierSegment3 = new PolyBezierSegment();
            pBezierSegment3.Points.Add(new Point(440, -10));
            pBezierSegment3.Points.Add(new Point(440, -10));
            pBezierSegment3.Points.Add(new Point(440, -10));
            pFigure3.Segments.Add(pBezierSegment3);
            animationPath3.Figures.Add(pFigure3);

            //freeze path for performance benefits
            animationPath3.Freeze();

            //create the animation to move the card horizontally
            DoubleAnimationUsingPath translateXAnimation3 = new DoubleAnimationUsingPath();
            translateXAnimation3.PathGeometry = animationPath3;
            translateXAnimation3.PathGeometry = animationPath3;
            translateXAnimation3.Duration = TimeSpan.FromSeconds(.3);

            //set source property to x
            translateXAnimation3.Source = PathAnimationSource.X;

            Storyboard.SetTargetName(translateXAnimation3, "AnimatedTranslateTransform3");
            Storyboard.SetTargetProperty(translateXAnimation3, new PropertyPath(TranslateTransform.XProperty));

            DoubleAnimationUsingPath translateYAnimation3 = new DoubleAnimationUsingPath();
            translateYAnimation3.PathGeometry = animationPath3;
            translateYAnimation3.Duration = TimeSpan.FromSeconds(.3);

            translateYAnimation3.Source = PathAnimationSource.Y;

            Storyboard.SetTargetName(translateYAnimation3, "AnimatedTranslateTransform3");
            Storyboard.SetTargetProperty(translateYAnimation3, new PropertyPath(TranslateTransform.YProperty));

            //create a storyboard
            Storyboard.SetTargetName(translateYAnimation3, "AnimatedTranslateTransform3");
            Storyboard.SetTargetProperty(translateYAnimation3, new PropertyPath(TranslateTransform.YProperty));

            ////////////////////////////////////////////////
            //////// Deal card 8 ///////////////////////////
            ////////////////////////////////////////////////
            TranslateTransform moveCard2 = new TranslateTransform();
            this.RegisterName("AnimatedTranslateTransform2", moveCard2);
            card2.RenderTransform = moveCard2;

            //create the path
            PathGeometry animationPath2 = new PathGeometry();
            PathFigure pFigure2 = new PathFigure();
            pFigure2.StartPoint = new Point(0, 0);
            PolyBezierSegment pBezierSegment2 = new PolyBezierSegment();
            pBezierSegment2.Points.Add(new Point(540, -10));
            pBezierSegment2.Points.Add(new Point(540, -10));
            pBezierSegment2.Points.Add(new Point(540, -10));
            pFigure2.Segments.Add(pBezierSegment2);
            animationPath2.Figures.Add(pFigure2);

            //freeze path for performance benefits
            animationPath2.Freeze();

            //create the animation to move the card horizontally
            DoubleAnimationUsingPath translateXAnimation2 = new DoubleAnimationUsingPath();
            translateXAnimation2.PathGeometry = animationPath2;
            translateXAnimation2.PathGeometry = animationPath2;
            translateXAnimation2.Duration = TimeSpan.FromSeconds(.2);

            //set source property to x
            translateXAnimation2.Source = PathAnimationSource.X;

            Storyboard.SetTargetName(translateXAnimation2, "AnimatedTranslateTransform2");
            Storyboard.SetTargetProperty(translateXAnimation2, new PropertyPath(TranslateTransform.XProperty));

            DoubleAnimationUsingPath translateYAnimation2 = new DoubleAnimationUsingPath();
            translateYAnimation2.PathGeometry = animationPath2;
            translateYAnimation2.Duration = TimeSpan.FromSeconds(.2);

            translateYAnimation2.Source = PathAnimationSource.Y;

            Storyboard.SetTargetName(translateYAnimation2, "AnimatedTranslateTransform2");
            Storyboard.SetTargetProperty(translateYAnimation2, new PropertyPath(TranslateTransform.YProperty));

            //create a storyboard
            Storyboard.SetTargetName(translateYAnimation2, "AnimatedTranslateTransform2");
            Storyboard.SetTargetProperty(translateYAnimation2, new PropertyPath(TranslateTransform.YProperty));

            ////////////////////////////////////////////////
            //////// Deal card 9 ///////////////////////////
            ////////////////////////////////////////////////
            TranslateTransform moveCard1 = new TranslateTransform();
            this.RegisterName("AnimatedTranslateTransform1", moveCard1);
            card1.RenderTransform = moveCard1;

            //create the path
            PathGeometry animationPath1 = new PathGeometry();
            PathFigure pFigure1 = new PathFigure();
            pFigure1.StartPoint = new Point(0, 0);
            PolyBezierSegment pBezierSegment1 = new PolyBezierSegment();
            pBezierSegment1.Points.Add(new Point(640, -10));
            pBezierSegment1.Points.Add(new Point(640, -10));
            pBezierSegment1.Points.Add(new Point(640, -10));
            pFigure1.Segments.Add(pBezierSegment1);
            animationPath1.Figures.Add(pFigure1);

            //freeze path for performance benefits
            animationPath1.Freeze();

            //create the animation to move the card horizontally
            DoubleAnimationUsingPath translateXAnimation1 = new DoubleAnimationUsingPath();
            translateXAnimation1.PathGeometry = animationPath1;
            translateXAnimation1.PathGeometry = animationPath1;
            translateXAnimation1.Duration = TimeSpan.FromSeconds(.1);

            //set source property to x
            translateXAnimation1.Source = PathAnimationSource.X;

            Storyboard.SetTargetName(translateXAnimation1, "AnimatedTranslateTransform1");
            Storyboard.SetTargetProperty(translateXAnimation1, new PropertyPath(TranslateTransform.XProperty));

            DoubleAnimationUsingPath translateYAnimation1 = new DoubleAnimationUsingPath();
            translateYAnimation1.PathGeometry = animationPath1;
            translateYAnimation1.Duration = TimeSpan.FromSeconds(.1);

            translateYAnimation1.Source = PathAnimationSource.Y;

            Storyboard.SetTargetName(translateYAnimation1, "AnimatedTranslateTransform1");
            Storyboard.SetTargetProperty(translateYAnimation1, new PropertyPath(TranslateTransform.YProperty));

            //create a storyboard
            Storyboard.SetTargetName(translateYAnimation1, "AnimatedTranslateTransform1");
            Storyboard.SetTargetProperty(translateYAnimation1, new PropertyPath(TranslateTransform.YProperty));

            ////////////////////////////////////////////////
            //////// Deal the cards ///////////////////////////
            ////////////////////////////////////////////////
            Storyboard pathAnimationStoryboard = new Storyboard();
            pathAnimationStoryboard.Children.Add(translateXAnimation9);
            pathAnimationStoryboard.Children.Add(translateYAnimation9);

            pathAnimationStoryboard.Children.Add(translateXAnimation8);
            pathAnimationStoryboard.Children.Add(translateYAnimation8);

            pathAnimationStoryboard.Children.Add(translateXAnimation7);
            pathAnimationStoryboard.Children.Add(translateYAnimation7);

            pathAnimationStoryboard.Children.Add(translateXAnimation6);
            pathAnimationStoryboard.Children.Add(translateYAnimation6);

            pathAnimationStoryboard.Children.Add(translateXAnimation5);
            pathAnimationStoryboard.Children.Add(translateYAnimation5);

            pathAnimationStoryboard.Children.Add(translateXAnimation4);
            pathAnimationStoryboard.Children.Add(translateYAnimation4);

            pathAnimationStoryboard.Children.Add(translateXAnimation3);
            pathAnimationStoryboard.Children.Add(translateYAnimation3);

            pathAnimationStoryboard.Children.Add(translateXAnimation2);
            pathAnimationStoryboard.Children.Add(translateYAnimation2);

            pathAnimationStoryboard.Children.Add(translateXAnimation1);
            pathAnimationStoryboard.Children.Add(translateYAnimation1);

            pathAnimationStoryboard.Begin(this);

            //change the image source of the card. will be used to display actual cards dealt to players/dealer
            string sUri = @"Images\clubs-2-150.png";
            Uri src = new Uri(sUri, UriKind.RelativeOrAbsolute);
            BitmapImage bmp = new BitmapImage(src);
            card9.Source = bmp;
            card8.Source = bmp;
            card7.Source = bmp;
            card6.Source = bmp;
            card5.Source = bmp;
            card4.Source = bmp;
            card3.Source = bmp;
        }
コード例 #26
0
        private static PathGeometry ArcBlock(Arc arc, double fromAngle, double toAngle, double tickLength)
        {
            PathGeometry geometry = new PathGeometry();
            PathFigure figure = new PathFigure();

            geometry.Figures.Add(figure);
            var op1 = arc.GetPoint(fromAngle);
            var ip1 = arc.GetPoint(fromAngle, -1 * tickLength);
            var op2 = arc.GetPoint(toAngle);
            var ip2 = arc.GetPoint(toAngle, -1 * tickLength);

            figure.StartPoint = op1;
            var rotationAngle = toAngle - fromAngle;
            var isLargeArc = arc.IsLargeAngle(fromAngle, toAngle);
            var sweepDirection = arc.SweepDirection(fromAngle, toAngle);
            figure.Segments.Add(new ArcSegment(op2, new Size(arc.Radius, arc.Radius), rotationAngle, isLargeArc, sweepDirection, true));
            figure.Segments.Add(new LineSegment(ip2, true));
            sweepDirection = arc.SweepDirection(toAngle, fromAngle);
            var ri = arc.Radius - tickLength;
            if (ri < 0)
            {
                ri = 0;
            }
            figure.Segments.Add(new ArcSegment(ip1, new Size(ri, ri), rotationAngle, isLargeArc, sweepDirection, true));
            figure.Segments.Add(new LineSegment(op1, true));
            figure.IsClosed = true;
            figure.Freeze();
            geometry.Freeze();
            return geometry;
        }
コード例 #27
0
ファイル: Shapes.cs プロジェクト: litdev1/LitDev
        /// <summary>
        /// Draw a polygon filled with a gradient of colours.
        /// </summary>
        /// <param name="brush">
        /// A previously created gradient or image brush (LDShapes.BrushGradient LDShapes.BrushImage).
        /// </param>
        /// <param name="points">
        /// An array of coordinates for the polygon corners with the form points[i][1] = x, points[i][2] = y.
        /// 
        /// The number of points must be 3 or more.
        /// </param>
        /// <returns>
        /// None.
        /// </returns>
        public static void BrushPolygon(Primitive brush, Primitive points)
        {
            Type GraphicsWindowType = typeof(GraphicsWindow);
            DrawingGroup _mainDrawing;

            try
            {
                _mainDrawing = (DrawingGroup)GraphicsWindowType.GetField("_mainDrawing", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.IgnoreCase).GetValue(null);
                InvokeHelper ret = new InvokeHelper(delegate
                {
                    try
                    {
                        foreach (GradientBrush i in brushes)
                        {
                            if (i.name == brush)
                            {
                                PointCollection _points = getPoints(points);
                                if (_points.Count < 3) return;
                                DrawingContext drawingContext = _mainDrawing.Append();
                                PathFigure pathFigure = new PathFigure();
                                pathFigure.IsClosed = true;
                                pathFigure.StartPoint = _points[0];
                                for (int j = 1; j < _points.Count; j++)
                                {
                                    pathFigure.Segments.Add(new LineSegment(_points[j], true));
                                }
                                PathFigureCollection pathFigureCollection = new PathFigureCollection();
                                pathFigureCollection.Add(pathFigure);
                                PathGeometry pathGeometry = new PathGeometry();
                                pathGeometry.Figures = pathFigureCollection;
                                pathGeometry.Freeze();
                                drawingContext.DrawGeometry(i.getBrush(), null, pathGeometry);
                                drawingContext.Close();
                                GraphicsWindowType.GetMethod("AddRasterizeOperationToQueue", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.IgnoreCase).Invoke(null, new object[] { });
                            }
                        }

                    }
                    catch (Exception ex)
                    {
                        Utilities.OnError(Utilities.GetCurrentMethod(), ex);
                    }
                });
                FastThread.Invoke(ret);
            }
            catch (Exception ex)
            {
                Utilities.OnError(Utilities.GetCurrentMethod(), ex);
            }
        }
コード例 #28
0
        // Creates a border geometry used to render complex border brushes
        private static Geometry GenerateBorderGeometry(Rect rect, Thickness borderThickness)
        {
            PathGeometry geometry = new PathGeometry();

            // Add outer rectangle figure
            geometry.Figures.Add(GenerateRectFigure(rect)); 

            // Subtract inner rectangle figure 
            geometry.Figures.Add(GenerateRectFigure(HelperDeflateRect(rect, borderThickness)));

            geometry.Freeze();

            return geometry;
        }
コード例 #29
0
        private void TerminalLoad(object sender, RoutedEventArgs e)
        {
            System.Windows.Forms.Cursor.Hide();
            //Debug.WriteLine("staaart!");
            int Width = SystemInformation.PrimaryMonitorSize.Width;
            int Height = SystemInformation.PrimaryMonitorSize.Height;
            DockPanel MainDockPanel = new DockPanel();
            this.MainGrid.Children.Add(MainDockPanel);
            MainDockPanel.VerticalAlignment = VerticalAlignment.Top;
            LinearGradientBrush GreenGradientBrush = new LinearGradientBrush();
            GreenGradientBrush.GradientStops.Add(new GradientStop(Colors.Green, 0.0));
            GreenGradientBrush.GradientStops.Add(new GradientStop(Colors.White, 0.5));
            GreenGradientBrush.GradientStops.Add(new GradientStop(Colors.Green, 1.0));
            this.Advertismen.Background = GreenGradientBrush;
            DockPanel.SetDock(this.Advertismen, Dock.Top);
            MainDockPanel.LastChildFill = true;
            MainDockPanel.Children.Add(this.Advertismen);
            this.Advertismen.Width = (double)Width;
            this.Advertismen.Height = (double)(Height / 10);
            DockPanel LeftGrid = new DockPanel();
            Grid RightGrid = new Grid();
            DockPanel.SetDock(LeftGrid, Dock.Left);
            DockPanel.SetDock(RightGrid, Dock.Right);
            LeftGrid.Background = GreenGradientBrush;
            RightGrid.Background = new ImageBrush
            {
                ImageSource = new BitmapImage(new Uri("sampleImages\\главная фоновое.jpg", UriKind.Relative))
            };
            this.MoveGridWidth = Width / 10 * 7;
            this.MoveGridHidth = Height / 10 * 9;
            this.RightInputGrid.Width = (double)(Width / 10 * 7 / 2);
            this.RightInputGrid.Height = (double)(Height / 10 * 9);
            this.RightInputGrid.Children.Add(this.Text);
            this.Text.TextWrapping = TextWrapping.Wrap;
            this.Text.FontSize = 20.0;
            this.RightInputGrid.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            this.RightInputGrid.Background = new SolidColorBrush(Color.FromArgb(0, 255, 255, 255));
            this.RightInputGridLeft.Width = (double)(Width / 10 * 7 / 2);
            this.RightInputGridLeft.Height = (double)(Height / 10 * 9);
            this.RightInputGridLeft.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
            this.MoveGrid.Children.Add(this.RightInputGridLeft);
            MainDockPanel.Children.Add(LeftGrid);
            MainDockPanel.Children.Add(RightGrid);
            LeftGrid.Height = (double)(Height / 10 * 9);
            RightGrid.Height = (double)(Height / 10 * 9);
            LeftGrid.Width = (double)(Width / 10 * 3);
            RightGrid.Width = (double)(Width / 10 * 7);
            System.Windows.Controls.ListBox GroupList = new System.Windows.Controls.ListBox();
            LeftGrid.Children.Add(this.GroupGrid);
            LeftGrid.Children.Add(this.RecipeGrid);
            DockPanel.SetDock(this.GroupGrid, Dock.Top);
            DockPanel.SetDock(this.RecipeGrid, Dock.Bottom);
            this.GroupGrid.Height = LeftGrid.Height / 2.0;
            this.RecipeGrid.Height = LeftGrid.Height / 2.0;
            this.GroupGrid.Width = LeftGrid.Width;
            this.RecipeGrid.Width = LeftGrid.Width;
            AdvertismentTxt = new TextBlock();
            setAdvertismentText("Березинский биосферный заповедник");
            menuLevel = 0;
            //AdvertismentTxt.Text = "Березинский биосферный заповедник";
            //AdvertismentTxt.VerticalAlignment = VerticalAlignment.Center;
            //AdvertismentTxt.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
            //AdvertismentTxt.TextAlignment = TextAlignment.Center;
            //AdvertismentTxt.FontFamily = new FontFamily("Arial Black");
            //AdvertismentTxt.TextWrapping = TextWrapping.Wrap;

            //AdvertismentTxt.BitmapEffect = new BevelBitmapEffect();
            AdvertismentTxt.FontSize = 32.0;
            this.Advertismen.Children.Add(AdvertismentTxt);
            this.GroupGrid.Children.Add(this.GroupListBox);

            //TextBlock[] tb = new TextBlock[6];
            //for (int i = 0; i < 6; i++ )
            //{
            //    tb[i] = new TextBlock();
            //    tb[i].FontFamily = new FontFamily("Arial Black");
            //    tb[i].FontSize = 14;
            //}

            //MyListBoxItem itm = new MyListBoxItem(new FontFamily("Arial Black"), "О заповеднике");
            //itm.Style.
            //this.GroupListBox.Items.Add(new MyListBoxItem(new FontFamily("Arial Black"), "Природные условия"));
            //this.GroupListBox.Items.Add(new MyListBoxItem(new FontFamily("Arial Black"), "Деятельность заповедника"));
            //this.GroupListBox.Items.Add(new MyListBoxItem(new FontFamily("Arial Black"), "Экологические маршруты"));
            //this.GroupListBox.Items.Add(new MyListBoxItem(new FontFamily("Arial Black"), "Экологическое просвещение"));
            //this.GroupListBox.Items.Add(new MyListBoxItem(new FontFamily("Arial Black"), "Туристические услуги"));
            //this.GroupListBox.Items.Add(new MyListBoxItem(new FontFamily("Arial Black"), "Контактная информация"));
            //ListBoxItem itm;
            //Style st = new Style()

            //itm.Style
            //tb[0].Text = "О заповеднике";
            //this.GroupListBox.Items.Add(tb[0]);
            //tb[1].Text = "Природные условия";
            //this.GroupListBox.Items.Add(tb[1]);
            //tb[2].Text = "Деятельность заповедника";
            //this.GroupListBox.Items.Add(tb[2]);
            //tb[3].Text = "Экологические маршруты";
            //this.GroupListBox.Items.Add(tb[3]);
            //tb[4].Text = "Экологическое просвещение";
            //this.GroupListBox.Items.Add(tb[4]);
            //tb[5].Text = "Контактная информация";
            //this.GroupListBox.Items.Add(tb[5]);

            //System.Windows.Forms.ListView lv = new System.Windows.Forms.ListView;
            this.GroupListBox.Items.Add("О заповеднике");
            this.GroupListBox.Items.Add("Природные условия");
            this.GroupListBox.Items.Add("Деятельность заповедника");
            this.GroupListBox.Items.Add("Экологические маршруты");
            this.GroupListBox.Items.Add("Экологическое просвещение");
            this.GroupListBox.Items.Add("Туристические услуги");
            this.GroupListBox.Items.Add("Контактная информация");

            this.SmallImageListBox.Height = LeftGrid.Height / 2.0;
            this.SmallImageListBox.Width = LeftGrid.Width - 5.0;
            RightGrid.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
            this.SmallImageListBox.VerticalAlignment = VerticalAlignment.Top;
            this.SmallImageListBox.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            this.GroupListBox.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
            this.GroupListBox.VerticalAlignment = VerticalAlignment.Top;
            this.GroupListBox.SelectionChanged += new SelectionChangedEventHandler(this.GroupListBox_SelectionChanged);
            this.SmallImageListBox.SelectionChanged += new SelectionChangedEventHandler(this.SmallImageListBox_SelectionChanged);
            RightGrid.Children.Add(this.MoveGrid);
            this.MoveGrid.Height = RightGrid.Height;
            this.MoveGrid.Width = RightGrid.Width;
            DoubleAnimation MoveAnimation = new DoubleAnimation();
            MoveAnimation.Duration = TimeSpan.FromSeconds(5.0);
            MoveAnimation.From = new double?((double)Width);
            MoveAnimation.To = new double?(base.Width + 100.0);
            MoveAnimation.Duration = new Duration(TimeSpan.FromMilliseconds(500.0));
            TranslateTransform TransformMove = new TranslateTransform();
            MoveAnimation.By = new double?(0.2);
            this.MoveGrid.Children.Add(this.RightInputGrid);
            this.Img.Height = this.MoveGrid.Height;
            this.Img.Width = this.MoveGrid.Width;
            RotateTransform animatedRotateTransform = new RotateTransform();
            TranslateTransform animatedTranslateTransform = new TranslateTransform();
            base.RegisterName("AnimatedRotateTransform", animatedRotateTransform);
            base.RegisterName("AnimatedTranslateTransform", animatedTranslateTransform);
            TransformGroup tGroup = new TransformGroup();
            tGroup.Children.Add(animatedRotateTransform);
            tGroup.Children.Add(animatedTranslateTransform);
            this.MoveGrid.RenderTransform = tGroup;
            PathGeometry animationPath = new PathGeometry();
            PathFigure pFigure = new PathFigure();
            pFigure.StartPoint = new Point(0.0, 0.0);
            PolyBezierSegment pBezierSegment = new PolyBezierSegment();
            pBezierSegment.Points.Add(new Point(RightGrid.Width, 0.0));
            pBezierSegment.Points.Add(new Point(300.0, 0.0));
            pBezierSegment.Points.Add(new Point(RightGrid.Width, 0.0));
            pFigure.Segments.Add(pBezierSegment);
            animationPath.Figures.Add(pFigure);
            animationPath.Freeze();
            DoubleAnimationUsingPath angleAnimation = new DoubleAnimationUsingPath();
            angleAnimation.PathGeometry = animationPath;
            angleAnimation.Duration = TimeSpan.FromMilliseconds(500.0);
            angleAnimation.Source = PathAnimationSource.Angle;
            Storyboard.SetTargetName(angleAnimation, "AnimatedRotateTransform");
            Storyboard.SetTargetProperty(angleAnimation, new PropertyPath(RotateTransform.AngleProperty));
            DoubleAnimationUsingPath translateXAnimation = new DoubleAnimationUsingPath();
            translateXAnimation.PathGeometry = animationPath;
            translateXAnimation.Duration = TimeSpan.FromMilliseconds(500.0);
            translateXAnimation.Source = PathAnimationSource.X;
            Storyboard.SetTargetName(translateXAnimation, "AnimatedTranslateTransform");
            Storyboard.SetTargetProperty(translateXAnimation, new PropertyPath(TranslateTransform.XProperty));
            DoubleAnimationUsingPath translateYAnimation = new DoubleAnimationUsingPath();
            translateYAnimation.PathGeometry = animationPath;
            translateYAnimation.Duration = TimeSpan.FromMilliseconds(500.0);
            translateYAnimation.Source = PathAnimationSource.Y;
            Storyboard.SetTargetName(translateYAnimation, "AnimatedTranslateTransform");
            Storyboard.SetTargetProperty(translateYAnimation, new PropertyPath(TranslateTransform.YProperty));
            this.pathAnimationStoryboard.AutoReverse = true;
            this.pathAnimationStoryboard.Children.Add(angleAnimation);
            this.pathAnimationStoryboard.Children.Add(translateXAnimation);
            this.pathAnimationStoryboard.Children.Add(translateYAnimation);
            this.BattonPanel.Height = 150.0;
            this.BattonPanel.Width = 300.0;
            ImageBrush myBackBrush = new ImageBrush();
            myBackBrush.ImageSource = new BitmapImage(new Uri("sampleImages\\back.png", UriKind.Relative));
            this.BattonPanel.Background = myBackBrush;
            TextBlock InfoButtonText = new TextBlock();
            InfoButtonText.Text = "    НАЗАД";
            InfoButtonText.FontFamily = new FontFamily("Arial Black");
            InfoButtonText.TextWrapping = TextWrapping.Wrap;
            //InfoButtonText.BitmapEffect = new BevelBitmapEffect();
            InfoButtonText.FontSize = 32.0;
            this.BattonPanel.MouseDown += new MouseButtonEventHandler(this.InfoCloseButton_Click);
        }
コード例 #30
0
 /// <summary>
 /// Renders the control.
 /// </summary>
 /// <param name="drawingContext"></param>
 protected override void OnRender(DrawingContext drawingContext)
 {
     System.Windows.CornerRadius cornerRadius = this.CornerRadius;
     Rect rect = new Rect(new Point(5.0, 5.0), new Size(base.RenderSize.Width, base.RenderSize.Height));
     System.Windows.Media.Color c = this.Color;
     if (((rect.Width > 0.0) && (rect.Height > 0.0)) && (c.A > 0))
     {
         double width = (rect.Right - rect.Left) - 10.0;
         double height = (rect.Bottom - rect.Top) - 10.0;
         double num3 = Math.Min((double)(width * 0.5), (double)(height * 0.5));
         cornerRadius.TopLeft = Math.Min(cornerRadius.TopLeft, num3);
         cornerRadius.TopRight = Math.Min(cornerRadius.TopRight, num3);
         cornerRadius.BottomLeft = Math.Min(cornerRadius.BottomLeft, num3);
         cornerRadius.BottomRight = Math.Min(cornerRadius.BottomRight, num3);
         Brush[] brushes = this.GetBrushes(c, cornerRadius);
         double num4 = rect.Top + 5.0;
         double num5 = rect.Left + 5.0;
         double num6 = rect.Right - 5.0;
         double num7 = rect.Bottom - 5.0;
         double[] guidelinesX = new double[] { num5, num5 + cornerRadius.TopLeft, num6 - cornerRadius.TopRight, num5 + cornerRadius.BottomLeft, num6 - cornerRadius.BottomRight, num6 };
         double[] guidelinesY = new double[] { num4, num4 + cornerRadius.TopLeft, num4 + cornerRadius.TopRight, num7 - cornerRadius.BottomLeft, num7 - cornerRadius.BottomRight, num7 };
         drawingContext.PushGuidelineSet(new GuidelineSet(guidelinesX, guidelinesY));
         cornerRadius.TopLeft += 5.0;
         cornerRadius.TopRight += 5.0;
         cornerRadius.BottomLeft += 5.0;
         cornerRadius.BottomRight += 5.0;
         Rect rectangle = new Rect(rect.Left, rect.Top, cornerRadius.TopLeft, cornerRadius.TopLeft);
         drawingContext.DrawRectangle(brushes[0], null, rectangle);
         double num8 = guidelinesX[2] - guidelinesX[1];
         if (num8 > 0.0)
         {
             Rect rect3 = new Rect(guidelinesX[1], rect.Top, num8, 5.0);
             drawingContext.DrawRectangle(brushes[1], null, rect3);
         }
         Rect rect4 = new Rect(guidelinesX[2], rect.Top, cornerRadius.TopRight, cornerRadius.TopRight);
         drawingContext.DrawRectangle(brushes[2], null, rect4);
         double num9 = guidelinesY[3] - guidelinesY[1];
         if (num9 > 0.0)
         {
             Rect rect5 = new Rect(rect.Left, guidelinesY[1], 5.0, num9);
             drawingContext.DrawRectangle(brushes[3], null, rect5);
         }
         double num10 = guidelinesY[4] - guidelinesY[2];
         if (num10 > 0.0)
         {
             Rect rect6 = new Rect(guidelinesX[5], guidelinesY[2], 5.0, num10);
             drawingContext.DrawRectangle(brushes[5], null, rect6);
         }
         Rect rect7 = new Rect(rect.Left, guidelinesY[3], cornerRadius.BottomLeft, cornerRadius.BottomLeft);
         drawingContext.DrawRectangle(brushes[6], null, rect7);
         double num11 = guidelinesX[4] - guidelinesX[3];
         if (num11 > 0.0)
         {
             Rect rect8 = new Rect(guidelinesX[3], guidelinesY[5], num11, 5.0);
             drawingContext.DrawRectangle(brushes[7], null, rect8);
         }
         Rect rect9 = new Rect(guidelinesX[4], guidelinesY[4], cornerRadius.BottomRight, cornerRadius.BottomRight);
         drawingContext.DrawRectangle(brushes[8], null, rect9);
         if (((cornerRadius.TopLeft == 5.0) && (cornerRadius.TopLeft == cornerRadius.TopRight)) && ((cornerRadius.TopLeft == cornerRadius.BottomLeft) && (cornerRadius.TopLeft == cornerRadius.BottomRight)))
         {
             Rect rect10 = new Rect(guidelinesX[0], guidelinesY[0], width, height);
             drawingContext.DrawRectangle(brushes[4], null, rect10);
         }
         else
         {
             PathFigure figure = new PathFigure();
             if (cornerRadius.TopLeft > 5.0)
             {
                 figure.StartPoint = new Point(guidelinesX[1], guidelinesY[0]);
                 figure.Segments.Add(new LineSegment(new Point(guidelinesX[1], guidelinesY[1]), true));
                 figure.Segments.Add(new LineSegment(new Point(guidelinesX[0], guidelinesY[1]), true));
             }
             else
             {
                 figure.StartPoint = new Point(guidelinesX[0], guidelinesY[0]);
             }
             if (cornerRadius.BottomLeft > 5.0)
             {
                 figure.Segments.Add(new LineSegment(new Point(guidelinesX[0], guidelinesY[3]), true));
                 figure.Segments.Add(new LineSegment(new Point(guidelinesX[3], guidelinesY[3]), true));
                 figure.Segments.Add(new LineSegment(new Point(guidelinesX[3], guidelinesY[5]), true));
             }
             else
             {
                 figure.Segments.Add(new LineSegment(new Point(guidelinesX[0], guidelinesY[5]), true));
             }
             if (cornerRadius.BottomRight > 5.0)
             {
                 figure.Segments.Add(new LineSegment(new Point(guidelinesX[4], guidelinesY[5]), true));
                 figure.Segments.Add(new LineSegment(new Point(guidelinesX[4], guidelinesY[4]), true));
                 figure.Segments.Add(new LineSegment(new Point(guidelinesX[5], guidelinesY[4]), true));
             }
             else
             {
                 figure.Segments.Add(new LineSegment(new Point(guidelinesX[5], guidelinesY[5]), true));
             }
             if (cornerRadius.TopRight > 5.0)
             {
                 figure.Segments.Add(new LineSegment(new Point(guidelinesX[5], guidelinesY[2]), true));
                 figure.Segments.Add(new LineSegment(new Point(guidelinesX[2], guidelinesY[2]), true));
                 figure.Segments.Add(new LineSegment(new Point(guidelinesX[2], guidelinesY[0]), true));
             }
             else
             {
                 figure.Segments.Add(new LineSegment(new Point(guidelinesX[5], guidelinesY[0]), true));
             }
             figure.IsClosed = true;
             figure.Freeze();
             PathGeometry geometry = new PathGeometry
             {
                 Figures = { figure }
             };
             geometry.Freeze();
             drawingContext.DrawGeometry(brushes[4], null, geometry);
         }
         drawingContext.Pop();
     }
 }
コード例 #31
0
		/// <summary>
		/// Creates the geometry.
		/// Returns null when the geometry is empty!
		/// </summary>
		public Geometry CreateGeometry()
		{
			CloseFigure();
			if (figures.Count != 0) {
				PathGeometry g = new PathGeometry(figures);
				g.Freeze();
				return g;
			} else {
				return null;
			}
		}
コード例 #32
0
        // The shadow geometry is the right borders with top rounded corner 
        private Geometry GenerateTabTopShadowGeometry(Rect bounds, bool outerBorder)
        {
            double outerRadius = outerBorder ? 3.0 : 2.0;
            double innerRadius = outerRadius - 1.0;
            Size outerCorner = new Size(outerRadius, outerRadius), innerCorner = new Size(innerRadius, innerRadius);

            double right = bounds.Right, top = bounds.Top, bottom = bounds.Bottom - 1.0; 

            PathFigure figure = new PathFigure();
            //Start at bottom left, tracing the outside clockwise
            figure.StartPoint = new Point(right - 1.0, bottom);
            figure.Segments.Add(new LineSegment(new Point(right - 1.0, top + outerRadius), true));  //left side
            figure.Segments.Add(new ArcSegment(new Point(right - 1.0 - innerRadius * 0.293, top + 1.0 + innerRadius * 0.293), innerCorner, 0.0, false, SweepDirection.Counterclockwise, true)); //inner left rounded corner
            figure.Segments.Add(new LineSegment(new Point(right - outerRadius * 0.293, top + outerRadius * 0.293), true)); //top right corner  
            figure.Segments.Add(new ArcSegment(new Point(right, top + outerRadius), outerCorner, 0.0, false, SweepDirection.Clockwise, true)); //top right corner  
            figure.Segments.Add(new LineSegment(new Point(right, bottom), true)); //right side
            figure.IsClosed = true; //bottom side
            figure.Freeze();

            PathGeometry geometry = new PathGeometry();
            geometry.Figures.Add(figure);
            geometry.Freeze();

            return geometry;
        }