public override void ViewDidLoad () { base.ViewDidLoad (); aButton.TouchUpInside += (sender, e) => { if (InitialActionCompleted != null){ aButton.Hidden = true; InitialActionCompleted.Invoke (this, new EventArgs ()); Title = "Xamarin Chat"; // You must set your senderId and display name SenderId = sender.Id; SenderDisplayName = sender.DisplayName; // These MessagesBubbleImages will be used in the GetMessageBubbleImageData override var bubbleFactory = new MessagesBubbleImageFactory (); outgoingBubbleImageData = bubbleFactory.CreateOutgoingMessagesBubbleImage (UIColorExtensions.MessageBubbleLightGrayColor); incomingBubbleImageData = bubbleFactory.CreateIncomingMessagesBubbleImage (UIColorExtensions.MessageBubbleBlueColor); // Remove the AccessoryButton as we will not be sending pics InputToolbar.ContentView.LeftBarButtonItem = null; // Remove the Avatars CollectionView.CollectionViewLayout.IncomingAvatarViewSize = CoreGraphics.CGSize.Empty; CollectionView.CollectionViewLayout.OutgoingAvatarViewSize = CoreGraphics.CGSize.Empty; // Load some messagees to start messages.Add (new Message (sender.Id, sender.DisplayName, NSDate.DistantPast, "Hi There")); messages.Add (new Message (friend.Id, friend.DisplayName, NSDate.DistantPast, "I'm sorry, my responses are limited. You must ask the right questions.")); }
public override void ViewDidLoad() { base.ViewDidLoad(); Title = "Xamarin Chat"; // You must set your senderId and display name SenderId = sender.Id; SenderDisplayName = sender.DisplayName; // These MessagesBubbleImages will be used in the GetMessageBubbleImageData override var bubbleFactory = new MessagesBubbleImageFactory(); outgoingBubbleImageData = bubbleFactory.CreateOutgoingMessagesBubbleImage(UIColorExtensions.MessageBubbleLightGrayColor); incomingBubbleImageData = bubbleFactory.CreateIncomingMessagesBubbleImage(UIColorExtensions.MessageBubbleBlueColor); // Remove the AccessoryButton as we will not be sending pics InputToolbar.ContentView.LeftBarButtonItem = null; // Remove the Avatars CollectionView.CollectionViewLayout.IncomingAvatarViewSize = CoreGraphics.CGSize.Empty; CollectionView.CollectionViewLayout.OutgoingAvatarViewSize = CoreGraphics.CGSize.Empty; // Load some messagees to start messages.Add(new Message(sender.Id, sender.DisplayName, NSDate.DistantPast, "Hi There")); messages.Add(new Message(friend.Id, friend.DisplayName, NSDate.DistantPast, "I'm sorry, my responses are limited. You must ask the right questions.")); }
public override void ViewDidLoad() { base.ViewDidLoad(); var bubbleFactory = new MessagesBubbleImageFactory(); outgoingBubbleImageData = bubbleFactory.CreateOutgoingMessagesBubbleImage(UIColor.FromRGB(0xE9, 0xE4, 0xD9)); incomingBubbleImageData = bubbleFactory.CreateIncomingMessagesBubbleImage(UIColor.FromRGB(0x7B, 0xBA, 0xE4)); messages.Add(new Message(DemoConstants.DemoAvatarIdJFK, DemoConstants.DemoAvatarDisplayNameJFK, NSDate.DistantPast, "Is this line secure?")); messages.Add(new Message(DemoConstants.DemoAvatarIdPatton, DemoConstants.DemoAvatarDisplayNamePatton, NSDate.DistantPast, "Sure Thing!")); Title = @"Patriot Conversation"; // You MUST set your senderId and display name SenderId = DemoConstants.DemoAvatarIdJFK; SenderDisplayName = DemoConstants.DemoAvatarDisplayNameJFK; // Load up our fake data for the demo CollectionView.CollectionViewLayout.IncomingAvatarViewSize = CoreGraphics.CGSize.Empty; CollectionView.CollectionViewLayout.OutgoingAvatarViewSize = CoreGraphics.CGSize.Empty; ShowLoadEarlierMessagesHeader = false; NavigationItem.RightBarButtonItem = new UIBarButtonItem( bubbleImageFromBundleWithName("typing"), UIBarButtonItemStyle.Bordered, ReceiveMessagePressed); }
public override async void ViewDidLoad() { base.ViewDidLoad(); //CollectionView.BackgroundColor = new UIColor(red:0.39f, green:0.33f, blue:0.50f, alpha:1.0f); //CollectionView.BackgroundColor = new UIColor(red: 0.04f, green: 0.11f, blue: 0.32f, alpha: 1.0f); Title = "Xamarin Shopping Bot"; this.NavigationController.NavigationBar.TintColor = new UIColor(red: 0.04f, green: 0.11f, blue: 0.32f, alpha: 1.0f); //instantiate an HTTPClient, and set properties to our DirectLine bot _client = new HttpClient(); _client.BaseAddress = new Uri("https://directline.botframework.com/api/conversations/"); _client.DefaultRequestHeaders.Accept.Clear(); _client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("BotConnector", DirectLineKey); var response = await _client.GetAsync("/api/tokens/"); if (response.IsSuccessStatusCode) { var conversation = new Conversation(); HttpContent contentPost = new StringContent(JsonConvert.SerializeObject(conversation), Encoding.UTF8, "application/json"); response = await _client.PostAsync("/api/conversations/", contentPost); if (response.IsSuccessStatusCode) { var conversationInfo = await response.Content.ReadAsStringAsync(); _lastConversation = JsonConvert.DeserializeObject <Conversation>(conversationInfo); } } // You must set your senderId and display name SenderId = sender.Id; SenderDisplayName = sender.DisplayName; UIImage av = FromUrl("https://raw.githubusercontent.com/Microsoft/XamarinAzure_ShoppingDemoApp/master/Shopping.DemoApp.iOS/Resources/Images.xcassets/AppIcons.appiconset/Icon-83.5%402x.png"); // These MessagesBubbleImages will be used in the GetMessageBubbleImageData override var bubbleFactory = new MessagesBubbleImageFactory(); outgoingBubbleImageData = bubbleFactory.CreateOutgoingMessagesBubbleImage(UIColorExtensions.MessageBubbleLightGrayColor); //incomingBubbleImageData = bubbleFactory.CreateIncomingMessagesBubbleImage(new UIColor(red: 0.31f, green: 0.00f, blue: 0.28f, alpha: 1.0f)); incomingBubbleImageData = bubbleFactory.CreateIncomingMessagesBubbleImage(new UIColor(red: 0.51f, green: 0.18f, blue: 0.51f, alpha: 1.0f)); incomingAvatar = new MessagesAvatarImage(av, av, av); //incomingAvatar.AvatarImage = UIImage.FromBundle("headshot"); outgoingAvatar = new MessagesAvatarImage(av, av, av); // Remove the AccessoryButton as we will not be sending pics InputToolbar.ContentView.LeftBarButtonItem = null; // Remove the Avatars //CollectionView.CollectionViewLayout.IncomingAvatarViewSize = CoreGraphics.CGSize.Empty; //CollectionView.CollectionViewLayout.OutgoingAvatarViewSize = CoreGraphics.CGSize.Empty; // Load some messagees to start messages.Add(new Message(friend.Id, friend.DisplayName, NSDate.DistantPast, "Welcome to the Xamarin Shop! How may I help you?")); FinishReceivingMessage(true); }
public override async void ViewDidLoad() { base.ViewDidLoad(); Title = "متحدث رمضان الآلي"; // initialize colors lightGray = new UIColor(red: 0.85f, green: 0.85f, blue: 0.85f, alpha: 1.0f); darkBlue = new UIColor(red: 0.33f, green: 0.41f, blue: 0.51f, alpha: 1.0f); // instantiate an HTTPClient, and set properties to our DirectLine bot _client = new HttpClient(); _client.BaseAddress = new Uri("https://directline.botframework.com/api/conversations/"); _client.DefaultRequestHeaders.Accept.Clear(); _client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("BotConnector", DirectLineKey); var response = await _client.GetAsync("/api/tokens/"); if (response.IsSuccessStatusCode) { var conversation = new Conversation(); HttpContent contentPost = new StringContent(JsonConvert.SerializeObject(conversation), Encoding.UTF8, "application/json"); response = await _client.PostAsync("/api/conversations/", contentPost); if (response.IsSuccessStatusCode) { var conversationInfo = await response.Content.ReadAsStringAsync(); _lastConversation = JsonConvert.DeserializeObject <Conversation>(conversationInfo); } } // You must set your senderId and display name SenderId = sender.Id; SenderDisplayName = sender.DisplayName; // These MessagesBubbleImages will be used in the GetMessageBubbleImageData override var bubbleFactory = new MessagesBubbleImageFactory(); outgoingBubbleImageData = bubbleFactory.CreateOutgoingMessagesBubbleImage(lightGray); CollectionView.CollectionViewLayout.OutgoingAvatarViewSize = CoreGraphics.CGSize.Empty; // Incoming from Bot incomingBubbleImageData = bubbleFactory.CreateIncomingMessagesBubbleImage(darkBlue); UIImage av = FromUrl("http://norashare.com/wp-content/uploads/2017/06/RamadanLogo.png"); incomingAvatar = new MessagesAvatarImage(av, av, av); // Load some messagees to start string initialMessage = "أهلا بك في متحدث رمضان الآلي.\nتستطيع أن تسألني عن: وقت الفطور، وقت الإمساك، الخيمات الرمضانية."; messages.Add(new Message(friend.Id, friend.DisplayName, NSDate.DistantPast, initialMessage)); FinishReceivingMessage(true); }
public ChatViewController(IntPtr handle) : base(handle) { var bubbleFactory = new MessagesBubbleImageFactory (); var border = UIImage.FromBundle ("bubble_stroked"); var bubble = UIImage.FromBundle ("bubble_regular"); var bubbleSrc = bubbleFactory.CreateIncomingMessagesBubbleImage (Theme.Current.BackgroundColor); var img = CreateBubbleWithBorder (bubble, Theme.Current.BackgroundColor, border, Theme.Current.IncomingBubbleStroke); var highlighedImg = bubbleSrc.MessageBubbleHighlightedImage; incomingBubbleImageData = new MessagesBubbleImage (img, highlighedImg); outgoingBubbleImageData = bubbleFactory.CreateOutgoingMessagesBubbleImage (Theme.Current.OutgoingBubbleColor); HidesBottomBarWhenPushed = true; }
public ChatViewController(IntPtr handle) : base(handle) { var bubbleFactory = new MessagesBubbleImageFactory(); var border = UIImage.FromBundle("bubble_stroked"); var bubble = UIImage.FromBundle("bubble_regular"); var bubbleSrc = bubbleFactory.CreateIncomingMessagesBubbleImage(Theme.Current.BackgroundColor); var img = CreateBubbleWithBorder(bubble, Theme.Current.BackgroundColor, border, Theme.Current.IncomingBubbleStroke); var highlighedImg = bubbleSrc.MessageBubbleHighlightedImage; incomingBubbleImageData = new MessagesBubbleImage(img, highlighedImg); outgoingBubbleImageData = bubbleFactory.CreateOutgoingMessagesBubbleImage(Theme.Current.OutgoingBubbleColor); HidesBottomBarWhenPushed = true; }
public override void ViewDidLoad() { base.ViewDidLoad(); Title = string.Empty; ManageMessages(); SenderId = sender.Id; SenderDisplayName = sender.DisplayName; var bubbleFactory = new MessagesBubbleImageFactory(); outgoingBubbleImageData = bubbleFactory.CreateOutgoingMessagesBubbleImage(UIColorExtensions.MessageBubbleGreenColor); incomingBubbleImageData = bubbleFactory.CreateIncomingMessagesBubbleImage(UIColorExtensions.MessageBubbleGreenColor); CollectionView.CollectionViewLayout.IncomingAvatarViewSize = new CGSize(25, 25); CollectionView.CollectionViewLayout.OutgoingAvatarViewSize = CGSize.Empty; }
public override void ViewDidLoad () { base.ViewDidLoad (); // Perform any additional setup after loading the view, typically from a nib. var menuButtonItem = new UIBarButtonItem (UIImage.FromBundle ("Menu"), UIBarButtonItemStyle.Plain, delegate { navigation.ToggleMenu (); }); Title = "Watson Chat"; menuButtonItem.TintColor = Theme.PrimaryColor; NavigationItem.LeftBarButtonItem = menuButtonItem; NavigationController.NavigationBar.TitleTextAttributes = new UIStringAttributes (){ Font = UIFont.PreferredHeadline, ForegroundColor = Theme.PrimaryColor }; //TODO: App.UserName SenderId = "user"; SenderDisplayName = "user"; var bubbleFactory = new MessagesBubbleImageFactory (); outgoingBubbleImageData = bubbleFactory.CreateOutgoingMessagesBubbleImage (Theme.PrimaryColor); incomingBubbleImageData = bubbleFactory.CreateIncomingMessagesBubbleImage (UIColorExtensions.MessageBubbleLightGrayColor); CollectionView.CollectionViewLayout.MessageBubbleFont = UIFont.PreferredBody; this.InputToolbar.ContentView.LeftBarButtonItem = null; this.InputToolbar.ContentView.TextView.PlaceHolder = "Message"; this.InputToolbar.ContentView.RightBarButtonItem.SetTitleColor(Theme.PrimaryColor, UIControlState.Normal); this.InputToolbar.ContentView.RightBarButtonItem.SetTitleColor(Theme.DarkPrimaryColor, UIControlState.Highlighted); spinner = new UIActivityIndicatorView (UIActivityIndicatorViewStyle.Gray); spinner.Frame = new CGRect(0, 0, 25, 25); spinner.Tag = 1; spinner.Color = Theme.PrimaryColor; NavigationItem.RightBarButtonItem = new UIBarButtonItem (spinner); }
public override void ViewDidLoad () { base.ViewDidLoad (); // You must set your senderId and display name SenderId = sender.Id; SenderDisplayName = sender.DisplayName; // These MessagesBubbleImages will be used in the GetMessageBubbleImageData override var bubbleFactory = new MessagesBubbleImageFactory (); outgoingBubbleImageData = bubbleFactory.CreateOutgoingMessagesBubbleImage (UIColorExtensions.MessageBubbleLightGrayColor); incomingBubbleImageData = bubbleFactory.CreateIncomingMessagesBubbleImage (UIColorExtensions.MessageBubbleBlueColor); // Remove the AccessoryButton as we will not be sending pics InputToolbar.ContentView.LeftBarButtonItem = null; // Remove the Avatars CollectionView.CollectionViewLayout.IncomingAvatarViewSize = CoreGraphics.CGSize.Empty; CollectionView.CollectionViewLayout.OutgoingAvatarViewSize = CoreGraphics.CGSize.Empty; // Load some messages to start messages.Add (new Message (friend.Id, friend.DisplayName, NSDate.DistantPast, "Hi There")); // messages.Add (new Message (friend.Id, friend.DisplayName, NSDate.DistantPast, "I'm sorry, my responses are limited. You must ask the right questions.")); //we use this to generate random messages Timer timer = new Timer(2000); timer.Elapsed += async ( sender, e ) => await HandleTimer(); timer.Start(); // Remove the Avatars //CollectionView.CollectionViewLayout.IncomingAvatarViewSize = CoreGraphics.CGSize.Empty; //CollectionView.CollectionViewLayout.OutgoingAvatarViewSize = CoreGraphics.CGSize.Empty; }
/// <summary> /// Starts the thread that will create a conversation if there is none, or get the conversation that exists. /// </summary> public override void ViewDidLoad () { base.ViewDidLoad (); contact = new User () { phoneNumber = abContact.GetPhones ().GetValues() [0], name = (abContact.FirstName +" "+ abContact.LastName) }; //We start the thread. It won't run forever. var ThreadRequest = new Thread(DoRequest); ThreadRequest.Start (); Title = contact.name; // You must set your senderId and display name SenderId = myPhoneNumber; SenderDisplayName = myName; // These MessagesBubbleImages will be used in the GetMessageBubbleImageData override var bubbleFactory = new MessagesBubbleImageFactory (); outgoingBubbleImageData = bubbleFactory.CreateOutgoingMessagesBubbleImage (UIColorExtensions.MessageBubbleLightGrayColor); incomingBubbleImageData = bubbleFactory.CreateIncomingMessagesBubbleImage (UIColorExtensions.MessageBubbleBlueColor); // Remove the Avatars CollectionView.CollectionViewLayout.IncomingAvatarViewSize = CoreGraphics.CGSize.Empty; CollectionView.CollectionViewLayout.OutgoingAvatarViewSize = CoreGraphics.CGSize.Empty; }
public override void ViewDidLoad () { base.ViewDidLoad (); //Title = "Xamarin Chat"; this.NavigationItem.HidesBackButton = true; // You must set your senderId and display name SenderId = sender.Id; SenderDisplayName = sender.DisplayName; UIView navView = new UIView (new CoreGraphics.CGRect (0.0,64, UIScreen.MainScreen.Bounds.Width, 64)); UIView backButtonView = new UIView (new CoreGraphics.CGRect (0.0,0, UIScreen.MainScreen.Bounds.Width, 20)); UIView userInfoView = new UIView (new CoreGraphics.CGRect (0.0,20, UIScreen.MainScreen.Bounds.Width, 44)); chatView.Frame = new CGRect(50.0f, 64f, UIScreen.MainScreen.Bounds.Width-50, UIScreen.MainScreen.Bounds.Height-64); UILabel titleLabel = new UILabel (new CoreGraphics.CGRect ((UIScreen.MainScreen.Bounds.Width - 200) / 2, 5, 200, 20)); UIButton carButton = new UIButton (new CoreGraphics.CGRect (UIScreen.MainScreen.Bounds.Width - 50, 5, 30, 30)); navView.BackgroundColor = UIColor.Clear; // backButtonView.BackgroundColor = UIColor.Red; UIButton backButton = new UIButton (new CoreGraphics.CGRect (0.0,3, 120, 14)); backButton.SetTitle ("Conversation", UIControlState.Normal); backButton.SetImage (UIImage.FromFile ("nav_Back.png"), UIControlState.Normal); backButton.SetTitleColor (UIColor.Black, UIControlState.Normal); backButton.Font = UIFont.SystemFontOfSize (12.0f); backButtonView.AddSubview (backButton); backButton.TouchUpInside += (object sender, EventArgs e) => { if(UserInterfaceIsPhone) this.NavigationController.PopViewController(true); }; userInfoView.BackgroundColor = UIColor.DarkGray; UIButton available = new UIButton (new CoreGraphics.CGRect (15, 15, 15, 15)); available.SetImage (UIImage.FromFile ("Available.png"), UIControlState.Normal); carButton.SetImage (UIImage.FromFile ("imgtexi.png"), UIControlState.Normal); carButton.TouchUpInside += (object sender, EventArgs e) => { List<ContactData> ContactList; ContactList = ContactData.getContact (); UITableView rightsidemenu = new UITableView(new CGRect(0.0f, 0.0f, chatView.Frame.Width, chatView.Frame.Height)); var TableViewSource = new TSChatTableSource (); rightsidemenu.BackgroundColor = UIColor.Yellow; rightsidemenu.Source = TableViewSource; rightsidemenu.ReloadData (); chatView.Add(rightsidemenu); this.View.AddSubview(chatView); }; titleLabel.Text = "John Anderson"; titleLabel.TextAlignment = UITextAlignment.Center; titleLabel.TextColor = UIColor.Orange; userInfoView.AddSubview (available); userInfoView.AddSubview (carButton); userInfoView.AddSubview (titleLabel); navView.AddSubview (backButtonView); navView.AddSubview (userInfoView); this.View.AddSubview(navView); // These MessagesBubbleImages will be used in the GetMessageBubbleImageData override var bubbleFactory = new MessagesBubbleImageFactory (); outgoingBubbleImageData = bubbleFactory.CreateOutgoingMessagesBubbleImage (UIColorExtensions.MessageBubbleLightGrayColor); incomingBubbleImageData = bubbleFactory.CreateIncomingMessagesBubbleImage (UIColorExtensions.MessageBubbleBlueColor); // Remove the AccessoryButton as we will not be sending pics InputToolbar.ContentView.LeftBarButtonItem = null; // Remove the Avatars CollectionView.CollectionViewLayout.IncomingAvatarViewSize = CoreGraphics.CGSize.Empty; CollectionView.CollectionViewLayout.OutgoingAvatarViewSize = CoreGraphics.CGSize.Empty; // Load some messagees to start messages.Add (new Message (sender.Id, sender.DisplayName, NSDate.DistantPast, "Hi There")); messages.Add (new Message (friend.Id, friend.DisplayName, NSDate.DistantPast, "I'm sorry, my responses are limited. You must ask the right questions.")); }