private void Watcher_PositionChanged(object sender, GeoPositionChangedEventArgs <GeoCoordinate> e) { var coord = new GeoCoordinate(e.Position.Location.Latitude, e.Position.Location.Longitude); if (_line.Path.Count > 0) { var previousPoint = _line.Path.Last(); var distance = coord.GetDistanceTo(previousPoint); var millisPerKilometer = (1000.0 / distance) * (System.Environment.TickCount - _previousPositionChangeTick); _kilometres += distance / 1000.0; paceLabel.Text = TimeSpan.FromMilliseconds(millisPerKilometer).ToString(@"mm\:ss"); distanceLabel.Text = string.Format("{0:f2} km", _kilometres); caloriesLabel.Text = string.Format("{0:f0}", _kilometres * 65); PositionHandler handler = new PositionHandler(); var heading = handler.CalculateBearing(new Position(previousPoint), new Position(coord)); Map.SetView(coord, Map.ZoomLevel, heading, MapAnimationKind.Parabolic); ShellTile.ActiveTiles.First().Update(new IconicTileData() { Title = "WP8Runner", WideContent1 = string.Format("{0:f2} km", _kilometres), WideContent2 = string.Format("{0:f0} calories", _kilometres * 65), }); } else { Map.Center = coord; } _line.Path.Add(coord); _previousPositionChangeTick = System.Environment.TickCount; }
private void Watcher_PositionChanged(object sender, GeoPositionChangedEventArgs <GeoCoordinate> e) { var coord = new GeoCoordinate(e.Position.Location.Latitude, e.Position.Location.Longitude); TimeSpan time = TimeSpan.FromTicks(System.Environment.TickCount - _previousPositionChangeTick); double secondsFromTs = time.TotalSeconds; if (_line.Path.Count > 0) { var previousPoint = _line.Path.Last(); var distance = coord.GetDistanceTo(previousPoint); _kilometres += distance / 1000.0; double metersPerSecond = (distance / (secondsFromTs * 1000)); double kilometersPerHours = (metersPerSecond * 3.6); speedTextBlock.Text = string.Format("{0:f2} Km/H", kilometersPerHours.ToString("0.0")); distanceTextBlock.Text = string.Format("{0:f2} km", _kilometres); PositionHandler handler = new PositionHandler(); var heading = handler.CalculateBearing(new Position(previousPoint), new Position(coord)); Map.SetView(coord, Map.ZoomLevel, heading, MapAnimationKind.Parabolic); } else { Map.Center = coord; } _line.Path.Add(coord); _previousPositionChangeTick = System.Environment.TickCount; }
private void Awake() { if (instance == null) { instance = this; } }
/// <summary> /// Update the information stored in the position handler according to the time line /// </summary> protected override void UpdatePositionHandler() { PositionHandler.CleanPositions(); if (TimeLine != null) { List <ModelEvent> events = new List <ModelEvent>(TimeLine.Events); foreach (ModelEvent evt in events) { if (FilterConfiguration.VisibleEvent(evt) || evt is SubStepActivated) { PositionHandler.RegisterEvent(evt); } } } base.UpdatePositionHandler(); // Scroll to the end of the execution int drawWidth = DrawArea.Size.Width; if (VScroll) { drawWidth = drawWidth + SystemInformation.VerticalScrollBarWidth; } int val = drawWidth - Size.Width; val = Math.Max(HorizontalScroll.Minimum, val); val = Math.Min(HorizontalScroll.Maximum, val); HorizontalScroll.Value = Math.Max(0, val); }
private void Watcher_PositionChanged(object sender, GeoPositionChangedEventArgs <GeoCoordinate> e) { var coord = new GeoCoordinate(e.Position.Location.Latitude, e.Position.Location.Longitude); if (_line.Path.Count > 0) { var previousPoint = _line.Path.Last(); var distance = coord.GetDistanceTo(previousPoint); var millisPerKilometer = (1000.0 / distance) * (System.Environment.TickCount - _previousPositionChangeTick); _kilometres += distance / 1000.0; paceLabel.Text = TimeSpan.FromMilliseconds(millisPerKilometer).ToString(@"mm\:ss"); distanceLabel.Text = string.Format("{0:f2} km", _kilometres); caloriesLabel.Text = string.Format("{0:f0}", _kilometres * 65); PositionHandler handler = new PositionHandler(); var heading = handler.CalculateBearing(new Position(previousPoint), new Position(coord)); Map.SetView(coord, Map.ZoomLevel, heading, MapAnimationKind.Parabolic); Map.CartographicMode = MapCartographicMode.Hybrid; } else { Map.Center = coord; } _line.Path.Add(coord); _previousPositionChangeTick = System.Environment.TickCount; //MessageBox.Show("Time : "+System.Environment.TickCount); }
private void Awake() { positionHandler = new PositionHandler(ironBellyTestSetting.maxSearchDistance); activeNeighbors = new List <Neighbor>(); Neighbor.OnNeighborEnabled += Initialized; SetPool(); }
private void button1_Click(object sender, EventArgs e) { TimeAnimator animator = new TimeAnimator(); label1.BackColor = Color.Blue; var size = new SizeHandler(new Size(10, 400), new Size(300, 250), x => label1.Size = x); var color = new ColorHandler(Color.Brown, Color.Blue, x => label1.BackColor = x); var location = new PositionHandler(new Point(0, 200), new Point(1200, 200), x => label1.Location = x); animator.Animate(1000, 100, new AnimateHandlerGroup(new IAnimateHandler[] { color, location, size }), null, AnimateFunctionType.CubicEaseInOut); }
public PositionHandler(float maxSearchLength = 99) { if (Instance != null) { Instance.objectsToUpdateNearestNeighbours = null; } objectsToUpdateNearestNeighbours = new List <FindNearestNeighbour>(); kdTree = new KdTree <FindNearestNeighbour>(); kdTree.SearchLength = maxSearchLength; Instance = this; }
public MainWindowViewModel(Window window, PositionHandler positionHandler) { this.positionHandler = positionHandler; this.window = window; settings = new Settings(); settings.Load(DataLoaded); timerHours = new DispatcherTimer(); timerHours.Tick += new EventHandler(HoursTimer_Tick); timerHours.Interval = TimeSpan.FromSeconds(1.0); timerWindowState = new DispatcherTimer(); timerWindowState.Tick += new EventHandler(WindowStateTimer_Tick); timerWindowState.Interval = TimeSpan.FromMilliseconds(1500.0); }
/// <summary> /// Update the information stored in the position handler according to the test case /// </summary> protected override void UpdatePositionHandler() { Util.DontNotify(() => { PositionHandler.CleanPositions(); if ((TestCase != null) || SubSequence != null) { double currentTime = 0.0; foreach (Step step in Steps) { if (step.SubSteps.Count > 0) { foreach (SubStep subStep in step.SubSteps) { PositionSubStep(currentTime, subStep); currentTime += 1; } } else { StepActivation stepActivated = new StepActivation(step) { Time = currentTime }; PositionHandler.RegisterEvent(stepActivated); currentTime += 1; } } } else if (Translation != null) { double currentTime = 0.0; if (Translation.SubSteps.Count > 0) { foreach (SubStep subStep in Translation.SubSteps) { PositionSubStep(currentTime, subStep); currentTime += 1; } } } }); base.UpdatePositionHandler(); }
/// <summary> /// Positions a substep in the time line /// </summary> /// <param name="currentTime"></param> /// <param name="subStep"></param> /// <returns></returns> private void PositionSubStep(double currentTime, SubStep subStep) { SubStepActivated subStepActivated = new SubStepActivated(subStep, null) { Time = currentTime }; PositionHandler.RegisterEvent(subStepActivated); foreach (Action action in subStep.Actions) { VariableUpdate variableUpdate = new VariableUpdate(action, action, null); PositionHandler.RegisterEvent(variableUpdate); } foreach (Expectation expectation in subStep.Expectations) { Expect expect = new Expect(expectation, null); PositionHandler.RegisterEvent(expect); } }
// Use this for initialization void Start() { //Check if instance already exists if (instance == null) { instance = this; } else if (instance != this) { Destroy(gameObject); } DontDestroyOnLoad(gameObject); //positionHandler = new RandomPositionHandler(); //positionHandler = new CsvFilePositionHandler("positions.csv"); positionHandler = new NetworkPositionHandler(); NetworkServer posServer = new NetworkServer((NetworkPositionHandler)positionHandler); posServer.Start(); SetupObjects(); }
public void SetUp() { positionHandler = new PositionHandler(); prefab = Resources.Load <FindNearestNeighbour>("TestResources/GameObject_FindNearestNeighbour"); areaOfMove = new AreaOfMove(); }
void RegisterAvailabilityListeners() { AbilityHandler.ListenToCasting(UpdateAvailability); PositionHandler.ListenToIsRepositioning(UpdateAvailability); HealthHandler.RegisterListener(UpdateAvailability); }
public void SubEventPosition(PositionHandler dl) { _audioPlayer.PositionEvent += dl; }
private void InitializeHandlers(HeadQuater hq) { if (PositionHandler == null) PositionHandler = new PositionHandler(this, EventAgent, hq.Origin); if (ProductionHandler == null) ProductionHandler = new ProductionHandler(this, EventAgent, PositionHandler); HandlersInitialized = true; }
public void UnsubEventPosition(PositionHandler dl) { _audioPlayer.PositionEvent -= dl; }
private void OnEnable() { PositionHandler.RegisterFindNearestNeighbour(this); }
public void SetPointAsWaypointForFigure(GameFigure setFigure) { //figureOnThisPoint = setFigure; OnPositionClick += setFigure.SetTargetPos; pointForMove = true; }
public void ClearPointSettings() { OnPositionClick = null; pointForMove = true; gameFieldPointArea.positionArea.SetActive(false); }
public void Deregister() { PositionHandler.DeregisterFindNearestNeighbour(this); }
public ProductionHandler(IArtificialIntelligence ai, IEventAgent eventAgent, PositionHandler positionHandler) { _ai = ai; _eventAgent = eventAgent; _positionHandler = positionHandler; }
/// <summary> /// Cleans the event positions /// </summary> public void CleanEventPositions() { HandledEvents = -1; PositionHandler.CleanPositions(); }
public static ILayer CreateRouteLayer(string strRoute, IStyle style = null) { var features = new Features(); var GPSlineString = (LineString)Geometry.GeomFromText(strRoute); //Lines between each waypoint var lineString = new LineString(GPSlineString.Vertices.Select(v => SphericalMercator.FromLonLat(v.Y, v.X))); features.Add(new Feature { Geometry = lineString }); //End of route var FeatureEnd = new Feature { Geometry = lineString.EndPoint }; FeatureEnd.Styles.Add(new SymbolStyle { SymbolScale = 1.5f, MaxVisible = 2.0f, MinVisible = 0.0f, RotateWithMap = true, SymbolType = SymbolType.Ellipse, Fill = new Brush { FillStyle = FillStyle.Cross, Color = Color.Red, Background = Color.Transparent }, Outline = new Pen { Color = Color.Red, Width = 1.5f } }); features.Add(FeatureEnd); //Start of route var FeatureStart = new Feature { Geometry = lineString.StartPoint }; FeatureStart.Styles.Add(new SymbolStyle { SymbolScale = 1.5f, MaxVisible = 2.0f, MinVisible = 0.0f, RotateWithMap = true, SymbolType = SymbolType.Ellipse, Fill = new Brush { FillStyle = FillStyle.Cross, Color = Color.Green, Background = Color.Transparent }, Outline = new Pen { Color = Color.Green, Width = 1.5f } }); features.Add(FeatureStart); //Add arrow halfway between waypoints var bitmapId = GetBitmapIdForEmbeddedResource("hajk.Images.Arrow-up.svg"); for (int i = 0; i < GPSlineString.NumPoints - 1; i++) { //End points for line Position p1 = new Position(GPSlineString.Vertices[i].X, GPSlineString.Vertices[i].Y); Position p2 = new Position(GPSlineString.Vertices[i + 1].X, GPSlineString.Vertices[i + 1].Y); //Center point on line for arrow Point p_center = Utils.Misc.CalculateCenter(lineString.Vertices[i].Y, lineString.Vertices[i].X, lineString.Vertices[i + 1].Y, lineString.Vertices[i + 1].X); //Bearing of arrow var p = new PositionHandler(); var angle = p.CalculateBearing(p1, p2); var FeatureArrow = new Feature { Geometry = p_center }; FeatureArrow.Styles.Add(new SymbolStyle { BitmapId = bitmapId, SymbolScale = 0.5f, MaxVisible = 2.0f, MinVisible = 0.0f, RotateWithMap = true, SymbolRotation = angle, SymbolOffset = new Offset(0, 0), }); features.Add(FeatureArrow); //Waypoins var FeatureWaypoint = new Feature { Geometry = lineString.Vertices[i] }; FeatureWaypoint.Styles.Add(new SymbolStyle { SymbolScale = 0.7f, MaxVisible = 2.0f, MinVisible = 0.0f, RotateWithMap = true, SymbolRotation = 45, SymbolType = SymbolType.Ellipse, Fill = null, // new Brush { FillStyle = FillStyle.Cross, Color = Color.Red, Background = Color.Transparent}, Outline = new Pen { Color = Color.Blue, Width = 1.5f } }); features.Add(FeatureWaypoint); } return(new MemoryLayer { DataSource = new MemoryProvider(features), Name = "RouteLayer", Style = style }); }