public KaazingDemoLoginPage(KaazingJMSDemoController controller) { _controller = controller; #region Set some properties on the Page Padding = new Thickness(20); Title = "Login"; HeightRequest = 200; WidthRequest = 400; #endregion #region Create some Entry controls to capture username and password. Entry loginInput = new Entry { Placeholder = "User Name" }; loginInput.SetBinding(Entry.TextProperty, "UserName"); loginInput.Focus(); Entry passwordInput = new Entry { IsPassword = true, Placeholder = "Password" }; passwordInput.SetBinding(Entry.TextProperty, "Password"); #endregion #region Create a button to login with Button loginButton = new Button { Text = "Login", BorderRadius = 5, TextColor = Color.White, BackgroundColor = Colours.BackgroundGrey }; loginButton.SetBinding(BackgroundColorProperty, new Binding("LoginButtonColour")); loginButton.Command = new Command(o => { _controller.SetUsernameAndPassword(loginInput.Text, passwordInput.Text); this.Navigation.PopModalAsync(); }); loginInput.Focus(); #endregion Content = new StackLayout { VerticalOptions = LayoutOptions.Center, Children = { loginInput, passwordInput, loginButton }, Spacing = 10, }; }
public KaazingJMSDemoPage() { _controller = new KaazingJMSDemoController(this); Title = "KaazingJMSXamarinDemo"; BackgroundColor = Color.FromRgb(255, 140, 0); uriEntry = new Entry { HorizontalOptions = LayoutOptions.FillAndExpand, MinimumHeightRequest = 5, HeightRequest = 5, Text = "ws://localhost:8001/jms", //Text = "ws://192.168.0.109:8001/jms", }; uriEntry.Focus(); destinationEntry = new Entry { HorizontalOptions = LayoutOptions.FillAndExpand, HeightRequest = 8, Text = "/topic/destination" }; messageEntry = new Entry { HorizontalOptions = LayoutOptions.FillAndExpand, HeightRequest = 8, Text = "Hello Kaazing!" }; connectButton = new Button { Text = "Connect", BindingContext = this, }; connectButton.Clicked += _controller.ConnectOrDisconnect; subscribeButton = new Button { Text = "Subscribe", BindingContext = this, }; subscribeButton.Clicked += _controller.Subscribe; sendButton = new Button { Text = "Send", BindingContext = this, }; sendButton.Clicked += _controller.SendMessage; clearButton = new Button { Text = "Clear", BindingContext = this, }; clearButton.Clicked += _controller.ClearLog; logLabel = new Label { HorizontalOptions = LayoutOptions.Start, VerticalOptions = LayoutOptions.End, TextColor = Color.Black }; // Create a grid to hold the Labels & Entry controls. Grid inputGrid = new Grid { ColumnDefinitions = { new ColumnDefinition { Width = GridLength.Auto }, new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }, }, Children = { { new Label { Text = "URI:", XAlign = TextAlignment.End, Font = Fonts.SmallTitle, TextColor = Colours.SubTitle },0,0 }, { new Label { Text = "Destination:", XAlign = TextAlignment.End, Font = Fonts.SmallTitle, TextColor = Colours.SubTitle }, 0,1 }, { new Label { Text = "Message: ", XAlign = TextAlignment.End, Font = Fonts.SmallTitle, TextColor = Colours.SubTitle },0, 2 }, { uriEntry, 1, 0 }, { destinationEntry, 1, 1 }, { messageEntry, 1, 2 }, { connectButton, 3, 0}, { subscribeButton, 3, 1}, { sendButton, 3, 2} } }; inputGrid.Padding = new Thickness(10); var logView = new ScrollView { Content = new StackLayout { Padding = new Thickness(5), BackgroundColor = Color.White, Children = { logLabel } }, VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.Fill, Orientation = ScrollOrientation.Vertical, BackgroundColor = Color.White }; var relativeLayout = new RelativeLayout { VerticalOptions = LayoutOptions.End, HorizontalOptions = LayoutOptions.End, HeightRequest = 40 }; relativeLayout.Children.Add(clearButton, Constraint.RelativeToParent((parent) => { return parent.Width - 60; }), Constraint.RelativeToParent((parent) => { return 0; })); Content = new StackLayout { Children = { inputGrid, logView, relativeLayout } }; EnableUI(false); }
/// <summary> /// constructor /// <para>pass in main form for callback</para> /// </summary> /// <param name="form"></param> public KaazingDemoLoginHandler(KaazingJMSDemoController controller) { _controller = controller; }