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

		Title = "Text View";
		textView = new UITextView (View.Frame){
			TextColor = UIColor.Black,
			Font = UIFont.FromName ("Arial", 18f),
			BackgroundColor = UIColor.White,
			Text = "This code brought to you by ECMA 334, ECMA 335 and the Mono Team at Novell\n\n\nEmbrace the CIL!",
			ReturnKeyType = UIReturnKeyType.Default,
			KeyboardType = UIKeyboardType.Default,
			ScrollEnabled = true,
			AutoresizingMask = UIViewAutoresizing.FlexibleHeight,
		};

		// Provide our own save button to dismiss the keyboard
		textView.Started += delegate {
			var saveItem = new UIBarButtonItem (UIBarButtonSystemItem.Done, delegate {
				textView.ResignFirstResponder ();
				NavigationItem.RightBarButtonItem = null;
				});
			NavigationItem.RightBarButtonItem = saveItem;
		};

		View.AddSubview (textView);
	}
示例#2
0
        // saves the inputs to iCloud keys
        void Save(object sender, EventArgs ea)
        {
            var store = NSUbiquitousKeyValueStore.DefaultStore;

            store.SetString(UIDevice.CurrentDevice.Name, localText.Text);
            store.SetString(sharedKeyName, testText.Text);
            var synchronized = store.Synchronize();

            outputText.Text += String.Format("\n--- Local save ({4}) ---\n{0}: {1}\n{2}: {3}",
                                             UIDevice.CurrentDevice.Name, localText.Text, sharedKeyName, testText.Text, synchronized);

            localText.ResignFirstResponder();
            testText.ResignFirstResponder();
        }
示例#3
0
        /// <summary>
        ///  Copies the value from the UITextView in the EntryElement to the
        //   Value property and raises the Changed event if necessary.
        /// </summary>
        public void FetchValue()
        {
            if (entry == null)
            {
                return;
            }

            var newValue = entry.Text;

            if (newValue == Value)
            {
                return;
            }

            if (AcceptReturns == false)
            {
                // check for return key and resign responder if it is
                if (newValue.IndexOf('\n') >= 0)
                {
                    entry.Text = entry.Text.Replace("\n", "");
                    entry.ResignFirstResponder();
                    return;
                }
            }

            Value = newValue;
        }
示例#4
0
        public NewCommentViewController(Func <string, Task> saveAction)
        {
            ViewModel = new NewCommentViewModel(saveAction);

            Title = "New Comment";
            EdgesForExtendedLayout = UIRectEdge.None;

            var discardButton = new UIBarButtonItem {
                Image = Images.Buttons.Cancel
            };
            var doneButton = new UIBarButtonItem(UIBarButtonSystemItem.Save);

            NavigationItem.RightBarButtonItem = doneButton;
            NavigationItem.LeftBarButtonItem  = discardButton;

            _textView                  = new UITextView();
            _textView.Font             = UIFont.PreferredBody;
            _textView.AutoresizingMask = UIViewAutoresizing.FlexibleHeight | UIViewAutoresizing.FlexibleWidth;

            // Work around an Apple bug in the UITextView that crashes
            if (ObjCRuntime.Runtime.Arch == ObjCRuntime.Arch.SIMULATOR)
            {
                _textView.AutocorrectionType = UITextAutocorrectionType.No;
            }

            OnActivation(d =>
            {
                discardButton
                .GetClickedObservable()
                .SelectUnit()
                .BindCommand(ViewModel.DiscardCommand)
                .AddTo(d);

                this.WhenAnyValue(x => x.ViewModel.DoneCommand.CanExecute)
                .Switch()
                .Subscribe(x => doneButton.Enabled = x)
                .AddTo(d);

                doneButton
                .GetClickedObservable()
                .Do(_ => _textView.ResignFirstResponder())
                .SelectUnit()
                .BindCommand(ViewModel.DoneCommand)
                .AddTo(d);

                _textView
                .GetChangedObservable()
                .Subscribe(x => ViewModel.Text = x)
                .AddTo(d);

                this.WhenAnyValue(x => x.ViewModel.Text)
                .Subscribe(x => _textView.Text = x)
                .AddTo(d);

                this.WhenAnyObservable(x => x.ViewModel.DismissCommand)
                .Select(_ => Unit.Default)
                .Subscribe(_dismissSubject)
                .AddTo(d);
            });
        }
示例#5
0
    public override void ViewDidLoad()
    {
        base.ViewDidLoad();

        Title    = "Text View";
        textView = new UITextView(View.Frame)
        {
            TextColor        = UIColor.Black,
            Font             = UIFont.FromName("Arial", 18f),
            BackgroundColor  = UIColor.White,
            Text             = "This code brought to you by ECMA 334, ECMA 335 and the Mono Team at Novell\n\n\nEmbrace the CIL!",
            ReturnKeyType    = UIReturnKeyType.Default,
            KeyboardType     = UIKeyboardType.Default,
            ScrollEnabled    = true,
            AutoresizingMask = UIViewAutoresizing.FlexibleHeight,
        };

        // Provide our own save button to dismiss the keyboard
        textView.Started += delegate {
            var saveItem = new UIBarButtonItem(UIBarButtonSystemItem.Done, delegate {
                textView.ResignFirstResponder();
                NavigationItem.RightBarButtonItem = null;
            });
            NavigationItem.RightBarButtonItem = saveItem;
        };

        View.AddSubview(textView);
    }
