public CreateOrderPresenter(ICreateOrderView view, ICreateOrderModel model)
        {
            _model = model;

            _view = view;

            WireUpEvents();
        }
Beispiel #2
0
        public CapturePage()
        {
            BindingContext = customerModel = ServiceContainer.Resolve <ICreateOrderModel>();
            Title          = "Identify";

            // Activity Indicator
            activityIndicator           = new ActivityIndicator();
            activityIndicator.IsRunning = false;
            activityIndicator.IsVisible = false;

            this.ToolbarItems.Add(
                new ToolbarItem("Pick Photo", null, () => PickPhoto())
            {
                Icon = "folder.png"
            }
                );

            if (Device.RuntimePlatform == Device.UWP || CrossMedia.Current.IsCameraAvailable)
            {
                BackgroundColor = Color.Black;

                // Camera Preview
                cameraPreview                     = new CameraPreview();
                cameraPreview.Filename            = "capture";
                cameraPreview.CameraOption        = Settings.CameraOption;
                cameraPreview.CapturePathCallback = new Action <string>(ProcessCameraPhoto);
                cameraPreview.CameraReady        += (s, e) => StartCamera();

                AbsoluteLayout.SetLayoutBounds(cameraPreview, new Rectangle(1, 1, 1, 1));
                AbsoluteLayout.SetLayoutFlags(cameraPreview, AbsoluteLayoutFlags.All);

                // Capture Button
                var buttonSize    = 60;
                var captureButton = new Button();
                captureButton.Clicked          += CaptureButton_Clicked;
                captureButton.BackgroundColor   = Color.White;
                captureButton.WidthRequest      = buttonSize;
                captureButton.HeightRequest     = buttonSize;
                captureButton.BorderRadius      = buttonSize / 2;
                captureButton.BorderWidth       = 1;
                captureButton.BorderColor       = Color.Black;
                captureButton.HorizontalOptions = LayoutOptions.Center;

                AbsoluteLayout.SetLayoutBounds(captureButton, new Rectangle(.5, .9, buttonSize, buttonSize));
                AbsoluteLayout.SetLayoutFlags(captureButton, AbsoluteLayoutFlags.PositionProportional);

                activityIndicator.Color = Color.White;
                AbsoluteLayout.SetLayoutBounds(activityIndicator, new Rectangle(.5, .5, buttonSize, buttonSize));
                AbsoluteLayout.SetLayoutFlags(activityIndicator, AbsoluteLayoutFlags.PositionProportional);

                var layout = new AbsoluteLayout();
                layout.Children.Add(cameraPreview);
                layout.Children.Add(captureButton);
                layout.Children.Add(activityIndicator);

                Content = layout;

                this.ToolbarItems.Add(
                    new ToolbarItem("Toggle Camera", null, () => ToggleCamera())
                {
                    Icon = "toggle.png"
                }
                    );
            }

            else
            {
                var label = new Label()
                {
                    Text = "Camera Not Available",
                    HorizontalOptions = LayoutOptions.CenterAndExpand
                };

                activityIndicator.Color             = Color.Black;
                activityIndicator.HorizontalOptions = LayoutOptions.CenterAndExpand;

                var centerLayout = new StackLayout();
                centerLayout.HorizontalOptions = LayoutOptions.CenterAndExpand;
                centerLayout.VerticalOptions   = LayoutOptions.CenterAndExpand;
                centerLayout.Children.Add(label);
                centerLayout.Children.Add(activityIndicator);

                Content = centerLayout;
            }
        }
Beispiel #3
0
        public CreateOrderPage()
        {
            BindingContext = createOrderModel = ServiceContainer.Resolve <ICreateOrderModel>();

            var image = new Image();

            image.SetBinding(Image.SourceProperty, new Binding("ImageUri", BindingMode.Default));
            image.Aspect        = Aspect.AspectFit;
            image.WidthRequest  = 200;
            image.HeightRequest = 200;

            entryFirstName = new EntryCell {
                Label = "First Name", Placeholder = ""
            };
            entryFirstName.SetBinding(EntryCell.TextProperty, new Binding("FirstName"));

            var entryLastName = new EntryCell {
                Label = "Last Name", Placeholder = ""
            };

            entryLastName.SetBinding(EntryCell.TextProperty, new Binding("LastName"));

            var entryGender = new EntryCell {
                Label = "Gender", Placeholder = "", IsEnabled = false
            };

            entryGender.SetBinding(EntryCell.TextProperty, new Binding("Gender", BindingMode.Default));

            var entryAge = new EntryCell {
                Label = "Age", Placeholder = "", IsEnabled = false
            };

            entryAge.SetBinding(EntryCell.TextProperty, new Binding("Age", BindingMode.Default, stringFormat: "{0:F1}"));

            var entryEmotion = new EntryCell {
                Label = "Emotion", Placeholder = "", IsEnabled = false
            };

            entryEmotion.SetBinding(EntryCell.TextProperty, new Binding("Emotion", BindingMode.Default));

            entryDescription = new EntryCell {
                Label = "Order", Placeholder = "Customer order"
            };
            entryDescription.SetBinding(EntryCell.TextProperty, new Binding("CurrentOrderDescription", BindingMode.TwoWay));

            entryTotal = new EntryCell {
                Label = "Total", Placeholder = "0", Keyboard = Keyboard.Numeric
            };
            entryTotal.SetBinding(EntryCell.TextProperty, new Binding("Total", BindingMode.TwoWay));

            var entryPreviousDate = new EntryCell {
                Label = "Previous Date", Placeholder = "", IsEnabled = false
            };

            entryPreviousDate.SetBinding(EntryCell.TextProperty, new Binding("PreviousOrderDate", BindingMode.Default, stringFormat: "{0:MMMM dd, yyyy}"));

            var entryPreviousDescription = new EntryCell {
                Label = "Previous Order", Placeholder = "", IsEnabled = false
            };

            entryPreviousDescription.SetBinding(EntryCell.TextProperty, new Binding("PreviousOrderDescription", BindingMode.Default));

            Content = new TableView
            {
                HasUnevenRows = true,
                Root          = new TableRoot {
                    new TableSection("Photo")
                    {
                        new ViewCell()
                        {
                            View = image
                        }
                    },
                    new TableSection("Customer")
                    {
                        entryFirstName,
                        entryLastName,
                        entryGender,
                        entryAge,
                        entryEmotion
                    },
                    new TableSection("Order")
                    {
                        entryDescription,
                        entryTotal
                    },
                    new TableSection("Previous Order")
                    {
                        entryPreviousDate,
                        entryPreviousDescription
                    }
                },
                Intent = TableIntent.Settings
            };

            this.ToolbarItems.Add(
                new ToolbarItem("Submit", null, async() => SubmitOrder())
                );
        }