Beispiel #1
0
        private static void ResolveUserRequestOnMainPage(ConsoleKey key)
        {
            switch (key)
            {
            case ConsoleKey.D1:
                ConstructGazePointStreamPage();
                _currentPage = SamplePage.GazePointMenu;
                break;

            case ConsoleKey.D2:
                ConstructFixationStreamPage();
                _currentPage = SamplePage.FixationMenu;
                break;

            case ConsoleKey.D3:
                ConstructEyePositionStreamPage();
                _currentPage = SamplePage.EyePositionMenu;
                break;

            case ConsoleKey.D4:
                ConstructHeadPoseStreamPage();
                _currentPage = SamplePage.HeadPoseMenu;
                break;
            }
        }
Beispiel #2
0
        private static void ResolveUserRequestOnHeadPosePage(ConsoleKey key)
        {
            switch (key)
            {
            case ConsoleKey.D0:
                ConstructMainMenu();
                _currentPage = SamplePage.Main;
                break;

            case ConsoleKey.D1:
                CreateAndVisualizeHeadPoseStream();
                break;

            case ConsoleKey.D2:
                ToggleHeadPoseStream();
                break;

            default:
                Console.WriteLine();
                _headPoseStream.IsEnabled = false;
                PrintHeadPoseStreamDescription();
                PrintHeadPoseStreamPageActions();
                break;
            }
        }
Beispiel #3
0
        private static void ResolveUserRequestOnFixationPage(ConsoleKey key)
        {
            switch (key)
            {
            case ConsoleKey.D0:
                ConstructMainMenu();
                _currentPage = SamplePage.Main;
                break;

            case ConsoleKey.D1:
                CreateAndVisualizeSensitiveFilteredFixationsStream();
                break;

            case ConsoleKey.D2:
                CreateAndVisualizeSlowFilteredFixationsStream();
                break;

            default:
                ToggleFixationDataStream();
                Console.WriteLine();
                PrintFixationStreamDescription();
                PrintFixationStreamPageActions();
                break;
            }
        }
Beispiel #4
0
        private static void ResolveUserRequestOnGazePointPage(ConsoleKey key)
        {
            switch (key)
            {
            case ConsoleKey.D0:
                ConstructMainMenu();
                _currentPage = SamplePage.Main;
                break;

            case ConsoleKey.D1:
                CreateAndVisualizeLightlyFilteredGazePointStream();
                break;

            case ConsoleKey.D2:
                CreateAndVisualizeUnfilteredGazePointStream();
                break;

            default:
                ToggleGazePointDataStream();
                Console.WriteLine();
                PrintGazePointStreamDescription();
                PrintGazePointStreamPageActions();
                break;
            }
        }
Beispiel #5
0
        private async Task SampleClicked(SamplePage page)
        {
            switch (page)
            {
            case SamplePage.NoKeyboardEntry:
                await Navigation.PushAsync(new NoKeyboardEntry());

                break;

            case SamplePage.CollectionViewSearch:
                await Navigation.PushAsync(new CollectionViewSearch());

                break;

            case SamplePage.WebViewAutoHeight:
                await Navigation.PushAsync(new WebViewAutoHeight());

                break;

            case SamplePage.FadingEdges:
                await Navigation.PushAsync(new FadingEdge());

                break;
            }
        }
Beispiel #6
0
        private void UpdateXamlRender(string text)
        {
            if (XamlCodeEditor == null)
            {
                return;
            }

            // Hide any Previous Errors
            XamlCodeEditor.ClearErrors();

            // Try and Render Xaml to a UIElement
            UIElement element = null;

            try
            {
                element = _xamlRenderer.Render(text);
            }
            catch (Exception ex)
            {
                ShowExceptionNotification(ex);
            }

            if (element != null)
            {
                // Add element to main panel
                if (SamplePage == null)
                {
                    return;
                }

                var root = SamplePage.FindDescendantByName("XamlRoot");

                if (root is Panel)
                {
                    // If we've defined a 'XamlRoot' element to host us as a panel, use that.
                    (root as Panel).Children.Clear();
                    (root as Panel).Children.Add(element);
                }
                else
                {
                    // Otherwise, just replace the entire page's content
                    SamplePage.Content = element;
                }

                // Tell the page we've finished with an update to the XAML contents, after the control has rendered.
                if (element is FrameworkElement fe)
                {
                    fe.Loaded += XamlFrameworkElement_Loaded;
                }
            }
            else if (_xamlRenderer.Errors.Count > 0)
            {
                var error = _xamlRenderer.Errors.First();

                XamlCodeEditor.ReportError(error);
            }
        }