示例#6
0
        public static void UiSetKeyboardEditorWithCloseButton(this UITextField txt, UIKeyboardType keyboardType)
        {
            var toolbar = new UIToolbar
            {
                BarStyle = UIBarStyle.Black,
                Translucent = true,
            };
            txt.KeyboardType = keyboardType;
            toolbar.SizeToFit();

            var text = new UITextView(new CGRect(0, 0, 200, 32))
            {
                ContentInset = UIEdgeInsets.Zero,
                KeyboardType = keyboardType,
                Text = txt.Text,
                UserInteractionEnabled = true
            };
            text.Layer.CornerRadius = 4f;
            text.BecomeFirstResponder();

            var doneButton = new UIBarButtonItem("Done", UIBarButtonItemStyle.Done,
                                 (s, e) =>
                {
                    text.ResignFirstResponder();
                    txt.ResignFirstResponder();
                });

            toolbar.UserInteractionEnabled = true;
            toolbar.SetItems(new UIBarButtonItem[] { doneButton }, true);

            txt.InputAccessoryView = toolbar;
        }
示例#7
0
        /// <summary>
        /// Fades out the control and then removes it from the super view
        /// </summary>
        public void Hide()
        {
            UIView.Animate(
                0.5,                 // duration
                () => { Alpha = 0; },
                () =>
            {
                notesTextView.ResignFirstResponder();
                RemoveFromSuperview();
                cancelNotesButton.TouchUpInside -= CancelNotesButton_TouchUpInside;
                updateNotesButton.TouchUpInside -= UpdateNotesButton_TouchUpInside;

                this.RemoveGestureRecognizer(HideKeyboardGesture);

                //keyboard observers
                // Keyboard popup
                NSNotificationCenter.DefaultCenter.RemoveObserver
                    (UIKeyboard.DidShowNotification);

                //Keyboard Down
                NSNotificationCenter.DefaultCenter.RemoveObserver
                    (UIKeyboard.WillHideNotification);

                updateCallbackAction = null;

                //GC.Collect();
            }
                );
        }
示例#8
0
        public static void UiSetKeyboardEditorWithCloseButton(this UITextField txt, UIKeyboardType keyboardType)
        {
            var toolbar = new UIToolbar
            {
                BarStyle    = UIBarStyle.Black,
                Translucent = true,
            };

            txt.KeyboardType = keyboardType;
            toolbar.SizeToFit();

            var text = new UITextView(new CGRect(0, 0, 200, 32))
            {
                ContentInset           = UIEdgeInsets.Zero,
                KeyboardType           = keyboardType,
                Text                   = txt.Text,
                UserInteractionEnabled = true
            };

            text.Layer.CornerRadius = 4f;
            text.BecomeFirstResponder();

            var doneButton = new UIBarButtonItem("Done", UIBarButtonItemStyle.Done,
                                                 (s, e) =>
            {
                text.ResignFirstResponder();
                txt.ResignFirstResponder();
            });

            toolbar.UserInteractionEnabled = true;
            toolbar.SetItems(new UIBarButtonItem[] { doneButton }, true);

            txt.InputAccessoryView = toolbar;
        }
示例#9
0
        public override UITableViewCell GetCell(UITableView tv)
        {
            var cell = tv.DequeueReusableCell(CellKey);

            if (cell == null)
            {
                cell = new UITableViewCell(UITableViewCellStyle.Default, CellKey);
                cell.SelectionStyle = UITableViewCellSelectionStyle.None;
            }
            else
            {
                RemoveTag(cell, 1);
            }

            if (entry == null)
            {
                SizeF size    = ComputeEntryPosition(tv, cell);
                float yOffset = (GetHeight(this.GetContainerTableView(), IndexPath) - size.Height) / 2;
                float width   = cell.ContentView.Bounds.Width - size.Width - 2;                // remove two pixels to fix up appearance in case this is the only control in section

                entry = CreateTextView(new RectangleF(size.Width, yOffset, width, size.Height));
                if (AcceptReturns == false)
                {
                    entry.ReturnKeyType = UIReturnKeyType.Done;
                }
                else
                {
                    entry.ReturnKeyType = UIReturnKeyType.Default;
                }

                entry.KeyboardType       = UIKeyboardType.Default;
                entry.AutocorrectionType = UITextAutocorrectionType.Default;

                entry.Changed += delegate {
                    FetchValue();
                    if (Changed != null)
                    {
                        Changed(this, new EventArgs());
                    }
                };
                entry.Ended += delegate {
                    FetchValue();
                    if (Changed != null)
                    {
                        Changed(this, new EventArgs());
                    }
                    entry.ResignFirstResponder();
                    this.GetImmediateRootElement().TableView.EndEditing(true);
                };

                entry.Started += delegate {
                    tv.ScrollToRow(IndexPath, UITableViewScrollPosition.Middle, true);
                };
            }

            cell.TextLabel.Text = Caption;
            cell.ContentView.AddSubview(entry);
            return(cell);
        }
		public override bool ShouldChangeText (UITextView textView, NSRange range, string text)
		{
			if (!text.Contains ("\n"))
				return true;

			textView.ResignFirstResponder ();
			return false;
		}
示例#11
0
 private static bool Close(UITextView textView, NSRange range, string value)
 {
     if (value.Equals("\n"))
     {
         textView.ResignFirstResponder();
     }
     return(true);
 }
示例#12
0
 public ViewController()
 {
     // Done button in the top right of the nav bar to dismiss the keyboard.
     NavigationItem.RightBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Done, delegate
     {
         _textView.ResignFirstResponder();
     });
 }
        private void RemoveFocusFromTextFields()
        {
            descriptionTextField.ResignFirstResponder();
            titleTextField.ResignFirstResponder();
            tagField.ResignFirstResponder();

            NavigationItem.RightBarButtonItem = null;
        }
示例#14
0
 bool DescriptionText_ShouldChangeText(UITextView textView, NSRange range, string text)
 {
     if (text.Length == 1 && text == Environment.NewLine)
     {
         textView.ResignFirstResponder();
         return(false);
     }
     return(true);
 }
