1. Query String Parameters : You can receive values from the query string in the URL.

     Request URL : /Home/Index?name=John

    public IActionResult Index(string name) {
       
    }

2. Route Parameters : You can use parameters defined in the route template.

    Request URL : /Home/Index/1

    [Route("Home/Index/{id}")]
    public IActionResult Index(int id) {

    }

3. Form Data : You can receive form data from HTTP POST requests.

    Request Body(form data) : name = john

    [HttpPost]
    public IActionResult Index([FromForm] string name)

4. Request Body : You can receive the HTTP request body. This is mainly used to receive JSON data.

    Request Body(Json): {"Name":"John","Age":30}
    public class User {
        public string Name { get; set; }
        public int Age { get; set; }

    }

    [HttpPost]
    public IActionResult Index([FromBody] User user) {
    }

  5. Route Data : You can receive values from route data. 

    Request URL : /Home/Index/1

    public IActionResult Index() {
        var id = RouteData.Values["id"];
    }

HitTest.zip
0.01MB

These days I need a HitTest program which is circle sector with empty in the middle of it and there are some rectangles.

 

There is a rectangle In the middle of the circle and the hit count of the circle is one.

I referenced lots of good articles and thanks for them.

 

This sample is so simple that I will explain it brifly.

Please see the source.

Thank you.

 

This is DrawImagtes, that is drawing sector circle and one rectangle.

        private void DrawImages()
        {
            PathGeometry pg1 = DrawArc(40, 100, new Point(100, 100), 0);
            PathGeometry pg2 = DrawArc(40, 60, new Point(100, 100), 0);

            PathGeometry pg3 = DrawArc(40, 100, new Point(100, 100), 90);
            PathGeometry pg4 = DrawArc(40, 60, new Point(100, 100), 90);

            PathGeometry pg5 = DrawArc(40, 100, new Point(100, 100), 180);
            PathGeometry pg6 = DrawArc(40, 60, new Point(100, 100), 180);

            PathGeometry pg7 = DrawArc(40, 100, new Point(100, 100), 270);
            PathGeometry pg8 = DrawArc(40, 60, new Point(100, 100), 270);

            Rectangle rect1 = new Rectangle();
            rect1.Width = 10;
            rect1.Height = 10;
            rect1.Fill = Brushes.Red;
            Canvas.SetTop(rect1, 100);
            Canvas.SetLeft(rect1, 100);
            canvas1.Children.Add(rect1);
        }

And DrawArc function is as follow.

   private PathGeometry DrawArc(int interval, int size, Point center, int angle)
        {
            PathFigure pf1 = new PathFigure();

            switch (angle)
            {
                case 0:
                    pf1.StartPoint = new Point(center.X, center.Y - size);

                    pf1.Segments.Add(
                    new ArcSegment(
                        new Point(center.X + size, center.Y),
                        new Size(size, size),
                        0,
                        false, /* IsLargeArc */
                        SweepDirection.Clockwise,
                        true /* IsStroked */ ));

                    pf1.Segments.Add(
                        new LineSegment(
                            new Point(center.X + size - interval, center.Y),


                    pf1.Segments.Add(
                    new ArcSegment(
                        new Point(center.X, center.Y - size + interval),
                        new Size(size - interval, size - interval),
                        0,
                        false, /* IsLargeArc */
                        SweepDirection.Counterclockwise,
                        true /* IsStroked */ ));

                    pf1.Segments.Add(
                        new LineSegment(
                            pf1.StartPoint,
                            true /* IsStroked */ ));
                    break;
              .........................
            }

            PathGeometry pg1 = new PathGeometry();
            pg1.Figures.Add(pf1);

            Path p1 = new Path();
            p1.Stroke = Brushes.Black;
            p1.StrokeThickness = 2;
            p1.Data = pg1;

            canvas1.Children.Add(p1);
            return pg1;
        }

'C# > WPF' 카테고리의 다른 글

Make a animation button  (0) 2018.12.19



https://youtu.be/xL03WcmrRvs?list=PLNqsvjhP1nzSksXTUqabD3Ntti7mLzj1V

https://youtu.be/Y1EODxv6eV0?list=PLNqsvjhP1nzSksXTUqabD3Ntti7mLzj1V

https://youtu.be/DDsEs3-xnXM?list=PLNqsvjhP1nzSksXTUqabD3Ntti7mLzj1V

https://youtu.be/B76_oZQ6PD8?list=PLNqsvjhP1nzSksXTUqabD3Ntti7mLzj1V

https://youtu.be/ahxWvLhiNyI?list=PLNqsvjhP1nzSksXTUqabD3Ntti7mLzj1V

+ Recent posts