Ejemplo n.º 1
0
        public override UITableViewCell GetCell(UITableView tableView, Foundation.NSIndexPath indexPath)
        {
            var cell = tableView.DequeueReusableCell("LeagueChooserCell", indexPath);

            cell.TextLabel.Text = Leagues[indexPath.Row].Name;

            var switchView = new UISwitch();

            switchView.SetState(Leagues[indexPath.Row].Value, true);
            switchView.Tag = indexPath.Row;

            switchView.ValueChanged += SwitchValueChanged;

            cell.AccessoryView = switchView;

            return(cell);
        }
        partial void DHTAction(UISwitch sender)
        {
            var controller = UIAlertController.Create("DHT state changing", "Changes will take effect only after application reboot.", UIAlertControllerStyle.Alert);
            var reboot     = UIAlertAction.Create("Reboot", UIAlertActionStyle.Destructive, delegate {
                NSUserDefaults.StandardUserDefaults.SetBool(sender.On, UserDefaultsKeys.DHTEnabled);
                Manager.Singletone.SaveState();
                Thread.CurrentThread.Abort();
            });
            var later = UIAlertAction.Create("Not now", UIAlertActionStyle.Cancel, delegate {
                sender.SetState(!sender.On, true);
            });

            controller.AddAction(reboot);
            controller.AddAction(later);

            PresentViewController(controller, true, null);
        }
Ejemplo n.º 3
0
        void CreateUISwitch()
        {
            _switch = new UISwitch {
                Frame = new RectangleF(new PointF(10, 10), SizeF.Empty)
            };
            _switch.SetState(true, false);
            _switch.ValueChanged += delegate {
                _text           = _switch.On.ToString();
                _testLabel.Text = _text;
            };

            View.AddSubview(_switch);

            _testLabel = new UILabel {
                Frame = new RectangleF(10, 200, 100, 50)
            };
            View.AddSubview(_testLabel);
        }
Ejemplo n.º 4
0
 public static Action <bool> BindIsOn(this UISwitch @switch)
 => isOn => @switch.SetState(isOn, true);