示例#15
0
 public override bool ShouldChangeText(UITextView textView, NSRange range, string text)
 {
     if (text == "\n")
     {
         textView.ResignFirstResponder();
         return(false);
     }
     return(true);
 }
示例#16
0
		public override void ViewDidLoad ()
		{	
			base.ViewDidLoad ();
			
			#region UI Controls (you could do this in XIB if you want)
			saveButton = UIButton.FromType(UIButtonType.RoundedRect);
			saveButton.Frame = new RectangleF(10,10,145,50);
			saveButton.SetTitle("Save", UIControlState.Normal);
			saveButton.SetTitle("waiting...", UIControlState.Disabled);
			saveButton.Enabled = false;
			
			doneSwitch = new UISwitch();
			doneSwitch.Frame = new RectangleF(180, 25, 145, 50);
			doneSwitch.Enabled = false;
			doneLabel = new UILabel();
			doneLabel.Frame = new RectangleF(200, 10, 145, 15);
			doneLabel.Text = "Done?";

			titleText = new UITextView(new RectangleF(10, 70, 300, 40));
			titleText.BackgroundColor = UIColor.FromRGB(240,240,240);
			titleText.Editable = true;
			titleText.BackgroundColor = UIColor.FromRGB(240,240,240);

			descriptionText = new UITextView(new RectangleF(10, 130, 300, 180));
			descriptionText.BackgroundColor = UIColor.FromRGB(240,240,240);
			descriptionText.Editable = true;
			descriptionText.ScrollEnabled = true;
			descriptionText.AutoresizingMask = UIViewAutoresizing.FlexibleHeight;

			// Add the controls to the view
			this.Add(saveButton);
			this.Add(doneLabel);
			this.Add(doneSwitch);
			this.Add(descriptionText);
			this.Add(titleText);
			#endregion

			saveButton.TouchUpInside += (sender, e) => {

				doc.TheTask.Title = titleText.Text;
				doc.TheTask.Description = descriptionText.Text;
				doc.TheTask.IsDone = doneSwitch.On;

				doc.UpdateChangeCount (UIDocumentChangeKind.Done);	// tell UIDocument it needs saving
				descriptionText.ResignFirstResponder ();			// hide keyboard
				titleText.ResignFirstResponder ();
			};
			
			LoadData ();

			NSNotificationCenter.DefaultCenter.AddObserver (this
				, new Selector("dataReloaded:")
				, new NSString("taskModified"),
				null);

		}
        public override void EditingEnded(UITextView textView)
        {
            if (textView.Text == "")
            {
                textView.Text      = "Add Comment";
                textView.TextColor = UIColor.DarkGray;
            }

            textView.ResignFirstResponder();
        }
		public override void EditingEnded (UITextView textView)
		{
			if (textView.Text == "") 
			{
				textView.Text = "Add Comment";
				textView.TextColor = UIColor.DarkGray;
			}

			textView.ResignFirstResponder ();
		}
示例#19
0
        public override void EditingEnded(UITextView textView)
        {
            if (textView.Text == "") {
                textView.Text = "Content";
                textView.TextColor = UIColor.LightGray;
                textView.Font = FontConstants.SourceSansProBold (13);
            }

            textView.ResignFirstResponder ();
        }
        public override UITableViewCell GetCell(UITableView tv)
        {
            var cell = tv.DequeueReusableCell(ekey);

            if (cell == null)
            {
                cell = new UITableViewCell(UITableViewCellStyle.Default, ekey);
                cell.SelectionStyle = UITableViewCellSelectionStyle.None;
            }
            else
            {
                RemoveTag(cell, 1);
            }


            if (entry == null)
            {
                SizeF size = ComputeEntryPosition(tv, cell);

                /*entry = new UITextField (new RectangleF (size.Width, (cell.ContentView.Bounds.Height-size.Height)/2-1, 320-size.Width, size.Height)){
                 *      Tag = 1,
                 *      Placeholder = placeholder,
                 *      SecureTextEntry = isPassword
                 * };*/
                entry                  = new UITextView(new RectangleF(size.Width, (cell.ContentView.Bounds.Height - size.Height) / 2 - 1, 320 - size.Width, 96));
                entry.Text             = Value ?? "";
                entry.AutoresizingMask = UIViewAutoresizing.FlexibleWidth |
                                         UIViewAutoresizing.FlexibleLeftMargin;

                entry.Ended += delegate {
                    Value = entry.Text;
                };
                entry.ReturnKeyType = UIReturnKeyType.Done;
                entry.Changed      += delegate(object sender, EventArgs e) {
                    int iTextLength = 0;

                    if (entry.Text.Length > 0)
                    {
                        iTextLength = entry.Text.Length - 1;
                    }

                    int i = entry.Text.IndexOf("\n", iTextLength);
                    if (i > -1)
                    {
                        entry.Text = entry.Text.Substring(0, iTextLength);
                        entry.ResignFirstResponder();
                    }
                };
            }


            cell.TextLabel.Text = Caption;
            cell.ContentView.AddSubview(entry);
            return(cell);
        }
