-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainPage.xaml.cs
123 lines (115 loc) · 3.77 KB
/
MainPage.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using System.Threading;
using System.Threading.Tasks;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
//Szablon elementu Pusta strona jest udokumentowany na stronie https://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x415
namespace Sasinator
{
/// <summary>
/// Pusta strona, która może być używana samodzielnie lub do której można nawigować wewnątrz ramki.
/// </summary>
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
}
bool tryb = false;
private async void Button_Click(object sender, RoutedEventArgs e)
{
double sasiny = 0;
if (String.IsNullOrEmpty(Liczba.Text))
{
Sasin.PlaceholderText = "Wpisz poprawną liczbę";
}
else if (tryb == false)
{
int test;
if (!int.TryParse(Liczba.Text, out test))
{
Sasin.PlaceholderText = "Wpisz poprawną liczbę";
}
else
{
sasiny = Int64.Parse(Liczba.Text);
czysto();
Progress.Visibility = Visibility.Visible;
for (int i = 1; i <= 100; i++)
{
Progress.Value = Progress.Value + 1;
await Task.Delay(5);
}
sasiny = sasiny / 70000000;
sasiny = Math.Round(sasiny, 13);
Progress.Value = 100;
Sasin.Text = sasiny.ToString("F13");
await Task.Delay(250);
Progress.Visibility = Visibility.Collapsed;
Progress.Value = 0;
}
}
else if (tryb == true)
{
double test;
if (!double.TryParse(Liczba.Text, out test))
{
Sasin.PlaceholderText = "Wpisz poprawną liczbę";
}
else
{
sasiny = Double.Parse(Liczba.Text);
czysto();
Progress.Visibility = Visibility.Visible;
for (int i = 1; i <= 100; i++)
{
Progress.Value = Progress.Value + 1;
await Task.Delay(5);
}
sasiny = sasiny * 70000000;
sasiny = Math.Round(sasiny, 0);
Progress.Value = 100;
Sasin.Text = sasiny.ToString();
await Task.Delay(250);
Progress.Visibility = Visibility.Collapsed;
Progress.Value = 0;
}
}
}
private void Zmiana_Click(object sender, RoutedEventArgs e)
{
tryb = !tryb;
if(tryb == false)
{
znak.Text = "=";
jednostka.Text = "sasina";
}
else
{
znak.Text = "sasinów = ";
jednostka.Text = "";
}
czysto();
}
void czysto()
{
Sasin.Text = "";
Sasin.PlaceholderText = "";
}
private void Liczba_GotFocus(object sender, RoutedEventArgs e)
{
Liczba.Text = "";
}
}
}