示例#1
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Set Localized Strings
            String title = NSBundle.MainBundle.LocalizedString("Vernacular_P0_tutorial_3_title", null).PrepareForLabel();

            lblTitle.Text = title;

            String body1 = NSBundle.MainBundle.LocalizedString("Vernacular_P0_tutorial_3_question", null).PrepareForLabel();

            lblBody1.Text = body1;

            String motorcycleString = NSBundle.MainBundle.LocalizedString("Vernacular_P0_vehicle_motorcycle", null).PrepareForLabel();
            String carString        = NSBundle.MainBundle.LocalizedString("Vernacular_P0_vehicle_car", null).PrepareForLabel();
            String truckString      = NSBundle.MainBundle.LocalizedString("Vernacular_P0_vehicle_truck", null).PrepareForLabel();

            lblBody2.Text = carString;

            String bottom = NSBundle.MainBundle.LocalizedString("Vernacular_P0_tutorial_bottom_question_notice", null).PrepareForLabel();

            lblBottom.Text = bottom;

            // Set UI String elements
            View.BackgroundColor = StyleSettings.ThemePrimaryDarkLightenedColor();
            lblTitle.TextColor   = StyleSettings.ThemePrimaryColor();
            lblBody1.TextColor   = StyleSettings.TextOnDarkColor();
            lblBody2.TextColor   = StyleSettings.ThemePrimaryColor();
            lblBottom.TextColor  = StyleSettings.SubduedTextOnDarkColor();
            btnCar.SetTitle("", UIControlState.Normal);
            btnMotorcycle.SetTitle("", UIControlState.Normal);
            btnTruck.SetTitle("", UIControlState.Normal);

            // Set button backgrounds
            btnMotorcycle.ClipsToBounds = true;
            btnMotorcycle.ContentMode   = UIViewContentMode.ScaleAspectFit;
            btnMotorcycle.SetBackgroundImage(UIImage.FromBundle("icon_motorcycle"), UIControlState.Normal);
            btnCar.ClipsToBounds = true;
            btnCar.ContentMode   = UIViewContentMode.ScaleAspectFit;
            btnCar.SetBackgroundImage(ChangeImageColor.GetColoredImage("icon_car", StyleSettings.ThemePrimaryColor()), UIControlState.Normal);
            btnTruck.ClipsToBounds = true;
            btnTruck.ContentMode   = UIViewContentMode.ScaleAspectFit;
            btnTruck.SetBackgroundImage(UIImage.FromBundle("icon_bus"), UIControlState.Normal);

            // Button handlers

            // car button
            btnCar.TouchUpInside += delegate {
                btnCar.SetBackgroundImage(ChangeImageColor.GetColoredImage("icon_car", StyleSettings.ThemePrimaryColor()), UIControlState.Normal);
                btnMotorcycle.SetBackgroundImage(UIImage.FromBundle("icon_motorcycle"), UIControlState.Normal);
                btnTruck.SetBackgroundImage(UIImage.FromBundle("icon_bus"), UIControlState.Normal);

                lblBody2.Text = carString;
                selectVehicle(VehicleType.Car);
            };

            // motorcycle button
            btnMotorcycle.TouchUpInside += delegate {
                btnMotorcycle.SetBackgroundImage(ChangeImageColor.GetColoredImage("icon_motorcycle", StyleSettings.ThemePrimaryColor()), UIControlState.Normal);
                btnCar.SetBackgroundImage(UIImage.FromBundle("icon_car"), UIControlState.Normal);
                btnTruck.SetBackgroundImage(UIImage.FromBundle("icon_bus"), UIControlState.Normal);

                lblBody2.Text = motorcycleString;
                selectVehicle(VehicleType.Motorcycle);
            };

            // truck button
            btnTruck.TouchUpInside += delegate {
                btnTruck.SetBackgroundImage(ChangeImageColor.GetColoredImage("icon_bus", StyleSettings.ThemePrimaryColor()), UIControlState.Normal);
                btnMotorcycle.SetBackgroundImage(UIImage.FromBundle("icon_motorcycle"), UIControlState.Normal);
                btnCar.SetBackgroundImage(UIImage.FromBundle("icon_car"), UIControlState.Normal);

                lblBody2.Text = truckString;
                selectVehicle(VehicleType.Truck);
            };
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Set Localized Strings
            String title = NSBundle.MainBundle.LocalizedString("Vernacular_P0_tutorial_4_title", null).PrepareForLabel();

            lblTitle.Text = title;

            String body1 = NSBundle.MainBundle.LocalizedString("Vernacular_P0_tutorial_4_question", null).PrepareForLabel();

            lblBody1.Text = body1;

            String matString   = NSBundle.MainBundle.LocalizedString("Vernacular_P0_anchorage_mat", null).PrepareForLabel();
            String staffString = NSBundle.MainBundle.LocalizedString("Vernacular_P0_anchorage_bracket", null).PrepareForLabel();
            String otherString = NSBundle.MainBundle.LocalizedString("Vernacular_P0_anchorage_pocket", null).PrepareForLabel();

            lblBody2.Text = staffString;

            String bottom = NSBundle.MainBundle.LocalizedString("Vernacular_P0_tutorial_bottom_question_notice", null).PrepareForLabel();

            lblBottom.Text = bottom;

            // Set UI elements
            View.BackgroundColor = StyleSettings.ThemePrimaryDarkLightenedColor();
            lblTitle.TextColor   = StyleSettings.ThemePrimaryColor();
            lblBody1.TextColor   = StyleSettings.TextOnDarkColor();
            lblBody2.TextColor   = StyleSettings.ThemePrimaryColor();
            lblBottom.TextColor  = StyleSettings.SubduedTextOnDarkColor();
            btnMat.SetTitle("", UIControlState.Normal);
            btnStaff.SetTitle("", UIControlState.Normal);
            btnOther.SetTitle("", UIControlState.Normal);

            // Set button backgrounds
            btnStaff.ClipsToBounds = true;
            btnStaff.ContentMode   = UIViewContentMode.ScaleAspectFit;
            btnStaff.SetBackgroundImage(ChangeImageColor.GetColoredImage("icon_bracket", StyleSettings.ThemePrimaryColor()), UIControlState.Normal);
            btnMat.ClipsToBounds = true;
            btnMat.ContentMode   = UIViewContentMode.ScaleAspectFit;
            btnMat.SetBackgroundImage(UIImage.FromBundle("icon_mat"), UIControlState.Normal);
            btnOther.ClipsToBounds = true;
            btnOther.ContentMode   = UIViewContentMode.ScaleAspectFit;
            btnOther.SetBackgroundImage(UIImage.FromBundle("icon_pocket"), UIControlState.Normal);

            // Button handlers

            // car button
            btnMat.TouchUpInside += delegate {
                btnMat.SetBackgroundImage(ChangeImageColor.GetColoredImage("icon_mat", StyleSettings.ThemePrimaryColor()), UIControlState.Normal);
                btnStaff.SetBackgroundImage(UIImage.FromBundle("icon_bracket"), UIControlState.Normal);
                btnOther.SetBackgroundImage(UIImage.FromBundle("icon_pocket"), UIControlState.Normal);

                lblBody2.Text = matString;
                selectAnchorage(AnchorageType.MobileMat);
            };

            // motorcycle button
            btnStaff.TouchUpInside += delegate {
                btnStaff.SetBackgroundImage(ChangeImageColor.GetColoredImage("icon_bracket", StyleSettings.ThemePrimaryColor()), UIControlState.Normal);
                btnMat.SetBackgroundImage(UIImage.FromBundle("icon_mat"), UIControlState.Normal);
                btnOther.SetBackgroundImage(UIImage.FromBundle("icon_pocket"), UIControlState.Normal);

                lblBody2.Text = staffString;
                selectAnchorage(AnchorageType.MobileBracket);
            };

            // truck button
            btnOther.TouchUpInside += delegate {
                btnOther.SetBackgroundImage(ChangeImageColor.GetColoredImage("icon_pocket", StyleSettings.ThemePrimaryColor()), UIControlState.Normal);
                btnStaff.SetBackgroundImage(UIImage.FromBundle("icon_bracket"), UIControlState.Normal);
                btnMat.SetBackgroundImage(UIImage.FromBundle("icon_mat"), UIControlState.Normal);

                lblBody2.Text = otherString;
                selectAnchorage(AnchorageType.Pocket);
            };
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Initialize Recorder
            RVM = new RecordingViewModel();

            // Perform any additional setup after loading the view, typically from a nib.
            // Init audio session
            AudioSession.Initialize(null, NSRunLoop.NSDefaultRunLoopMode);
            AudioSession.AudioRouteChanged += AudioSession_AudioRouteChanged;

            // Init call event handler
            callcenter.CallEventHandler += callState.CallEvent;

            // Set menu button
            UIImageView menuImageView = new UIImageView();

            menuImageView.Bounds = new CGRect(0, 0, 20, 20);
            menuImageView.Image  = UIImage.FromBundle("threelines");

            menuButton = new UIBarButtonItem(
                menuImageView.Image,
                UIBarButtonItemStyle.Plain,
                (s, e) => {
                System.Diagnostics.Debug.WriteLine("menu button tapped");
                if (RVM.IsRecording)
                {
                    SidebarController.ToggleMenu();
                    var okAlertController = UIAlertController.Create("", UiStrings.MainNotificationSuspendUserAction, UIAlertControllerStyle.Alert);
                    //Add Action
                    okAlertController.AddAction(UIAlertAction.Create(NSBundle.MainBundle.GetLocalizedString("Vernacular_P0_dialog_ok"), UIAlertActionStyle.Default, alert => {
                        RVM.StopRecordingCommand.Execute(null);
                    }));

                    PresentViewController(okAlertController, true, null);
                }
                else
                {
                    SidebarController.ToggleMenu();
                }
            }
                );

            // Add button to item array
            barButtonItems [0] = menuButton;
            NavigationItem.LeftBarButtonItem = menuButton;

            // Set bottom view labels
            lblTitle.Text = "";
            lblBody.Text  = "";

            // Set start button style
            btnStart.SetBackgroundImage(UIImage.FromBundle("CarButton"), UIControlState.Normal);
            View.BackgroundColor = StyleSettings.ThemePrimaryDarkLightenedColor();
            btnStart.SetTitle("", UIControlState.Normal);

            // Add square to stop || TODO: change to image
            UIView stopSquare = new UIView(new RectangleF(
                                               (float)(btnStop.Bounds.X + 15),
                                               (float)(btnStop.Bounds.Y + 15),
                                               (float)(btnStop.Bounds.Width - 30),
                                               (float)(btnStop.Bounds.Height - 30))
                                           );

            // Set stop button attributes
            stopButtonTranslation      = btnStopBottomConstraint.Constant;
            stopSquare.BackgroundColor = UIColor.White;
            btnStop.SetBackgroundImage(UIImage.FromBundle("srs-stop-btn"), UIControlState.Normal);
            btnStop.Layer.CornerRadius = btnStop.Bounds.Width / 2;

            lblLeft.Hidden   = true;
            lblCenter.Hidden = true;
            lblRight.Hidden  = true;

            // Set initial status of vehicle type & support
            btnSupport.Hidden        = true;
            btnVehicle.Hidden        = true;
            lblCalibration.Hidden    = true;
            lblCalibration.Text      = NSBundle.MainBundle.LocalizedString("Vernacular_P0_label_setup", null);
            lblCalibration.TextColor = StyleSettings.SubduedTextOnDarkColor();

            // Logic
            btnStart.TouchUpInside += (object sender, EventArgs e) => {
                if (Settings.CalibrationDone)
                {
                    if (RVM.IsRecording)
                    {
                        return;
                    }

                    var passengerNumberPickerVC = Storyboard.InstantiateViewController("PassengerNumberPickerViewController") as PassengerNumberPickerViewController;
                    passengerNumberPickerVC.ModalPresentationStyle = UIModalPresentationStyle.OverCurrentContext;
                    passengerNumberPickerVC.ModalTransitionStyle   = UIModalTransitionStyle.CoverVertical;
                    passengerNumberPickerVC.parentVC = this;
                    NavigationController.PresentViewController(passengerNumberPickerVC, true, null);
                }
                else
                {
                    // TODO: warn user that calibration has to be done
                }
            };

            btnStop.TouchUpInside += (object sender, EventArgs e) => {
                UnbindFromService();
                AnimateStopButton();
                RVM.OnDestroy();
                StopRecording();
                UpdateRecordButtonUi();
                UploadData();
                lblCenter.Hidden = true;
            };

            btnVehicle.TouchUpInside += (object sender, EventArgs e) => {
                OpenSettingsVC();
            };

            btnSupport.TouchUpInside += (object sender, EventArgs e) => {
                OpenSettingsVC();
            };
        }