示例#21
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            #region UI Controls (you could do this in XIB if you want)
            saveButton       = UIButton.FromType(UIButtonType.RoundedRect);
            saveButton.Frame = new RectangleF(10, 10, 145, 50);
            saveButton.SetTitle("Save", UIControlState.Normal);
            saveButton.SetTitle("waiting...", UIControlState.Disabled);
            saveButton.Enabled = false;

            doneSwitch         = new UISwitch();
            doneSwitch.Frame   = new RectangleF(180, 25, 145, 50);
            doneSwitch.Enabled = false;
            doneLabel          = new UILabel();
            doneLabel.Frame    = new RectangleF(200, 10, 145, 15);
            doneLabel.Text     = "Done?";

            titleText = new UITextView(new RectangleF(10, 70, 300, 40));
            titleText.BackgroundColor = UIColor.FromRGB(240, 240, 240);
            titleText.Editable        = true;
            titleText.BackgroundColor = UIColor.FromRGB(240, 240, 240);

            descriptionText = new UITextView(new RectangleF(10, 130, 300, 180));
            descriptionText.BackgroundColor  = UIColor.FromRGB(240, 240, 240);
            descriptionText.Editable         = true;
            descriptionText.ScrollEnabled    = true;
            descriptionText.AutoresizingMask = UIViewAutoresizing.FlexibleHeight;

            // Add the controls to the view
            this.Add(saveButton);
            this.Add(doneLabel);
            this.Add(doneSwitch);
            this.Add(descriptionText);
            this.Add(titleText);
            #endregion

            saveButton.TouchUpInside += (sender, e) => {
                doc.TheTask.Title       = titleText.Text;
                doc.TheTask.Description = descriptionText.Text;
                doc.TheTask.IsDone      = doneSwitch.On;

                doc.UpdateChangeCount(UIDocumentChangeKind.Done);                       // tell UIDocument it needs saving
                descriptionText.ResignFirstResponder();                                 // hide keyboard
                titleText.ResignFirstResponder();
            };

            LoadData();

            NSNotificationCenter.DefaultCenter.AddObserver(this
                                                           , new Selector("dataReloaded:")
                                                           , new NSString("taskModified"),
                                                           null);
        }
示例#22
0
        protected async void Save(object sender, EventArgs e)
        {
            task.Title       = titleText.Text;
            task.Description = descriptionText.Text;
            task.IsDone      = doneSwitch.On;

            descriptionText.ResignFirstResponder();                                     // hide keyboard
            titleText.ResignFirstResponder();

            NavigationController.PopToRootViewController(true);

            // save to Parse
            try {
                await task.ToParseObject().SaveAsync();

                await screen.ReloadAsync();
            } catch (ParseException pe) {
                Console.WriteLine("Parse Exception:{0}", pe.Message);
            }
        }
示例#23
0
 public override bool ShouldChangeText(UITextView textView, NSRange range, string text)
 {
     if (text.Equals("\n"))
     {
         textView.ResignFirstResponder();
         // Return FALSE so that the final '\n' character doesn't get added
         return(false);
     }
     // For any other character return TRUE so that the text gets added to the view
     return(true);
 }
示例#24
0
        public override void EditingEnded(UITextView textView)
        {
            if (textView.Text == "")
            {
                textView.Text      = "Content";
                textView.TextColor = UIColor.LightGray;
                textView.Font      = FontConstants.SourceSansProBold(13);
            }

            textView.ResignFirstResponder();
        }
        public override bool ShouldChangeText(UITextView textView, NSRange range, string text)
        {
            if (!text.Contains(Environment.NewLine))
            {
                return(true);
            }

            textView.ResignFirstResponder();

            return(false);
        }
示例#26
0
 public override bool ShouldChangeText(UITextView textView, NSRange range, string text)
 {
     if ("\n" == text)
     {
         textView.ResignFirstResponder();
         return(false);
     }
     lastText = new NSString(text);
     return(true);
     //return base.ShouldChangeText(textView, range, text);
 }
 protected virtual bool OnNewLineDismiss_ShouldChangeText(UITextView textView, NSRange range, string text)
 {
     return(this.ExecuteFunction("OnNewLineDismiss_ShouldChangeText", delegate()
     {
         if (text == "\n")
         {
             textView.ResignFirstResponder();
             return false;
         }
         return true;
     }));
 }
 void close(object sender, EventArgs e)
 {
     messageTextView.ResignFirstResponder();
     UIView.Animate(0.3f, delegate {
         View.Alpha = 0f;
         currentMessageSourceWindow.TintAdjustmentMode = UIViewTintAdjustmentMode.Automatic;
     },
                    delegate {
         currentMessageWindow = null;
         currentMessageSourceWindow.MakeKeyAndVisible();
     });
 }
        public void EditingStarted(UITextView textView)
        {
            // Provide a "Done" button for the user to select to signify completion with writing text in the text view.
            var doneBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Done, (sender, e) =>
            {
                // Dismiss the keyboard by removing it as the first responder.
                textView.ResignFirstResponder();
                NavigationItem.SetRightBarButtonItem(null, true);
            });

            NavigationItem.SetRightBarButtonItem(doneBarButtonItem, true);
            AdjustTextViewSelection(textView);
        }
示例#30
0
        public static void ShowCloseButtonOnKeyboard(this UITextView text, Action onClosePressed = null)
        {
            Action <object, EventArgs> onClose = (sender, e) =>
            {
                text.ResignFirstResponder();
                if (onClosePressed != null)
                {
                    onClosePressed();
                }
            };

            text.InputAccessoryView = CreateAccessoryViewWithCloseButton(onClose);
        }
        public void SetupToolbarOnKeyboard(UITextView txt)
        {
            UIToolbar toolbar = new UIToolbar ();
            toolbar.BarStyle = UIBarStyle.Black;
            toolbar.Translucent = true;
            toolbar.SizeToFit ();
            UIBarButtonItem doneButton = new UIBarButtonItem ("Close", UIBarButtonItemStyle.Done,
                                                              (s, e) => {
                txt.ResignFirstResponder ();
            });
            doneButton.TintColor = UIColor.Gray;

            UIBarButtonItem goButton = new UIBarButtonItem ("Run", UIBarButtonItemStyle.Done,
                                                              (s, e) => {

                txt.ResignFirstResponder ();
                OnRun ();
            });

            toolbar.SetItems (new UIBarButtonItem[]{doneButton, goButton}, true);

            txt.InputAccessoryView = toolbar;
        }
        public void SetupToolbarOnKeyboard(UITextView txt)
        {
            UIToolbar toolbar = new UIToolbar();

            toolbar.BarStyle    = UIBarStyle.Black;
            toolbar.Translucent = true;
            toolbar.SizeToFit();
            UIBarButtonItem doneButton = new UIBarButtonItem("Close", UIBarButtonItemStyle.Done,
                                                             (s, e) => {
                txt.ResignFirstResponder();
            });

            doneButton.TintColor = UIColor.Gray;

            UIBarButtonItem goButton = new UIBarButtonItem("Run", UIBarButtonItemStyle.Done,
                                                           (s, e) => {
                txt.ResignFirstResponder();
                OnRun();
            });

            toolbar.SetItems(new UIBarButtonItem[] { doneButton, goButton }, true);

            txt.InputAccessoryView = toolbar;
        }
