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

            // Keyboard popup
            _observer1 = NSNotificationCenter.DefaultCenter.AddObserver
                             (UIKeyboard.DidShowNotification, KeyBoardUpNotification);

            // Keyboard Down
            _observer2 = NSNotificationCenter.DefaultCenter.AddObserver
                             (UIKeyboard.WillHideNotification, KeyBoardDownNotification);

            if (App.Locator.AddSeekios.IsAdding)
            {
                // Seekios Name Toolbar (next -> go to IMEI)
                var toolbarName = new UIToolbar();
                toolbarName.BarStyle    = UIBarStyle.Default;
                toolbarName.Translucent = true;
                toolbarName.SizeToFit();
                var nextNameButton = new UIBarButtonItem(Application.LocalizedString("Next"), UIBarButtonItemStyle.Done, (s, e) =>
                {
                    SeekiosNameTextField.ResignFirstResponder();
                    SeekiosIMEITextField.BecomeFirstResponder();
                });
                toolbarName.SetItems(new UIBarButtonItem[] { nextNameButton }, true);
                SeekiosNameTextField.InputAccessoryView = toolbarName;

                // Seekios IMEI Toolbar (next -> go to Pin Code)
                var toolbarIMEI = new UIToolbar();
                toolbarIMEI.BarStyle    = UIBarStyle.Default;
                toolbarIMEI.Translucent = true;
                toolbarIMEI.SizeToFit();
                var nextIMEIButton = new UIBarButtonItem(Application.LocalizedString("Next"), UIBarButtonItemStyle.Done, (s, e) =>
                {
                    SeekiosIMEITextField.ResignFirstResponder();
                    SeekiosPinCodeTextField.BecomeFirstResponder();
                });
                toolbarIMEI.SetItems(new UIBarButtonItem[] { nextIMEIButton }, true);
                SeekiosIMEITextField.InputAccessoryView = toolbarIMEI;

                // Seekios Pin Code Toolbar (Done -> save the seekios)
                var toolbarPinCode = new UIToolbar();
                toolbarPinCode.BarStyle    = UIBarStyle.Default;
                toolbarPinCode.Translucent = true;
                toolbarPinCode.SizeToFit();
                var nextPinCodeButton = new UIBarButtonItem(Application.LocalizedString("DoneButton"), UIBarButtonItemStyle.Done, (s, e) =>
                {
                    SeekiosPinCodeTextField.ResignFirstResponder();
                    SaveButton_TouchUpInside(null, null);
                });
                toolbarPinCode.SetItems(new UIBarButtonItem[] { nextPinCodeButton }, true);
                SeekiosPinCodeTextField.InputAccessoryView = toolbarPinCode;
            }

            SeekiosImageView.AddGestureRecognizer(new UITapGestureRecognizer(() => { ModifySeekiosImageButton_TouchDown(null, null); }));
            ModifySeekiosImageButton.TouchDown += ModifySeekiosImageButton_TouchDown;
            DeleteButton.TouchUpInside         += DeleteButton_TouchUpInside;
            BuySeekiosButton.TouchDown         += BuySeekiosButton_TouchDown;
            SaveButton.TouchUpInside           += SaveButton_TouchUpInside;
            NeedUpdateButton.TouchDown         += NeedUpdateButton_TouchDown;
        }
        void ReleaseDesignerOutlets()
        {
            if (BuySeekiosButton != null)
            {
                BuySeekiosButton.Dispose();
                BuySeekiosButton = null;
            }

            if (DeleteButton != null)
            {
                DeleteButton.Dispose();
                DeleteButton = null;
            }

            if (IMEILabel != null)
            {
                IMEILabel.Dispose();
                IMEILabel = null;
            }

            if (MaxSizeSeekiosIMEILabel != null)
            {
                MaxSizeSeekiosIMEILabel.Dispose();
                MaxSizeSeekiosIMEILabel = null;
            }

            if (MaxSizeSeekiosNameLabel != null)
            {
                MaxSizeSeekiosNameLabel.Dispose();
                MaxSizeSeekiosNameLabel = null;
            }

            if (MaxSizeSeekiosPinCodeLabel != null)
            {
                MaxSizeSeekiosPinCodeLabel.Dispose();
                MaxSizeSeekiosPinCodeLabel = null;
            }

            if (ModifySeekiosImageButton != null)
            {
                ModifySeekiosImageButton.Dispose();
                ModifySeekiosImageButton = null;
            }

            if (NeedUpdateButton != null)
            {
                NeedUpdateButton.Dispose();
                NeedUpdateButton = null;
            }

            if (NotificationDontMoveLabel != null)
            {
                NotificationDontMoveLabel.Dispose();
                NotificationDontMoveLabel = null;
            }

            if (NotificationDontMoveSwitch != null)
            {
                NotificationDontMoveSwitch.Dispose();
                NotificationDontMoveSwitch = null;
            }

            if (NotificationTrackingLabel != null)
            {
                NotificationTrackingLabel.Dispose();
                NotificationTrackingLabel = null;
            }

            if (NotificationTrackingSwitch != null)
            {
                NotificationTrackingSwitch.Dispose();
                NotificationTrackingSwitch = null;
            }

            if (NotificationZoneLabel != null)
            {
                NotificationZoneLabel.Dispose();
                NotificationZoneLabel = null;
            }

            if (NotificationZoneSwitch != null)
            {
                NotificationZoneSwitch.Dispose();
                NotificationZoneSwitch = null;
            }

            if (PinLabel != null)
            {
                PinLabel.Dispose();
                PinLabel = null;
            }

            if (SaveButton != null)
            {
                SaveButton.Dispose();
                SaveButton = null;
            }

            if (ScrollView != null)
            {
                ScrollView.Dispose();
                ScrollView = null;
            }

            if (SeekiosImageView != null)
            {
                SeekiosImageView.Dispose();
                SeekiosImageView = null;
            }

            if (SeekiosIMEITextField != null)
            {
                SeekiosIMEITextField.Dispose();
                SeekiosIMEITextField = null;
            }

            if (SeekiosNameLabel != null)
            {
                SeekiosNameLabel.Dispose();
                SeekiosNameLabel = null;
            }

            if (SeekiosNameTextField != null)
            {
                SeekiosNameTextField.Dispose();
                SeekiosNameTextField = null;
            }

            if (SeekiosPinCodeTextField != null)
            {
                SeekiosPinCodeTextField.Dispose();
                SeekiosPinCodeTextField = null;
            }
        }
