Release 4.0.0-preview1-00051
[platform/core/csapi/tizenfx.git] / src / ElmSharp / ElmSharp / Polygon.cs
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 using System;
18
19 namespace ElmSharp
20 {
21     /// <summary>
22     /// The Polygon is a widget that used to draw a polygon (filled).
23     /// </summary>
24     public class Polygon : EvasObject
25     {
26         /// <summary>
27         /// Creates and initializes a new instance of the Polygon class.
28         /// <param name="parent">The EvasObject to which the new Polygon will be attached as a child.</param>
29         /// </summary>
30         public Polygon(EvasObject parent) : base(parent)
31         {
32         }
33
34         /// <summary>
35         /// Adds a new vertex to the Polygon.
36         /// <param name="x">The X coordinate of the new vertex.</param>
37         /// <param name="y">The Y coordinate of the new vertex.</param>
38         /// </summary>
39         public void AddPoint(int x, int y)
40         {
41             Interop.Evas.evas_object_polygon_point_add(Handle, x, y);
42         }
43
44         /// <summary>
45         /// Adds a new vertex to the Polygon.
46         /// <param name="p">The coordinates of the new vertex.</param>
47         /// </summary>
48         public void AddPoint(Point p)
49         {
50             AddPoint(p.X, p.Y);
51         }
52
53         /// <summary>
54         /// Removes all the vertices of the Polygon, making it empty.
55         /// </summary>
56         public void ClearPoints()
57         {
58             Interop.Evas.evas_object_polygon_points_clear(Handle);
59         }
60
61         protected override IntPtr CreateHandle(EvasObject parent)
62         {
63             IntPtr evas = Interop.Evas.evas_object_evas_get(parent.Handle);
64             return Interop.Evas.evas_object_polygon_add(evas);
65         }
66     }
67 }