示例#33
0
        public void ResignFirstResponder(bool animated)
        {
            becomeResponder = false;
            var tv = GetContainerTableView();

            if (tv == null)
            {
                return;
            }
            tv.ScrollToRow(IndexPath, UITableViewScrollPosition.Middle, animated);
            if (entry != null)
            {
                entry.ResignFirstResponder();
            }
        }
            public override void EditingEnded(UITextView textView)
            {
                if (textView.Text == "")
                {
                    textView.Text      = _hint;
                    editorView.Text    = _hint;
                    textView.TextColor = UIColor.FromRGB(150, 150, 150);
                }
                else
                {
                    editorView.Text = textView.Text;
                }

                textView.ResignFirstResponder();
            }
示例#35
0
        void PostCallback ()
        {
            SendItem.Enabled = false;
            TextView.ResignFirstResponder();

            try
            {
                if (ReturnAction != null)
                    ReturnAction(Text);
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine(e.Message + " - " + e.StackTrace);
            }
        }
示例#36
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            #region UI controls, you could do this in a XIB if you wanted
            saveButton       = UIButton.FromType(UIButtonType.RoundedRect);
            saveButton.Frame = new CGRect(10.0, 10.0, 160.0, 50.0);
            saveButton.SetTitle("UpdateChangeCount", UIControlState.Normal);
            saveButton.Enabled = false;

            alertText = new UITextView(new CGRect(175.0, 10.0, 140.0, 50.0))
            {
                TextColor = UIColor.Red,
                Editable  = false
            };

            docText = new UITextView(new CGRect(10.0, 70.0, 300.0, 150.0))
            {
                Editable        = true,
                ScrollEnabled   = true,
                BackgroundColor = UIColor.FromRGB(224, 255, 255)
            };

            // Add the controls to the view
            Add(saveButton);
            Add(docText);
            Add(alertText);
            #endregion

            saveButton.TouchUpInside += (sender, e) => {
                // we're not checking for conflicts or anything, just saving the edited version over the top
                Console.WriteLine("UpdateChangeCount -> hint for iCloud to save");
                doc.DocumentString = docText.Text;
                alertText.Text     = string.Empty;
                doc.UpdateChangeCount(UIDocumentChangeKind.Done);
                docText.ResignFirstResponder();
            };

            // listen for notifications that the document was modified via the server
            NSNotificationCenter.DefaultCenter.AddObserver(this,
                                                           new Selector("dataReloaded:"),
                                                           new NSString("monkeyDocumentModified"),
                                                           null
                                                           );
        }
示例#37
0
        /*
         * [Export("textView:shouldInteractWithURL:inRange:")]
         * public bool ShouldInteractWithUrl(UITextView textView, NSUrl URL, NSRange characterRange)
         * {
         *  return true;
         * }
         */
        /*
         * bool LinkText_ShouldReturn(UITextField textField)
         * {
         *  textField.ResignFirstResponder();
         *  return false; // We do not want UITextField to insert line-breaks.
         * }
         */
        bool ShareText_ShouldChangeText(UITextView textView, NSRange range, string text)
        {
            if (text.Length == 1 && text == Environment.NewLine)
            {
                if (ShareTemplate != null)
                {
                    ShareModel share = new ShareModel();
                    share.ShareTransactionId = ShareTemplate.ShareTransactionID;
                    share.BodyMessage        = textView.Text;
                    share.ShareEntryList     = System.Linq.Enumerable.ToList(ShareTemplate.NetworkShareList);
                    SL.Manager.PostShare(share, PostShareResponse);
                }

                textView.ResignFirstResponder();
                return(false);
            }
            return(true);
        }
		public override void ViewDidLoad ()
		{	
			base.ViewDidLoad ();

			#region UI controls, you could do this in a XIB if you wanted
			saveButton = UIButton.FromType (UIButtonType.RoundedRect);
			saveButton.Frame = new CGRect (10.0, 10.0, 160.0, 50.0);
			saveButton.SetTitle ("UpdateChangeCount", UIControlState.Normal);
			saveButton.Enabled = false;
			
			alertText = new UITextView (new CGRect (175.0, 10.0, 140.0, 50.0)) {
				TextColor = UIColor.Red,
				Editable = false
			};

			docText = new UITextView (new CGRect (10.0, 70.0, 300.0, 150.0)) {
				Editable = true,
				ScrollEnabled = true,
				BackgroundColor = UIColor.FromRGB (224, 255, 255)
			};
			
			// Add the controls to the view
			Add (saveButton);
			Add (docText);
			Add (alertText);
			#endregion

			saveButton.TouchUpInside += (sender, e) => {
				// we're not checking for conflicts or anything, just saving the edited version over the top
				Console.WriteLine ("UpdateChangeCount -> hint for iCloud to save");
				doc.DocumentString = docText.Text;
				alertText.Text = string.Empty;
				doc.UpdateChangeCount (UIDocumentChangeKind.Done);
				docText.ResignFirstResponder ();
			};
			
			// listen for notifications that the document was modified via the server
			NSNotificationCenter.DefaultCenter.AddObserver (this,
				new Selector ("dataReloaded:"),
				new NSString ("monkeyDocumentModified"),
				null
			);
		}
