Exemple #1
0
        public Form1()
        {
            InitializeComponent();
            controller.EventContext        = WindowsFormsSynchronizationContext.Current;
            controller.FrameReady         += newFrameHandler;
            controller.ImageReady         += onImageReady;
            controller.ImageRequestFailed += onImageRequestFailed;
            ytv = new YoutubeVids();
            //set greyscale palette for image Bitmap object
            ColorPalette grayscale = bitmap.Palette;

            for (int i = 0; i < 256; i++)
            {
                grayscale.Entries[i] = Color.FromArgb((int)255, i, i, i);
            }
            bitmap.Palette = grayscale;
            currentObj     = Parser.Start(j);
        }
Exemple #2
0
 public void DisplayHackathon(Hackathon thing)
 {
     textBox5.Text = thing.Hackathon_name;
     textBox6.Text = thing.Hackathon_date;
     textBox7.Text = thing.Hackathon_location;
 }
Exemple #3
0
        void newFrameHandler(object sender, FrameEventArgs eventArgs)
        {
            Frame frame = eventArgs.frame;

            this.displayID.Text        = frame.Id.ToString();
            this.displayTimestamp.Text = frame.Timestamp.ToString();
            this.displayFPS.Text       = frame.CurrentFramesPerSecond.ToString();
            string whichHand = "";

            if (frame.Hands.Count == 1)
            {
                foreach (Hand hand in frame.Hands)
                {
                    if (hand.IsLeft)
                    {
                        whichHand = "left";
                    }
                    else
                    if (hand.IsRight)
                    {
                        whichHand = "right";
                    }
                }
            }
            else
            {
                whichHand = "both hands";
            }
            if (frame.Hands.Count == 0)
            {
                whichHand = "no hands";
            }

            if (prevHand == whichHand)
            {
                timer++;
            }
            else
            {
                timer = 0;
            }
            if (timer == 40)
            {
                this.displayHandCount.Text = whichHand;
                if (whichHand == "right" && actionMade == false)
                {
                    //Process.Start("chrome", @ytv.getRandomUrl());
                    j         += 2;
                    actionMade = true;
                }
                if (whichHand == "left" && actionMade == false)
                {
                    char[]   delimiterChars = { '"' };
                    char[]   delim2         = { ',' };
                    string[] locs           = currentObj.Hackathon_location.Split(delim2);
                    // var thingum = api.QueryFlights("London", locs[0]).Result;
                    //string json = JsonConvert.SerializeObject(thingum, Formatting.Indented);
                    //System.IO.File.WriteAllText(@"D:\Visual Studio Repository\skyscanner-test\api_output.txt", json);
                    string text = System.IO.File.ReadAllText(@"D:\Visual Studio Repository\skyscanner-test\api_output.txt");
                    //System.Console.WriteLine("Original text: '{0}'", text);

                    string[] words = text.Split(delimiterChars);
                    // System.Console.WriteLine("{0} words in text:", words.Length);

                    Process.Start("chrome", words[5]);
                    //Process.Start("chrome", @ytv.getRandomUrl());
                    actionMade = true;
                }

                timer = 0;
            }
            if (whichHand == "no hands")
            {
                actionMade = false;
            }

            prevHand = whichHand;

            controller.RequestImages(frame.Id, Leap.Image.ImageType.DEFAULT, imagedata);
            currentObj = Parser.Start(j);
            DisplayHackathon(currentObj);
        }