FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
UnityLauncherPro/UnityLauncherPro/UpgradeWindow.xaml.cs at 213 · unitycoder/UnityLauncherPro · GitHub
unitycoder
UnityLauncherPro
Repository navigation
Code
Issues
23
(23)
Pull requests
Discussions
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
UnityLauncherPro
/
UnityLauncherPro
/
UpgradeWindow.xaml.cs
Copy path
More file actions
More file actions
Latest commit
History
History
History
165 lines (137 loc) · 5.45 KB
Breadcrumbs
UnityLauncherPro
/
UnityLauncherPro
/
UpgradeWindow.xaml.cs
Copy path
File metadata and controls
165 lines (137 loc) · 5.45 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
161
162
163
164
165
using
System
.
Linq
;
using
System
.
Windows
;
using
System
.
Windows
.
Controls
;
using
System
.
Windows
.
Input
;
using
System
.
Windows
.
Media
;
namespace
UnityLauncherPro
{
/// <summary>
/// Interaction logic for UpgradeWindow.xaml
/// </summary>
public
partial
class
UpgradeWindow
:
Window
{
public
static
string
upgradeVersion
=
null
;
public
UpgradeWindow
(
string
currentVersion
,
string
projectPath
,
string
commandLineArguments
=
null
)
{
InitializeComponent
(
)
;
txtCurrentVersion
.
Text
=
currentVersion
;
txtCurrentPlatform
.
Text
=
Tools
.
GetTargetPlatform
(
projectPath
)
;
if
(
!
ReferenceEquals
(
gridAvailableVersions
.
ItemsSource
,
MainWindow
.
unityInstallationsSource
)
)
{
gridAvailableVersions
.
ItemsSource
=
MainWindow
.
unityInstallationsSource
;
}
gridAvailableVersions
.
SelectedItem
=
null
;
// if dont have exact version, show red outline
if
(
currentVersion
==
null
||
MainWindow
.
unityInstalledVersions
.
ContainsKey
(
currentVersion
)
==
false
)
{
txtCurrentVersion
.
BorderBrush
=
Brushes
.
Red
;
txtCurrentVersion
.
BorderThickness
=
new
Thickness
(
1
)
;
}
if
(
currentVersion
!=
null
)
{
// we know the version, enable buttons
btnOpenReleasePage
.
IsEnabled
=
true
;
btnDownload
.
IsEnabled
=
true
;
// remove china c1 from version, NOTE not used anymore.. its Tuanjie
if
(
currentVersion
.
Contains
(
"c"
)
)
currentVersion
=
currentVersion
.
Replace
(
"c1"
,
""
)
;
// find nearest version
string
nearestVersion
=
Tools
.
FindNearestVersion
(
currentVersion
,
MainWindow
.
unityInstalledVersions
.
Keys
.
ToList
(
)
)
;
if
(
nearestVersion
!=
null
&&
MainWindow
.
unityInstallationsSource
!=
null
)
{
// select nearest version
for
(
int
i
=
0
;
i
<
MainWindow
.
unityInstallationsSource
.
Count
;
i
++
)
{
if
(
MainWindow
.
unityInstallationsSource
[
i
]
.
Version
==
nearestVersion
)
{
gridAvailableVersions
.
SelectedIndex
=
i
;
gridAvailableVersions
.
ScrollIntoView
(
gridAvailableVersions
.
SelectedItem
)
;
break
;
}
}
}
}
gridAvailableVersions
.
Focus
(
)
;
}
private
void
BtnUpgradeProject_Click
(
object
sender
,
RoutedEventArgs
e
)
{
Upgrade
(
)
;
}
private
void
BtnCancelUpgrade_Click
(
object
sender
,
RoutedEventArgs
e
)
{
DialogResult
=
false
;
}
private
void
BtnOpenReleasePage_Click
(
object
sender
,
RoutedEventArgs
e
)
{
Tools
.
OpenReleaseNotes
(
txtCurrentVersion
.
Text
)
;
}
private
void
BtnDownloadEditor_Click
(
object
sender
,
RoutedEventArgs
e
)
{
Tools
.
DownloadInBrowser
(
txtCurrentVersion
.
Text
)
;
}
private
void
BtnDownload_Click
(
object
sender
,
RoutedEventArgs
e
)
{
Tools
.
DownloadInBrowser
(
txtCurrentVersion
.
Text
)
;
}
private
void
btnInstall_Click
(
object
sender
,
RoutedEventArgs
e
)
{
Tools
.
DownloadAndInstall
(
txtCurrentVersion
.
Text
)
;
}
private
void
Window_PreviewKeyDown
(
object
sender
,
System
.
Windows
.
Input
.
KeyEventArgs
e
)
{
// override Enter for datagrid
if
(
e
.
Key
==
Key
.
Return
&&
e
.
KeyboardDevice
.
Modifiers
==
ModifierKeys
.
None
)
{
e
.
Handled
=
true
;
var
k
=
(
UnityInstallation
)
gridAvailableVersions
.
SelectedItem
;
upgradeVersion
=
k
.
Version
;
DialogResult
=
true
;
return
;
}
else
// other keys
{
switch
(
e
.
Key
)
{
case
Key
.
Escape
:
DialogResult
=
false
;
break
;
default
:
break
;
}
}
base
.
OnKeyDown
(
e
)
;
}
private
void
GridAvailableVersions_PreviewKeyDown
(
object
sender
,
KeyEventArgs
e
)
{
Tools
.
HandleDataGridScrollKeys
(
sender
,
e
)
;
}
private
void
GridAvailableVersions_Loaded
(
object
sender
,
RoutedEventArgs
e
)
{
Tools
.
SetFocusToGrid
(
gridAvailableVersions
)
;
// bolded for current item
DataGridRow
row
=
(
DataGridRow
)
(
(
DataGrid
)
sender
)
.
ItemContainerGenerator
.
ContainerFromIndex
(
gridAvailableVersions
.
SelectedIndex
)
;
if
(
row
==
null
)
return
;
row
.
Foreground
=
Brushes
.
White
;
row
.
FontWeight
=
FontWeights
.
Bold
;
}
private
void
GridAvailableVersions_PreviewMouseDoubleClick
(
object
sender
,
MouseButtonEventArgs
e
)
{
var
src
=
VisualTreeHelper
.
GetParent
(
(
DependencyObject
)
e
.
OriginalSource
)
;
var
srcType
=
src
.
GetType
(
)
;
if
(
srcType
==
typeof
(
ContentPresenter
)
)
{
Upgrade
(
)
;
}
}
void
Upgrade
(
)
{
var
k
=
(
UnityInstallation
)
gridAvailableVersions
.
SelectedItem
;
if
(
k
==
null
)
{
DialogResult
=
false
;
return
;
}
upgradeVersion
=
k
.
Version
;
DialogResult
=
true
;
}
}
}
Back
|
FazBrowse Home
|
New Git URL