Beispiel #7
0
        public void TestSamplePage()
        {
            // set up
            _ = new Xamarin.Forms.Application();
            var page = new SamplePage();

            // check
            Assert.IsNotNull(page.BindingContext, "binding context must be non-null");
        }
        protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
        {
            IsCamera = SamplePage.IsCamera;

            base.OnActivityResult(requestCode, resultCode, data);

            if (IsCamera == true)
            {
                Intent mediaScanIntent = new Intent(Intent.ActionMediaScannerScanFile);
                Uri    contentUri      = Uri.FromFile(AppClass._file);
                mediaScanIntent.SetData(contentUri);
                SendBroadcast(mediaScanIntent);

                //int height = Resources.DisplayMetrics.HeightPixels;
                int width = Resources.DisplayMetrics.WidthPixels;
                AppClass.bitmap = AppClass._file.Path.LoadAndResizeBitmap(width, width);

                byte[] bitmapData = new byte[0];

                if (AppClass.bitmap != null)
                {
                    using (var stream = new MemoryStream())
                    {
                        AppClass.bitmap.Compress(Bitmap.CompressFormat.Png, 50, stream);
                        bitmapData = stream.ToArray();
                    }

                    AppClass.bitmap = null;
                }

                GC.Collect();

                SamplePage.Cameraimage(bitmapData);
            }
            else
            {
                if (requestCode == 1)
                {
                    if (resultCode == Result.Ok)
                    {
                        if (data.Data != null)
                        {
                            Android.Net.Uri uri = data.Data;

                            int orientation       = getOrientation(uri);
                            BitmapWorkerTask task = new BitmapWorkerTask(this.ContentResolver, uri);
                            task.Execute(orientation);
                        }
                    }
                }
            }
        }
        protected override void OnPostExecute(Bitmap bitmap)
        {
            if (bitmap != null)
            {
                MemoryStream stream = new MemoryStream();
                bitmap.Compress(Bitmap.CompressFormat.Jpeg, 50, stream);
                byte[] bitmapData = stream.ToArray();

                SamplePage.Galleryimage(bitmapData);

                bitmap.Recycle();
                GC.Collect();
            }
        }
