public UserPointsCreatedEvent(Guid userId, PointKind kind, int points, DateTimeOffset createdOn) { UserId = userId; Kind = kind; Points = points; CreatedOn = createdOn; }
void AddPoint(float x, float y, PointKind kind) { var p = new GlyphPoint(x, y, kind); #if DEBUG p.dbugOwnerPart = dbug_ownerPart; #endif points.Add(p); }
public void AddPoints(PointKind kind, int quantity, DateTimeOffset?createdOn = null) { if (Points == null) { Points = new List <UserPoint>(); } var points = new UserPoint(this, Guid.NewGuid(), kind, quantity, createdOn ?? DateTimeOffset.UtcNow); Points.Add(points); RefreshPoints(); }
public UserPoint(User user, Guid id, PointKind kind, int quantity, DateTimeOffset createdOn) { if (quantity < 0) { throw SheaftException.Validation("Le nombre de point doit être supérieur à 0."); } Id = id; Kind = kind; Quantity = quantity; CreatedOn = createdOn; UserId = user.Id; }
// video_dic は高速化のため public static void ParseRankingTermPointHtml(string html, DateTime getting_dt, List <Video> video_list, Dictionary <string, Video> video_dic) { PointKind point_kind = JudgePointKind(html); foreach (int index in EnumerateRankingHtmlVideoInfoIndex(html)) { Video video; int value; DateTime date; int view; int res; int mylist; string video_id; string title; ParseRankingHtmlVideoInfo(html, index, out value, out date, out view, out res, out mylist, out video_id, out title); if (!video_dic.TryGetValue(video_id, out video)) { video = new Video(); video.point.getting_date = getting_dt; video.submit_date = date; video.point.view = 0; video.point.res = 0; video.point.mylist = 0; video.video_id = video_id; video.title = title; video_list.Add(video); video_dic.Add(video_id, video); } switch (point_kind) { case PointKind.View: video.point.view = value; break; case PointKind.Res: video.point.res = value; break; case PointKind.Mylist: video.point.mylist = value; break; } } }
// Rectangle symbols may be translated into multiple symbols (if there is a grid). Symbol[] CreateRectangleSymbol(OcadObject obj, LineSymDef symdef, RectangleInfo rectinfo) { List<Symbol> symlist = new List<Symbol>(); // list of symbols we're creating. if (symdef == null) throw new OcadFileFormatException("Object has unknown or inconsistent symbol type {0}", obj.Sym); if (obj.coords == null || obj.coords.Length < 2) return null; // Create the main rectangle symbol. // Determine size of the rectangle, and matrix needed to transform points to their correct location. PointF[] pts = {PointFromOcadCoord(obj.coords[0]), PointFromOcadCoord(obj.coords[1]), PointFromOcadCoord(obj.coords[2]), PointFromOcadCoord(obj.coords[3])}; SizeF size = new SizeF(Util.DistanceF(pts[0], pts[1]), Util.DistanceF(pts[0], pts[3])); float angle = Util.Angle(pts[0], pts[1]); Matrix matrix = new Matrix(); matrix.Translate(pts[0].X, pts[0].Y); matrix.Rotate(angle); SymPath path; PointKind[] kinds; PointF[] pathpts; if (rectinfo.cornerRadius == 0) { kinds = new PointKind[] {PointKind.Corner, PointKind.Corner, PointKind.Corner, PointKind.Corner, PointKind.Corner}; pathpts = new PointF[] { new PointF(0,0), new PointF(0, size.Height), new PointF(size.Width, size.Height), new PointF(size.Width, 0), new PointF(0,0)}; } else { kinds = new PointKind[] {PointKind.Normal, PointKind.Normal, PointKind.BezierControl, PointKind.BezierControl, PointKind.Normal, PointKind.Normal, PointKind.BezierControl, PointKind.BezierControl, PointKind.Normal, PointKind.Normal, PointKind.BezierControl, PointKind.BezierControl, PointKind.Normal, PointKind.Normal, PointKind.BezierControl, PointKind.BezierControl, PointKind.Normal}; pathpts = new PointF[] { new PointF(rectinfo.cornerRadius, 0), new PointF(size.Width - rectinfo.cornerRadius, 0), new PointF(size.Width - (1-Util.kappa) * rectinfo.cornerRadius, 0), new PointF(size.Width, (1-Util.kappa) * rectinfo.cornerRadius), new PointF(size.Width, rectinfo.cornerRadius), new PointF(size.Width, size.Height - rectinfo.cornerRadius), new PointF(size.Width, size.Height - (1-Util.kappa) * rectinfo.cornerRadius), new PointF(size.Width - (1-Util.kappa) * rectinfo.cornerRadius, size.Height), new PointF(size.Width - rectinfo.cornerRadius, size.Height), new PointF(rectinfo.cornerRadius, size.Height), new PointF((1-Util.kappa) * rectinfo.cornerRadius, size.Height), new PointF(0, size.Height - (1-Util.kappa) * rectinfo.cornerRadius), new PointF(0, size.Height - rectinfo.cornerRadius), new PointF(0, rectinfo.cornerRadius), new PointF(0, (1-Util.kappa) * rectinfo.cornerRadius), new PointF((1-Util.kappa) * rectinfo.cornerRadius, 0), new PointF(rectinfo.cornerRadius, 0)}; } pathpts = GraphicsUtil.TransformPoints(pathpts, matrix); for (int i = 0; i < pathpts.Length; ++i) pathpts[i] = new PointF((float) Math.Round(pathpts[i].X, 2), (float) Math.Round(pathpts[i].Y, 2)); // round to 2 decimals, so round trip to OCAD without change. path = new SymPath(pathpts, kinds); symlist.Add(new LineSymbol(symdef, path)); if (rectinfo.grid) { if (size.Width > 0 && size.Height > 0) { int cxCells = (int) Math.Round(size.Width / rectinfo.cellWidth); if (cxCells < 1) cxCells = 1; int cyCells = (int) Math.Round(size.Height / rectinfo.cellHeight); if (cyCells < 1) cyCells = 1; float width = size.Width / cxCells; float height = size.Height / cyCells; CreateGridLines(size, matrix, cxCells, cyCells, width, height, rectinfo.gridLines, symlist); CreateGridText(size, matrix, angle, cxCells, cyCells, width, height, rectinfo, symlist); } } return symlist.ToArray(); }
// Add the stroke to an OCAD Map glyph with the given box size. public void AddToMapGlyph(Glyph glyph, SymColor color, float boxSize) { float scaleFactor = boxSize / 200.0F; // symbols are designed in box from -100 to 100. switch (kind) { case SymbolStrokes.Disc: glyph.AddFilledCircle(color, new PointF(points[0].X * scaleFactor, points[0].Y * scaleFactor), radius * 2 * scaleFactor); break; case SymbolStrokes.Circle: glyph.AddCircle(color, new PointF(points[0].X * scaleFactor, points[0].Y * scaleFactor), thickness * scaleFactor, (radius * 2 + thickness) * scaleFactor); break; case SymbolStrokes.Polyline: { PointKind[] pathKinds = new PointKind[points.Length]; PointF[] pathPoints = new PointF[points.Length]; for (int i = 0; i < points.Length; ++i) { pathKinds[i] = PointKind.Normal; pathPoints[i] = new PointF(points[i].X * scaleFactor, points[i].Y * scaleFactor); } SymPath path = new SymPath(pathPoints, pathKinds); glyph.AddLine(color, path, thickness * scaleFactor, corners, ends); break; } case SymbolStrokes.Polygon: { PointKind[] pathKinds = new PointKind[points.Length + 1]; PointF[] pathPoints = new PointF[points.Length + 1]; for (int i = 0; i < points.Length; ++i) { pathKinds[i] = PointKind.Normal; pathPoints[i] = new PointF(points[i].X * scaleFactor, points[i].Y * scaleFactor); } pathKinds[points.Length] = pathKinds[0]; pathPoints[points.Length] = pathPoints[0]; SymPath path = new SymPath(pathPoints, pathKinds); glyph.AddLine(color, path, thickness * scaleFactor, corners, corners == LineJoin.Round ? LineCap.Round : LineCap.Flat); break; } case SymbolStrokes.FilledPolygon: { PointKind[] pathKinds = new PointKind[points.Length + 1]; PointF[] pathPoints = new PointF[points.Length + 1]; for (int i = 0; i < points.Length; ++i) { pathKinds[i] = PointKind.Normal; pathPoints[i] = new PointF(points[i].X * scaleFactor, points[i].Y * scaleFactor); } pathKinds[points.Length] = pathKinds[0]; pathPoints[points.Length] = pathPoints[0]; SymPath path = new SymPath(pathPoints, pathKinds); glyph.AddArea(color, new SymPathWithHoles(path, null)); break; } case SymbolStrokes.PolyBezier: { PointKind[] pathKinds = new PointKind[points.Length]; PointF[] pathPoints = new PointF[points.Length]; for (int i = 0; i < points.Length; ++i) { pathKinds[i] = (i % 3 == 0) ? PointKind.Normal : PointKind.BezierControl; pathPoints[i] = new PointF(points[i].X * scaleFactor, points[i].Y * scaleFactor); } SymPath path = new SymPath(pathPoints, pathKinds); glyph.AddLine(color, path, thickness * scaleFactor, corners, ends); break; } case SymbolStrokes.FilledPolyBezier: { PointKind[] pathKinds = new PointKind[points.Length]; PointF[] pathPoints = new PointF[points.Length]; for (int i = 0; i < points.Length; ++i) { pathKinds[i] = (i % 3 == 0) ? PointKind.Normal : PointKind.BezierControl; pathPoints[i] = new PointF(points[i].X * scaleFactor, points[i].Y * scaleFactor); } SymPath path = new SymPath(pathPoints, pathKinds); glyph.AddArea(color, new SymPathWithHoles(path, null)); break; } default: Debug.Fail("Bad SymbolStroke kind"); break; } }
// Create a SymPath that is a Bezier curver matching some points. public static SymPath BezierFromPoints(PointF[] points) { int length = points.Length; PointF[] newpts; PointKind[] kinds; if (length <= 2) { newpts = points; kinds = new PointKind[length]; for (int i = 0; i < length; ++i) kinds[i] = PointKind.Normal; } else { newpts = new PointF[length + (length - 1) * 2]; kinds = new PointKind[length + (length - 1) * 2]; // find control points for all but the end. for (int i = 1; i < points.Length - 1; ++i) { newpts[i * 3] = points[i]; kinds[i * 3] = PointKind.Normal; FindControlPoints(points[i-1], points[i], points[i+1], out newpts[i * 3 - 1], out newpts[i * 3 + 1]); kinds[i * 3 - 1] = PointKind.BezierControl; kinds[i * 3 + 1] = PointKind.BezierControl; } // newpts[0] = points[0]; newpts[(length-1) * 3] = points[length - 1]; kinds[0] = PointKind.Normal; kinds[(length-1) * 3] = PointKind.Normal; if (points[0] == points[length - 1]) { // closed curve FindControlPoints(points[length - 2], points[0], points[1], out newpts[(length-1) * 3 - 1], out newpts[1]); } else { // open curve newpts[1] = FindEndControlPoint(points[0], points[1], newpts[2]); newpts[(length-1) * 3 - 1] = FindEndControlPoint(points[length - 1], points[length - 2], newpts[(length-1) * 3 - 2]); } kinds[(length-1) * 3 - 1] = PointKind.BezierControl; kinds[1] = PointKind.BezierControl; } kinds[kinds.Length - 1] = PointKind.Normal; return new SymPath(newpts, kinds); }
public GlyphPoint2D(double x, double y, PointKind kind) { this.x = x; this.y = y; this.kind = kind; }
// Create a path from pt1 to pt2, with the given radius around the legs. If the leg would // be of zero length, return null. If bends is non-null, then the path should include those bends. // If gaps is non-null, updates the gaps by subtracting the radius from them. private static SymPath GetLegPath(PointF pt1, double radius1, PointF pt2, double radius2, PointF[] bends, LegGap[] gaps) { double legLength = Geometry.Distance(pt1, pt2); // Check for no leg. if (legLength <= radius1 + radius2) return null; int bendCount = (bends == null) ? 0 : bends.Length; PointF[] coords = new PointF[2 + bendCount]; PointKind[] kinds = new PointKind[2 + bendCount]; // Set the end points. coords[0] = Geometry.DistanceAlongLine(pt1, (bendCount > 0) ? bends[0] : pt2, radius1); coords[coords.Length - 1] = Geometry.DistanceAlongLine(pt2, (bendCount > 0) ? bends[bends.Length - 1] : pt1, radius2); // Set the bends. if (bendCount > 0) Array.Copy(bends, 0, coords, 1, bendCount); // Create the path. for (int i = 0; i < kinds.Length; ++i) kinds[i] = PointKind.Normal; // Update the gaps (if any). if (gaps != null) { for (int i = 0; i < gaps.Length; ++i) gaps[i].distanceFromStart -= (float) radius1; } return new SymPath(coords, kinds); }
void GetPaths(out SymPath path1, out SymPath path2) { PointKind[] kinds = { PointKind.Normal, PointKind.BezierControl, PointKind.BezierControl, PointKind.Normal }; PointF[] pts = ScaleCoords((PointF[]) coords1.Clone()); path1 = new SymPath(pts, kinds); kinds = new PointKind[4] { PointKind.Normal, PointKind.BezierControl, PointKind.BezierControl, PointKind.Normal }; pts = ScaleCoords((PointF[]) coords2.Clone()); path2 = new SymPath(pts, kinds); }
SymPathWithHoles path; // closed path with the area to fill #endregion Fields #region Constructors protected AreaCourseObj(Id<ControlPoint> controlId, Id<CourseControl> courseControlId, Id<Special> specialId, float scaleRatio, CourseAppearance appearance, PointF[] pts) : base(controlId, courseControlId, specialId, scaleRatio, appearance) { bool lastPtSynthesized = false; if (pts[pts.Length - 1] != pts[0]) { // If needed, synthesize a final point to close the path. PointF[] newPts = new PointF[pts.Length + 1]; Array.Copy(pts, newPts, pts.Length); newPts[pts.Length] = pts[0]; pts = newPts; lastPtSynthesized = true; } PointKind[] kinds = new PointKind[pts.Length]; for (int i = 0; i < kinds.Length; ++i) kinds[i] = PointKind.Normal; this.path = new SymPathWithHoles(new SymPath(pts, kinds, null, lastPtSynthesized), null); }
public GlyphPoint(float x, float y, PointKind kind) { this._ox = this.newX = x; this._oy = this.newY = y; this.kind = kind; }
public override string ToString() { //TODO: review adjust value again return(this.dbugId + " :" + (_ox + "," + _oy + " " + PointKind.ToString())); }
SymPath CreateSymPath(OcadCoord[] coords) { int dummy; bool anyCutouts; coords = FixOcadCoords(coords, false, out dummy, out anyCutouts); PointF[] points = new PointF[coords.Length]; PointKind[] kinds = new PointKind[coords.Length]; byte[] startStopFlags = null; if (anyCutouts) startStopFlags = new byte[coords.Length - 1]; for (int i = 0; i < coords.Length; ++i) { points[i] = PointFromOcadCoord(coords[i]); kinds[i] = PointKindFromOcadCoord(coords[i]); if (anyCutouts && i < coords.Length - 1) startStopFlags[i] = StartStopFlagsFromCoord(coords[i]); } return new SymPath(points, kinds, startStopFlags, false); }
// Creates holes, and also closes the path (and holes) SymPathWithHoles CreateAreaSymPath(OcadCoord[] coords) { int numHoles; bool anyCutouts; coords = FixOcadCoords(coords, true, out numHoles, out anyCutouts); SymPath[] holes; if (numHoles > 0) holes = new SymPath[numHoles]; else holes = null; SymPath path = null; // Pass 2: allocate the correct sizes of arrays and fill them in int startIndex = 0; int holeNumber = -1; for (int i = 1; i <= coords.Length; ++i) { if (i == coords.Length || IsOcadCoordHoleStart(coords[i])) { // Found the end of the main path or hole. int size = i - startIndex; int arraySize = size; // Make a closed path by duplicating first coord? bool closed = (size <= 1 || PointFromOcadCoord(coords[i-1]) != PointFromOcadCoord(coords[startIndex])); if (closed) { ++arraySize; } PointF[] points = new PointF[arraySize]; PointKind[] kinds = new PointKind[arraySize]; byte[] startStopFlags = null; if (anyCutouts) startStopFlags = new byte[arraySize - 1]; for (int pointIndex = 0; pointIndex < size; ++pointIndex) { points[pointIndex] = PointFromOcadCoord(coords[pointIndex + startIndex]); kinds[pointIndex] = PointKindFromOcadCoord(coords[pointIndex + startIndex]); if (startStopFlags != null && pointIndex < startStopFlags.Length) startStopFlags[pointIndex] = StartStopFlagsFromCoord(coords[pointIndex + startIndex]); } if (closed) { points[arraySize - 1] = PointFromOcadCoord(coords[startIndex]); kinds[arraySize - 1] = PointKindFromOcadCoord(coords[startIndex]); } SymPath p = new SymPath(points, kinds, startStopFlags, closed); if (holeNumber == -1) path = p; else holes[holeNumber] = p; ++holeNumber; startIndex = i; } } return new SymPathWithHoles(path, holes); }
public GlyphPoint(float x, float y, PointKind kind) { _ox = _newX = x; _oy = _newY = y; _kind = kind; }