private void InitListViewModel(PointItemsViewModel viewModel, PointItems list) { foreach (var item in viewModel.Items) { InitBaseItemViewModel(item); } }
public IActionResult _EditPointItems(int Itemskey) { if (Itemskey <= 0) { return(Json(new StatusMessageData(StatusMessageType.Error, "找不到该积分项目!"))); } PointItems pointItem = pointItemsService.GetFullPointItems(Itemskey); EditPointItemsModel model = new EditPointItemsModel() { Applicationid = pointItem.Applicationid, Description = pointItem.Description, DisplayOrder = pointItem.DisplayOrder, ExperiencePoints = pointItem.ExperiencePoints, Itemstyle = pointItem.Itemstyle, Itemsname = pointItem.Itemsname, SexyPoints = pointItem.SexyPoints }; IEnumerable <PointType> pointType = pointTypeService.GetPointTypeList(); if (pointType != null) { ViewData["PointType"] = new SelectList(pointType, "Typekey", "Typename", pointItem.Itemskey); } return(View(model)); }
public ActionResult List(PointFilterViewModel filterViewModel) { InitPointFilterViewModel(ref filterViewModel, true); var filter = Mapper.Map <PointFilter>(filterViewModel); PointItems list = _pointRepository.GetPointItems(UserContext.User.Id, UserContext.User.OrganizationId, filter); PointItemsViewModel viewModel = Mapper.Map <PointItemsViewModel>(list); viewModel.Filter = filterViewModel; InitListViewModel(viewModel, list); return(View(Mvc.View.Point.List, viewModel)); }
private void CalculatePointItemBasemOnCalculatedPoints(IEnumerable <Point> points, PixelsCaclulator parametrizedPixelsCaclulator) { Coordinates GetCalculatedPixels(Point vs) { var coor = parametrizedPixelsCaclulator.CalculatePixel(vs.ListOfVariables[0], vs.ListOfVariables[1]); coor.X -= _calculatedPointSize / 2; // change the coordinates to put pixel in the center of the point coor.Y -= _calculatedPointSize / 2; return(coor); } void ConnectPointWithLine(PointItem A, PointItem B) { var CoorA = new Coordinates(A.Coordinates.X + _calculatedPointSize / 2, A.Coordinates.Y + _calculatedPointSize / 2); var CoorB = new Coordinates(B.Coordinates.X + _calculatedPointSize / 2, B.Coordinates.Y + _calculatedPointSize / 2); var lineItem = new LineItem(CoorA, CoorB); LinesConnectingPoints.Add(lineItem); } if (points == null || points.Count() == 0) { return; } var point = points.ElementAt(0); var coordinates = GetCalculatedPixels(point); var PointItem = new PointItem(coordinates, point, _calculatedPointSize); PointItems.Add(PointItem); for (int i = 1; i < points.Count(); i++) { point = points.ElementAt(i); coordinates = GetCalculatedPixels(point); PointItem = new PointItem(coordinates, point, _calculatedPointSize); PointItems.Add(PointItem); ConnectPointWithLine(PointItems.ElementAt(i - 1), PointItem); } }
public IActionResult AddPointItems(EditPointItemsModel model) { PointItems pointItems = PointItems.New(); pointItems.Description = model.Description; pointItems.ExperiencePoints = model.ExperiencePoints; pointItems.DisplayOrder = model.DisplayOrder; pointItems.Itemsname = model.Itemsname; pointItems.Itemstyle = model.Itemstyle; pointItems.SexyPoints = model.SexyPoints; pointItems.Applicationid = model.Applicationid; bool result = pointItemsService.AddPointItems(pointItems); if (result) { return(Json(new StatusMessageData(StatusMessageType.Success, "添加成功!"))); } return(Json(new StatusMessageData(StatusMessageType.Error, "添加失败!"))); }
public async void Create(double imageSize, double range, int step, double CentrumX = 0, double CentrumY = 0) { _eventAggregator.GetEvent <CreateCounterLineInfoEvent>().Publish(true); // Counterine is Creatng BitmapSize = imageSize; var pixelsCaclulator = new PixelsCaclulator(imageSize, imageSize, range, step, CentrumX, CentrumY); PointItems.Clear(); LinesConnectingPoints.Clear(); var centralCoordinate = pixelsCaclulator.CalculatePixel(CentrumX, CentrumY); CentralPoint = new PointItem(centralCoordinate, new Point(CentrumX, CentrumY), _calculatedPointSize); var pixels = await GetPixelsTask(pixelsCaclulator); Bitmap = BitmapCreator.CreateBitmap(pixels); _eventAggregator.GetEvent <CreateCounterLineInfoEvent>().Publish(false); // Counterine is not Creatng CalculatePointItemBasemOnCalculatedPoints(CalculatedPoints, pixelsCaclulator); }
public IActionResult EditPointItems(EditPointItemsModel model) { if (model.Itemskey <= 0) { return(Json(new StatusMessageData(StatusMessageType.Error, "找不到该积分项目!"))); } PointItems pointItems = pointItemsService.GetFullPointItems(model.Itemskey); pointItems.Itemsname = model.Itemsname; pointItems.Applicationid = model.Applicationid; pointItems.Description = model.Description; pointItems.DisplayOrder = model.DisplayOrder; pointItems.ExperiencePoints = model.ExperiencePoints; pointItems.Itemstyle = model.Itemstyle; pointItems.SexyPoints = model.SexyPoints; bool result = pointItemsService.EditPointItems(pointItems); if (result) { return(Json(new StatusMessageData(StatusMessageType.Success, "编辑成功!"))); } return(Json(new StatusMessageData(StatusMessageType.Error, "编辑失败!"))); }
private PointPresenter[] CalculateMinimalConvex() { return(PointItems?.OfType <PointPresenter>().ToArray()); }
/// <summary> /// Calculates the corner points of a rectangle that surrounds the polygon with a given gradient. /// The lines that are used to calculate distance are tangents of an ellipse that surrounds /// the world map coordinate system with equation of x^2/255^2 + y^2/130^2 = 1. Therefore /// every location on the map can use this function. /// </summary> /// <param name="gradient"></param> /// <returns></returns> private List <PointItem> IntersectingPoints(double gradient) { double distance; double perpdistance; int indexmax = 0; int indexmin = 0; int indexmaxperp = 0; int indexminperp = 0; double min = 0; double max = 0; double minp = 0; double maxp = 0; double perpendiculargradient = 1 / -gradient; foreach (PointItem i in PointItems) { int j = PointItems.IndexOf(i); distance = i.DistanceToEllipseTangent(false, gradient); perpdistance = i.DistanceToEllipseTangent(true, perpendiculargradient); // Saves index of closest point to tangent if (min == 0 || distance < min) { min = distance; indexmin = j; } // Saves index of furthest point from tangent if (max == 0 || distance > max) { max = distance; indexmax = j; } // Saves index of closest point to perpendicular tangent if (minp == 0 || perpdistance < minp) { minp = perpdistance; indexminperp = j; } // Saves index of furthest point from perpendicular tangent if (maxp == 0 || perpdistance > maxp) { maxp = perpdistance; indexmaxperp = j; } } // Add indexes to array to allow iteration int[] indexes = new int[] { indexmin, indexmax, indexminperp, indexmaxperp }; double x; double y; List <PointItem> list = new List <PointItem>(); // Creates points at the intersection of lines through closest and furthest points to tangents // i / 2 = 0,0,1,1 for values of i = 0,1,2,3 // i % 2 + 2 = 2,3,2,3 for values of i = 0,1,2,3 for (int i = 0; i < 4; i++) { if (gradient == 0) { x = PointItems[indexes[i % 2 + 2]].Longitude; y = PointItems[indexes[i / 2]].Latitude; } else if (perpendiculargradient == 0) { x = PointItems[indexes[(i / 2)]].Longitude; y = PointItems[indexes[i % 2 + 2]].Latitude; } else { x = ((gradient * PointItems[indexes[i / 2]].Longitude) - (perpendiculargradient * PointItems[indexes[i % 2 + 2]].Longitude) + PointItems[indexes[i % 2 + 2]].Latitude - PointItems[indexes[i / 2]].Latitude) / (gradient - perpendiculargradient); y = gradient * (x - PointItems[indexes[i / 2]].Longitude) + PointItems[indexes[i / 2]].Latitude; } list.Add(new PointItem(y, x, i)); } // Rearranges list for use in CreateFlightLines() list.Reverse(2, 2); return(list); }