Beispiel #10
0
        public static void Main(string[] args)
        {
            InitializeHost();

            _defaultForegroundColor = Console.ForegroundColor;
            ConstructMainMenu();
            _currentPage = SamplePage.Main;

            var userResponce = Console.ReadKey(true);

            while (!ReadyToExit(userResponce))
            {
                switch (_currentPage)
                {
                case SamplePage.Main:
                    ResolveUserRequestOnMainPage(userResponce.Key);
                    break;

                case SamplePage.GazePointMenu:
                    ResolveUserRequestOnGazePointPage(userResponce.Key);
                    break;

                case SamplePage.FixationMenu:
                    ResolveUserRequestOnFixationPage(userResponce.Key);
                    break;

                case SamplePage.EyePositionMenu:
                    ResolveUserRequestOnEyePositionPage(userResponce.Key);
                    break;

                case SamplePage.HeadPoseMenu:
                    ResolveUserRequestOnHeadPosePage(userResponce.Key);
                    break;
                }

                userResponce = Console.ReadKey(true);
            }

            DisableConnectionWithTobiiEngine();
        }
        private void GotAccessToCamera()
        {
            var imagePicker = new UIImagePickerController {
                SourceType = UIImagePickerControllerSourceType.Camera
            };

            var window = UIApplication.SharedApplication.KeyWindow;
            var vc     = window.RootViewController;

            while (vc.PresentedViewController != null)
            {
                vc = vc.PresentedViewController;
            }

            vc.PresentViewController(imagePicker, true, null);

            imagePicker.FinishedPickingMedia += (sender, e) =>
            {
                UIImage image = (UIImage)e.Info.ObjectForKey(new NSString("UIImagePickerControllerOriginalImage"));

                UIImage rotateImage = RotateImage(image, image.Orientation);

                rotateImage = rotateImage.Scale(new CGSize(rotateImage.Size.Width, rotateImage.Size.Height), 0.5f);

                var jpegImage = rotateImage.AsJPEG();

                byte[] myByteArray = new byte[jpegImage.Length];
                System.Runtime.InteropServices.Marshal.Copy(jpegImage.Bytes, myByteArray, 0, Convert.ToInt32(jpegImage.Length));

                SamplePage.Cameraimage(myByteArray);

                Device.BeginInvokeOnMainThread(() =>
                {
                    vc.DismissViewController(true, null);
                });
            };


            imagePicker.Canceled += (sender, e) => vc.DismissViewController(true, null);
        }
