Example #1
0
        public EditableCoreTextView(RectangleF frame)
            : base(frame)
        {
            // Add tap gesture recognizer to let the user enter editing mode
            UITapGestureRecognizer tap = new UITapGestureRecognizer(Tap)
            {
                ShouldReceiveTouch = delegate(UIGestureRecognizer recognizer, UITouch touch) {
                    // If gesture touch occurs in our view, we want to handle it
                    return(touch.View == this);
                }
            };

            AddGestureRecognizer(tap);

            // Create our tokenizer and text storage
            tokenizer = new UITextInputStringTokenizer(this);

            // Create and set up our SimpleCoreTextView that will do the drawing
            textView = new SimpleCoreTextView(Bounds.Inset(5, 5));
            textView.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
            UserInteractionEnabled    = true;
            AutosizesSubviews         = true;
            AddSubview(textView);
            textView.Text = string.Empty;
            textView.UserInteractionEnabled = false;
        }
		protected override void Dispose (bool disposing)
		{
			markedTextStyle = null;
			tokenizer = null;
			text = null;
			textView = null;
			base.Dispose (disposing);
		}
Example #3
0
 protected override void Dispose(bool disposing)
 {
     markedTextStyle = null;
     tokenizer       = null;
     text            = null;
     textView        = null;
     base.Dispose(disposing);
 }
		public EditableCoreTextView (RectangleF frame)
			: base (frame)
		{
			// Add tap gesture recognizer to let the user enter editing mode
			UITapGestureRecognizer tap = new UITapGestureRecognizer (this, new Selector ("Tap:"));
			AddGestureRecognizer (tap);
			tap.Delegate = new TapGestureRecognizerDelegate (this); 
        
			// Create our tokenizer and text storage
			tokenizer = new UITextInputStringTokenizer (this);

			// Create and set up our SimpleCoreTextView that will do the drawing
			textView = new SimpleCoreTextView (Bounds.Inset (5, 5));
			textView.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
			UserInteractionEnabled = true;
			AutosizesSubviews = true;
			AddSubview (textView);
			textView.Text = string.Empty;
			textView.UserInteractionEnabled = false;
		}
        public EditableCoreTextView(RectangleF frame)
            : base(frame)
        {
            // Add tap gesture recognizer to let the user enter editing mode
            UITapGestureRecognizer tap = new UITapGestureRecognizer(this, new Selector("Tap:"));

            AddGestureRecognizer(tap);
            tap.Delegate = new TapGestureRecognizerDelegate(this);

            // Create our tokenizer and text storage
            tokenizer = new UITextInputStringTokenizer(this);

            // Create and set up our SimpleCoreTextView that will do the drawing
            textView = new SimpleCoreTextView(Bounds.Inset(5, 5));
            textView.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
            UserInteractionEnabled    = true;
            AutosizesSubviews         = true;
            AddSubview(textView);
            textView.Text = string.Empty;
            textView.UserInteractionEnabled = false;
        }
		public EditableCoreTextView (RectangleF frame)
			: base (frame)
		{
			// Add tap gesture recognizer to let the user enter editing mode
			UITapGestureRecognizer tap = new UITapGestureRecognizer (Tap) {
				ShouldReceiveTouch = delegate(UIGestureRecognizer recognizer, UITouch touch) {
					// If gesture touch occurs in our view, we want to handle it
					return touch.View == this;
				}
			};
			AddGestureRecognizer (tap);
        
			// Create our tokenizer and text storage
			tokenizer = new UITextInputStringTokenizer (this);

			// Create and set up our SimpleCoreTextView that will do the drawing
			textView = new SimpleCoreTextView (Bounds.Inset (5, 5));
			textView.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
			UserInteractionEnabled = true;
			AutosizesSubviews = true;
			AddSubview (textView);
			textView.Text = string.Empty;
			textView.UserInteractionEnabled = false;
		}
		public override void ViewDidLoad()
		{
			base.ViewDidLoad();

			posterImage.SetUserImage(Post.userPoster);
			posterUsername.SetTitle(Post.userPoster.username);


			postImage.Layer.CornerRadius = 8;
			postImage.ClipsToBounds = true;

			captionTextView.AttributedText = NativeStringUtils.ParseStringForKeywords(Post, Post.text);
			UITapGestureRecognizer tapGesture = new UITapGestureRecognizer(delegate (UITapGestureRecognizer obj)
			{
				UITextView textView = (UITextView)obj.View;
				UITextInputStringTokenizer token = (UITextInputStringTokenizer)textView.Tokenizer;
				if (token == null)
				{
					token = new UITextInputStringTokenizer();
				}

				UITextRange textRange = token.GetRangeEnclosingPosition(textView.GetClosestPositionToPoint(obj.LocationInView(textView)), UITextGranularity.Word, UITextDirection.Left);
				if (textRange == null)
				{
					return;
				}

				nint newLoc = textView.GetOffsetFromPosition(textView.BeginningOfDocument, textRange.Start) - 1;
				nint newLen = textView.GetOffsetFromPosition(textRange.Start, textRange.End);


				if (textRange == null || newLoc == -1)
				{
					return;
				}

				string prefix = textView.Text.Substring((int)newLoc, 1);

				if (prefix == "@")
				{
					TenServiceHelper.GoToGuestProfile(textView.Text.Substring((int)newLoc + 1, (int)newLen));
				}
				else if (prefix == "#")
				{
					TenServiceHelper.GoToSearchTags(textView.Text.Substring((int)newLoc + 1, (int)newLen));
				}
				else {
					return;
				}
			});
			captionTextView.AddGestureRecognizer(tapGesture);


			likeButton.SetImage((Post.liked) ? UIImage.FromBundle("LikeSelected") : UIImage.FromBundle("Like"));
			repostButton.SetImage((Post.isReposted) ? UIImage.FromBundle("RepostSelected") : UIImage.FromBundle("Repost"));
			commentButton.SetImage((Post.commented) ? UIImage.FromBundle("CommentSelected") : UIImage.FromBundle("Comment"));


			if (Post.userPoster.IsMe())
			{
				likeButton.Hidden = true;
				repostButton.Hidden = true;
			}
			else {
				likeButton.Hidden = false;
				repostButton.Hidden = false; 
			}

			repostButton.Enabled = !Post.userPoster.isprivate;

			if (Post.userReposter != null)
			{
				repostLabel.Hidden = false;
				repostLabel.SetTitle((Post.userReposter.IsMe()) ? "by you" : "by " + Post.userReposter.username);
			}
			else
			{
				repostLabel.Hidden = true;
				repostLabel.SetTitle("");
			}


			timeElapsed.Text = StringUtils.GetPrettyDateAbs(Post.datestamp);

			ShowTimeRemaining();

		}