Niestety, nikt nie powie Ci czym jest FluxBB - musisz go poznać sam!
Nie jesteś zalogowany na forum.
Strony: 1
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:Przyklad1"
x:Class="Przyklad1.MainPage">
<ContentPage.Content>
<StackLayout>
<Entry x:Name="entryNazwisko"/>
<Entry x:Name="entryImie"/>
<Entry x:Name="entryEmail"/>
<Button x:Name="buttonZaładujRekord"
Text="Załaduj rekord"
Clicked="clickedZaladujRekord"/>
</StackLayout>
</ContentPage.Content>
</ContentPage>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
using System.Reflection;
using System.IO;namespace Przyklad1
{
public partial class MainPage : ContentPage
{private StreamReader reader;
public MainPage()
{
InitializeComponent();var assembly = IntrospectionExtensions.GetTypeInfo(typeof(MainPage)).Assembly;
Stream stream = assembly.GetManifestResourceStream("Przyklad1.Pliki.kontakty.txt");
reader = new System.IO.StreamReader(stream);if (reader.Peek() >= 0)
{
string tekst = reader.ReadLine();wyswietlaDane(tekst);
}
else
DisplayAlert("UWAGA !!", "Brak danych do wyświetlenia", "OK");}
private void clickedZaladujRekord(object sender, EventArgs e)
{
if (reader.Peek() >= 0)
{
string tekst = reader.ReadLine();wyswietlaDane(tekst);
}
else
DisplayAlert("UWAGA !!", "Brak danych do wyświetlenia", "OK");}
private void wyswietlaDane(string wiersz)
{
string[] wierszPodzielony = wiersz.Split(';');entryNazwisko.Text = wierszPodzielony[0];
entryImie.Text = wierszPodzielony[1];
entryEmail.Text = wierszPodzielony[2];
}}
}
Wiadomość dodana po 06 min 20 s:
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:Przyklad3"
x:Class="Przyklad3.MainPage">
<ContentPage.Content>
<StackLayout>
<Entry x:Name="input"/>
<StackLayout Orientation="Horizontal"
HorizontalOptions="Center">
<Button x:Name="buttonZapisz"
Text="Save"
Clicked="clickedSave"/>
<Button x:Name="buttonOdczytaj"
Text="Load"
Clicked="clickedLoad"/>
</StackLayout>
<Entry x:Name="output"/>
</StackLayout>
</ContentPage.Content>
</ContentPage>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
using PCLStorage;
namespace Przyklad3
{
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
}
private async void clickedSave(object sender, EventArgs e)
{
IFolder rootFolder = FileSystem.Current.LocalStorage;
IFile file = await rootFolder.CreateFileAsync("Dane.txt",
CreationCollisionOption.ReplaceExisting);
await file.WriteAllTextAsync(input.Text);
}
private async void clickedLoad(object sender, EventArgs e)
{
var file = await FileSystem.Current.LocalStorage.GetFileAsync("Dane.txt");
output.Text = await file.ReadAllTextAsync();
}
}
}
Offline
Strony: 1