public void Update(Location location) {
     SetLastCurveOperationType(location);
     if(location.UseRelativeCoordinates)
         UpdateCore(ref relLocation, location);
     else
         UpdateCore(ref absLocation, location);
 }
 void SetLastCurveOperationType(Location location) {
     switch(location.CommandType) {
         case PathCommandType.CurveTo:
         case PathCommandType.SmoothCurveTo: lastCurveOperationType = CurveType.Cubic; break;
         case PathCommandType.QuadraticCurveTo:
         case PathCommandType.SmoothQuadraticCurveTo: lastCurveOperationType = CurveType.Quadratic; break;
         default: lastCurveOperationType = CurveType.None; break;
     }
 }
 public void MoveTo(MoveToCommandArgs args) {
     LocationInfo.Update(args.Locations[0]);
     if(args.Locations.Length > 1) {
         int length = args.Locations.Length - 1;
         Location[] locations = new Location[length];
         Array.Copy(args.Locations, 1, locations, 0, length);
         LineTo(new MoveToCommandArgs(args.CommandType, locations));
     }
     LocationInfo.UpdateLastCurveControlPoints(PathLocationInfo.CurveType.None);
 }
 void SmoothQuadraticBezierCurveToCore(MoveToCommandArgs args) {
     Location curveEndLocation = args.Locations[0];
     Location curveControlLocation;
     if(args.PathLocationInfo.HasSavedLastCurveLocations(PathLocationInfo.CurveType.Quadratic)) {
         curveControlLocation = args.PathLocationInfo.CalcCurveControlPoint(curveEndLocation); 
     }
     else {
         PointF actualLocation = args.PathLocationInfo.GetActualLocation(args.UseRelativeCoordinates);
         curveControlLocation = new Location(actualLocation, args.CommandType, args.PathLocationInfo, args.UseRelativeCoordinates);
     }
     Location[] locations = { curveControlLocation, curveEndLocation };
     MoveToCommandArgs totalArgs = new MoveToCommandArgs(args.CommandType, locations, args.PathLocationInfo);
     QuadraticBezierCurveToCore(totalArgs);
 }
 public virtual Location CalcCurveControlPoint(Location curveEndPoint, Location endControlPoint = default(Location)) {
     PointF currentLocation = GetActualLocation(curveEndPoint.UseRelativeCoordinates);
     PointF lastCurveControlPoint = lastCurveLocations.Last();
     PointF[] vectors = new PointF[2];
     PointF[] points = new PointF[2];
     if(lastCurveOperationType == CurveType.Cubic) {
         vectors[0] = new PointF(currentLocation.X - lastCurveControlPoint.X, currentLocation.Y - lastCurveControlPoint.Y);
         points[0] = lastCurveControlPoint;
         vectors[1] = new PointF(endControlPoint.X - currentLocation.X, endControlPoint.Y - currentLocation.Y);
         points[1] = endControlPoint;
     }
     else {
         PointF prevCurveStartLocation = lastCurveLocations[0];
         vectors[0] = new PointF(lastCurveControlPoint.X - prevCurveStartLocation.X, lastCurveControlPoint.Y - prevCurveStartLocation.Y);
         points[0] = curveEndPoint;
         vectors[1] = new PointF(currentLocation.X - lastCurveControlPoint.X, currentLocation.Y - lastCurveControlPoint.Y);
         points[1] = currentLocation;
     }
     PointF result = CalcCurveControlPointCore(vectors, points);
     return new Location(result, curveEndPoint.CommandType, this, curveEndPoint.UseRelativeCoordinates); ;
 }
 void SmoothCubicBezierCurveToCore(MoveToCommandArgs args) {
     Location firstCurveControlLocation;
     Location secondCurveControlLocation = args.Locations[args.Locations.Length - 2];
     Location endCurveLocation = args.Locations[args.Locations.Length - 1];
     if(args.PathLocationInfo.HasSavedLastCurveLocations(PathLocationInfo.CurveType.Cubic)) {
         firstCurveControlLocation = args.PathLocationInfo.CalcCurveControlPoint(endCurveLocation, secondCurveControlLocation);
     }
     else {
         PointF actualLocation = args.PathLocationInfo.GetActualLocation(args.UseRelativeCoordinates);
         firstCurveControlLocation = new Location(actualLocation, args.CommandType, args.PathLocationInfo, args.UseRelativeCoordinates);
     }
     Location[] locations = { firstCurveControlLocation, secondCurveControlLocation, endCurveLocation };
     MoveToCommandArgs newArgs = new MoveToCommandArgs(args.CommandType, locations);
     CubicBezierCurveToCore(newArgs);
 }
 public void CurveTo(MoveToCommandArgs args) {
     int nLocations;
     Action<MoveToCommandArgs> curveRenderMethod = GetCurveRenderMethod(args, out nLocations);
     for(int i = 0; i < args.Locations.Length / nLocations; i++) {
         var locations = new Location[nLocations];
         Array.Copy(args.Locations, i * nLocations, locations, 0, nLocations);
         MoveToCommandArgs newArgs = new MoveToCommandArgs(args.CommandType, locations, args.PathLocationInfo);
         curveRenderMethod(newArgs);
     }
 }
 protected virtual void UpdateCore(ref PointF location, Location assignLocation) {
     if((assignLocation.UnitType & LocationUnitType.X) != 0)
         location.X = assignLocation.X;
     if((assignLocation.UnitType & LocationUnitType.Y) != 0)
         location.Y = assignLocation.Y;
 }
 protected override void ParseCore(string[] args, PathLocationInfo pathLocationInfo) {
     radiusCore.Width = Convert.ToSingle(args[0], CultureInfo.InvariantCulture);
     radiusCore.Height = Convert.ToSingle(args[1], CultureInfo.InvariantCulture);
     XAxisRotation = Convert.ToBoolean(Convert.ToInt32(args[2], CultureInfo.InvariantCulture), CultureInfo.InvariantCulture);
     LargeArcFlag = Convert.ToBoolean(Convert.ToInt32(args[3], CultureInfo.InvariantCulture), CultureInfo.InvariantCulture);
     SweepFlag = Convert.ToBoolean(Convert.ToInt32(args[4], CultureInfo.InvariantCulture), CultureInfo.InvariantCulture);
     PointF location = new PointF(Convert.ToSingle(args[5], CultureInfo.InvariantCulture), Convert.ToSingle(args[6], CultureInfo.InvariantCulture));
     locationCore = new Location(location, CommandType, pathLocationInfo, UseRelativeCoordinates);
 }
