public static void AsyncPost(string url, string Parameters, PostBack Callback) { System.Threading.Thread ap = new System.Threading.Thread(new System.Threading.ThreadStart(() => { try { var req = System.Net.WebRequest.Create(url); req.ContentType = "application/x-www-form-urlencoded"; req.Method = "POST"; byte[] bytes = System.Text.Encoding.ASCII.GetBytes(Parameters); req.ContentLength = bytes.Length; System.IO.Stream os = req.GetRequestStream(); os.Write(bytes, 0, bytes.Length); os.Close(); System.Threading.Thread.Sleep(100); System.Net.WebResponse resp = req.GetResponse(); if (resp == null) { Callback?.Invoke("nodata"); } var sr = new System.IO.StreamReader(resp.GetResponseStream()); Callback?.Invoke(sr.ReadToEnd().Trim()); sr.Close(); } catch { Callback?.Invoke("error"); } })); ap.Start(); }
public View Render() { StackLayout stackLayout = new StackLayout() { Margin = new Thickness(5) }; View = stackLayout; if (!string.IsNullOrWhiteSpace(Label)) { Label label = new Label { Text = Label, Margin = new Thickness(5, 0, 0, 0), FontAttributes = FontAttributes.Bold }; if (ElementTextColor != null) { label.TextColor = ElementTextColor; } stackLayout.Children.Add(label); } entry = new Entry() { Text = Value, Keyboard = (Keyboard) new KeyboardTypeConverter().ConvertFromInvariantString(Keyboard ?? "Default") }; if (Required) { entry.Placeholder = "(Required)"; } stackLayout.Children.Add(entry); if (ElementBackgroundColor != null) { entry.BackgroundColor = ElementBackgroundColor; } if (ElementTextColor != null) { entry.TextColor = ElementTextColor; } entry.TextChanged += (s, e) => { if (AutoPostBack) { PostBack?.Invoke(s, Key); } }; AttributeHelper.ApplyTranslation(entry, Attributes); return(View); }
public View Render() { StackLayout stackLayout = new StackLayout() { Margin = new Thickness(5) }; if (!string.IsNullOrWhiteSpace(Label)) { Label label = new Label { Text = Label, Margin = new Thickness(5, 0, 0, 5), FontAttributes = FontAttributes.Bold }; if (ElementTextColor != null) { label.TextColor = ElementTextColor; } stackLayout.Children.Add(label); } datePicker = new DatePicker(); stackLayout.Children.Add(datePicker); if (ElementBackgroundColor != null) { datePicker.BackgroundColor = ElementBackgroundColor; } if (ElementTextColor != null) { datePicker.TextColor = ElementTextColor; } datePicker.DateSelected += (s, e) => { if (AutoPostBack) { PostBack?.Invoke(s, Key); } }; View = stackLayout; return(View); }
public View Render() { StackLayout stackLayout = new StackLayout() { Margin = new Thickness(5) }; if (!string.IsNullOrWhiteSpace(Label)) { Label label = new Label { Text = Label, Margin = new Thickness(5, 0, 0, 0), FontAttributes = FontAttributes.Bold }; if (ElementTextColor != null) { label.TextColor = ElementTextColor; } stackLayout.Children.Add(label); } editor = new Editor() { Keyboard = (Keyboard) new KeyboardTypeConverter().ConvertFromInvariantString(Keyboard ?? "Default"), HeightRequest = HeightRequest }; stackLayout.Children.Add(editor); if (ElementBackgroundColor != null) { editor.BackgroundColor = ElementBackgroundColor; } editor.TextChanged += (s, e) => { if (AutoPostBack) { PostBack?.Invoke(s, Key); } }; View = stackLayout; return(View); }
public View Render() { // In Xamarin pickers (aka dropdown list) are just a list of options // We need to have a key value type list to work with Rock // So the strat is to swap keys and values // and insure no two values are the same foreach (var pair in Options) { var optionKey = pair.Value; var counter = 1; while (optionList.Contains(optionKey)) { optionKey = string.Format("{0} ({1})", pair.Value, counter); counter++; } optionList.Add(optionKey); reversedOptions.Add(optionKey, pair.Key); } StackLayout stackLayout = new StackLayout() { Margin = new Thickness(5) }; View = stackLayout; if (!string.IsNullOrWhiteSpace(Label)) { Label label = new Label { Text = Label, Margin = new Thickness(5, 0, 0, 0), FontAttributes = FontAttributes.Bold }; if (ElementTextColor != null) { label.TextColor = ElementTextColor; } stackLayout.Children.Add(label); } picker = new Picker() { ItemsSource = optionList, }; if (Required) { picker.Title = "(Required)"; } stackLayout.Children.Add(picker); if (ElementBackgroundColor != null) { picker.BackgroundColor = ElementBackgroundColor; } if (ElementTextColor != null) { picker.TextColor = ElementTextColor; } picker.Unfocused += (s, e) => { if (AutoPostBack && ((string)picker.SelectedItem) != originalValue) { PostBack?.Invoke(s, Key); } }; return(View); }