Ejemplo n.º 5
0
 public static void UpdateIsToggled(this UISwitch uiSwitch, ISwitch view)
 {
     uiSwitch.SetState(view.IsToggled, true);
 }
            public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
            {
                UITableViewCell cell = tableView.DequeueReusableCell("PopoverSettingIdentifier");

                try
                {
                    if (cell == null)
                    {
                        cell = new UITableViewCell(UITableViewCellStyle.Default, "PopoverSettingIdentifier");
                    }

                    cell.Accessory      = UITableViewCellAccessory.None;
                    cell.SelectionStyle = UITableViewCellSelectionStyle.Default;

                    if (indexPath.Section == 0 && indexPath.Row == 1)
                    {
                        cell.SelectionStyle = UITableViewCellSelectionStyle.None;

                        cell.TextLabel.Text  = "Content Sync";
                        cell.ImageView.Image = UIImage.FromBundle("Assets/Icons/sync.png");

                        if (syncSwitch == null)
                        {
                            syncSwitch               = new UISwitch();
                            syncSwitch.Frame         = new CGRect(tableView.Frame.Size.Width - 20 - syncSwitch.Frame.Width, 22f - (syncSwitch.Frame.Height / 2f), syncSwitch.Frame.Width, syncSwitch.Frame.Height);
                            syncSwitch.ValueChanged += (object sender, EventArgs e) =>
                            {
                                Settings.WriteSyncOn(syncSwitch.On);

                                if (Settings.SyncOn)
                                {
                                    if (parent.SyncOnEvent != null)
                                    {
                                        parent.SyncOnEvent();
                                    }
                                }
                                else
                                {
                                    if (parent.SyncOffEvent != null)
                                    {
                                        parent.SyncOffEvent();
                                    }
                                }
                            };

                            // Disable syncing for Demo server
                            syncSwitch.SetState(Settings.SyncOn, false);

                            if (Reachability.IsDefaultNetworkAvailable() && !URL.ServerURL.Contains(StringRef.DemoURL))
                            {
                                syncSwitch.Enabled = true;
                            }
                            else
                            {
                                syncSwitch.Enabled = false;
                            }
                        }
                        cell.ContentView.AddSubview(syncSwitch);
                    }
                    else
                    {
                        if (indexPath.Section == 0)
                        {
                            cell.TextLabel.Text  = "Library Setting";
                            cell.ImageView.Image = UIImage.FromBundle("Assets/Icons/server.png");
                        }
                        else
                        {
                            if (indexPath.Row == 0)
                            {
                                cell.TextLabel.Text  = "About eBriefing";
                                cell.ImageView.Image = UIImage.FromBundle("Assets/Icons/about.png");
                            }
                            else if (indexPath.Row == 1)
                            {
                                cell.TextLabel.Text  = "Tutorial";
                                cell.ImageView.Image = UIImage.FromBundle("Assets/Icons/tutorial.png");
                            }
//                            else if (indexPath.Row == 2)
//                            {
//                                cell.TextLabel.Text = "Privacy Policy";
//                                cell.ImageView.Image = UIImage.FromBundle("Assets/Icons/privacy.png");
//                            }
                            else if (indexPath.Row == 2)
                            {
                                cell.TextLabel.Text  = "Give Feedback";
                                cell.ImageView.Image = UIImage.FromBundle("Assets/Icons/feedback.png");
                            }
                            else
                            {
                                cell.TextLabel.Text  = "Rate This App";
                                cell.ImageView.Image = UIImage.FromBundle("Assets/Icons/rate.png");
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Logger.WriteLineDebugging("PopoverSettingDataSource - GetCell: {0}", ex.ToString());
                }

                return(cell);
            }
Ejemplo n.º 7
0
 public static void UpdateIsOn(this UISwitch uiSwitch, ISwitch view)
 {
     uiSwitch.SetState(view.IsOn, true);
 }
        public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
        {
            UITableViewCell cell = tableView.DequeueReusableCell(cellIdentifier);

            if (cell == null)
            {
                cell = new UITableViewCell(UITableViewCellStyle.Default, cellIdentifier);
            }

            var rightBorder = 35;

            var datePicker = new UIDatePicker();

            datePicker.Mode     = UIDatePickerMode.Time;
            datePicker.TimeZone = NSTimeZone.LocalTimeZone;
            datePicker.UserInteractionEnabled = true;

            var textField = new CustomTextField();

            textField.Text        = settingsValues[indexPath.Row];
            textField.TextColor   = UIColor.Gray;
            textField.ContentMode = UIViewContentMode.Right;

            cell.TextLabel.Text = tableItems[indexPath.Row];
            //cell.TextLabel.Lines = 2;

            if (indexPath.Row == 0)
            {
                cell.TextLabel.Font          = UIFont.SystemFontOfSize(28, UIFontWeight.Bold);
                cell.TextLabel.TextColor     = UIColor.FromRGB(198, 123, 112);
                cell.TextLabel.TextAlignment = UITextAlignment.Center;
            }
            else if (indexPath.Row == 1)
            {
                var enableNotifSwitch = new UISwitch();
                int buttonSize        = 30;
                enableNotifSwitch.Frame = new CGRect(tableView.Frame.Width - buttonSize - rightBorder, (tableView.RowHeight - buttonSize) / 2, buttonSize, tableView.RowHeight);
                enableNotifSwitch.SetState(Convert.ToBoolean(settingsValues[indexPath.Row]), true);
                enableNotifSwitch.OnTintColor = UIColor.FromRGB(198, 123, 112);

                enableNotifSwitch.ValueChanged += (sender, e) =>
                {
                    plist.SetBool(((UISwitch)sender).On, "enableNotifications");

                    if (!((UISwitch)sender).On)
                    {
                        UNUserNotificationCenter.Current.RemoveAllPendingNotificationRequests();
                    }
                };

                cell.ContentView.AddSubview(enableNotifSwitch);
            }
            else if (indexPath.Row == 2 || indexPath.Row == 3)
            {
                int textFieldSize = 100;
                textField.Frame = new CGRect(UIScreen.MainScreen.Bounds.Size.Width - textFieldSize + 10, (tableView.RowHeight - textFieldSize * 0.9) / 2, textFieldSize, tableView.RowHeight);

                // Set default value for datePicker
                var dateFromString = DateTime.Parse(settingsValues[indexPath.Row]);
                var specifiedDate  = DateTime.SpecifyKind(dateFromString, DateTimeKind.Local);
                datePicker.SetDate((NSDate)specifiedDate, true);

                textField.AllEditingEvents += delegate {
                    textField.InputView = datePicker;
                };

                datePicker.ValueChanged += (sender, e) =>
                {
                    textField.Text = DateTime.Parse(datePicker.Date.ToString()).ToString("hh:mm tt", System.Globalization.CultureInfo.InvariantCulture);

                    if (indexPath.Row == 2)
                    {
                        plist.SetString(textField.Text, "promptStartTime");
                    }
                    else if (indexPath.Row == 3)
                    {
                        plist.SetString(textField.Text, "promptEndTime");
                    }
                };

                cell.ContentView.AddSubview(textField);
            }
            else if (indexPath.Row == 4)
            {
                int textFieldSize = 50;
                textField.Frame        = new CGRect(UIScreen.MainScreen.Bounds.Size.Width - 30, tableView.RowHeight / 2 - 45, textFieldSize, tableView.RowHeight);
                textField.KeyboardType = UIKeyboardType.NumberPad;
                //textField.ReturnKeyType = UIReturnKeyType.Done;

                textField.EditingChanged += (sender, e) => {
                    if (textField.Text.Length > 2)
                    {
                        textField.Text = textField.Text.Substring(2, 1);
                    }

                    if (textField.Text != "")
                    {
                        if (Convert.ToInt32(textField.Text) > 24)
                        {
                            textField.Text = "24";
                        }
                        else if (Convert.ToInt32(textField.Text) < 1)
                        {
                            textField.Text = "1";
                        }
                    }
                    else
                    {
                        textField.Text = settingsValues[indexPath.Row];
                    }
                };

                textField.EditingDidEnd += delegate {
                    //if (textField.Text == "")
                    //textField.Text = settingsValues[indexPath.Row];
                    plist.SetString(textField.Text, "promptMinInterval");
                    Console.WriteLine(plist.StringForKey("promptMinInterval"));
                };

                //textField.ShouldReturn = ((txtField) =>
                //{
                //    // Dismiss the Keyboard
                //    textField.ResignFirstResponder();

                //    return true;
                //});

                cell.ContentView.AddSubview(textField);
            }

            cell.BackgroundColor = UIColor.Clear;
            cell.SelectionStyle  = UITableViewCellSelectionStyle.None;
            return(cell);
        }
 void CreateUISwitch ()
 {
     _switch = new UISwitch {Frame = new RectangleF (new PointF(10,10), SizeF.Empty)};
     _switch.SetState (true, false);
     _switch.ValueChanged += delegate {
         _text = _switch.On.ToString ();
         _testLabel.Text = _text;
     };
     
     View.AddSubview (_switch);
     
     _testLabel = new UILabel { Frame = new RectangleF (10, 200, 100, 50) };
     View.AddSubview (_testLabel);
 }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            try
            {
                this.Title = "SignUp to RDNation";
                View.Frame = UIScreen.MainScreen.Bounds;
                View.BackgroundColor = UIColor.White;
                View.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;

                UIScrollView scroll = new UIScrollView(new RectangleF(0, 0, View.Bounds.Width, View.Bounds.Height));
                scroll.ContentSize = new SizeF(View.Bounds.Width, 1000);

                swith = new UISwitch(new RectangleF(10, 10, 100, 25));
                swith.SetState(true, false);
                swith.TouchUpInside += swith_TouchUpInside;
                scroll.AddSubview(swith);

                UILabel doYouDerbyLbl = new UILabel(new RectangleF(80, 15, 200, 25));
                doYouDerbyLbl.Text = "Do You Derby?";
                scroll.AddSubview(doYouDerbyLbl);

                UILabel userNameLbl = new UILabel(new RectangleF(10, 50, View.Bounds.Width, 25));
                userNameLbl.Text = "Email:";
                scroll.AddSubview(userNameLbl);

                userNameTxt = new UITextField(new RectangleF(10, 75, View.Bounds.Width - 20, 35));
                userNameTxt.Layer.BorderWidth = 1;
                userNameTxt.Layer.MasksToBounds = true;
                userNameTxt.Layer.CornerRadius = 8;
                userNameTxt.Layer.BorderColor = UIColor.Purple.CGColor;
                userNameTxt.Text = SettingsMobile.Instance.User.UserName;
                scroll.AddSubview(userNameTxt);

                UILabel passwordLbl = new UILabel(new RectangleF(10, 110, View.Bounds.Width, 25));
                passwordLbl.Text = "Password:"******"Derby Name:";
                scroll.AddSubview(derbyNameLbl);

                derbyNameTxt = new UITextField(new RectangleF(10, 195, View.Bounds.Width - 20, 35));
                derbyNameTxt.BorderStyle = UITextBorderStyle.RoundedRect;
                derbyNameTxt.Layer.BorderWidth = 1;
                derbyNameTxt.Layer.MasksToBounds = true;
                derbyNameTxt.Layer.CornerRadius = 8;
                derbyNameTxt.Layer.BorderColor = UIColor.Purple.CGColor;
                //passwordTxt.SecureTextEntry = true;
                scroll.AddSubview(derbyNameTxt);

                firstNameLbl = new UILabel(new RectangleF(10, 230, View.Bounds.Width, 25));
                firstNameLbl.Text = "First Name:";
                scroll.AddSubview(firstNameLbl);

                firstNameTxt = new UITextField(new RectangleF(10, 255, View.Bounds.Width - 20, 35));
                firstNameTxt.BorderStyle = UITextBorderStyle.RoundedRect;
                firstNameTxt.Layer.BorderWidth = 1;
                firstNameTxt.Layer.MasksToBounds = true;
                firstNameTxt.Layer.CornerRadius = 8;
                firstNameTxt.Layer.BorderColor = UIColor.Purple.CGColor;
                scroll.AddSubview(firstNameTxt);

                loginBtn = new UIButton(new RectangleF(View.Bounds.Width / 2 - 50, 320, 100, 35));
                loginBtn.Layer.BorderWidth = 1;
                loginBtn.Layer.MasksToBounds = true;
                loginBtn.Layer.CornerRadius = 8;
                loginBtn.Layer.BorderColor = UIColor.Purple.CGColor;
                loginBtn.SetTitleColor(UIColor.Black, UIControlState.Normal);
                loginBtn.SetTitle("Sign Up", UIControlState.Normal);
                loginBtn.TouchUpInside += loginBtn_TouchUpInside;
                scroll.AddSubview(loginBtn);

                warningTxt = new UILabel(new RectangleF(10, 290, View.Bounds.Width - 20, 35));
                warningTxt.TextColor = UIColor.Red;
                scroll.AddSubview(warningTxt);

                View.AddSubview(scroll);
            }
            catch (Exception exception)
            {
                ErrorHandler.Save(exception, MobileTypeEnum.iPhone);
            }
        }
        private void InitializeControls()
        {
            this.View.BackgroundColor = UIColor.White;
            this.NavigationItem.Title = "Connect to Enterprise Library";

            // scrollView
            scrollView = new UIScrollView();
            scrollView.AutoresizingMask = UIViewAutoresizing.FlexibleDimensions;
            scrollView.Frame            = new CGRect(0, 0, this.View.Frame.Width, this.View.Frame.Height);
            this.View.AddSubview(scrollView);

            // licenseLabel
//			licenseLabel = eBriefingAppearance.GenerateLabel(17);
//			licenseLabel.AutoresizingMask = UIViewAutoresizing.FlexibleLeftMargin;
//			licenseLabel.Text = "NEED ENTERPRISE LICENSE?";
//			licenseLabel.Frame = new CGRect(scrollView.Frame.Right - 280, 50, 240, 21);
//			scrollView.AddSubview(licenseLabel);

            // noticeLabel
            UILabel noticeLabel = eBriefingAppearance.GenerateLabel(21);

            noticeLabel.Frame         = new CGRect(40, 50, 400, 42);
            noticeLabel.Lines         = 2;
            noticeLabel.LineBreakMode = UILineBreakMode.WordWrap;
            noticeLabel.Text          = "*Requires web front end for your SharePoint Environment to continue setup";
            noticeLabel.SizeToFit();
            scrollView.AddSubview(noticeLabel);

            // learnButton
//			learnButton = UIButton.FromType(UIButtonType.Custom);
//			learnButton.AutoresizingMask = UIViewAutoresizing.FlexibleLeftMargin;
//			learnButton.Frame = new CGRect(licenseLabel.Frame.X, licenseLabel.Frame.Bottom + 20, licenseLabel.Frame.Width, 44);
//			learnButton.Font = eBriefingAppearance.ThemeBoldFont(21);
//			learnButton.SetTitle("Learn More", UIControlState.Normal);
//			learnButton.SetTitleColor(eBriefingAppearance.Gray1, UIControlState.Normal);
//			learnButton.SetTitleColor(UIColor.White, UIControlState.Highlighted);
//			learnButton.SetBackgroundImage(UIImage.FromBundle("Assets/Buttons/green_unfilled.png").CreateResizableImage(new UIEdgeInsets(15f, 14f, 15f, 14f)), UIControlState.Normal);
//			learnButton.SetBackgroundImage(UIImage.FromBundle("Assets/Buttons/green_filled.png").CreateResizableImage(new UIEdgeInsets(15f, 14f, 15f, 14f)), UIControlState.Highlighted);
//			learnButton.TouchUpInside += HandleLearnButtonTouchUpInside;
//			scrollView.AddSubview(learnButton);

            // formsLabel
            UILabel formsLabel = eBriefingAppearance.GenerateLabel(21);

            formsLabel.Text  = "Use Forms Authentication";
            formsLabel.Frame = new CGRect(noticeLabel.Frame.X, noticeLabel.Frame.Bottom + 20, this.View.Frame.Width - 80, 21);
            scrollView.AddSubview(formsLabel);

            // formSwitch
            formSwitch               = new UISwitch();
            formSwitch.Frame         = new CGRect(300, formsLabel.Center.Y - (formSwitch.Frame.Height / 2), formSwitch.Frame.Width, formSwitch.Frame.Height);
            formSwitch.ValueChanged += HandleFormSwitchValueChanged;
            formSwitch.SetState(Settings.UseFormsAuth, true);
            scrollView.AddSubview(formSwitch);

            // urlLabel
            UILabel urlLabel = eBriefingAppearance.GenerateLabel(21);

            urlLabel.Text  = "Library URL";
            urlLabel.Frame = new CGRect(noticeLabel.Frame.X, formSwitch.Frame.Bottom + 40, 130, 21);
            scrollView.AddSubview(urlLabel);

            // urlField
            urlField = GenerateTextField("  Type library URL here", new CGPoint(178, formSwitch.Frame.Bottom + 30), 0);

            // idLabel
            UILabel idLabel = eBriefingAppearance.GenerateLabel(21);

            idLabel.Text  = "User ID";
            idLabel.Frame = new CGRect(noticeLabel.Frame.X, urlLabel.Frame.Bottom + 40, 130, 21);
            scrollView.AddSubview(idLabel);

            // idField
            idField = GenerateTextField("  Type user ID here", new CGPoint(178, urlLabel.Frame.Bottom + 30), 1);

            // passwordLabel
            passwordLabel       = eBriefingAppearance.GenerateLabel(21);
            passwordLabel.Text  = "Password";
            passwordLabel.Frame = new CGRect(noticeLabel.Frame.X, idLabel.Frame.Bottom + 40, 130, 21);
            scrollView.AddSubview(passwordLabel);

            // passwordField
            passwordField = GenerateTextField("  Type password here", new CGPoint(178, idLabel.Frame.Bottom + 30), 2);
            passwordField.SecureTextEntry = true;

            // domainLabel
            domainLabel       = eBriefingAppearance.GenerateLabel(21);
            domainLabel.Text  = "Domain";
            domainLabel.Frame = new CGRect(noticeLabel.Frame.X, passwordLabel.Frame.Bottom + 40, 130, 21);
            scrollView.AddSubview(domainLabel);

            // domainField
            domainField = GenerateTextField("  Type domain here", new CGPoint(178, passwordLabel.Frame.Bottom + 30), 3);
            domainField.ReturnKeyType = UIReturnKeyType.Go;

            // connectButton
            connectButton       = UIButton.FromType(UIButtonType.Custom);
            connectButton.Frame = new CGRect(scrollView.Frame.Width - 247, domainField.Frame.Bottom + 60, 207, 44);
            connectButton.Font  = eBriefingAppearance.ThemeBoldFont(21);
            connectButton.SetTitle("Connect", UIControlState.Normal);
            connectButton.SetTitleColor(eBriefingAppearance.Gray1, UIControlState.Normal);
            connectButton.SetTitleColor(UIColor.White, UIControlState.Highlighted);
            connectButton.SetTitleColor(UIColor.LightGray, UIControlState.Disabled);
            connectButton.SetBackgroundImage(UIImage.FromBundle("Assets/Buttons/green_unfilled.png").CreateResizableImage(new UIEdgeInsets(15f, 14f, 15f, 14f)), UIControlState.Normal);
            connectButton.SetBackgroundImage(UIImage.FromBundle("Assets/Buttons/gray_unfilled.png").CreateResizableImage(new UIEdgeInsets(0f, 22f, 0f, 22f)), UIControlState.Disabled);
            connectButton.SetBackgroundImage(UIImage.FromBundle("Assets/Buttons/green_filled.png").CreateResizableImage(new UIEdgeInsets(15f, 14f, 15f, 14f)), UIControlState.Highlighted);
            connectButton.TouchUpInside   += HandleConnectButtonTouchUpInside;
            connectButton.Enabled          = false;
            connectButton.AutoresizingMask = UIViewAutoresizing.FlexibleLeftMargin | UIViewAutoresizing.FlexibleBottomMargin;
            scrollView.AddSubview(connectButton);

            // Register tableView Keyboard Notification for auto scroll
            autoScroll = new KeyboardAutoScroll();
            autoScroll.RegisterForKeyboardNotifications(this.View, KeyboardAutoScroll.ScrollType.SCROLLVIEW);
        }
Ejemplo n.º 12
0
 private void UpdateUiSwitch(Component component, UISwitch uiSwitch)
 {
     InvokeOnMainThread(() =>
     {
         if (component.DeviceStatus == uiSwitch.On) return;
         uiSwitch.SetState(component.DeviceStatus, true);
     });
 }