I'm currently working with the Raspberry PI 3 with Windows 10 IoT and I'm trying to make the game 'Simon Says' in Visual Studio 2015.
Everything is plugged in as followed:
Fritzing image
I got the LEDs working but I can't really figure out how to detect when a button is being pressed.
Parts of the source code:
Variables
private const int BTNRED = 5;
private const int BTNBLUE = 6;
private const int BTNYELLOW = 13;
private const int BTNGREEN = 19;
private GpioPin _btnRed;
private GpioPin _btnBlue;
private GpioPin _btnYellow;
private GpioPin _btnGreen;
private Random rnd;
private static GpioController _gpioController;
Method to recognize when a button is being pressed.
public static IList<Step> PressedButtons
{
get
{
List<Step> returnVal = new List<Step>();
if (GetMap._btnBlue.Read() == GpioPinValue.High)
{ returnVal.Add(Step.Blue); }
if (GetMap._btnGreen.Read() == GpioPinValue.High)
{ returnVal.Add(Step.Green); }
if (GetMap._btnRed.Read() == GpioPinValue.High)
{ returnVal.Add(Step.Red); }
if (GetMap._btnYellow.Read() == GpioPinValue.High)
{ returnVal.Add(Step.Yellow); }
return returnVal;
}
}
/// <summary>
/// Checks if any of the 4 buttons is pressed.
/// </summary>
/// <returns>Returns false if no button is pressed.</returns>
public static bool isButtonPressed
{
get
{
if (GetMap._btnBlue.Read() == GpioPinValue.Low)
{ return true; }
if (GetMap._btnGreen.Read() == GpioPinValue.Low)
{ return true; }
if (GetMap._btnRed.Read() == GpioPinValue.Low)
{ return true; }
if (GetMap._btnYellow.Read() == GpioPinValue.Low)
{ return true; ; }
return false;
}
}
Assigning the right pins on the GPIO to the corresponding variables
private GPIOMap()
{
rnd = new Random();
_gpioController = GpioController.GetDefault();
if (_gpioController == null) { return; }
_ledRed = _gpioController.OpenPin(LEDRED);
_ledRed.SetDriveMode(GpioPinDriveMode.Output);
_ledYellow = _gpioController.OpenPin(LEDYELLOW);
_ledYellow.SetDriveMode(GpioPinDriveMode.Output);
_ledGreen = _gpioController.OpenPin(LEDGREEN);
_ledGreen.SetDriveMode(GpioPinDriveMode.Output);
_ledBlue = _gpioController.OpenPin(LEDBLUE);
_ledBlue.SetDriveMode(GpioPinDriveMode.Output);
_btnBlue = _gpioController.OpenPin(BTNBLUE);
_btnGreen = _gpioController.OpenPin(BTNGREEN);
_btnRed = _gpioController.OpenPin(BTNRED);
_btnYellow = _gpioController.OpenPin(BTNYELLOW);
}
private static GPIOMap GPIOMapInstance;
public static GPIOMap GetMap
{
get
{
if (GPIOMapInstance == null || _gpioController == null)
{ GPIOMapInstance = new GPIOMap(); }
return GPIOMapInstance;
}
}
Run game, where as you can see it should bring me to state 2 whenever a button is being pressed. However this isn't quite the case as the idle animation keeps on going on.
private void RunGame()
{
while (_isRunning)
{
switch (_state)
{
//Idle state
case (0x01):
//If any button is pressed, start the game.
if (GPIOMap.isButtonPressed)
{
_state = 0x02;
Task.Delay(500).Wait();
GPIOMap.PlayStartAnimation();
Task.Delay(1000).Wait();
break;
}
//If nothing happens, continue playing the idle animation.
GPIOMap.PlayIdleAnimationOnce();
break;
//Playback state
case (0x02):
//Play all the currently existing steps.
for (int i = 0; i <= _gameInstance.TotalSteps; i++)
{ GPIOMap.BlinkLight(_gameInstance.GetNextStep(), 500); }
//Generate and play a new step.
GPIOMap.BlinkLight(_gameInstance.GetNextStep(), 500);
//Switch to the input state.
_state = 0x03;
//Set the start time for the input.
_answerPending = DateTime.UtcNow;
break;
//Input state
case (0x03):
if(_gameInstance.CurrentStep > MAXSTEPS)
{
//Win Game
ResetGame();
break;
}
//If the player waits too long before answering, lose the game.
if ((DateTime.UtcNow - _answerPending) > _timeout)
{
GPIOMap.ConfirmWrongAnswer();
ResetGame();
break;
}
//If there are no more steps to re-trace, go back to playback state.
if (_gameInstance.CurrentStep > _gameInstance.TotalSteps)
{ _gameInstance.ResetSteps(); _state = 0x02; break; }
//If no buttons are pressed, keep polling.
if (!GPIOMap.isButtonPressed) { break; }
IList<Step> pressedButtons = GPIOMap.PressedButtons;
//If anything but one button is pressed, lose the game.
if (pressedButtons.Count != 1)
{
GPIOMap.ConfirmWrongAnswer();
ResetGame();
break;
}
if (_gameInstance.VerifyStep(pressedButtons[0]))
{
GPIOMap.BlinkLight(pressedButtons[0], 500);
}
else//Wrong step, end game
{
GPIOMap.ConfirmWrongAnswer();
ResetGame();
break;
}
break;
}
}
}
How can I get my source code to recognize when a button is being pressed so I can go to the next state which involves getting user input on the buttons.
You can use GPIO ValueChanged to catch the button pressed event like this:
_btnBlue = _gpioController.OpenPin(BTNBLUE);
_btnBlue.ValueChanged += btnValueChanged;
public void btnValueChanged(GpioPin pin, GpioPinValueChangedEventArgs e)
{
if (_btnBlue.Read() == GpioPinValue.Low)
{
isBlueButtonPressed = true;
}
}
Related
I have 4 buttons and each of this button activates an image (Please see the link - Stacking). One script is attached to all the 4 buttons. There are 4 placeholders. I am using an approach of stack to stack images one after another. That is, if the first slot is empty, the image goes there. The button has two functions, to add image and to remove image. If the first slot's image is removed, the second slot's image is placed on 1st slot and third slot's image is placed on 2nd slot.
How do I add push and pop to this scenario?
Edit: I tried with List but I am lost. Could there be a way simpler approach?
public class ActivateStackImages : MonoBehaviour {
public GameObject ImageGameObject_To_Add; //Each instance of this script has unique image
public Vector3[] PositionOfImages; //4 positions
private ActivateStackImages [] activateImages; //Script added to 4 buttons
public bool Slot_1_Filled = false;
public bool Slot_2_Filled = false;
public bool Slot_3_Filled = false;
public bool Slot_4_Filled = false;
public bool isImageAdded = false;
private void Awake () {
activateImages= FindObjectsOfType (typeof (ActivateStackImages )) as ActivateStackImages [];
}
public void ActivateGraph () {
if (this.isImageAdded == false) {
for (int i = 0; i < activateImages.Length; i++) {
if (activateImages[i].Slot_1_Filled == false) {
ImageGameObject_To_Add.SetActive (true);
ImageGameObject_To_Add.GetComponent<RectTransform> ().anchoredPosition = PositionOfImages[0];
activateImages[i].Slot_1_Filled = true;
} else if (activateImages[i].Slot_2_Filled == false) {
ImageGameObject_To_Add.SetActive (true);
ImageGameObject_To_Add.GetComponent<RectTransform> ().anchoredPosition = PositionOfImages[2];
activateImages[i].Slot_2_Filled = true;
} else if (activateImages[i].Slot_3_Filled == false) {
ImageGameObject_To_Add.SetActive (true);
ImageGameObject_To_Add.GetComponent<RectTransform> ().anchoredPosition = PositionOfImages[2];
activateImages[i].Slot_3_Filled = true;
} else if (activateImages[i].Slot_4_Filled == false) {
ImageGameObject_To_Add.SetActive (true);
ImageGameObject_To_Add.GetComponent<RectTransform> ().anchoredPosition = PositionOfImages[3];
activateImages[i].Slot_4_Filled = true;
}
}
this.isImageAdded = true;
} else if (this.isImageAdded == true) {
ImageGameObject_To_Add.SetActive (false);
}
}
}
Stacking
I'm trying to code a Simon Says game and I ran into a problem. I cannot figure out how to make my Randomizer timer (that randomizes which boxes are lit up) to run by waves. I want it to run once, then when it's referred to again - run twice and so on.
This is RandomPlace():
private PictureBox RandomPlace()
{
PictureBox p = new PictureBox();
Random rnd = new Random();
switch (rnd.Next(1, 5))
{
case 1:
p = TopRight;
break;
case 2:
p = TopLeft;
break;
case 3:
p = BottomRight;
break;
case 4:
p = BottomLeft;
break;
}
return p;
} //Gets a random PictureBox
This is RandomImage():
private void RandomImage()
{
TopLeft.Enabled = false;
TopRight.Enabled = false;
BottomLeft.Enabled = false;
BottomRight.Enabled = false;
PictureBox a = RandomPlace();
if (a == TopLeft)
{
TopLeft.Image = Resources.TopLeftLit;
label1.Text = "TopLeft";
Thread.Sleep(500);
TopLeft.Image = Resources.TopLeft;
label2.Text = "TopLeftAFTERSLEEP";
Thread.Sleep(500);
pattern[patternRightNow] = 1;
patternRightNow++;
}
if (a == TopRight)
{
TopRight.Image = Resources.TopRightLit;
label1.Text = "TopRight";
Thread.Sleep(500);
TopRight.Image = Resources.TopRight;
label2.Text = "TopRightAFTERSLEEP"; //FIGURE OUT HOW TO RESET PICTURE
Thread.Sleep(500);
pattern[patternRightNow] = 2;
patternRightNow++;
}
if (a == BottomLeft)
{
this.BottomLeft.Image = Resources.BottomLeftLit;
label1.Text = "BottomLeft";
Thread.Sleep(500);
this.BottomLeft.Image = Resources.BottomLeft;
label2.Text = "BottomLeftAFTERSLEEP";
Thread.Sleep(500);
pattern[patternRightNow] = 3;
patternRightNow++;
}
if (a == BottomRight)
{
this.BottomRight.Image = Resources.BottomRightLit;
label1.Text = "BottomRight";
Thread.Sleep(500);
this.BottomRight.Image = Resources.BottomRight;
label2.Text = "BottomRightAFTERSLEEP";
Thread.Sleep(500);
pattern[patternRightNow] = 4;
patternRightNow++;
}
} //Lits up the random PictureBoxes and sets them back to normal
This is Randomizer_Tick():
rivate void Randomizer_Tick(object sender, EventArgs e)
{
RandomImage();
patternRightNow = 0;
tickCount++;
Randomizer.Stop();
ClickCheck();
} //Use RandomImage() to lit up random PictureBoxes on 5 waves, wave 1 - 1 PictureBox, wave 2 - 2 PictureBoxes and so on.
This is ClickCheck():
private void ClickCheck()
{
TopLeft.Enabled = true;
TopRight.Enabled = true;
BottomLeft.Enabled = true;
BottomRight.Enabled = true;
if (tickCount == clickCount)
{
CheckIfWin();
Randomizer.Start();
}
} //Enables the PictureBoxes to be pressed, after the user input reaches the current wave's amount of PictureBoxes lit up, disable PictureBoxes again and start the randomizer
Instead of using timers, I advise you to look at Tasks. It's much easier to create such statemachines.
Fill a list with colors and play it. Wait until the user pressed enough buttons and check the results.
For example: (haven't tested it, it's just for example/pseudo code)
It might contain some typo's.
private List<int> _sequence = new List<int>();
private List<int> _userInput = new List<int>();
private Random _rnd = new Random(DataTime.UtcNow.Milliseconds);
private bool _running = true;
private bool _inputEnabled = false;
private TaskCompletionSource<object> _userInputReady;
public async void ButtonStart_Click(object sender, EventArgs e)
{
if(_running)
return;
while(_running)
{
// add a color/button
_sequence.Add(_rnd.Next(4));
// play the sequence
for(int color in _sequence)
{
// light-up your image, whatever
Console.WriteLine(color);
// wait here...
await Task.Delay(300);
// turn-off your image, whatever
}
// clear userinput
_userInput.Clear();
_userInputReady = new TaskCompletionSource<object>();
_inputEnabled = true;
// wait for user input.
await _userInputReady.Task;
// compare the user input to the sequence.
for(int i=0;i<_sequence.Count;i++)
{
if(_sequence[i] != _userInput[i])
{
_running = false;
break;
}
}
}
Console.WriteLine("Not correct");
}
// one handler for all buttons. Use the .Tag property to store 0, 1, 2, 3
public void ButtonClick(object sender, EventArgs e)
{
if(!_inputEnabled)
return;
var button = (Button)sender;
// add user input to the queue
_userInput.Add((int)button.Tag);
if(_userInput.Count >= _sequence.Count)
_userInputReady.SetResult(null);
}
I am actually making a game, the issue is that when a card moves (I'm using Timer), it makes me freeze the entire form, sometimes it manages to load, sometimes it freezes the entire game. (+ prevents from clicking a label and clicking a MessageBox)
Issue : (.png)
Here
Code : (timers)
public void moveCardsAdv6_2_Tick(object sender, EventArgs e)
{
if (Partie)
{
Distrib = true;
int y6_2 = 48;
int x6_2 = 13;
pictureBoxd6_2.Top += y6_2;
pictureBoxd6_2.Left += x6_2;
#region Adversaire 6
if (pictureBoxd6_2.Top >= 560 && pictureBoxd6_2.Left >= 110)
{
dist6_1 = true;
SecondDistr = true;
moveCardsAdv6_2.Stop();
pictureBoxd6_2.Location = pictureBoxDeck.Location;
GenCartesAdv();
dist6_1 = false;
SecondDistr = false;
moveCardsAdv7_2.Enabled = true;
moveCardsAdv7_2.Start();
}
#endregion
}
}
Card gen code
#region Adversaire 6
int CarteAleaA6 = CarteAleatoire();
Cartes carteA6 = jeu[CarteAleaA6];
CartesUtilisees.Add(CarteAleaA6);
int CarteAleaA6_2 = CarteAleatoire();
while (CartesUtilisees.Contains(CarteAleaA6_2))
{
CarteAleaA6_2 = CarteAleatoire();
}
CarteAleaA6_2 = 1 * CarteAleaA6_2;
ListeCartes.Add(carteA6);
if (Distrib && dist6_1)
{
if (SecondDistr == false)
{
pictureBoxAdv6_1.ImageLocation = carteA6.Image;
}
else
{
Cartes carteA6_2 = jeu[CarteAleaA6_2];
CartesUtilisees.Add(CarteAleaA6_2);
ListeCartes.Add(carteA6_2);
pictureBoxAdv6_2.ImageLocation = carteA6_2.Image;
}
}
#endregion
As the others suggested, maybe try moving them into asnyc functions and await them.
public async void moveCardsAdv6_2_Tick(object sender, EventArgs e)
{
await moveCardsAdv6_2_TickAsync();
}
private async Task moveCardsAdv6_2_TickAsync()
{
if (Partie)
{
Distrib = true;
int y6_2 = 48;
int x6_2 = 13;
pictureBoxd6_2.Top += y6_2;
pictureBoxd6_2.Left += x6_2;
#region Adversaire 6
if (pictureBoxd6_2.Top >= 560 && pictureBoxd6_2.Left >= 110)
{
dist6_1 = true;
SecondDistr = true;
moveCardsAdv6_2.Stop();
pictureBoxd6_2.Location = pictureBoxDeck.Location;
GenCartesAdv();
dist6_1 = false;
SecondDistr = false;
moveCardsAdv7_2.Enabled = true;
moveCardsAdv7_2.Start();
}
#endregion
}
}
I've been working on a project that reads a person's heart rate from a Polar H7 hrm. I've been successful in connecting the device and getting the heart rate which the program shows as text in the UI. However, there are instances where the program suddenly stops getting input from the device.
I have already checked the connection of the device to my Win 10 laptop and saw that it was stable, there were also no exceptions getting thrown by the program. The text simply stops changing.
Here is the code I've written:
public sealed partial class MainPage : Page
{
private GattDeviceService device;
public MainPage()
{
this.InitializeComponent();
init();
}
async void init()
{
var devices = await DeviceInformation.FindAllAsync(GattDeviceService.GetDeviceSelectorFromUuid(GattServiceUuids.HeartRate));
Status.Text = devices.Count.ToString();
device = await GattDeviceService.FromIdAsync(devices[0].Id);
enableSensor();
}
private async void enableSensor()
{
IReadOnlyList<GattCharacteristic> characteristicList;
characteristicList = device.GetAllCharacteristics();
if (characteristicList != null)
{
GattCharacteristic characteristic = characteristicList[0];
if (characteristic.CharacteristicProperties.HasFlag(GattCharacteristicProperties.Notify))
{
characteristic.ValueChanged += SendNotif;
await characteristic.WriteClientCharacteristicConfigurationDescriptorAsync(GattClientCharacteristicConfigurationDescriptorValue.Notify);
}
}
}
async void SendNotif(GattCharacteristic sender, GattValueChangedEventArgs eventArgs)
{
if (eventArgs.CharacteristicValue.Length != 0) {
byte[] hrData = new byte[eventArgs.CharacteristicValue.Length];
DataReader.FromBuffer(eventArgs.CharacteristicValue).ReadBytes(hrData);
var hrValue = ProcessData(hrData);
await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
{
Status.Text = hrValue.ToString();
});
}
}
private int ProcessData(byte[] data)
{
// Heart Rate profile defined flag values
const byte heartRateValueFormat = 0x01;
byte currentOffset = 0;
byte flags = data[currentOffset];
bool isHeartRateValueSizeLong = ((flags & heartRateValueFormat) != 0);
currentOffset++;
ushort heartRateMeasurementValue;
if (isHeartRateValueSizeLong)
{
heartRateMeasurementValue = (ushort)((data[currentOffset + 1] << 8) + data[currentOffset]);
currentOffset += 2;
}
else
{
heartRateMeasurementValue = data[currentOffset];
}
return heartRateMeasurementValue;
}
}
I have written a Kinect swipe testing program from scratch that read gbd files produced by Visual gesture builder Kinect Swipe Test Project here.
The Main 4 gestures I want to focus in this questions is Left & right Hands up, Left & right hand Swipe up.
In the github link i posted above it works fine integrated together.
However, when i port the code over to my main project, Left hand Hands
Up and Right hand Swipe up gestures both malfunctioned. Both gesture
are unable to be detected.
I cannot post my Main project here so i will be posting the code snippets of how i implemented on the 2 Main project files, Mainly GestureDetector.cs and GestureResultsView.cs
Here are the respective snippet of the i had issue with files.
GestureDetector.cs :
public class GestureDetector : IDisposable
{
//stores an array of paths that leads to the gbd files
private string[] databaseArray = {//Left Hand
#"Database\LeftHandDownToTop.gbd"
//, #"Database\LeftHandHandsUp.gbd"
//, #"Database\LeftHandLeftToRight.gbd"
//, #"Database\LeftHandRightToLeft.gbd"
//Right Hand
, #"Database\RightHandBottomToUp.gbd"
, #"Database\RightHandHandsUp.gbd"
//, #"Database\RightHandLeftToRight.gbd"
//, #"Database\RightHandRightToLeft.gbd"
};
//stores an array of the names of the gesture found inside the gbd file
private string[] databaseGestureNameArray = { //Swipe Up
"SwipeUp_Left",
"SwipeUp_Right",
//Swipe Right
//"SwipeRight_Left",
//"SwipeRight_Right",
//Swipe Left
// "SwipeLeft_Left",
// "SwipeLeft_Right",
//Hands Up
//"HandsUp_Left",
"HandsUp_Right"
};
for (int i = 0; i < databaseArray.Length; i++)
{
// load the 'Seated' gesture from the gesture database
using (VisualGestureBuilderDatabase database = new VisualGestureBuilderDatabase(databaseArray[i]))
{
// we could load all available gestures in the database with a call to vgbFrameSource.AddGestures(database.AvailableGestures),
// but for this program, we only want to track one discrete gesture from the database, so we'll load it by name
foreach (Gesture gesture in database.AvailableGestures)
{
if (gesture.Name.Equals(databaseGestureNameArray[i]))
{
this.vgbFrameSource.AddGesture(gesture);
}
}
}
}
}
/// <summary>
/// Handles gesture detection results arriving from the sensor for the associated body tracking Id
/// </summary>
/// <param name="sender">object sending the event</param>
/// <param name="e">event arguments</param>
private void Reader_GestureFrameArrived(object sender, VisualGestureBuilderFrameArrivedEventArgs e)
{
VisualGestureBuilderFrameReference frameReference = e.FrameReference;
using (VisualGestureBuilderFrame frame = frameReference.AcquireFrame())
{
if (frame != null)
{
// get the discrete gesture results which arrived with the latest frame
IReadOnlyDictionary<Gesture, DiscreteGestureResult> discreteResults = frame.DiscreteGestureResults;
bool foundGesture = false;
if (discreteResults != null)
{
// we only have one gesture in this source object, but you can get multiple gestures
foreach (Gesture gesture in this.vgbFrameSource.Gestures)
{
for (int i = 0; i < databaseGestureNameArray.Length; i++)
{
if (gesture.Name.Equals(databaseGestureNameArray[i]) && gesture.GestureType == GestureType.Discrete)
{
DiscreteGestureResult result = null;
discreteResults.TryGetValue(gesture, out result);
if (result != null && !foundGesture)
{
// update the GestureResultView object with new gesture result values & update the label
foundGesture = this.GestureResultView.UpdateGestureResult(true, result.Detected, result.Confidence, databaseGestureNameArray[i]);
}
}
}
}
}
}
}
}
GestureResultView.cs :
public bool UpdateGestureResult(bool isBodyTrackingIdValid, bool isGestureDetected, float detectionConfidence, string gestureName)
{
this.IsTracked = isBodyTrackingIdValid;
this.Confidence = 0.0f;
bool gestureFound = false;
if (!this.IsTracked)
{
this.ImageSource = this.notTrackedImage;
this.Detected = false;
this.BodyColor = Brushes.Gray;
}
else
{
this.Detected = isGestureDetected;
this.BodyColor = this.trackedColors[this.BodyIndex];
if (this.Detected)
{
this.Confidence = detectionConfidence;
if (this.Confidence > 0.4)
{
this.ImageSource = this.seatedImage;
//https://stackoverflow.com/questions/15425495/change-wpf-mainwindow-label-from-another-class-and-separate-thread
//to change label in other class wpf
//http://the--semicolon.blogspot.co.id/p/change-wpf-window-label-content-from.html
string state = App.Current.Properties["state"].ToString();
switch (gestureName)
{
case "SwipeUp_Right":
SwipeUp(state);
break;
case "SwipeUp_Left":
SwipeUp(state);
break;
case "SwipeDown_Right":
break;
case "SwipeDown_Left":
break;
case "SwipeLeft_Right":
break;
case "SwipeLeft_Left":
break;
case "HandsUp_Right":
if (state.Equals("GoBackHome"))
{
}
else
{
Thread.Sleep(350);
MainWindow.handsUp();
}
break;
case "HandsUp_Left":
if (state.Equals("GoBackHome"))
{
}
else
{
Thread.Sleep(350);
MainWindow.handsUp();
}
break;
}
//"HandsUp_Right"
// , "SwipeRight_Right"
// , "SwipeUp_Right"
// , "SwipeLeft_Right"
// , "HandsUp_Left"
// , "SwipeRight_Left"
gestureFound = true;
}
}
else
{
this.ImageSource = this.notSeatedImage;
}
}
return gestureFound;
}
}
//Routing for gesture start
/// <summary>
/// Take in the current screen, filtered swipe up gesture
/// </summary>
/// <param name="state"></param>
private void SwipeUp(string state)
{
if (state.Equals("Home"))
{
int milliseconds = 350;
Thread.Sleep(milliseconds);
//await Task.Delay(500);
Home.swipeUp();
}
else if (state.Equals("ItemChoice"))
{
int milliseconds = 350;
Thread.Sleep(milliseconds);
//await Task.Delay(500);
ItemChoice.swipeUp();
}
else if (state.Equals("ItemParentChoice"))
{
int milliseconds = 350;
Thread.Sleep(milliseconds);
//await Task.Delay(500);
ItemParentChoice.swipeUp();
}
else if (state.Equals("LoanSummary"))
{
int milliseconds = 350;
Thread.Sleep(milliseconds);
//await Task.Delay(500);
LoanSummary.swipeUp();
}
else if (state.Equals("Timeslot"))
{
int milliseconds = 350;
Thread.Sleep(milliseconds);
//await Task.Delay(500);
Timeslot.swipeUp();
}
else if (state.Equals("ViewLoans"))
{
int milliseconds = 350;
Thread.Sleep(milliseconds);
//await Task.Delay(500);
ViewLoans.swipeUp();
}
else if (state.Equals("WhatToDo"))
{
int milliseconds = 350;
Thread.Sleep(milliseconds);
//await Task.Delay(500);
//WhatToDo.swipeUp();
}
}
/// <summary>
/// Take in the current screen, filtered swipe right gesture
/// </summary>
/// <param name="state"></param>
private void swipeRight(string state)
{
if (state.Equals("Home"))
{
//int milliseconds = 500;
//Thread.Sleep(milliseconds);
//Home.swipeUp();
}
else if (state.Equals("ItemChoice"))
{
int milliseconds = 500;
Thread.Sleep(milliseconds);
ItemChoice.swipeRight();
}
else if (state.Equals("ItemParentChoice"))
{
int milliseconds = 500;
Thread.Sleep(milliseconds);
ItemParentChoice.swipeRight();
}
else if (state.Equals("LoanSummary"))
{
//int milliseconds = 500;
//Thread.Sleep(milliseconds);
//LoanSummary.swipeUp();
}
else if (state.Equals("Timeslot"))
{
int milliseconds = 500;
Thread.Sleep(milliseconds);
Timeslot.swipeRight();
}
else if (state.Equals("ViewLoans"))
{
//int milliseconds = 500;
//Thread.Sleep(milliseconds);
//ViewLoans.swipeUp();
}
else if (state.Equals("WhatToDo"))
{
//int milliseconds = 500;
//Thread.Sleep(milliseconds);
//Home.swipeUp();
}
}
/// <summary>
/// Take in the current screen, filtered swipe right gesture
/// </summary>
/// <param name="state"></param>
private void swipeLeft(string state)
{
if (state.Equals("Home"))
{
//int milliseconds = 500;
//Thread.Sleep(milliseconds);
//Home.swipeUp();
}
else if (state.Equals("ItemChoice"))
{
int milliseconds = 500;
Thread.Sleep(milliseconds);
ItemChoice.swipeLeft();
}
else if (state.Equals("ItemParentChoice"))
{
int milliseconds = 500;
Thread.Sleep(milliseconds);
ItemParentChoice.swipeLeft();
}
else if (state.Equals("LoanSummary"))
{
//int milliseconds = 500;
//Thread.Sleep(milliseconds);
//LoanSummary.swipeUp();
}
else if (state.Equals("Timeslot"))
{
int milliseconds = 500;
Thread.Sleep(milliseconds);
Timeslot.swipeLeft();
}
else if (state.Equals("ViewLoans"))
{
//int milliseconds = 500;
//Thread.Sleep(milliseconds);
//ViewLoans.swipeUp();
}
else if (state.Equals("WhatToDo"))
{
//int milliseconds = 500;
//Thread.Sleep(milliseconds);
//Home.swipeUp();
}
}
//routing for gesture end
}