Example #3
0
        public override void SetDataAndStyleToView()
        {
            InitialiseAllStrings();

            if (App.Locator.AddSeekios.IsAdding)
            {
                NavigationItem.Title = Application.LocalizedString("AddSeekiosTitle");
                NotificationTrackingSwitch.Hidden = true;
                NotificationZoneSwitch.Hidden     = true;
                NotificationDontMoveSwitch.Hidden = true;
                NotificationTrackingLabel.Hidden  = true;
                NotificationZoneLabel.Hidden      = true;
                NotificationDontMoveLabel.Hidden  = true;
                DeleteButton.Hidden = true;
            }
            else
            {
                NotificationTrackingSwitch.On = App.Locator.DetailSeekios.SeekiosSelected.SendNotificationOnNewTrackingLocation;
                NotificationZoneSwitch.On     = App.Locator.DetailSeekios.SeekiosSelected.SendNotificationOnNewOutOfZoneLocation;
                NotificationDontMoveSwitch.On = App.Locator.DetailSeekios.SeekiosSelected.SendNotificationOnNewDontMoveLocation;

                NavigationItem.Title = Application.LocalizedString("Parameters");
                try
                {
                    // Sometimes : System.Exception: Could not initialize an instance of the type 'UIKit.UIImage': the native 'initWithData:' method returned nil.
                    // Solution : Clean & Rebuild https://forums.xamarin.com/discussion/25248/how-to-find-the-image-that-is-not-found-on-ios
                    SetSeekiosDataToView();
                }
                catch (Exception) { }
            }

            // Round seekios image
            SeekiosImageView.Layer.CornerRadius = SeekiosImageView.Frame.Size.Width / 2;
            SeekiosImageView.ClipsToBounds      = true;

            // Round corner on the button modify the image of the seekios
            ModifySeekiosImageButton.Layer.CornerRadius = 4;
            ModifySeekiosImageButton.Layer.BorderWidth  = 1;
            ModifySeekiosImageButton.Layer.BorderColor  = UIColor.FromRGBA(98, 218, 115, 255).CGColor;
            ModifySeekiosImageButton.ContentEdgeInsets  = new UIEdgeInsets(5, 10, 5, 10);

            // Round corner on the button save data
            SaveButton.Layer.CornerRadius        = 4;
            SaveButton.Layer.MasksToBounds       = true;
            BuySeekiosButton.Layer.CornerRadius  = 4;
            BuySeekiosButton.Layer.MasksToBounds = true;
            DeleteButton.Layer.CornerRadius      = 4;
            DeleteButton.Layer.MasksToBounds     = true;

            // Set up the max of caractere, only digit and the type of the keyboard sould be numeric
            SeekiosNameTextField.EditingChanged    += SeekiosNameTextField_EditingChanged;
            SeekiosIMEITextField.EditingChanged    += SeekiosIMEITextField_EditingChanged;
            SeekiosPinCodeTextField.EditingChanged += SeekiosPinCodeTextField_EditingChanged;
            SeekiosNameTextField.ShouldReturn      += (textField) =>
            {
                SeekiosNameTextField.ResignFirstResponder();
                if (App.Locator.AddSeekios.IsAdding)
                {
                    SeekiosIMEITextField.BecomeFirstResponder();
                }
                return(true);
            };
            SeekiosIMEITextField.ShouldReturn += (textField) =>
            {
                SeekiosIMEITextField.ResignFirstResponder();
                return(true);
            };
            SeekiosPinCodeTextField.ShouldReturn += (textField) =>
            {
                SeekiosPinCodeTextField.ResignFirstResponder();
                return(true);
            };
            SeekiosPinCodeTextField.ShouldChangeCharacters = (textField, range, replacement) =>
            {
                int number;
                return(replacement.Length == 0 || int.TryParse(replacement, out number));
            };
            SeekiosIMEITextField.ShouldChangeCharacters = (textField, range, replacement) =>
            {
                int number;
                return(replacement.Length == 0 || int.TryParse(replacement, out number));
            };

            if (App.Locator.AddSeekios.IsAdding)
            {
                SeekiosNameTextField.ReturnKeyType    = UIReturnKeyType.Next;
                SeekiosIMEITextField.ReturnKeyType    = UIReturnKeyType.Next;
                SeekiosPinCodeTextField.ReturnKeyType = UIReturnKeyType.Done;
            }
            else
            {
                SeekiosNameTextField.ReturnKeyType = UIReturnKeyType.Done;
            }

            SeekiosIMEITextField.KeyboardType    = UIKeyboardType.DecimalPad;
            SeekiosPinCodeTextField.KeyboardType = UIKeyboardType.DecimalPad;
        }