private void GameAvatarImage_Initialized(object sender, EventArgs e)
        {
            var picture = _game.Picture;

            Border imageBorder = GameAvatarImage.Parent as Border;

            GameAvatarImage.Stretch = Stretch.UniformToFill;

            try
            {
                GameAvatarImage.Source = new BitmapImage(new Uri(ImageUploaded.GetDestinationPath(picture.ImageSource, "../GameConstructor.Core/Images")));;

                if (picture.IsBorderRequired)
                {
                    imageBorder.BorderThickness = new Thickness(defaultBorderThickness);
                }

                else
                {
                    imageBorder.BorderThickness = new Thickness(0);
                }
            }

            catch
            {
                GameAvatarImage.Source = new BitmapImage(new Uri(ImageUploaded.GetDestinationPath(defaultImageSource, "../GameConstructor.Core/Images")));;

                imageBorder.BorderThickness = new Thickness(defaultBorderThickness);
            }
        }
Пример #2
0
        private void GameAvatarImage_Initialized(object sender, EventArgs e)
        {
            Image image = sender as Image;

            Game   game   = image.DataContext as Game;
            Border border = image.Parent as Border;

            image.Stretch = Stretch.UniformToFill;

            try
            {
                image.Source = new BitmapImage(new Uri(ImageUploaded.GetDestinationPath(game.Picture.ImageSource, "../GameConstructor.Core/Images")));;

                if (game.Picture.IsBorderRequired)
                {
                    border.BorderThickness = new Thickness(defaultBorderThickness);
                }

                else
                {
                    border.BorderThickness = new Thickness(0);
                }
            }

            catch
            {
                image.Source = new BitmapImage(new Uri(ImageUploaded.GetDestinationPath(
                                                           "gamepad.png", "../GameConstructor.Core/Images")));
                border.BorderThickness = new Thickness(defaultBorderThickness);
            }
        }
        private void UploadImageButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                ImageUploaded imageUploadingProcess = new ImageUploaded();

                imageUploadingProcess.UploadImageAndSave();

                _picture = imageUploadingProcess.Picture;

                EditAvatarImage.Source = new BitmapImage(new Uri(ImageUploaded.GetDestinationPath(_picture.ImageSource, "../GameConstructor.Core/Images")));

                if (_picture.IsBorderRequired)
                {
                    (EditAvatarImage.Parent as Border).BorderThickness = new Thickness(defaultBorderThickness);
                }

                else
                {
                    (EditAvatarImage.Parent as Border).BorderThickness = new Thickness(0);
                }
            }

            catch { }
        }
        public async Task ServiceBusWaitAndCheckTwentySecondUploadTest()
        {
            const int TIMEOUT           = 20000;
            const int WAITTIME          = 20000;
            const int ACCEPTABLELATENCY = 2000;

            var topic         = Guid.NewGuid().ToString();
            var subscription  = Guid.NewGuid().ToString();
            var messageToSend = new TestMessage {
                Message = $"{subscription}"
            };
            var filter        = "foobar";
            var imageUploaded = new ImageUploaded();

            await EnsureTopicExists(_d.Settings.ServiceBusAccount, topic);

            Ended endedHow = Ended.Unknown;

            try
            {
                var sw = new Stopwatch();
                sw.Start();

                _ = Task.Run(() =>
                {
                    try
                    {
                        Task.Delay(WAITTIME).Wait();
                        imageUploaded.Uploaded();
                        SendMessageAsync(_d.Settings.ServiceBusAccount, topic, messageToSend, subscriptionFilter: filter).Wait();
                    }
                    catch
                    {
                    }
                });

                await using (var waitAndCheck = new ServiceBusWaitAndCheck(_d.Settings.ServiceBusAccount, topic, subscription, filter, () => { return(Task.FromResult(imageUploaded.IsUploaded)); }, TIMEOUT))
                {
                    await waitAndCheck.WaitAsync();

                    endedHow = waitAndCheck.EndedHow;
                }

                sw.Stop();

                Assert.IsTrue(sw.ElapsedMilliseconds > WAITTIME, "Did not wait long enough.");
                Assert.IsTrue(sw.ElapsedMilliseconds > TIMEOUT, "Released before timeout.");
                Assert.IsTrue(sw.ElapsedMilliseconds < (WAITTIME + ACCEPTABLELATENCY), "Did not receive message in time.");
                Assert.IsTrue(endedHow == Ended.Timeout || endedHow == Ended.Success);
            }
            finally
            {
                await DeleteTopic(_d.Settings.ServiceBusAccount, topic);
            }
        }
Пример #5
0
 private void OnImageUploaded(ImageUploaded e) => ImagePath = e.ImagePath;
    // Use this for initialization
    void Awake()
    {
        mc = GameObject.FindGameObjectWithTag("Controller").GetComponent <MainController>();
        keywords.Add("Recognize this", () =>
        {
            // Call the OnReset method on every descendant object.
            Debug.Log("test");
        });

        keywords.Add("Capture Photo", () =>
        {
            Debug.Log("photo");
            mc.TakePhoto();
        });

        keywords.Add("Capture Capture", () =>
        {
            if (FindObjectOfType <ModeManager>().currentMode == ModeManager.ModeManagerMode.Capture)
            {
                FindObjectOfType <ModeManager>().SetMode(ModeManager.ModeManagerMode.Gallery);
            }
        });

        keywords.Add("Take New Photo", () =>
        {
            Debug.Log("Take New Photo said");
            mc.SwitchToCapture();
        });

        keywords.Add("Gallery", () =>
        {
            Debug.Log("To Gallery said");
            mc.SwitchToGallery();
        });

        keywords.Add("Help", () =>
        {
            Debug.Log("Help said");
            mc.SwitchToHelp();
        });

        keywords.Add("Log In", () =>
        {
            Debug.Log("login said");
            mc.SwitchToLogin();
        });

        keywords.Add("crack", () =>
        {
            Debug.Log("crack said");
        });

        keywords.Add("Open in Browser", () =>
        {
            ImageUploaded uploaded = FindObjectOfType <ImageUploaded>();
            if (uploaded != null)
            {
                uploaded.OpenInBrowser();
            }
        });

        keywords.Add("Dismiss", () =>
        {
            ImageUploaded uploaded = FindObjectOfType <ImageUploaded>();
            if (uploaded != null)
            {
                uploaded.Dismiss();
            }
        });

        //Debug.Log("registering buttons");
        foreach (KeywordAssigner assigner in FindObjectsOfType <KeywordAssigner>())
        {
            string word = assigner.GetKeyWord();
            if (word != null && word.Length != 0 && !buttonWords.ContainsKey(word) && !keywords.ContainsKey(word))
            {
                //Debug.LogFormat("Registering button: {0}", assigner.GetKeyWord());

                buttonWords.Add(assigner.GetKeyWord(), assigner.gameObject);
            }
        }
        Debug.Log("done registering buttons");

        string[] keyArray = keywords.Keys.ToArray().Concat(buttonWords.Keys.ToArray()).ToArray();

        Debug.Log(string.Join(",", keyArray));

        // Tell the KeywordRecognizer about our keywords.
        keywordRecognizer = new KeywordRecognizer(keyArray, ConfidenceLevel.Low);
        keywordRecognizer.OnPhraseRecognized += KeywordRecognizer_OnPhraseRecognized;
        keywordRecognizer.Start();

        //buttonRecognizer = new KeywordRecognizer(buttonWords.Keys.ToArray());
        //buttonRecognizer.OnPhraseRecognized += ButtonRecognized;
        //buttonRecognizer.Start();

        Debug.Log("Started speech");
    }