This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private double _mouseVerticalPosition; | |
public MainPage() | |
{ | |
InitializeComponent(); | |
// take care of add events only one time | |
PointerEntered += MainPage_PointerEntered; | |
animationButton.PointerMoved += UIElement_OnPointerMoved; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private async void UIElement_OnPointerMoved(object sender, PointerRoutedEventArgs e) | |
{ | |
double pointerY = args.EventArgs.GetCurrentPoint(this).Position.Y; | |
double deltaY = pointerY - _mouseVerticalPosition; | |
double newHeigthValue = -animatedPanel.Margin.Bottom - deltaY; | |
// you need to stop the animation (from top to bottom) before the last block | |
if (newHeigthValue < 0) | |
newHeigthValue = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private DateTime _lastCalculation; | |
private async void UIElement_OnPointerMoved(object sender, PointerRoutedEventArgs e) | |
{ | |
// repeat UI refresh only every 15 milliseconds | |
if (DateTime.Now.Subtract(_lastCalculation).TotalMilliseconds > 15) | |
{ | |
// your logic (animation with dispatcher part) | |
// refresh timer |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public MainPage() | |
{ | |
InitializeComponent(); | |
PointerEntered += MainPage_PointerEntered; | |
// Create an Observable about PointerMove firing event each 15 miliseconds | |
var pointerMoved = Observable.FromEventPattern<PointerRoutedEventArgs>(animationButton, "PointerMoved") | |
.Sample(TimeSpan.FromMilliseconds(15)) | |
.ObserveOnDispatcher(CoreDispatcherPriority.High); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const getPullRequestQuery = (repoOwner: string, repoName: string, number: number): string => { | |
return ` | |
query { | |
repository(owner: "${repoOwner}", name: "${repoName}") { | |
pullRequest(number: ${number}) { | |
id, | |
body, | |
comments(first: 100) { | |
edges { | |
node { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class OpenParkingCommand | |
{ | |
public string ParkingName { get; set; } | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void Handle(OpenParkingCommand command) | |
{ | |
var parking = _dbContext.Set<Models.Parking>() | |
.FirstOrDefault(p => p.Name == command.ParkingName); | |
if (parking == null) | |
{ | |
throw new Exception($"Cannot find parking '{command.ParkingName}'."); | |
} | |
if (parking.IsOpened) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class GetParkingInfoQuery | |
{ | |
public string ParkingName { get; set; } | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public ParkingInfo Handle(GetParkingInfoQuery query) | |
{ | |
var parking = _dbContext.Set<Models.Parking>() | |
.Include(p => p.Places) | |
.FirstOrDefault(p => p.Name == query.ParkingName); | |
if (parking == null) | |
{ | |
throw new Exception($"Cannot find parking '{query.ParkingName}'."); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void Push(object command) | |
{ | |
_dbContext.Set<Command>().Add( | |
new Command | |
{ | |
Type = command.GetType().Name, | |
Data = JsonConvert.SerializeObject(command), | |
CreatedAt = DateTime.Now, | |
UserId = _authenticationService.GetUserId() | |
} |