-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathAboutPage.xaml.cs
160 lines (148 loc) · 5.88 KB
/
AboutPage.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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Controls.Primitives;
using System.Windows.Navigation;
using Microsoft.Phone.Tasks;
using Microsoft.Phone.Controls;
using System.Windows.Resources;
namespace sbbs_client_wp7
{
public partial class AboutPage : PhoneApplicationPage
{
private StackPanel _licenses;
public AboutPage()
{
InitializeComponent();
}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
Uri manifest = new Uri("WMAppManifest.xml", UriKind.Relative);
var si = Application.GetResourceStream(manifest);
if (si != null)
{
using (StreamReader sr = new StreamReader(si.Stream))
{
bool haveApp = false;
while (!sr.EndOfStream)
{
string line = sr.ReadLine();
if (!haveApp)
{
int i = line.IndexOf("AppPlatformVersion=\"", StringComparison.InvariantCulture);
if (i >= 0)
{
haveApp = true;
line = line.Substring(i + 20);
int z = line.IndexOf("\"");
if (z >= 0)
{
// if you're interested in the app plat version at all
// AppPlatformVersion = line.Substring(0, z);
}
}
}
int y = line.IndexOf("Version=\"", StringComparison.InvariantCulture);
if (y >= 0)
{
int z = line.IndexOf("\"", y + 9, StringComparison.InvariantCulture);
if (z >= 0)
{
// We have the version, no need to read on.
VersionText.Text = line.Substring(y + 9, z - y - 9);
break;
}
}
}
}
}
else
{
VersionText.Text = "Unknown";
}
}
private void HyperlinkButton_Click(object sender, RoutedEventArgs e)
{
string s = ((ButtonBase)sender).Tag as string;
switch (s)
{
case "Review":
var task = new MarketplaceReviewTask();
task.Show();
break;
case "Email":
EmailComposeTask emailTask = new EmailComposeTask();
emailTask.To = ((ButtonBase)sender).Content.ToString();
emailTask.Subject = "定制Windows Phone应用";
emailTask.Show();
break;
case "Phone":
SmsComposeTask smsComposeTask = new SmsComposeTask();
smsComposeTask.To = ((ButtonBase)sender).Content.ToString();
smsComposeTask.Body = "定制Windows Phone应用";
smsComposeTask.Show();
break;
}
}
private void Pivot_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
Pivot piv = (Pivot)sender;
if (piv.SelectedIndex > 0 && _licenses == null)
{
Dispatcher.BeginInvoke(() =>
{
_licenses = new StackPanel();
StreamResourceInfo sri = Application.GetResourceStream(
new Uri("LICENSE.txt", UriKind.Relative));
if (sri != null)
{
using (StreamReader sr = new StreamReader(sri.Stream))
{
string line;
bool lastWasEmpty = true;
do
{
line = sr.ReadLine();
if (line == string.Empty)
{
Rectangle r = new Rectangle
{
Height = 20,
};
_licenses.Children.Add(r);
lastWasEmpty = true;
}
else
{
TextBlock tb = new TextBlock
{
TextWrapping = TextWrapping.Wrap,
Text = line,
Style = (Style)Application.Current.Resources["PhoneTextNormalStyle"],
};
if (!lastWasEmpty)
{
tb.Opacity = 0.7;
}
lastWasEmpty = false;
_licenses.Children.Add(tb);
}
} while (line != null);
}
}
sv1.Content = _licenses;
});
}
}
}
}