hercioneto

TA-2017 TelaApp

Oct 2nd, 2017
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 6.61 KB | None | 0 0
  1. MainPage.xaml.cs
  2.  
  3.  
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using Xamarin.Forms;
  10.  
  11. namespace TelaApp
  12. {
  13.     public partial class MainPage : ContentPage
  14.  
  15.     {
  16.         public Color BoxColor { get; set; }
  17.         public Keyboard KeyboardPersonalizado { get; set; }
  18.         public TimeSpan TimeSpan { get; set; }
  19.  
  20.  
  21.         public MainPage()
  22.         {
  23.             InitializeComponent();
  24.             BoxColor = Color.FromRgb(200, 100, 100);
  25.             TimeSpan = new TimeSpan(22, 35, 00);
  26.             KeyboardPersonalizado = Keyboard.Email;
  27.             BindingContext = this;
  28.         }
  29.         private void NewEntryTextoModificado(object sender, TextChangedEventArgs textChangedEventArgs)
  30.         {
  31.             var texto = textChangedEventArgs.NewTextValue;
  32.             System.Diagnostics.Debug.WriteLine("texto modificado " + texto);
  33.         }
  34.  
  35.         private void NewEntryTextoCompleto(object sender, EventArgs eventArgs)
  36.         {
  37.             var texto = entryUm.Text;
  38.             System.Diagnostics.Debug.WriteLine("texto concluído " + texto);
  39.         }
  40.         private void NewButtonClicado(object sender, EventArgs eventArgs)
  41.         {
  42.             var valor = entryUm.Text.ToString();
  43.             System.Diagnostics.Debug.WriteLine("Botão clicado! " + valor + " ??");
  44.         }
  45.         private void Editor_OnCompleted(object sender, EventArgs e)
  46.         {
  47.             System.Diagnostics.Debug.WriteLine("texto completo");
  48.         }
  49.  
  50.         private void Editor_OnTextChanged(object sender, TextChangedEventArgs e)
  51.         {
  52.             System.Diagnostics.Debug.WriteLine("texto editado");
  53.         }
  54.         private void Slider_OnValueChanged(object sender, ValueChangedEventArgs e)
  55.         {
  56.             System.Diagnostics.Debug.WriteLine("Valor antigo era " + e.OldValue);
  57.             System.Diagnostics.Debug.WriteLine("Valor novo é " + e.NewValue);
  58.         }
  59.         private void Stepper_OnValueChanged(object sender, ValueChangedEventArgs e)
  60.         {
  61.             System.Diagnostics.Debug.WriteLine("valor antigo era " + e.OldValue);
  62.             System.Diagnostics.Debug.WriteLine("Novo valor é " + e.NewValue);
  63.         }
  64.         private void Switch_OnToggled(object sender, ToggledEventArgs e)
  65.         {
  66.             System.Diagnostics.Debug.WriteLine("Status atual do switch: " + e.Value);
  67.         }
  68.         private void SearchBar_OnTextChanged(object sender, TextChangedEventArgs e)
  69.         {
  70.             System.Diagnostics.Debug.WriteLine("Texto que estava no elemento: " + e.OldTextValue);
  71.             System.Diagnostics.Debug.WriteLine("Texto que está no elemento: " + e.NewTextValue);
  72.         }
  73.  
  74.         private void SearchBar_OnSearchButtonPressed(object sender, EventArgs e)
  75.         {
  76.             System.Diagnostics.Debug.WriteLine("Texto no elemento: " + ((SearchBar)sender).Text);
  77.         }
  78.         private void DatePicker_OnDateSelected(object sender, DateChangedEventArgs e)
  79.         {
  80.             System.Diagnostics.Debug.WriteLine($"Data antiga: {e.OldDate.ToString("yy-MM-dd")}");
  81.             System.Diagnostics.Debug.WriteLine($"Data nova: {e.NewDate.ToString("yy-MM-dd")}");
  82.         }
  83.         private void Picker_OnSelectedIndexChanged(object sender, EventArgs e)
  84.         {
  85.             System.Diagnostics.Debug.WriteLine($"Índice escolhido do picker: {((Picker)sender).SelectedIndex}");
  86.             System.Diagnostics.Debug.WriteLine($"Elemento escolhido do picker: {((Picker)sender).Items[((Picker)sender).SelectedIndex]}");
  87.         }
  88.     }
  89. }
  90.  
  91. --------------------------------
  92.  
  93. MainPage.xaml
  94.  
  95. <?xml version="1.0" encoding="utf-8" ?>
  96. <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
  97. xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
  98. xmlns:local="clr-namespace:TelaApp"
  99. x:Class="NovoApp.MainPage">
  100.     <ScrollView>
  101.     <StackLayout
  102. HorizontalOptions="Center"
  103. VerticalOptions="Center">
  104.         <Label Text="Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet. Finish"
  105. LineBreakMode="WordWrap"
  106. VerticalOptions="Center"
  107. HorizontalOptions="Center"
  108. FontSize="15"          
  109. TextColor="#c864c8"/>
  110.         <Label Text="Label 2. Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet."
  111. LineBreakMode="WordWrap"
  112. VerticalOptions="Center"
  113. HorizontalOptions="Center"
  114. FontSize="15"
  115. TextColor="#999"/>
  116.         <Entry HorizontalOptions="FillAndExpand"
  117.                x:Name="entryUm"
  118. VerticalOptions="Center"
  119. Placeholder="Digite o texto aqui"
  120. Completed="NewEntryTextoCompleto"
  121. TextChanged="NewEntryTextoModificado"
  122. Keyboard="{Binding KeyboardPersonalizado}" />
  123.         <Button Text="Meu Botao"
  124. HorizontalOptions="FillAndExpand"
  125. VerticalOptions="Center"
  126. Clicked="NewButtonClicado" />
  127.         <Editor
  128. FontSize="35"
  129. FontAttributes="Italic"
  130. Text="teste"
  131. Completed="Editor_OnCompleted"
  132. TextChanged="Editor_OnTextChanged"
  133. />
  134.         <ActivityIndicator
  135. VerticalOptions="Center"
  136. HorizontalOptions="Center"
  137. IsRunning="True"
  138. IsVisible="True" />
  139.         <BoxView
  140. VerticalOptions = "Center"
  141. HorizontalOptions="Center"
  142. WidthRequest="200"
  143. HeightRequest="350"
  144. Color ="{Binding BoxColor}"/>
  145.         <ProgressBar
  146. Progress="0.5"
  147. HorizontalOptions="Fill"
  148. VerticalOptions="Center"
  149. />
  150.         <Slider
  151. Minimum="0"
  152. Maximum="125"
  153. VerticalOptions="Center"
  154. HorizontalOptions="Fill"
  155. Value="57"
  156. ValueChanged="Slider_OnValueChanged"
  157. />
  158.         <Switch
  159. HorizontalOptions="Center"
  160. VerticalOptions="Center"
  161. IsToggled="True"
  162. Toggled="Switch_OnToggled"
  163. />
  164.         <Stepper
  165. Maximum="10"
  166. Minimum="1"
  167. Increment="0.4"
  168. Value="5"
  169. VerticalOptions="Center"
  170. HorizontalOptions="Center"
  171. ValueChanged="Stepper_OnValueChanged"
  172. />
  173.         <SearchBar
  174. HorizontalOptions="Fill"
  175. VerticalOptions="Center"
  176. CancelButtonColor="Black"
  177. Placeholder="Digite o termo de busca"
  178. PlaceholderColor="Green"
  179. FontSize="25"
  180. FontAttributes="Bold"
  181. TextChanged="SearchBar_OnTextChanged"
  182. SearchButtonPressed="SearchBar_OnSearchButtonPressed"
  183. />
  184.         <TimePicker
  185. VerticalOptions="Center"
  186. HorizontalOptions="Fill"
  187. Time="{Binding TimeSpan}"
  188. Format="HH:mm"
  189. />
  190.         <DatePicker
  191. MinimumDate="2016/01/01"
  192. MaximumDate="2016/01/31"
  193. Format="yyyy/MM/dd"
  194. HorizontalOptions="Fill"
  195. VerticalOptions="Center"
  196. DateSelected="DatePicker_OnDateSelected"
  197. />
  198.         <Picker
  199. VerticalOptions="Center"
  200. HorizontalOptions="Fill"
  201. SelectedIndexChanged="Picker_OnSelectedIndexChanged">
  202.             <Picker.Items>
  203.                 <x:String>Opção 1</x:String>
  204.                 <x:String>Opção 2</x:String>
  205.                 <x:String>Opção 3</x:String>
  206.             </Picker.Items>
  207.         </Picker>
  208.     </StackLayout>
  209.     </ScrollView>
  210. </ContentPage>
Advertisement
Add Comment
Please, Sign In to add comment