示例#39
0
		public override void ViewDidLoad ()
		{
			// add the inputs to the DialogViewController - bit of a hack :)
			base.ViewDidLoad ();

			var f = TableView.Frame;
			f.Height -= 65;
			f.Y += 65;
			TableView.Frame = f;

			input = new UITextView(new RectangleF(3, 23, 247, 37));
			input.BackgroundColor= UIColor.FromRGB(207,220,255);
			input.Font = UIFont.SystemFontOfSize (16f);
			done = UIButton.FromType (UIButtonType.RoundedRect);
			done.Frame = new RectangleF(255, 23, 60, 37); // 400

			done.SetTitle ("Cloud", UIControlState.Normal);

			// SEND BUTTON 
			done.TouchUpInside += (sender, e) => {
				if (input.Text.Length > 0) {
					Console.WriteLine ("Update icloud kv with\n    " + UIDevice.CurrentDevice.Name+":"+ input.Text);
	
					// add chat to list
					chatSection.Add (new ChatBubble (BubbleType.Left, input.Text));
					// scroll to the end
					var lastIP = NSIndexPath.FromRowSection(chatSection.Count-1, 0);
					TableView.ScrollToRow (lastIP, UITableViewScrollPosition.Bottom, true);
					// update the cloud
					var store = NSUbiquitousKeyValueStore.DefaultStore;
					store.SetString(UIDevice.CurrentDevice.Name, input.Text);
					store.Synchronize ();
					// reset
					input.Text = "";
					input.ResignFirstResponder ();
				}
			};
		}
示例#40
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            #region UI Controls (you could do this in XIB if you want)
            saveButton = UIButton.FromType(UIButtonType.RoundedRect);
            saveButton.Frame = new RectangleF(10,240,145,40);
            saveButton.SetTitle("Save", UIControlState.Normal);
            saveButton.SetTitle("waiting...", UIControlState.Disabled);
            saveButton.Enabled = false;

            deleteButton = UIButton.FromType(UIButtonType.RoundedRect);
            deleteButton.Frame = new RectangleF(160,240,145,40);
            deleteButton.SetTitle("Delete", UIControlState.Normal);
            deleteButton.Enabled = false;

            doneSwitch = new UISwitch();
            doneSwitch.Frame = new RectangleF(10, 205, 145, 50);
            doneSwitch.Enabled = false;
            doneLabel = new UILabel();
            doneLabel.Frame = new RectangleF(100, 210, 100, 15);
            doneLabel.Text = "Done";

            titleText = new UITextView(new RectangleF(10, 10, 300, 40));
            titleText.BackgroundColor = UIColor.FromRGB(240,240,240);
            titleText.Editable = true;
            titleText.Font = UIFont.SystemFontOfSize(20f);
            titleText.BackgroundColor = UIColor.FromRGB(240,240,240);
            titleText.ReturnKeyType = UIReturnKeyType.Next;
            titleText.ShouldChangeText = (t, c, r) => {
                if (r == "\n") {
                    descriptionText.BecomeFirstResponder();
                    return false;
                }
                return true;
            };

            descriptionText = new UITextView(new RectangleF(10, 60, 300, 180));
            descriptionText.BackgroundColor = UIColor.FromRGB(240,240,240);
            descriptionText.Editable = true;
            descriptionText.ScrollEnabled = true;
            descriptionText.AutoresizingMask = UIViewAutoresizing.FlexibleHeight;
            descriptionText.ReturnKeyType = UIReturnKeyType.Done;
            descriptionText.ShouldChangeText = (t, c, r) => {
                if (r == "\n") {
                    descriptionText.ResignFirstResponder();
                    return false;
                }
                return true;
            };

            // Add the controls to the view
            this.Add(saveButton);
            this.Add(deleteButton);
            this.Add(doneLabel);
            this.Add(doneSwitch);
            this.Add(descriptionText);   // disabled for Azure demo (for now...)
            this.Add(titleText);
            #endregion

            LoadData ();

            saveButton.TouchUpInside += (sender, e) => {

                task.Title = titleText.Text;
                task.Description = descriptionText.Text;
                task.IsDone = doneSwitch.On;

                // save to Dropbox
                DropboxDatabase.Shared.Update(task);

                descriptionText.ResignFirstResponder ();			// hide keyboard
                titleText.ResignFirstResponder ();

                NavigationController.PopToRootViewController (true);
            };

            deleteButton.TouchUpInside += (sender, e) => {

                // delete to Dropbox
                DropboxDatabase.Shared.Delete(task);

                descriptionText.ResignFirstResponder ();			// hide keyboard
                titleText.ResignFirstResponder ();

                NavigationController.PopToRootViewController (true); // doesn't reflect deletion yet
            };
        }