Beispiel #12
0
        public void VerifyEmailFormatHasToBeCorrectToPostComment(string invalidEmail)
        {
            HomePage   homePage   = Utility.NavigateToPage <HomePage>();
            SamplePage samplePage = homePage.FooterMenu.ClickOnSamplePageLink();

            samplePage.CommentText = _randomText;
            samplePage.Author      = Author;
            samplePage.Email       = invalidEmail;
            samplePage.Website     = Website;
            samplePage.ClickOnPostComment();
            CommentErrorPage commentErrorPage = Utility.GetThisPage <CommentErrorPage>();

            Assert.IsTrue(commentErrorPage.ErrorMessageIsCorrect());
            samplePage             = commentErrorPage.ClickOnBack();
            samplePage.CommentText = _randomText;
            samplePage.Author      = Author;
            samplePage.Email       = ValidEmail;
            samplePage.Website     = Website;
            samplePage.ClickOnPostComment();
            Assert.IsTrue(samplePage.CommentHasBeenPosted(Author, _randomText));
            Assert.IsTrue(samplePage.UrlContainsComment());
        }
        public static void Main(string[] args)
        {
            InitializeHost();
            _defaultForegroundColor = Console.ForegroundColor;
            ConstructHeadPoseStreamPage();
            _currentPage = SamplePage.HeadPoseMenu;

            var userResponce = Console.ReadKey(true);

            while (!ReadyToExit(userResponce))
            {
                switch (userResponce.Key)
                {
                case ConsoleKey.D1:
                    //Console.WriteLine("Stream");
                    CreateAndVisualizeHeadPoseStream();
                    break;

                case ConsoleKey.D2:
                    //Console.WriteLine("Toggle");
                    ToggleHeadPoseStream();
                    break;

                case ConsoleKey.D3:
                    Console.WriteLine("Calibrate");
                    break;

                default:
                    Console.WriteLine();
                    _headPoseStream.IsEnabled = false;
                    PrintHeadPoseStreamDescription();
                    PrintHeadPoseStreamPageActions();
                    break;
                }
                userResponce = Console.ReadKey(true);
            }
            DisableConnectionWithTobiiEngine();
        }
        public void GalleryMedia()
        {
            var imagePicker = new UIImagePickerController {
                SourceType = UIImagePickerControllerSourceType.PhotoLibrary, MediaTypes = UIImagePickerController.AvailableMediaTypes(UIImagePickerControllerSourceType.PhotoLibrary)
            };

            imagePicker.AllowsEditing = true;

            var window = UIApplication.SharedApplication.KeyWindow;
            var vc     = window.RootViewController;

            while (vc.PresentedViewController != null)
            {
                vc = vc.PresentedViewController;
            }

            vc.PresentViewController(imagePicker, true, null);

            imagePicker.FinishedPickingMedia += (sender, e) =>
            {
                UIImage originalImage = e.Info[UIImagePickerController.EditedImage] as UIImage;
                if (originalImage != null)
                {
                    var    pngImage    = originalImage.AsPNG();
                    byte[] myByteArray = new byte[pngImage.Length];
                    System.Runtime.InteropServices.Marshal.Copy(pngImage.Bytes, myByteArray, 0, Convert.ToInt32(pngImage.Length));

                    SamplePage.Galleryimage(myByteArray);
                }

                Device.BeginInvokeOnMainThread(() =>
                {
                    vc.DismissViewController(true, null);
                });
            };
            imagePicker.Canceled += (sender, e) => vc.DismissViewController(true, null);
        }
        private void UpdateXamlRender(string text)
        {
            if (XamlCodeEditor == null)
            {
                return;
            }

            // Hide any Previous Errors
            XamlCodeEditor.ClearErrors();

            // Try and Render Xaml to a UIElement
            UIElement element = null;

            try
            {
                element = _xamlRenderer.Render(text);
            }
            catch (Exception ex)
            {
                ShowExceptionNotification(ex);
            }

            if (element != null)
            {
                // Add element to main panel or sub-panel
                FrameworkElement root = null;

                if (CurrentSample.HasType)
                {
                    root = SamplePage?.FindDescendant("XamlRoot");

                    if (root is Panel)
                    {
                        // If we've defined a 'XamlRoot' element to host us as a panel, use that.
                        (root as Panel).Children.Clear();
                        (root as Panel).Children.Add(element);
                    }
                    else if (SamplePage != null) // UNO TODO
                    {
                        // if we didn't find a XamlRoot host, then we replace the entire content of
                        // the provided sample page with the XAML.
                        SamplePage.Content = element;
                    }
                }
                else
                {
                    // Otherwise, just replace our entire presenter's content
                    SampleContent.Content = element;
                }

                // Tell the page we've finished with an update to the XAML contents, after the control has rendered.
                if (element is FrameworkElement fe)
                {
                    fe.Loaded += XamlFrameworkElement_Loaded;

                    // UNO TODO
                    Console.WriteLine($"UpdateXamlRenderAsync attach loaded fe.IsLoaded:{fe.IsLoaded}");

                    if (fe.IsLoaded)
                    {
                        XamlFrameworkElement_Loaded(fe, new RoutedEventArgs());
                    }
                }
            }
            else if (_xamlRenderer.Errors.Count > 0)
            {
                var error = _xamlRenderer.Errors.First();

                XamlCodeEditor.ReportError(error);
            }
        }
Beispiel #16
0
        public App()
        {
            InitializeComponent();

            MainPage = new SamplePage();
        }
 public SamplePObject NavigateToSamplePage()
 {
     SamplePage.Click();
     return(DoInitialize.PageElementsIn <SamplePObject>());
 }
Beispiel #18
0
 public SampleSteps(SamplePage page)
 {
     Page = page;
 }
