// FIXME: Optimize the loops // given a comparePoint, determine if that point is within this model's points. public bool isPointWithinFormation(PointModel comparePoint) { for (var i = 0; i < this.points.Count; i++) { PointModel point = this.points[i]; if (FormationModelComparator.isEqual(point, comparePoint)) { return true; } } return false; }
// count pieces on a particular gamePost public static int findPiecesOnPostForRowAndColumn(int row, int column) { int count = 0; for (var level = 0; level < gameBoard.GetLength(0); level++) { PointModel point = new PointModel(level, row, column); int foundPoint = findPlayerAtPoint(point); if (foundPoint != INVALID_PLAYER) { count++; } } return count; }
private void NotifyHelper_ScreenCaptureDataBind(CaptureEventArgs e) { if (e.CaptureViewMode != CaptureViewMode.Common) { return; } if (CurrentTreeViewItem == _dummyTreeGridViewItem) { CurrentTreeViewItem = new TreeGridViewItem() { DataContext = new EventTriggerModel() }; } if (RelativePosition == _dummyRelativePosition) { RelativePosition = new PointModel(); } RadioButtonRefresh(); }
private static PointModel <int> ReadModel(IDataRecord reader) { var id = reader.GetInt32(0); var dimension = reader.GetInt16(1); var dataType = reader.GetInt16(2); if (dataType != (byte)DataType.Int) { throw new CustomException($"Wrong Data Type. Int expected, got {(DataType)dataType}.", (byte)CustomErrorCode.WrongDataType); } var x = BitConverter.ToInt32((byte[])reader.GetValue(3), 0); var y = BitConverter.ToInt32((byte[])reader.GetValue(4), 0); var z = BitConverter.ToInt32((byte[])reader.GetValue(5), 0); var errorLogModel = new PointModel <int>(id, (byte)dimension, x, y, z); return(errorLogModel); }
public void PointModel() { PointModel <long> model = new PointModel <long>(); model.Measurement = "TestMeasurement"; model.Tags["TestTag1"] = "SomeTag1"; model.Tags["TestTag2"] = "SomeTag2"; model.Tags["TestTag3"] = "SomeTag3"; model.Fields["TestValu1"] = 12345; model.Fields["TestValu2"] = 54321; string json = JsonSerializer.Serialize(model, new JsonSerializerOptions { WriteIndented = true }); Console.WriteLine(json); //PointModel<long> model2 = JsonSerializer.Deserialize<PointModel<long>>(json); }
public ActionResult SaveAddPoint(PointModel p) { if (Request.Form["mad_AddPoint"] != null && Request.Form["m_id"] != null) { p.m_id = Request.Form["m_id"]; p.mad_AddPoint = Convert.ToInt32(Request.Form["mad_AddPoint"]); PointFactory factory = new PointFactory(); factory.儲存儲值資料(p); } if (p.m_id == null) { return(RedirectToAction("AddPoint")); } else { return(RedirectToAction("AddPoint", new { m_id = p.m_id })); } }
private void RadioButton_Click(object sender, RoutedEventArgs e) { if (CurrentTreeViewItem == _dummyTreeGridViewItem) { CurrentTreeViewItem = new TreeGridViewItem() { DataContext = new EventTriggerModel() }; } if (RelativePosition == _dummyRelativePosition) { RelativePosition = new PointModel(); } if (sender.Equals(rbMouse)) { CurrentTreeViewItem.DataContext <EventTriggerModel>().EventType = EventType.Mouse; } else if (sender.Equals(rbKeyboard)) { CurrentTreeViewItem.DataContext <EventTriggerModel>().EventType = EventType.Keyboard; } else if (sender.Equals(rbImage)) { CurrentTreeViewItem.DataContext <EventTriggerModel>().EventType = EventType.Image; if (CurrentTreeViewItem.DataContext <EventTriggerModel>().MouseTriggerInfo.MouseInfoEventType != MouseEventType.None) { CurrentTreeViewItem.DataContext <EventTriggerModel>().MouseTriggerInfo = new MouseTriggerInfo(); } } else if (sender.Equals(rbRelativeToImage)) { CurrentTreeViewItem.DataContext <EventTriggerModel>().EventType = EventType.RelativeToImage; if (CurrentTreeViewItem.DataContext <EventTriggerModel>().MouseTriggerInfo.MouseInfoEventType != MouseEventType.None) { CurrentTreeViewItem.DataContext <EventTriggerModel>().MouseTriggerInfo = new MouseTriggerInfo(); } RelativePosition.X = CurrentTreeViewItem.DataContext <EventTriggerModel>().MouseTriggerInfo.StartPoint.X; RelativePosition.Y = CurrentTreeViewItem.DataContext <EventTriggerModel>().MouseTriggerInfo.StartPoint.Y; } RadioButtonRefresh(); }
/*求已知经纬度两点距离公式 * //EARTH_RADIUS*2*Math.asin(Math.sqrt(Math.pow(Math.sin(a/2),2) + Math.cos(radLat1)*Math.cos(radLat2)*Math.pow(Math.sin(b/2),2))); */ /// <summary> /// 圆形区域查车 自由模式 /// </summary> /// <param name="model"></param> /// <param name="currentUserID"></param> /// <returns></returns> public static List <RealTimeSignalModel> GetRealTimeSingalsByCircle(GetCircleRealTimeSingalsModel model, int currentUserID) { //纠偏 PointModel point = NetDecryFixFalse(model.Lng, model.Lat); model.Lng = point.Longitude; model.Lat = point.Latitude; //目前用车代号代替 string sql = @"SELECT sg.* FROM dbo.VW_GetRealTimeSignals sg INNER JOIN dbo.Func_New_GetVehicleIDByUserId(@userID) vids ON sg.VID=vids.VehicleID WHERE 6378138.0*2*ASIN(SQRT(POWER(SIN((@lat*PI()/180-sg.Latitude*PI()/180)/2),2)+ COS(@lat*PI()/180)*COS(sg.Latitude*PI()/180)*POWER(SIN((@lng*PI()/180-sg.Longitude*PI()/180)/2),2)))<@radius"; SqlParameter[] paras = new SqlParameter[4]; paras[0] = new SqlParameter() { ParameterName = "@userID", Value = currentUserID, SqlDbType = SqlDbType.Int }; paras[1] = new SqlParameter() { ParameterName = "@lat", Value = model.Lat, SqlDbType = SqlDbType.Float }; paras[2] = new SqlParameter() { ParameterName = "@lng", Value = model.Lng, SqlDbType = SqlDbType.Float }; paras[3] = new SqlParameter() { ParameterName = "@radius", Value = model.Radius, SqlDbType = SqlDbType.Float }; return(ConvertToList <RealTimeSignalModel> .Convert(MSSQLHelper.ExecuteDataTable(CommandType.Text, sql, paras))); }
public ValidationMessage Validate(PointModel point) { if (Points.Contains(point)) { if (point.X > 1000 || point.X < -1000 || point.Y > 1000 || point.Y < -100) { return(new ValidationMessage() { Successfull = false, Message = "Out of range" }); } } return(new ValidationMessage() { Successfull = true, Message = "Point has been added" }); }
public override void Initialize( ) { if (pointBuffer != null) { pointBuffer.Dispose(); } model = source as PointModel; //Create the vertex buffer pointBuffer = new AutoVertexBuffer(d3d, typeof(CustomVertex.PositionNormal), 1, Usage.Dynamic, CustomVertex.PositionNormal.Format, Pool.Default); CustomVertex.PositionNormal[] verts = new CustomVertex.PositionNormal[1]; verts[0].Position = model.Position; verts[0].Normal = Direct3dRender.DefaultVertexNormal; pointBuffer.VB.SetData(verts, 0, LockFlags.None); }
public ActionResult Create(PointModel point) { try { if (ModelState.IsValid && MgtPoint.GetInstance().AddPoint(point.ToBo())) { return(RedirectToAction("Index", new { id = point.IdCourse })); } else { point.ListTypePointOptions = MgtTypePoint.GetInstance().GetAllItems(); return(View(point)); } } catch { point.ListTypePointOptions = MgtTypePoint.GetInstance().GetAllItems(); return(View(point)); } }
private Polygon DrawPolygon(PointModel points, KatDetayModel raf) { // SolidColorBrush s = new SolidColorBrush(); string ttString = ""; // s = UIOperation.GetScaleColor(raf.Oran); ttString = "Raf = " + raf.Name + "\nKoy = " + raf.Koy + "\nSıra = " + raf.Sira + "\nDoluluk Oranı = % " + Math.Round(raf.Oran, 1) + ""; ToolTip tt = new ToolTip() { Placement = System.Windows.Controls.Primitives.PlacementMode.Mouse, Content = ttString }; Polygon polygon = new Polygon() { Tag = raf, ToolTip = tt, Stroke = Brushes.Black, StrokeThickness = 0.2, VerticalAlignment = VerticalAlignment.Stretch, HorizontalAlignment = HorizontalAlignment.Left }; polygon.Fill = ((KatDetayModel)polygon.Tag).Color; PointCollection polygonPoints = new PointCollection { points.P1, points.P2, points.P3, points.P4 }; polygon.Points = polygonPoints; return(polygon); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { int input; try { DataGridRow dgc = (DataGridRow)value; //MessageBox.Show(dgc.DataContext.ToString()); PointModel rowView = (PointModel)dgc.DataContext; DateTime tmp = new DateTime(2015, 5, 21, 10, 0, 0); if (rowView.Open == 420) { //MessageBox.Show("!"); input = 0; } if (rowView.Open < rowView.Close) { input = 1; } else { input = 2; } //input = (int)rowView.Row.ItemArray[dgc. Column.DisplayIndex]; } catch (InvalidCastException e) { return(DependencyProperty.UnsetValue); } switch (input) { case 1: return(Brushes.GreenYellow); case 2: return(Brushes.OrangeRed); case 3: return(Brushes.Blue); default: return(DependencyProperty.UnsetValue); } }
/// <summary> /// Carga los datos de un punto /// </summary> internal PointModel GetPoint(string value, double defaultX = 0, double defaultY = 0) { PointModel point = new PointModel(0, 0); // Carga los datos if (!value.IsEmpty()) { string[] valueParts = value.Split(','); if (valueParts.Length > 0) { point.X = valueParts[0].GetDouble(defaultX); } if (valueParts.Length > 1) { point.Y = valueParts[1].GetDouble(defaultY); } } // Devuelve el punto return(point); }
public PointModel SetAction(ActionEnum moveAction) { currentMoveAction = moveAction; switch (currentMoveAction) { case ActionEnum.LEFT: SetLeftRotateResult(); break; case ActionEnum.MOVE: SetMoveResult(); break; case ActionEnum.RIGHT: SetRightRotateResult(); break; } PointModel pointModel = new PointModel(x, y, currentRotateAction); return(pointModel); }
public async Task <IActionResult> Get(string shippingOptionId) { var shippingPoint = await _shippingPointService.GetStoreShippingPointById(shippingOptionId); if (shippingPoint != null) { var viewModel = new PointModel() { ShippingPointName = shippingPoint.ShippingPointName, Description = shippingPoint.Description, PickupFee = _priceFormatter.FormatShippingPrice(shippingPoint.PickupFee), OpeningHours = shippingPoint.OpeningHours, Address1 = shippingPoint.Address1, City = shippingPoint.City, CountryName = (await _countryService.GetCountryById(shippingPoint.CountryId))?.Name, ZipPostalCode = shippingPoint.ZipPostalCode, }; return(View(viewModel)); } return(Content("ShippingPointController: given Shipping Option doesn't exist")); }
public bool DesactivatePoint(PointModel point) { if (point == null) { throw new ArgumentNullException("point"); } using (AppTourEntities data = new AppTourEntities()) { POINT actual = data.POINT.Single(x => x.ID == point.Id); if (actual != null) { actual.IS_ACTIVE = false; data.SaveChanges(); return(true); } return(false); } }
public ActionResult Delete(int idPoint, FormCollection collection) { try { PointModel point = MgtPoint.GetInstance().GetPointById(idPoint).ToModel(); List <Resultat> listResultats = MgtResultat.GetInstance().GetAllByPoint(idPoint).ToList(); //Suppression des résultats associés au point foreach (Resultat resultat in listResultats) { MgtResultat.GetInstance().DeleteResultat(resultat.id); } int ordre = point.Ordre; int taille = MgtPoint.GetInstance().GetAllWithCourseAndTypePointByCourse(point.IdCourse).Count; if (ordre < taille - 1) { while (ordre < taille - 1) { ordre++; Point pointSup = MgtPoint.GetInstance().GetPointByCourseAndOrder(point.IdCourse, ordre); pointSup.Ordre = ordre - 1; MgtPoint.GetInstance().UpdatePoint(pointSup); } } var result = MgtPoint.GetInstance().DeletePoint(idPoint); if (result) { return(RedirectToAction("Index", new { id = point.IdCourse })); } else { return(View()); } } catch { return(View()); } }
// custom drawing /// <summary> /// puts single point on canvas /// </summary> /// <param name="newPoint"></param> /// <param name="color"></param> public void putPoint(PointModel newPoint, string color) { // newPointsList.Add(newPoint); if (color == "green") { g.FillEllipse( Brushes.Green, (float)newPoint.x + center_x, -1 * (float)newPoint.y - center_y, 5, 5); } else if (color == "red") { g.FillEllipse( Brushes.Red, (float)newPoint.x + center_x, -1 * (float)newPoint.y - center_y, 5, 5); } else if (color == "pink") { g.FillEllipse( Brushes.DeepPink, (float)newPoint.x + center_x, -1 * (float)newPoint.y - center_y, 5, 5); } else { g.FillEllipse( Brushes.Black, (float)newPoint.x + center_x, -1 * (float)newPoint.y - center_y, 5, 5); } }
/// <summary> /// Method to update a Point in database. /// </summary> /// <param name="pointModel"></param> /// <returns></returns> public bool PointsUpdate(PointModel pointModel) { bool result = false; using (SqlConnection sqlConnection = new SqlConnection(base.ConnectionString)) { SqlCommand sqlCommand = new SqlCommand("PointsUpdate", sqlConnection); sqlCommand.CommandType = CommandType.StoredProcedure; sqlCommand.Parameters.AddWithValue("@PlayerID", pointModel.PlayerID); sqlCommand.Parameters.AddWithValue("@MatchID", pointModel.MatchID); sqlCommand.Parameters.AddWithValue("@Point", pointModel.Point); using (sqlCommand) { sqlConnection.Open(); sqlCommand.ExecuteScalar(); result = true; } } return(result); }
private void Start() { _controllerList = new ControllerList(); var asteroidFactory = new AsteroidFactory(); var playerFactory = new PlayerFactory(_data.PlayerData); var playerModel = new PlayerModel(playerFactory); var inputModel = new InputModel(); var pointModel = new PointModel(); var pauseModel = new PauseModel(); var enemyPool = new EnemyPool( _data.EnemyData.AsteroidPoolSize, _data.EnemyData, asteroidFactory); _controllerList.Add(new InputController( inputModel.GetInputKeyboard(), inputModel.GetInputMouse(), inputModel.Pause(), inputModel.Ability())); _controllerList.Add(new PlayerController( _data, inputModel, playerModel, pauseModel)); _controllerList.Add(new AsteroidController( _data.EnemyData, playerModel, pointModel, asteroidFactory, enemyPool)); _controllerList.Add(new UIController( inputModel, pointModel, enemyPool, pauseModel)); _controllerList.Add(new PauseController( pauseModel)); _controllerList.Initialize(); }
/// <summary> /// Process incoming quotes /// </summary> /// <param name="input"></param> protected void OnInputData(InputPointModel input) { var currentAsk = input.Ask; var currentBid = input.Bid; var previousAsk = _point?.Ask ?? currentAsk; var previousBid = _point?.Bid ?? currentBid; var instrument = $"{ input.Instrument }"; var point = new PointModel { Ask = currentAsk, Bid = currentBid, Time = input.Time, Bar = new PointBarModel(), Instrument = Account.Instruments[instrument], Last = ConversionManager.Compare(currentBid, previousBid) ? currentAsk : currentBid }; if (input.Asks.Any()) { var edge = input.Asks.Min(o => new { o.Price, o.Size }); point.Ask = Math.Min(point.Ask.Value, edge.Price.Value); point.AskSize = edge.Size; } if (input.Bids.Any()) { var edge = input.Bids.Max(o => new { o.Price, o.Size }); point.Bid = Math.Max(point.Bid.Value, edge.Price.Value); point.BidSize = edge.Size; } _point = point; UpdatePointProps(point); }
private async void AcceptChallenge() { try { if (!goal.GoalAccepted && !string.IsNullOrEmpty(goal.ChallengeId) && challengeOwner != null) { bool accepted = await DisplayAlert("New challenge!", "You have been challenged by " + challengeOwner.FirstName + " " + challengeOwner.LastName + " with the goal " + goal.Title, "Accept", "Decline"); if (accepted) { goal.GoalAccepted = true; await App.client.GetTable <GoalModel>().UpdateAsync(goal); // Register earned points PointModel point = new PointModel() { RegDate = DateTime.Now, Points = Helpers.Constants.POINTS_FOR_ACCEPTED_CHALLENGE, UserId = App.loggedInUser.Id }; await App.client.GetTable <PointModel>().InsertAsync(point); } else { await App.client.GetTable <GoalModel>().DeleteAsync(goal); await Navigation.PopAsync(); } } } catch (Exception ex) { var properties = new Dictionary <string, string> { { "Goal detail page", "Accept challenge" } }; Crashes.TrackError(ex, properties); } }
private static List <FormationModel> buildStacks() { List <FormationModel> allStacks = new List <FormationModel>(); for (var row = 0; row < MAX_LENGTH; row++) { for (var cell = 0; cell < MAX_LENGTH; cell++) { List <PointModel> singleStack = new List <PointModel>(); for (var level = 0; level < MAX_LENGTH; level++) { PointModel stack = new PointModel(level, row, cell); singleStack.Add(stack); } FormationModel singleStackFormationToAdd = new FormationModel("STACK_NATURAL", singleStack); allStacks.Add(singleStackFormationToAdd); } } return(allStacks); }
// 儲存月卡資料 public ActionResult SaveMonthlyCard(string m_id, string bmc_id, string bmc_Name, int bmc_Date, int bmc_Price) { PointFactory factory = new PointFactory(); PointModel p = new PointModel(); p.m_id = m_id; p.bmc_id = bmc_id; p.bmc_Name = bmc_Name; p.bmc_Date = bmc_Date; p.bmc_Price = bmc_Price; int 使用者剩餘點數 = factory.回傳目前此會員的剩餘點數(m_id); if (使用者剩餘點數 > bmc_Price) { factory.儲存月卡資料(p); } else { // 使用者錢不夠 } return(RedirectToAction("ShopMonthlyCard", new { m_id = p.m_id })); }
public ActionResult ShopBook(PointModel p) { PointFactory factory = new PointFactory(); int 使用者剩餘點數 = factory.回傳目前此會員的剩餘點數(p.m_id); if (使用者剩餘點數 > Convert.ToInt32(Request.Form["msd_CostPoint"])) { p.m_id = Request.Form["m_id"]; p.b_id = Request.Form["b_id"]; p.b_DatePrice = Convert.ToInt32(Request.Form["b_DatePrice"]); p.msd_CostPoint = Convert.ToInt32(Request.Form["msd_CostPoint"]); p.購買天數 = factory.判斷使用者購買書籍天數(p); } else { // 使用者錢不夠 } factory.儲存消費資料(p); return(RedirectToAction("BookPage", "CV", new { bid = p.b_id })); }
public IActionResult Get(string shippingOptionId) { var shippingPoint = _shippingPointService.GetStoreShippingPointById(shippingOptionId); if (shippingPoint != null) { var countryName = _countryService.GetCountryById(shippingPoint.CountryId); var viewModel = new PointModel() { ShippingPointName = shippingPoint.ShippingPointName, Description = shippingPoint.Description, PickupFee = _priceFormatter.FormatShippingPrice(shippingPoint.PickupFee, true), OpeningHours = shippingPoint.OpeningHours, Address1 = shippingPoint.Address1, City = shippingPoint.City, CountryName = _countryService.GetCountryById(shippingPoint.CountryId)?.Name, ZipPostalCode = shippingPoint.ZipPostalCode, }; return(View("~/Plugins/Shipping.ShippingPoint/Views/FormShippingOption.cshtml", viewModel)); } return(Content("ShippingPointController: given Shipping Option doesn't exist")); }
public static RealTimeSignalModel GetRealTimeSignalByVheicleID(long vehicleID) { string sql = @"SELECT vw.*,(select top 1 e.EmployeeName from [VehicleEmployeeInfo] v inner join [EmployeeInfo] e on v.EmployeeInfoID=e.ID where v.Type=1 and v.VehicleID=vw.VID) DriverName,(select top 1 e.ContactPhone from [VehicleEmployeeInfo] v inner join [EmployeeInfo] e on v.EmployeeInfoID=e.ID where v.Type=1 and v.VehicleID=vw.VID) DriverPhone,(select top 1 e.EmployeeName from [VehicleEmployeeInfo] v inner join [EmployeeInfo] e on v.EmployeeInfoID=e.ID where v.Type=2 and v.VehicleID=vw.VID) EscortName,(select top 1 e.ContactPhone from [VehicleEmployeeInfo] v inner join [EmployeeInfo] e on v.EmployeeInfoID=e.ID where v.Type=2 and v.VehicleID=vw.VID) EscortPhone,(SELECT top 1 e.EmployeeName from [VehicleEmployeeInfo] v inner join [EmployeeInfo] e on v.EmployeeInfoID=e.ID WHERE v.Type=3 and v.VehicleID=vw.VID) OwnersName,(SELECT top 1 e.ContactPhone from [VehicleEmployeeInfo] v inner join [EmployeeInfo] e on v.EmployeeInfoID=e.ID WHERE v.Type=3 and v.VehicleID=vw.VID) OwnersPhone FROM [dbo].[VW_GetRealTimeSignals] vw WHERE vw.VID = @vehicleID"; SqlParameter[] paras = new SqlParameter[1]; paras[0] = new SqlParameter() { ParameterName = "@vehicleID", Value = vehicleID, SqlDbType = SqlDbType.BigInt, }; var list = ConvertToList <RealTimeSignalModel> .Convert(MSSQLHelper.ExecuteDataTable(CommandType.Text, sql, paras)); if (list == null || list.Count == 0) { return(null); } else { string points = string.Empty; for (int i = 0; i < list.Count; i++) { //纠偏 PointModel point = NetDecryFixTrue(list[i].Longitude, list[i].Latitude); list[i].Longitude = point.Longitude; list[i].Latitude = point.Latitude; } } return(list[0]); }
public void putRaycasting() { PointModel mouse_position = new PointModel(mouse_x, -1 * (mouse_y - graph.Height)); LineModel rayGen = new LineModel(mouse_position, new PointModel(mouse_x + 500, -1 * (mouse_y - graph.Height))); foreach (LineModel wall in walls) { g.DrawLine( new Pen(Color.DeepPink, 3), (float)wall.A.x + center_x + 3, -1 * (float)wall.A.y - center_y + 3, (float)wall.B.x + center_x + 3, -1 * (float)wall.B.y - center_y + 3); } for (int i = 0; i <= 360; i += 3) { LineModel ray = Engine.LineRotation(rayGen, i); //PointModel p = null; foreach (LineModel wall in walls) { PointModel c = Engine.cast(ray, wall); if (c != null) { ray.B = c; } } //draw ray g.DrawLine( new Pen(Color.Cyan, 1), (float)ray.A.x + center_x + 3, -1 * (float)ray.A.y - center_y + 3, (float)ray.B.x + center_x + 3, -1 * (float)ray.B.y - center_y + 3); } //System.Threading.Thread.Sleep(100); }
public async Task <ActionResult <PointModel> > Put(PointModel model) { if (ModelState.IsValid) { try { var response = await _mediator.Send(new PointUpdateTransactionRequest() { Point = model }); if (response == null || response.Point == null) { return(NoContent()); } return(response.Point); } catch (NotFoundException) { return(NotFound()); } } return(BadRequest(ModelState)); }
/// <summary> /// 创建Point值之间的线性动画 /// </summary> public static PointAnimation BuildPointAnimation(PointModel Model) { PointAnimation _pointAnimation = new PointAnimation(); _pointAnimation.From = Model.From; _pointAnimation.To = Model.To; _pointAnimation.Duration = new Duration(TimeSpan.FromSeconds(Model.Duration)); _pointAnimation.AutoReverse = Model.AutoReverse; _pointAnimation.BeginTime = TimeSpan.FromSeconds(Model.BeginTime); _pointAnimation.By = Model.By; _pointAnimation.FillBehavior = Model.FillBehavior; _pointAnimation.RepeatBehavior = Model.RepeatBehavior; _pointAnimation.SpeedRatio = Model.SpeedRatio; if (Model.EasingFunction != null) { _pointAnimation.EasingFunction = Model.EasingFunction; } Storyboard.SetTarget(_pointAnimation, Model.Target); Storyboard.SetTargetProperty(_pointAnimation, new PropertyPath(Model.PropertyPath)); return(_pointAnimation); }
public async Task WritePointModelArray(string measurementName, int number) { var random = new Random(); PointModel <long>[] array = new PointModel <long> [number]; for (int i = 0; i < number; i++) { var value = random.Next(0, 100); var point = new PointModel <long> { Measurement = measurementName, Tags = { { "tag3", "test-tag31" }, { "tag4", "test-tag41" } }, Fields = { { "value1", value }, { "value2", value + 2 } }, Timestamp = DateTime.UtcNow.AddSeconds(-i) }; array[i] = point; Console.WriteLine(point.ConverToPointData().ToLineProtocol()); } await _writer.WriteAsync(array); }
public static bool isEqual(PointModel point, PointModel comparePoint) { return point.level == comparePoint.level && point.row == comparePoint.row && point.column == comparePoint.column; }
private static List<FormationModel> buildStacks() { List<FormationModel> allStacks = new List<FormationModel>(); for (var row = 0; row < MAX_LENGTH; row++) { for (var cell = 0; cell < MAX_LENGTH; cell++) { List<PointModel> singleStack = new List<PointModel>(); for (var level = 0; level < MAX_LENGTH; level++) { PointModel stack = new PointModel(level, row, cell); singleStack.Add(stack); } FormationModel singleStackFormationToAdd = new FormationModel("STACK_NATURAL", singleStack); allStacks.Add(singleStackFormationToAdd); } } return allStacks; }
private static List<FormationModel> buildRows(string variation) { List<FormationModel> allRows = new List<FormationModel>(); switch (variation) { case "NATURAL": for (var level = 0; level < MAX_LENGTH; level++) { for (var row = 0; row < MAX_LENGTH; row++) { List<PointModel> singleRow = new List<PointModel>(); for (var cell = 0; cell < MAX_LENGTH; cell++) { PointModel singleCellInRow = new PointModel(level, row, cell); singleRow.Add(singleCellInRow); } FormationModel formationModelForRow = new FormationModel("ROW_NATURAL", singleRow); allRows.Add(formationModelForRow); } } break; case "ASCENDING": for (var row = 0; row < MAX_LENGTH; row++) { List<PointModel> singleRow = new List<PointModel>(); for (var levelAndCell = 0; levelAndCell < MAX_LENGTH; levelAndCell++) { PointModel singleCellInRow = new PointModel(levelAndCell, row, levelAndCell); singleRow.Add(singleCellInRow); } FormationModel formationModelForRow = new FormationModel("ROW_ASCENDING", singleRow); allRows.Add(formationModelForRow); } break; case "DESCENDING": for (var row = 0; row < MAX_LENGTH; row++) { var decrementor = 3; List<PointModel> singleRow = new List<PointModel>(); for (var cell = 0; cell < MAX_LENGTH; cell++) { PointModel singleCellInRow = new PointModel(decrementor, row, cell); singleRow.Add(singleCellInRow); decrementor--; } FormationModel formationModelForRow = new FormationModel("ROW_DESCENDING", singleRow); allRows.Add(formationModelForRow); } break; default: break; } return allRows; }
// [Route("CalcDistance")] public IHttpActionResult CalcDistance(PointModel point) { int deltaX = point.StartPointX - point.EndPointX; int deltaY = point.StartPointY - point.EndPointY; return this.Ok(Math.Sqrt(deltaX * deltaX + deltaY * deltaY)); }
// verify that a given point is empty, ie its value is -1. public static bool isPointAvailable(PointModel point) { return findPlayerAtPoint(point) == INVALID_PLAYER; }
// is the move to be made valid public static bool isValidMove(PointModel point) { if (point.isPointOnBottomLevel()) { return isPointAvailable(point); } int level = point.findLevelBelowPoint(); PointModel comparePoint = new PointModel(level, point.row, point.column); return isPointAvailable(point) && (findPlayerAtPoint(comparePoint) != INVALID_PLAYER); }
// give a point return the player located at that point. // in the case where there isn't a player at that point, -1 will be returned. public static int findPlayerAtPoint(PointModel point) { int level = point.level; int row = point.row; int column = point.column; int playerAtPoint = gameBoard[level][row][column]; return playerAtPoint; }
// add a point to this instance // // originally split from the postname, gameBoardPosition is passed in as a string '0-0-0' // this string is run through a translator and returned as an int[] [0, 0, 0] private void addPoint(string gameBoardPosition) { PointModel pointToAdd = new PointModel(translatePostNameToBoardPosition(gameBoardPosition)); this.point = pointToAdd; }
// find all the formations that contain the point public List<FormationModel> filterFormationsForPoint(PointModel point) { List<FormationModel> filteredFormations = formations.Where(formation => formation.isPointWithinFormation(point)).ToList(); return filteredFormations; }