APP FINAL
Carlos Heredia 21-MIST-6-018
Sección: 713
Código Paginaprincipal.xaml
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="APKFINAL.Diseño.Paginaprincipal"
NavigationPage.HasNavigationBar="False">
<ContentPage.Content>
<StackLayout Orientation="Vertical"
BackgroundColor="Aquamarine">
<Label Text="Calcula tu peso"
FontSize="35"
FontAttributes="Bold"
Margin="0,20,0,0"
HorizontalOptions="Center" />
<Frame VerticalOptions="FillAndExpand"
Margin="40"
CornerRadius="20">
<StackLayout VerticalOptions="Center"
Spacing="10">
<Image
Source="https://hiraoka.com.pe/media/mageplaza/blog/post/c/o/c
omo_usar_una_balanza_para_conocer_mi_peso_ideal_1.jpg" />
<Label Text="KG a LB y LB a KG"
FontAttributes="Bold"
HorizontalOptions="Center"
FontSize="20" />
<Button Text="Calcular de KG a LB"
TextTransform="None"
BackgroundColor="GreenYellow"
CornerRadius="15"
FontSize="Medium"
FontAttributes="Bold"
x:Name="btnkgalb"
Clicked="btnkgalb_Clicked"/>
<Button Text="Calcular de LB a KG"
TextTransform="None"
BackgroundColor="GreenYellow"
CornerRadius="15"
FontSize="Medium"
FontAttributes="Bold"
x:Name="btnlbakg"
Clicked="btnlbakg_Clicked"/>
<Button Text="Salir"
TextTransform="None"
BackgroundColor="GreenYellow"
CornerRadius="15"
FontSize="Medium"
FontAttributes="Bold"
x:Name="btnsalir"
Clicked="btnsalir_Clicked"
Margin="0,30,0,0"/>
</StackLayout>
</Frame>
</StackLayout>
</ContentPage.Content>
</ContentPage>
Codigo paginaprincipal.xaml.cs
namespace APKFINAL.Diseño
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class Paginaprincipal : ContentPage
{
public Paginaprincipal()
{
InitializeComponent();
}
private async void btnkgalb_Clicked(object sender,
EventArgs e)
{
await Navigation.PushAsync(new KGALB());
}
private async void btnlbakg_Clicked(object sender,
EventArgs e)
{
await Navigation.PushAsync(new LBAKG());
}
private void btnsalir_Clicked(object sender, EventArgs
e)
{
System.Environment.Exit(0);
}
}
}
Diseño
Código KGLAB.xaml
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="APKFINAL.Diseño.KGALB"
NavigationPage.HasNavigationBar="False">
<Grid BackgroundColor="MediumAquamarine">
<StackLayout VerticalOptions="Center"
Margin="20"
Spacing="10">
<Image
Source="https://i.postimg.cc/CKQjXJBq/balanza.png"/>
<Frame CornerRadius="25">
<Entry Keyboard="Numeric"
Placeholder="Kilogramos (KG)"
FontSize="Medium"
x:Name="txtkg"/>
</Frame>
<Button Text="Procesar"
FontAttributes="Bold"
FontSize="Large"
CornerRadius="20"
TextTransform="None"
BackgroundColor="DarkSlateGray"
TextColor="Aquamarine"
x:Name="btnprocesar"
Clicked="btnprocesar_Clicked"/>
<StackLayout Orientation="Horizontal">
<Label Text="Resultado:"
FontSize="Large"
FontAttributes="Bold"
VerticalOptions="Center"/>
<Label Text="0"
FontSize="Large"
FontAttributes="Bold"
VerticalOptions="Center"
x:Name="lblres"/>
</StackLayout>
<Button Text="Limpiar"
TextTransform="None"
FontSize="Large"
FontAttributes="Bold"
CornerRadius="20"
BackgroundColor="DarkSlateGray"
TextColor="Aquamarine"
x:Name="btnlimpiar"
Clicked="btnlimpiar_Clicked" />
<Button Text="Regresar"
TextTransform="None"
FontSize="Large"
FontAttributes="Bold"
CornerRadius="20"
BackgroundColor="DarkSlateGray"
TextColor="Aquamarine"
x:Name="btnregresar"
Clicked="btnregresar_Clicked"/>
</StackLayout>
</Grid>
</ContentPage>
Codigo KGLAB.xaml.cs
namespace APKFINAL.Diseño
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class KGALB : ContentPage
{
double kg;
double lb;
public KGALB()
{
InitializeComponent();
}
private void DECISION()
{
kg = Convert.ToDouble(txtkg.Text);
lb = kg * 2.20462;
lblres.Text= lb.ToString() + " lbs";
}
private void CONFIRMACION()
{
if (!string.IsNullOrEmpty(txtkg.Text))
{
DECISION();
}
else
{
DisplayAlert("Error", "Debe ingresar su peso",
"Aceptar");
}
}
private void btnregresar_Clicked(object sender,
EventArgs e)
{
Navigation.PopAsync();
}
private void btnprocesar_Clicked(object sender,
EventArgs e)
{
CONFIRMACION();
}
private void btnlimpiar_Clicked(object sender,
EventArgs e)
{
lblres.Text = "";
txtkg.Text = "";
}
}
}
Código LBAKG.xaml
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="APKFINAL.Diseño.LBAKG"
NavigationPage.HasNavigationBar="False">
<Grid BackgroundColor="DarkSlateGray">
<StackLayout VerticalOptions="Center"
Margin="20"
Spacing="10">
<Image
Source="https://i.postimg.cc/CKQjXJBq/balanza.png" />
<Frame CornerRadius="25">
<Entry Keyboard="Numeric"
Placeholder="Libras (LB)"
FontSize="Medium"
x:Name="txtlb"/>
</Frame>
<Button Text="Procesar"
FontAttributes="Bold"
FontSize="Large"
CornerRadius="20"
TextTransform="None"
BackgroundColor="MediumAquamarine"
TextColor="Gray"
x:Name="btnprocesar"
Clicked="btnprocesar_Clicked"/>
<StackLayout Orientation="Horizontal">
<Label Text="Resultado:"
FontSize="Large"
FontAttributes="Bold"
VerticalOptions="Center" />
<Label Text="0"
FontSize="Large"
FontAttributes="Bold"
VerticalOptions="Center"
x:Name="lblres"/>
</StackLayout>
<Button Text="Limpiar"
TextTransform="None"
FontSize="Large"
FontAttributes="Bold"
CornerRadius="20"
BackgroundColor="MediumAquamarine"
TextColor="Gray"
x:Name="btnlimpiar"
Clicked="btnlimpiar_Clicked" />
<Button Text="Regresar"
TextTransform="None"
FontSize="Large"
FontAttributes="Bold"
CornerRadius="20"
BackgroundColor="MediumAquamarine"
TextColor="Gray"
x:Name="btnback"
Clicked="btnback_Clicked" />
</StackLayout>
</Grid>
</ContentPage>
Código LBAKG.xaml.cs
namespace APKFINAL.Diseño
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class LBAKG : ContentPage
{
double lb;
double kg;
public LBAKG()
{
InitializeComponent();
}
private void DECISION()
{
lb = Convert.ToDouble(txtlb.Text);
kg = lb / 2.20462;
lblres.Text = kg.ToString() + " kg";
}
private void CONFIRMACION()
{
if (!string.IsNullOrEmpty(txtlb.Text))
{
DECISION();
}
else
{
DisplayAlert("Error", "Debe ingresar su peso",
"Aceptar");
}
}
private void btnback_Clicked(object sender, EventArgs
e)
{
Navigation.PopAsync();
}
private void btnprocesar_Clicked(object sender,
EventArgs e)
{
CONFIRMACION();
}
private void btnlimpiar_Clicked(object sender,
EventArgs e)
{
lblres.Text = "";
txtlb.Text = "";
}
}
}
Resultado
De KG a LIBRA
De LIBRA a KG
Al darle sin agregar nada sale esta advertencia