Exemple #10
0
 public PointF GetActualLocation(Location location) {
     Update(location);
     return GetActualLocation(location.UseRelativeCoordinates);
 }
Exemple #11
0
 protected override void ParseCore(string[] coordinates, PathLocationInfo pathLocationInfo) {
     foreach(string coordinate in coordinates) {
         PointF point = new PointF(Convert.ToSingle(coordinate, CultureInfo.InvariantCulture), 0);
         Location location = new Location(point, CommandType, pathLocationInfo, UseRelativeCoordinates);
         location.UnitType = LocationUnitType.Y;
         AddLocation(location);
     }
 }
Exemple #12
0
 protected override void ParseCore(string[] coordinates, PathLocationInfo pathLocationInfo) {
     for(int i = 0, j = 0; i < coordinates.Length; i += 2, j++) {
         PointF point = new PointF(Convert.ToSingle(coordinates[i], CultureInfo.InvariantCulture), Convert.ToSingle(coordinates[i + 1], CultureInfo.InvariantCulture));
         Location location = new Location(point, CommandType, pathLocationInfo, UseRelativeCoordinates);
         AddLocation(location);
     }
 }
Exemple #13
0
 public void AddLocation(Location location) {
     locationsCore.Add(location);
 }
Exemple #14
0
 public MoveToCommandArgs(PathCommandType commandType, Location[] locations, PathLocationInfo pathLocationInfo) : base(commandType) {
     locationsCore = locations.ToList();
     PathLocationInfo = pathLocationInfo;
 }
Exemple #15
0
 public MoveToCommandArgs(PathCommandType commandType, Location[] locations) : base(commandType) {
     locationsCore = locations.ToList();
 }