Beispiel #19
0
        public MasterSamplePageWP(MasterSample sampleList)
        {
            contentRootLayout = new Grid
            {
                VerticalOptions = LayoutOptions.FillAndExpand,
                RowDefinitions  =
                {
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    },
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                }
            };

            settingLayout = new StackLayout {
                Orientation = StackOrientation.Horizontal, HorizontalOptions = LayoutOptions.CenterAndExpand, Padding = new Thickness(15)
            };

            if (App.Platform == Platforms.UWP && Device.Idiom == TargetIdiom.Phone)
            {
                settingLayout.Padding       = new Thickness(5, 0, 0, 5);
                settingLayout.HeightRequest = 30;
            }

            button = new Image();
            if (Device.OS == TargetPlatform.Windows && Device.Idiom == TargetIdiom.Phone)
            {
                NavigationPage.SetHasNavigationBar(this, false);
            }
            Title = Device.OS == TargetPlatform.Android ? "  " + sampleList.Title : sampleList.Title;


            listView = new ListView
            {
                ItemsSource  = sampleList.Samples,
                ItemTemplate = new DataTemplate(typeof(SampleListCell)),
                RowHeight    = 45
            };

            if (App.Platform == Platforms.UWP && Device.Idiom == TargetIdiom.Phone)
            {
                listView.RowHeight = 35;
            }

            var contentLayout = new StackLayout {
                Children = { listView }
            };

            if (Device.OS == TargetPlatform.Windows && Device.Idiom == TargetIdiom.Phone)
            {
                contentLayout.Padding = new Thickness(0, 0, 0, 60);
            }
            var master = new ContentPage {
                Title = "Sample List", Content = contentLayout
            };


            samplePage = Activator.CreateInstance(Type.GetType(sampleList.Samples[0].Type)) as SamplePage;


            listView.ItemSelected += (sender, args) =>
            {
                if (listView.SelectedItem == null)
                {
                    return;
                }

                sampleDetails      = args.SelectedItem as SampleDetails;
                App.SelectedSample = sampleDetails.Title;
                var type = Type.GetType(sampleDetails.Type);
                if (type == null)
                {
                    ChangeSample(new EmptyContent().ContentView);
                }
                else
                {
                    samplePage = Activator.CreateInstance(type) as SamplePage;

                    if (samplePage.ToolbarItems.Count > 0)
                    {
                        Image toolbarItem = new Image {
                            StyleId = "Settings"
                        };
                        toolbarItem.Source = App.IsDark ? "Assets/Setting_Light.png" : "Assets/Setting.png";
                        if (!settingLayout.Children.Contains(toolbarItem) && settingLayout.Children.Count <= 1)
                        {
                            settingLayout.Children.Add(toolbarItem);
                        }

                        var tapGesture1 = new TapGestureRecognizer();
                        tapGesture1.Tapped += (sender1, args1) =>
                        {
                            if (toolbarItem.StyleId == "Settings")
                            {
                                samplePage.ShowSettingsView();
                                toolbarItem.StyleId = "Apply";
                                toolbarItem.Source  = App.IsDark ? "Assets/Apply_Light.png" : "Assets/Apply.png";
                                button.IsVisible    = false;
                            }
                            else
                            {
                                samplePage.HideSettingsView();
                                toolbarItem.StyleId = "Settings";
                                toolbarItem.Source  = App.IsDark ? "Assets/Setting_Light.png" : "Assets/Setting.png";
                                if (sampleList.Samples.Count != 1)
                                {
                                    button.IsVisible = true;
                                }
                            }
                        };
                        toolbarItem.GestureRecognizers.Add(tapGesture1);
                    }
                    else
                    {
                        if (settingLayout.Children.Count > 1)
                        {
                            settingLayout.Children.RemoveAt(1);
                        }
                    }
                    ChangeSample(samplePage.Content);
                }
                //listView.SelectedItem = null;
                //   button.IsVisible = true;
            };

            if (sampleList.Samples.Count > 0)
            {
                listView.SelectedItem = sampleList.Samples[0];
            }

            contentRootLayout.Children.Add(samplePage.Content);
            button = new Image()
            {
                StyleId = "Samples List"
            };
            var tapGesture = new TapGestureRecognizer();

            tapGesture.Tapped += (sender1, args1) =>
            {
                OnSampleChanged(samplePage.Content);
            };
            button.GestureRecognizers.Add(tapGesture);
            button.Source = App.IsDark ? "Assets/Controls_Light.png" : "Assets/Controls.png";
            settingLayout.Children.Insert(0, button);

            if (sampleList.Samples.Count == 1)
            {
                button.IsVisible = false;
            }

            contentRootLayout.Children.Add(settingLayout, 0, 1);
            Content = contentRootLayout;
        }
Beispiel #20
0
 public App()
 {
     // The root page of your application
     MainPage = new SamplePage();
 }