示例#41
0
        public override UITableViewCell GetCell(UITableView tv)
        {
            var cell = tv.DequeueReusableCell (CellKey);
            if (cell == null){
                cell = new UITableViewCell (UITableViewCellStyle.Default, CellKey);
                cell.SelectionStyle = UITableViewCellSelectionStyle.None;
            } else
                RemoveTag (cell, 1);

            if (entry == null){
                SizeF size = ComputeEntryPosition (tv, cell);
                float yOffset = (GetHeight(this.GetContainerTableView(), IndexPath) - size.Height) / 2;
                float width = cell.ContentView.Bounds.Width - size.Width - 2;  // remove two pixels to fix up appearance in case this is the only control in section

                entry = CreateTextView (new RectangleF (size.Width, yOffset, width, size.Height));
                if (AcceptReturns == false)
                    entry.ReturnKeyType = UIReturnKeyType.Done;
                else
                    entry.ReturnKeyType = UIReturnKeyType.Default;

                entry.KeyboardType = UIKeyboardType.Default;
                entry.AutocorrectionType = UITextAutocorrectionType.Default;

                entry.Changed += delegate {
                    FetchValue ();
                    if (Changed != null)
                        Changed(this, new EventArgs());
                };
                entry.Ended += delegate {
                    FetchValue ();
                    if (Changed != null)
                        Changed(this, new EventArgs());
               					entry.ResignFirstResponder();
                    this.GetImmediateRootElement().TableView.EndEditing(true);
                };

                entry.Started += delegate {
                    tv.ScrollToRow (IndexPath, UITableViewScrollPosition.Middle, true);
                };
            }

            cell.TextLabel.Text = Caption;
            cell.ContentView.AddSubview (entry);
            return cell;
        }
示例#42
0
		private bool SaveText (UITextView tf)
		{	
		    tf.ResignFirstResponder ();
			_tableViewController.SaveAndClose(tf.Text);
			return true;
		}
示例#43
0
        public override UITableViewCell GetCell(UITableView tv)
        {
            var cell = tv.DequeueReusableCell (ekey);
            if (cell == null){
                cell = new MultiLineTableCell (UITableViewCellStyle.Subtitle, ekey);
                cell.SelectionStyle = UITableViewCellSelectionStyle.None;
            } else
                RemoveTag (cell, 1);

            if (entry == null)
            {
                entry = new UITextView(new RectangleF(0, 28, cell.ContentView.Bounds.Width, 16 + (20 * (Rows + 1))));
                entry.Font = UIFont.SystemFontOfSize(16);
                entry.Text = Value ?? "";
                entry.BackgroundColor = UIColor.Clear;
                entry.AutoresizingMask = UIViewAutoresizing.FlexibleWidth |
                    UIViewAutoresizing.FlexibleLeftMargin;

                entry.Ended += delegate {
                    Value = entry.Text;

                    entry.ResignFirstResponder();
                };
                entry.Changed += delegate(object sender, EventArgs e) {
                    if(!string.IsNullOrEmpty(entry.Text))
                    {
                        int i = entry.Text.IndexOf("\n", entry.Text.Length -1);
                        if (i > -1)
                        {
                            entry.Text = entry.Text.Substring(0,entry.Text.Length -1);
                            entry.ResignFirstResponder();
                        }
                    }
                    Value = entry.Text;
                };
                ////////////////
            //				entry.Started += delegate {
            //					MultiLineEntryElement focus = null;
            //					foreach (var e in (Parent as Section).Elements){
            //						if (e == this)
            //							focus = this;
            //						else if (focus != null && e is MultiLineEntryElement)
            //							focus = e as MultiLineEntryElement;
            //					}
            //					if (focus != this)
            //						focus.entry.BecomeFirstResponder ();
            //					else
            //						focus.entry.ResignFirstResponder ();
            //
            //				};

            //				entry.Started += delegate {
            //					MultiLineEntryElement self = null;
            //					var returnType = UIReturnKeyType.Default;
            //
            //					foreach (var e in (Parent as Section).Elements){
            //						if (e == this)
            //							self = this;
            //						else if (self != null && e is MultiLineEntryElement)
            //							returnType = UIReturnKeyType.Next;
            //					}
            //				};

                entry.ReturnKeyType = UIReturnKeyType.Done;
            }
            ///////////
            cell.TextLabel.Text = Caption;

            cell.ContentView.AddSubview (entry);
            return cell;
        }
			public override void EditingEnded (UITextView textView)
			{
				if (textView.Text == "")
				{
					textView.Text = _hint;
					editorView.Text = _hint;
					textView.TextColor = UIColor.FromRGB (150, 150, 150);
				} else
				{
					editorView.Text = textView.Text;
				}

				textView.ResignFirstResponder ();
			}
		public override UITableViewCell GetCell (UITableView tv)
		{
			var cell = tv.DequeueReusableCell (ekey);
			if (cell == null){
				cell = new TableViewCell(UITableViewCellStyle.Default, ekey);
				cell.SelectionStyle = UITableViewCellSelectionStyle.None;
				cell.BackgroundColor = UIColor.White;
			} else 
				RemoveTag (cell, 1);
			
			
			if (entry == null)
			{
				var s = new RectangleF(0, string.IsNullOrEmpty(Caption) ? 10.5f : 32,
				                       cell.ContentView.Bounds.Width, 12 + (20 * (Rows + 1)));
				entry = new UITextView(s);
				
				entry.Font = UIFont.SystemFontOfSize(17);
				entry.Text = Value ?? string.Empty;
				
				entry.AutoresizingMask = UIViewAutoresizing.FlexibleWidth |UIViewAutoresizing.FlexibleLeftMargin;

				//TODO: Find a way to just curver bottom
				//if (_topItem) { entry.Layer.CornerRadius = 15.0f; }
				if (_bottomItem) { entry.Layer.CornerRadius = 15.0f; }

				entry.Ended += delegate {
					if (entry != null)
					{
						Value = entry.Text;
						
						entry.ResignFirstResponder();
						if (entry.ReturnKeyType == UIReturnKeyType.Go)
						{
							//TODO: Do we submit the form here
							throw new ApplicationException("We need to submit form here");
						}
					}
				};
				entry.Changed += delegate(object sender, EventArgs e) {
					if(!string.IsNullOrEmpty(entry.Text))
					{
						int i = entry.Text.IndexOf("\n", entry.Text.Length -1);
						if (i > -1)
						{
							entry.Text = entry.Text.Substring(0,entry.Text.Length -1); 
							entry.ResignFirstResponder();	
						}
					}
					Value = entry.Text;
				};
				
				entry.ReturnKeyType = UIReturnKeyType.Done;
			}

			cell.TextLabel.Text = Caption; 
			cell.ContentView.AddSubview(entry);
			return cell;
		}
