Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4dcee8b

Browse files
committed
initial version of fetching Security warnings from Releases API. (displays orange outline in version column, with tooltip). #GITBUILD
1 parent600fd17 commit4dcee8b

File tree

5 files changed

+109
-23
lines changed

5 files changed

+109
-23
lines changed

‎UnityLauncherPro/Data/Project.cs‎

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
usingSystem;
2+
usingSystem.ComponentModel;
23
usingSystem.Globalization;
34
usingSystem.Windows.Data;
45

56
namespaceUnityLauncherPro
67
{
7-
publicclassProject:IValueConverter
8+
publicclassProject:IValueConverter,INotifyPropertyChanged
89
{
910
publicstringTitle{set;get;}
1011
publicstringVersion{set;get;}
@@ -18,6 +19,19 @@ public class Project : IValueConverter
1819
publicboolfolderExists{set;get;}
1920
publicstringSRP{set;get;}// Scriptable Render Pipeline, TODO add version info?
2021

22+
//public string InfoLabel { set; get; } // this is additional info from Releases API (like vulnerabilities..)
23+
privatestring_infoLabel;
24+
publicstringInfoLabel
25+
{
26+
get=>_infoLabel;
27+
set
28+
{
29+
if(_infoLabel==value)return;
30+
_infoLabel=value;
31+
OnPropertyChanged(nameof(InfoLabel));
32+
}
33+
}
34+
2135
// WPF keeps calling this method from AppendFormatHelper, GetNameCore..? not sure if need to return something else or default would be faster?
2236
publicoverridestringToString()
2337
{
@@ -41,5 +55,8 @@ public object ConvertBack(object value, Type targetType, object parameter, Cultu
4155
{
4256
thrownewNotSupportedException();
4357
}
58+
59+
publiceventPropertyChangedEventHandlerPropertyChanged;
60+
protectedvoidOnPropertyChanged(stringname)=>PropertyChanged?.Invoke(this,newPropertyChangedEventArgs(name));
4461
}
4562
}

‎UnityLauncherPro/Data/UnityInstallation.cs‎

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
usingSystem;
2+
usingSystem.ComponentModel;
23
usingSystem.Windows.Data;
34

45
namespaceUnityLauncherPro
56
{
6-
publicclassUnityInstallation:IValueConverter
7+
publicclassUnityInstallation:IValueConverter,INotifyPropertyChanged
78
{
89
publicstringVersion{set;get;}
910
publiclongVersionCode{set;get;}// version as number, cached for sorting
@@ -15,7 +16,19 @@ public class UnityInstallation : IValueConverter
1516
publicboolIsPreferred{set;get;}
1617
publicstringReleaseType{set;get;}// Alpha, Beta, LTS.. TODO could be enum
1718

18-
publicstringInfoLabel{set;get;}// this is additional info from Releases API (like vulnerabilities..)
19+
//public string InfoLabel { set; get; } // this is additional info from Releases API (like vulnerabilities..)
20+
21+
privatestring_infoLabel;
22+
publicstringInfoLabel
23+
{
24+
get=>_infoLabel;
25+
set
26+
{
27+
if(_infoLabel==value)return;
28+
_infoLabel=value;
29+
OnPropertyChanged(nameof(InfoLabel));
30+
}
31+
}
1932

2033
// https://stackoverflow.com/a/5551986/5452781
2134
publicobjectConvert(objectvalue,TypetargetType,objectparameter,System.Globalization.CultureInfoculture)
@@ -30,7 +43,7 @@ public object Convert(object value, Type targetType, object parameter, System.Gl
3043
//Console.WriteLine("checking version: "+version);
3144
if(checkInfoLabel&&string.IsNullOrEmpty(InfoLabel)==false)
3245
{
33-
Console.WriteLine("Contains warning: "+version);
46+
Console.WriteLine("Contains warning: "+version);
3447
return-1;// has warning
3548
}
3649
else
@@ -49,5 +62,9 @@ public object ConvertBack(object value, Type targetType, object parameter, Syste
4962
thrownewNotSupportedException();
5063
}
5164

65+
// status label results are ready
66+
publiceventPropertyChangedEventHandlerPropertyChanged;
67+
protectedvoidOnPropertyChanged(stringname)=>PropertyChanged?.Invoke(this,newPropertyChangedEventArgs(name));
68+
5269
}
5370
}

‎UnityLauncherPro/MainWindow.xaml‎

Lines changed: 42 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,6 @@
4949
<!-- Tab: Projects-->
5050
<TabItemHeader="Projects"Style="{DynamicResource TabItemStyle1}"Padding="0,0,0,0"Margin="-1,1,1,-1"BorderBrush="{x:Null}">
5151
<Grid>
52-
<Grid.ColumnDefinitions>
53-
<ColumnDefinitionWidth="185*"/>
54-
<ColumnDefinitionWidth="693*"/>
55-
</Grid.ColumnDefinitions>
5652
<!-- search box-->
5753
<GridBackground="{DynamicResource ThemeTextBoxBackground}"HorizontalAlignment="Left"VerticalAlignment="Top"Width="222"Margin="6,5,0,0"Height="20" Grid.ColumnSpan="2" >
5854
<!--<TextBlock Margin="3,2" MinWidth="100" Text="Search" Foreground="{DynamicResource ThemeSearchPlaceholder}" Visibility="{Binding Text.IsEmpty, Converter={StaticResource MyBoolToVisibilityConverter}, ElementName=txtSearchBox}" Height="24" />-->
@@ -117,19 +113,41 @@
117113
<DataGridTextColumn.CellStyle>
118114
<StyleTargetType="{x:Type DataGridCell}">
119115
<SetterProperty="Foreground"Value="{DynamicResource ThemeGridRedText}" />
120-
<SetterProperty="BorderBrush"Value="{x:Null}" />
116+
<SetterProperty="BorderBrush"Value="Orange" />
121117
<Style.Triggers>
122118
<DataTriggerBinding="{Binding Version, Converter={StaticResource VersionInstalledConverter}}"Value="1">
123119
<SetterProperty="Foreground"Value="{DynamicResource ThemeGridGreenText}" />
124-
<SetterProperty="BorderBrush"Value="{x:Null}" />
120+
<!--<Setter Property="BorderBrush" Value="{x:Null}" />-->
125121
</DataTrigger>
126122
<DataTriggerBinding="{Binding Version, Converter={StaticResource VersionInstalledConverter}}"Value="-1">
127123
<SetterProperty="Foreground"Value="{DynamicResource ThemeGridGreenText}" />
128-
<SetterProperty="BorderBrush"Value="Orange" />
124+
<!--<Setter Property="BorderBrush" Value="Orange" />-->
125+
</DataTrigger>
126+
<DataTriggerBinding="{Binding InfoLabel, IsAsync=True}"Value="{x:Null}">
127+
<SetterProperty="BorderBrush"Value="{x:Null}" />
129128
</DataTrigger>
130129
</Style.Triggers>
131130
</Style>
132131
</DataGridTextColumn.CellStyle>
132+
<DataGridTextColumn.ElementStyle>
133+
<StyleTargetType="TextBlock">
134+
<SetterProperty="ToolTip">
135+
<Setter.Value>
136+
<ToolTip>
137+
<TextBlockText="{Binding InfoLabel, IsAsync=True}"TextWrapping="Wrap"MaxWidth="480"/>
138+
</ToolTip>
139+
</Setter.Value>
140+
</Setter>
141+
<Style.Triggers>
142+
<DataTriggerBinding="{Binding InfoLabel}"Value="{x:Null}">
143+
<SetterProperty="ToolTip"Value="{x:Null}"/>
144+
</DataTrigger>
145+
<DataTriggerBinding="{Binding InfoLabel}"Value="">
146+
<SetterProperty="ToolTip"Value="{x:Null}"/>
147+
</DataTrigger>
148+
</Style.Triggers>
149+
</Style>
150+
</DataGridTextColumn.ElementStyle>
133151
</DataGridTextColumn>
134152
<!--CellStyle="{StaticResource NoFocusCellStyle"}-->
135153
<DataGridTextColumnHeader="Path"x:Name="txtColumnPath"Binding="{Binding Path}"ClipboardContentBinding="{x:Null}"IsReadOnly="True"Width="185">
@@ -368,7 +386,23 @@
368386
</DataGridTextColumn.ElementStyle>
369387
</DataGridTextColumn>
370388

371-
<DataGridTextColumnBinding="{Binding Version}"ClipboardContentBinding="{x:Null}"Header="Version"IsReadOnly="True"MinWidth="90"/>
389+
<DataGridTextColumnBinding="{Binding Version}"ClipboardContentBinding="{x:Null}"Header="Version"IsReadOnly="True"MinWidth="90">
390+
<DataGridTextColumn.HeaderTemplate>
391+
<DataTemplate>
392+
<TextBlockText="Version"IsHitTestVisible="False" />
393+
</DataTemplate>
394+
</DataGridTextColumn.HeaderTemplate>
395+
<DataGridTextColumn.CellStyle>
396+
<StyleTargetType="{x:Type DataGridCell}">
397+
<SetterProperty="BorderBrush"Value="Orange" />
398+
<Style.Triggers>
399+
<DataTriggerBinding="{Binding InfoLabel, IsAsync=True}"Value="{x:Null}">
400+
<SetterProperty="BorderBrush"Value="{x:Null}" />
401+
</DataTrigger>
402+
</Style.Triggers>
403+
</Style>
404+
</DataGridTextColumn.CellStyle>
405+
</DataGridTextColumn>
372406
<DataGridTextColumnHeader="Release"Binding="{Binding ReleaseType}"IsReadOnly="True"CanUserResize="False"MinWidth="50" />
373407
<DataGridTextColumnBinding="{Binding PlatformsCombined}"ClipboardContentBinding="{x:Null}"Header="Platforms"IsReadOnly="True"/>
374408
<DataGridTextColumnBinding="{Binding Installed, StringFormat=\{0:dd/MM/yyyy HH:mm:ss\}}"ClipboardContentBinding="{x:Null}"Header="Installed"IsReadOnly="True"/>

‎UnityLauncherPro/MainWindow.xaml.cs‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4125,6 +4125,11 @@ private void chkFetchAdditionalInfo_Checked(object sender, RoutedEventArgs e)
41254125
Settings.Default.Save();
41264126
}
41274127

4128+
privatevoidgridRecent_SelectionChanged(objectsender,SelectionChangedEventArgse)
4129+
{
4130+
4131+
}
4132+
41284133
//private void menuProjectProperties_Click(object sender, RoutedEventArgs e)
41294134
//{
41304135
// var proj = GetSelectedProject();

‎UnityLauncherPro/Tools.cs‎

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2925,7 +2925,7 @@ private static async Task FetchImplAsync()
29252925
{
29262926
foreach(varversioninMainWindow.unityInstalledVersions.Keys)
29272927
{
2928-
Console.WriteLine("******** Fetching "+version);
2928+
//Console.WriteLine("******** Fetching " + version);
29292929

29302930
varurl=$"https://services.api.unity.com/unity/editor/release/v1/releases?order=RELEASE_DATE_DESC&limit=1&version={Uri.EscapeDataString(version)}";
29312931

@@ -2953,17 +2953,30 @@ private static async Task FetchImplAsync()
29532953
//Console.WriteLine(label.description);
29542954

29552955
varu=MainWindow.unityInstallationsSource.FirstOrDefault(x=>x.Version==version);
2956-
u.InfoLabel=label.labelText;
2957-
// replace old item in list
2956+
2957+
stringinfoText=label.labelText+"\n"+label.description;;
2958+
2959+
u.InfoLabel=infoText;
29582960

29592961
intindex=MainWindow.unityInstallationsSource.IndexOf(u);
29602962
if(index>=0)
29612963
{
29622964
MainWindow.unityInstallationsSource[index]=u;
29632965
}
29642966

2965-
SetStatus($"Info for{version}:{label.labelText}");
2966-
Console.WriteLine("got infolabel for "+version);
2967+
// update all projectsSource items with this version too
2968+
foreach(varpinMainWindow.projectsSource)
2969+
{
2970+
if(p.Version==version)
2971+
{
2972+
p.InfoLabel=infoText;
2973+
}
2974+
}
2975+
2976+
2977+
2978+
//SetStatus($"Info for {version}: {label.labelText}");
2979+
//Console.WriteLine("got infolabel for " + version);
29672980
}
29682981
}
29692982

@@ -2974,7 +2987,7 @@ private static async Task FetchImplAsync()
29742987
}
29752988

29762989
// delay
2977-
awaitTask.Delay(5000).ConfigureAwait(false);
2990+
awaitTask.Delay(500).ConfigureAwait(false);
29782991

29792992
}// foreach version
29802993
}
@@ -3053,11 +3066,11 @@ private static UnityEditorInfoLabel ExtractLabelText(string json)
30533066
if(json[i]=='\"'&&json[i-1]!='\\')break;
30543067

30553068
if(i>qStart)
3056-
label.description=json.Substring(qStart,i-qStart)
3057-
.Replace("\\\"","\"")
3058-
.Replace("\\n","\n")
3059-
.Replace("\\r","\r")
3060-
.Replace("\\t","\t");
3069+
{
3070+
label.description=json.Substring(qStart,i-qStart).Replace("\\\"","\"").Replace("\\n","\n").Replace("\\r","\r").Replace("\\t","\t");
3071+
// strip HTML tags for now
3072+
label.description=System.Text.RegularExpressions.Regex.Replace(label.description,"<.*?>",string.Empty);
3073+
}
30613074
}
30623075
}
30633076

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp