DO NOT use ArrayList or List in public APIs.
https://docs.microsoft.com/en-us/dotnet/standard/design-guidelines/guidelines-for-collections
[global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Shape_AddPath")]
[return: global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.U1)]
- public static extern void AddPath(global::System.Runtime.InteropServices.HandleRef pShape, [global::System.Runtime.InteropServices.In, global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPArray)] BaseComponents.VectorGraphics.PathCommands.PathCommandType[] commands, uint commandCount, [global::System.Runtime.InteropServices.In, global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPArray)] float[] points, uint pointCount);
+ public static extern void AddPath(global::System.Runtime.InteropServices.HandleRef pShape, [global::System.Runtime.InteropServices.In, global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPArray)] BaseComponents.VectorGraphics.PathCommandType[] commands, uint commandCount, [global::System.Runtime.InteropServices.In, global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPArray)] float[] points, uint pointCount);
[global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Shape_Close")]
[return: global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.U1)]
*/
using System;
+using System.Collections.Generic;
using System.ComponentModel;
namespace Tizen.NUI.BaseComponents.VectorGraphics
[EditorBrowsable(EditorBrowsableState.Never)]
public class PathCommands
{
- private PathCommandType[] commands; //The array of commands.
- private uint commandCount; //The number of commands.
- private float[] points; //The array of points.
- private uint pointCount; //The number of points.
+ private IEnumerable<PathCommandType> commands; //The array of commands.
+ private IEnumerable<float> points; //The array of points.
/// <summary>
/// Initialize PathCommands.
/// </summary>
/// <param name="commands">The array of commands.</param>
- /// <param name="commandCount">The number of commands.</param>
/// <param name="points">The array of points.</param>
- /// <param name="pointCount">The number of points.</param>
/// <exception cref="ArgumentNullException"> Thrown when commands or points are null. </exception>
[EditorBrowsable(EditorBrowsableState.Never)]
- public PathCommands(PathCommandType[] commands, uint commandCount, float[] points, uint pointCount)
+ public PathCommands(IEnumerable<PathCommandType> commands, IEnumerable<float> points)
{
if (commands == null)
{
throw new ArgumentNullException(nameof(points));
}
this.commands = commands;
- this.commandCount = commandCount;
this.points = points;
- this.pointCount = pointCount;
- }
-
- /// <summary>
- /// Enumeration specifying the values of the path commands.
- /// Not to be confused with the path commands from the svg path element (like M, L, Q, H and many others).
- /// </summary>
- [EditorBrowsable(EditorBrowsableState.Never)]
- public enum PathCommandType
- {
- /// <summary>
- /// Ends the current sub-path and connects it with its initial point. This command doesn't expect any points.
- /// </summary>
- Close = 0,
- /// <summary>
- /// Sets a new initial point of the sub-path and a new current point. This command expects 1 point: the starting position.
- /// </summary>
- MoveTo,
- /// <summary>
- /// Draws a line from the current point to the given point and sets a new value of the current point. This command expects 1 point: the end-position of the line.
- /// </summary>
- LineTo,
- /// <summary>
- /// Draws a cubic Bezier curve from the current point to the given point using two given control points and sets a new value of the current point. This command expects 3 points: the 1st control-point, the 2nd control-point, the end-point of the curve.
- /// </summary>
- CubicTo
}
/// <summary>
/// The commands array.
/// </summary>
- /// <returns>The array of commands.</returns>
+ /// <exception cref="ArgumentNullException"> Thrown when commands is null. </exception>
[EditorBrowsable(EditorBrowsableState.Never)]
- public PathCommandType[] GetCommands()
+ public IEnumerable<PathCommandType> Commands
{
- return commands;
- }
-
- /// <summary>
- /// The number of commands.
- /// </summary>
- /// <returns>The number of commands.</returns>
- [EditorBrowsable(EditorBrowsableState.Never)]
- public uint GetCommandCount()
- {
- return commandCount;
+ get
+ {
+ return commands;
+ }
+ set
+ {
+ if (value == null)
+ {
+ throw new ArgumentNullException(nameof(value));
+ }
+ commands = value;
+ }
}
/// <summary>
/// The points array
/// </summary>
- /// <returns>The array of points.</returns>
+ /// <exception cref="ArgumentNullException"> Thrown when points is null. </exception>
[EditorBrowsable(EditorBrowsableState.Never)]
- public float[] GetPoints()
+ public IEnumerable<float> Points
{
- return points;
- }
-
- /// <summary>
- /// The number of points.
- /// </summary>
- /// <returns>The number of points.</returns>
- [EditorBrowsable(EditorBrowsableState.Never)]
- public uint GetPointCount()
- {
- return pointCount;
+ get
+ {
+ return points;
+ }
+ set
+ {
+ if (value == null)
+ {
+ throw new ArgumentNullException(nameof(value));
+ }
+ points = value;
+ }
}
}
}
using System.ComponentModel;
using System.Collections.ObjectModel;
using System.Collections.Generic;
+using System.Linq;
namespace Tizen.NUI.BaseComponents.VectorGraphics
{
throw new ArgumentNullException(nameof(pathCommands));
}
- Interop.Shape.AddPath(BaseHandle.getCPtr(this), pathCommands.GetCommands(), pathCommands.GetCommandCount(), pathCommands.GetPoints(), pathCommands.GetPointCount());
+ PathCommandType[] commands = null;
+ if (pathCommands.Commands is PathCommandType[] commandArray)
+ {
+ commands = commandArray;
+ }
+ else
+ {
+ commands = pathCommands.Commands.ToArray();
+ }
+
+ float[] points = null;
+ if (pathCommands.Points is float[] pointArray)
+ {
+ points = pointArray;
+ }
+ else
+ {
+ points = pathCommands.Points.ToArray();
+ }
+
+ Interop.Shape.AddPath(BaseHandle.getCPtr(this), commands, (uint)commands.Length, points, (uint)points.Length);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
*
*/
using System;
-using System.ComponentModel;
using System.Collections.Generic;
+using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
namespace Tizen.NUI.BaseComponents.VectorGraphics
/// The gradient pattern is repeated continuously beyond the gradient area until the expected region is filled.
/// </summary>
Repeat
- };
+ }
+
+ /// <summary>
+ /// Enumeration specifying the values of the path commands.
+ /// Not to be confused with the path commands from the svg path element (like M, L, Q, H and many others).
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public enum PathCommandType
+ {
+ /// <summary>
+ /// Ends the current sub-path and connects it with its initial point. This command doesn't expect any points.
+ /// </summary>
+ Close = 0,
+ /// <summary>
+ /// Sets a new initial point of the sub-path and a new current point. This command expects 1 point: the starting position.
+ /// </summary>
+ MoveTo,
+ /// <summary>
+ /// Draws a line from the current point to the given point and sets a new value of the current point. This command expects 1 point: the end-position of the line.
+ /// </summary>
+ LineTo,
+ /// <summary>
+ /// Draws a cubic Bezier curve from the current point to the given point using two given control points and sets a new value of the current point. This command expects 3 points: the 1st control-point, the 2nd control-point, the end-point of the curve.
+ /// </summary>
+ CubicTo
+ }
}
shape.Scale(0.5f);
shape.Translate(350.0f, 300.0f);
- shape.AddPath(new PathCommands(new PathCommands.PathCommandType[] { PathCommands.PathCommandType.MoveTo,
- PathCommands.PathCommandType.LineTo,
- PathCommands.PathCommandType.LineTo,
- PathCommands.PathCommandType.LineTo,
- PathCommands.PathCommandType.LineTo,
- PathCommands.PathCommandType.Close },
- 6,
+ shape.AddPath(new PathCommands(new PathCommandType[] { PathCommandType.MoveTo,
+ PathCommandType.LineTo,
+ PathCommandType.LineTo,
+ PathCommandType.LineTo,
+ PathCommandType.LineTo,
+ PathCommandType.Close },
new float[] {0.0f, -160.0f,
125.0f, 160.0f,
-180.0f, -45.0f,
180.0f, -45.0f,
- -125.0f, 160.0f },
- 10));
+ -125.0f, 160.0f }));
canvasView.AddDrawable(shape);