示例#46
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            #region UI Controls (you could do this in XIB if you want)
            saveButton = UIButton.FromType(UIButtonType.RoundedRect);
            saveButton.Frame = new RectangleF(10,10,145,40);
            saveButton.SetTitle("Save", UIControlState.Normal);
            saveButton.SetTitle("waiting...", UIControlState.Disabled);
            saveButton.Enabled = false;

            deleteButton = UIButton.FromType(UIButtonType.RoundedRect);
            deleteButton.Frame = new RectangleF(10,150,145,40);
            deleteButton.SetTitle("Delete", UIControlState.Normal);
            deleteButton.Enabled = false;

            doneSwitch = new UISwitch();
            doneSwitch.Frame = new RectangleF(185, 30, 145, 50);
            doneSwitch.Enabled = false;
            doneLabel = new UILabel();
            doneLabel.Frame = new RectangleF(200, 10, 145, 15);
            doneLabel.Text = "Done?";

            titleText = new UITextView(new RectangleF(10, 70, 300, 40));
            titleText.BackgroundColor = UIColor.FromRGB(240,240,240);
            titleText.Editable = true;
            titleText.BackgroundColor = UIColor.FromRGB(240,240,240);

            descriptionText = new UITextView(new RectangleF(10, 130, 300, 180));
            descriptionText.BackgroundColor = UIColor.FromRGB(240,240,240);
            descriptionText.Editable = true;
            descriptionText.ScrollEnabled = true;
            descriptionText.AutoresizingMask = UIViewAutoresizing.FlexibleHeight;

            // Add the controls to the view
            this.Add(saveButton);
            this.Add(deleteButton);
            this.Add(doneLabel);
            this.Add(doneSwitch);
            //this.Add(descriptionText);   // disabled for Azure demo (for now...)
            this.Add(titleText);
            #endregion

            LoadData ();

            saveButton.TouchUpInside += (sender, e) => {

                task.Title = titleText.Text;
                task.Description = descriptionText.Text;
                task.IsDone = doneSwitch.On;

                // save to Azure
                AzureWebService.UpdateTodo (task);

                descriptionText.ResignFirstResponder ();			// hide keyboard
                titleText.ResignFirstResponder ();

                NavigationController.PopToRootViewController (true);
            };

            deleteButton.TouchUpInside += (sender, e) => {

                // save to Azure
                AzureWebService.DeleteTodo (task);

                descriptionText.ResignFirstResponder ();			// hide keyboard
                titleText.ResignFirstResponder ();

                NavigationController.PopToRootViewController (true); // doesn't reflect deletion yet
            };
        }
            public override void EditingEnded(UITextView textView)
            {
                if (textView.Text == "")
                {
                    textView.Text = Placeholder;
                    textView.TextColor = UIColor.LightGray;
                }
				formsEditor.Text = textView.Text;
                textView.ResignFirstResponder();
                UIView view = getRootSuperView(textView);
                textView.BackgroundColor = UIColor.White;
                CoreGraphics.CGRect rect = view.Frame;
                rect.Y += 80;
                view.Frame = rect;
            }
		public override UITableViewCell GetCell (UITableView tv)
		{
			var cell = tv.DequeueReusableCell (ekey);
			if (cell == null){
				cell = new UITableViewCell (UITableViewCellStyle.Default, ekey);
				cell.SelectionStyle = UITableViewCellSelectionStyle.None;
			} else 
				RemoveTag (cell, 1);
			
			
			if (entry == null){
				SizeF size = ComputeEntryPosition (tv, cell);
				/*entry = new UITextField (new RectangleF (size.Width, (cell.ContentView.Bounds.Height-size.Height)/2-1, 320-size.Width, size.Height)){
					Tag = 1,
					Placeholder = placeholder,
					SecureTextEntry = isPassword
				};*/
				entry = new UITextView(new RectangleF(size.Width,(cell.ContentView.Bounds.Height-size.Height)/2-1, 320-size.Width, 96));
				entry.Text = Value ?? "";
				entry.AutoresizingMask = UIViewAutoresizing.FlexibleWidth |
					UIViewAutoresizing.FlexibleLeftMargin;
				
				entry.Ended += delegate {
					Value = entry.Text;
				};
				entry.ReturnKeyType = UIReturnKeyType.Done;
				entry.Changed += delegate(object sender, EventArgs e) {
					int i = entry.Text.IndexOf("\n", entry.Text.Length -1);
					if (i > -1)
					{
						entry.Text = entry.Text.Substring(0,entry.Text.Length -1); 
						entry.ResignFirstResponder();	
					}
				};
			}

			
			cell.TextLabel.Text = Caption;
			cell.ContentView.AddSubview (entry);
			return cell;
		}
        private void AddKeyboardAccessoryView(UITextView textView)
        {
            int toolbarHeight = 44;
            int toolbarWidth = (int)View.Frame.Width;

            var toolbar = new UIToolbar(new Rectangle(0, 0, toolbarWidth, toolbarHeight));
            toolbar.TintColor = AppDelegate.TintColor;
            toolbar.BarStyle = UIBarStyle.Default;

            toolbar.Items = new []
            {
                new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace),
                new UIBarButtonItem(UIBarButtonSystemItem.Done, delegate {
                    textView.ResignFirstResponder();
                })
            };

            textView.KeyboardAppearance = UIKeyboardAppearance.Light;
            textView.InputAccessoryView = toolbar;
        }