internal void PrintMessage(string formattedMessage) { LogUtils.Log("[CHAT] " + formattedMessage); if (!IsDedicatedServer()) { if (_chatView == null) { var gui = Player.MainPlayer.GUI; _chatView = new ChatScrollView("PlayerChat", gui.RootView); } _chatView.AddLine(formattedMessage); } }
void ReleaseDesignerOutlets() { if (CameraButton != null) { CameraButton.Dispose(); CameraButton = null; } if (ChatBackground != null) { ChatBackground.Dispose(); ChatBackground = null; } if (ChatScrollView != null) { ChatScrollView.Dispose(); ChatScrollView = null; } if (GalleryButton != null) { GalleryButton.Dispose(); GalleryButton = null; } if (LoadingIndicatorView != null) { LoadingIndicatorView.Dispose(); LoadingIndicatorView = null; } if (SendButton != null) { SendButton.Dispose(); SendButton = null; } if (SmileyButton != null) { SmileyButton.Dispose(); SmileyButton = null; } if (TextField != null) { TextField.Dispose(); TextField = null; } }
void SetupUI() { RegisterKeyboardEvents(); //hide keyboard on tap ChatScrollView.AddGestureRecognizer(new UITapGestureRecognizer(() => { TextField.ResignFirstResponder(); })); ChatScrollView.ContentSize = new CGSize(View.Frame.Width, View.Frame.Height); //set placeholder text if textfield is blank TextView_Delegate = new TextViewDelegate(ChatScrollView, ChatBackground); TextField.Delegate = TextView_Delegate; }
ChatBubbleViewExtension CreateChatBubble(PostItem post, PostStatusType postStatus) { bool IsLocal = false; if (postStatus == PostStatusType.SendingPost || postStatus == PostStatusType.PreviousPost) { IsLocal = true; } Console.WriteLine("postStatus is {0}, IsLocal is {1}", postStatus.ToString(), IsLocal); //base measurements var verticalImageAdjustment = 5f; var ChatAreaSpacing = 10f; var ImageDimension = 22f; nfloat labelSpacing = 5; var ChatBubbleWidth = 200; //use DecideChatBubbleWidth( var ChatBubbleHeight = 100; //heightDiff *1.5f; //dependent measurements ChatBubbleY += ChatBubbleHeight + ChatAreaSpacing; labelWidth = ChatBubbleWidth - (ChatBubbleWidth - (labelSpacing * 2)); labelHeight = ChatBubbleHeight - (ChatBubbleHeight - (labelSpacing * 2)); var ImageAndBubbleFrame = new CGRect(0, ChatBubbleY, ChatScrollView.Frame.Width, ChatBubbleHeight); var ImageX = IsLocal ? ImageAndBubbleFrame.Width - ChatAreaSpacing - ImageDimension : ChatAreaSpacing; var ChatBubbleX = IsLocal ? ImageX - ChatBubbleWidth - ChatAreaSpacing : ImageDimension + (ChatAreaSpacing * 2); //profile pic var ProfileImageView = new UIImageView(); ProfileImageView.Image = UIImage.FromFile("profilepics/people.png"); ProfileImageView.ContentMode = UIViewContentMode.ScaleAspectFill; ProfileImageView.Frame = new CGRect(ImageX, verticalImageAdjustment, ImageDimension, ImageDimension); //chat bubble without the profile pic var ChatFrame = new CGRect(ChatBubbleX, 0, ChatBubbleWidth, ChatBubbleHeight); var ChatMessage = new UIView(); ChatMessage.BackgroundColor = UIColor.White; ChatMessage.Layer.CornerRadius = 12; ChatMessage.Frame = ChatFrame; //this is the username var TitleLabel = new UILabel(new CGRect(labelSpacing, labelSpacing, labelWidth, labelHeight)); TitleLabel.TextColor = UIColor.LightGray; TitleLabel.TextAlignment = UITextAlignment.Left; TitleLabel.Font = UIFont.SystemFontOfSize(14); TitleLabel.Text = post.Title; TitleLabel.SizeToFit(); //message content var BodyLabel = new UILabel(new CGRect(labelSpacing, TitleLabel.Frame.Height + (labelSpacing * 2), labelWidth, labelHeight)); BodyLabel.TextColor = UIColor.Black; BodyLabel.Text = post.Body; BodyLabel.Font = UIFont.SystemFontOfSize(15); BodyLabel.SizeToFit(); BodyLabel.Lines = 50; BodyLabel.LineBreakMode = UILineBreakMode.WordWrap; //time message was sent var TimeStampLabel = new UILabel(new CGRect(ChatBubbleWidth - (labelWidth * 4), ChatBubbleHeight - labelHeight - (labelSpacing * 2) , labelWidth, labelHeight)); TimeStampLabel.TextAlignment = UITextAlignment.Left; TimeStampLabel.Font = UIFont.SystemFontOfSize(12); TimeStampLabel.Text = string.Format("{0}:{1}", DateTime.Now.TimeOfDay.Hours, DateTime.Now.TimeOfDay.Minutes); TimeStampLabel.TextColor = UIColor.LightGray; TimeStampLabel.SizeToFit(); //add message text into one bubble view ChatMessage.AddSubview(TitleLabel); ChatMessage.BringSubviewToFront(TitleLabel); ChatMessage.AddSubview(BodyLabel); ChatMessage.BringSubviewToFront(BodyLabel); ChatMessage.AddSubview(TimeStampLabel); ChatMessage.BringSubviewToFront(TimeStampLabel); ChatMessage.SizeToFit(); //add image and text bubble together //this is the chat bubble containing text and the profile pic var ImageAndBubbleViewContainer = new ChatBubbleViewExtension(); ImageAndBubbleViewContainer.BackgroundColor = UIColor.Clear; ImageAndBubbleViewContainer.Frame = ImageAndBubbleFrame; ImageAndBubbleViewContainer.AddSubview(ProfileImageView); ImageAndBubbleViewContainer.BringSubviewToFront(ProfileImageView); ImageAndBubbleViewContainer.AddSubview(ChatMessage); ImageAndBubbleViewContainer.BringSubviewToFront(ChatMessage); //add image and text bubble to chat window ChatScrollView.AddSubview(ImageAndBubbleViewContainer); ChatScrollView.BringSubviewToFront(ImageAndBubbleViewContainer); return(ImageAndBubbleViewContainer); }