Skip to content

Commit 03f6d52

Browse files
committed
Upgrade to .NET Core 3.1
1 parent 2f9b535 commit 03f6d52

File tree

19 files changed

+132
-621
lines changed

19 files changed

+132
-621
lines changed

EnhancePoE.sln

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.32106.194
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EnhancePoE", "EnhancePoE\EnhancePoE.csproj", "{B9A505C6-61BE-4E64-90D2-75C7C84B106D}"
7+
EndProject
8+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{8BAD9F45-AC7A-46C0-82EF-CD295F2CA3D6}"
9+
ProjectSection(SolutionItems) = preProject
10+
.editorconfig = .editorconfig
11+
EndProjectSection
12+
EndProject
13+
Global
14+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
15+
Debug|Any CPU = Debug|Any CPU
16+
Release|Any CPU = Release|Any CPU
17+
EndGlobalSection
18+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
19+
{B9A505C6-61BE-4E64-90D2-75C7C84B106D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
20+
{B9A505C6-61BE-4E64-90D2-75C7C84B106D}.Debug|Any CPU.Build.0 = Debug|Any CPU
21+
{B9A505C6-61BE-4E64-90D2-75C7C84B106D}.Release|Any CPU.ActiveCfg = Release|Any CPU
22+
{B9A505C6-61BE-4E64-90D2-75C7C84B106D}.Release|Any CPU.Build.0 = Release|Any CPU
23+
EndGlobalSection
24+
GlobalSection(SolutionProperties) = preSolution
25+
HideSolutionNode = FALSE
26+
EndGlobalSection
27+
GlobalSection(ExtensibilityGlobals) = postSolution
28+
SolutionGuid = {FF26E406-D4E5-435A-AAE9-6C5B56E3A11F}
29+
EndGlobalSection
30+
EndGlobal

EnhancePoE/App.xaml.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@ public partial class App : Application
1010
{
1111
public App()
1212
{
13-
SetupUnhandledExceptionHandling();
1413
if ( !SingleInstance.Claim() )
1514
{
1615
Shutdown();
1716
}
17+
18+
SetupUnhandledExceptionHandling();
1819
}
1920

2021
private void SetupUnhandledExceptionHandling()

EnhancePoE/EnhancePoE.csproj

Lines changed: 31 additions & 311 deletions
Large diffs are not rendered by default.

EnhancePoE/Model/ApiAdapter.cs

Lines changed: 45 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ private static async Task<bool> GetProps( string accName, string league )
117117
{
118118
return false;
119119
}
120-
if ( Properties.Settings.Default.SessionId == "" )
120+
if ( string.IsNullOrEmpty( Properties.Settings.Default.SessionId ) )
121121
{
122122
_ = MessageBox.Show( "Missing Settings!" + Environment.NewLine + "Please set PoE Session Id." );
123123
return false;
@@ -146,53 +146,44 @@ private static async Task<bool> GetProps( string accName, string league )
146146
{
147147
// add user agent
148148
client.DefaultRequestHeaders.Add( "User-Agent", $"EnhancePoEApp/v{Assembly.GetExecutingAssembly().GetName().Version}" );
149-
using ( var res = await client.GetAsync( propsUri ) )
149+
using var res = await client.GetAsync( propsUri );
150+
if ( res.IsSuccessStatusCode )
150151
{
151-
if ( res.IsSuccessStatusCode )
152-
{
153-
using ( var content = res.Content )
154-
{
155-
string resContent = await content.ReadAsStringAsync();
156-
PropsList = JsonSerializer.Deserialize<StashTabPropsList>( resContent );
152+
using var content = res.Content;
153+
string resContent = await content.ReadAsStringAsync();
154+
PropsList = JsonSerializer.Deserialize<StashTabPropsList>( resContent );
157155

158-
Trace.WriteLine( res.Headers, "res headers" );
156+
Trace.WriteLine( res.Headers, "res headers" );
159157

160-
// get new rate limit values
161-
string rateLimit = res.Headers.GetValues( "X-Rate-Limit-Account" ).FirstOrDefault();
162-
string rateLimitState = res.Headers.GetValues( "X-Rate-Limit-Account-State" ).FirstOrDefault();
163-
string responseTime = res.Headers.GetValues( "Date" ).FirstOrDefault();
164-
RateLimit.DeserializeRateLimits( rateLimit, rateLimitState );
165-
RateLimit.DeserializeResponseSeconds( responseTime );
166-
}
167-
}
168-
else
169-
{
170-
if ( res.StatusCode == HttpStatusCode.Forbidden )
171-
{
172-
_ = MessageBox.Show( "Connection forbidden. Please check your Accountname and POE Session ID. You may have to refresh your POE Session ID sometimes.", "Error fetching data", MessageBoxButton.OK, MessageBoxImage.Error );
173-
}
174-
else
175-
{
176-
_ = MessageBox.Show( res.ReasonPhrase, "Error fetching data", MessageBoxButton.OK, MessageBoxImage.Error );
177-
}
178-
FetchError = true;
179-
return false;
180-
}
158+
// get new rate limit values
159+
string rateLimit = res.Headers.GetValues( "X-Rate-Limit-Account" ).FirstOrDefault();
160+
string rateLimitState = res.Headers.GetValues( "X-Rate-Limit-Account-State" ).FirstOrDefault();
161+
string responseTime = res.Headers.GetValues( "Date" ).FirstOrDefault();
162+
RateLimit.DeserializeRateLimits( rateLimit, rateLimitState );
163+
RateLimit.DeserializeResponseSeconds( responseTime );
164+
}
165+
else
166+
{
167+
_ = MessageBox.Show( res.StatusCode == HttpStatusCode.Forbidden ?
168+
"Connection forbidden. Please check your Accountname and POE Session ID. You may have to refresh your POE Session ID sometimes." :
169+
res.ReasonPhrase, "Error fetching data", MessageBoxButton.OK, MessageBoxImage.Error );
170+
FetchError = true;
171+
return false;
181172
}
182173
}
183174

184175
IsFetching = false;
185176
return true;
186177
}
187178

188-
public async static Task<bool> GetItems()
179+
public static async Task<bool> GetItems()
189180
{
190181
if ( IsFetching )
191182
{
192183
Trace.WriteLine( "already fetching" );
193184
return false;
194185
}
195-
if ( Properties.Settings.Default.SessionId == "" )
186+
if ( string.IsNullOrEmpty( Properties.Settings.Default.SessionId ) )
196187
{
197188
_ = MessageBox.Show( "Missing Settings!" + Environment.NewLine + "Please set PoE Session Id." );
198189
return false;
@@ -228,35 +219,31 @@ public async static Task<bool> GetItems()
228219
if ( !usedUris.Contains( i.StashTabUri ) )
229220
{
230221
cookieContainer.Add( i.StashTabUri, new Cookie( "POESESSID", sessionId ) );
231-
using ( var res = await client.GetAsync( i.StashTabUri ) )
222+
using var res = await client.GetAsync( i.StashTabUri );
223+
usedUris.Add( i.StashTabUri );
224+
if ( res.IsSuccessStatusCode )
232225
{
233-
usedUris.Add( i.StashTabUri );
234-
if ( res.IsSuccessStatusCode )
235-
{
236-
using ( var content = res.Content )
237-
{
238-
// get new rate limit values
239-
string rateLimit = res.Headers.GetValues( "X-Rate-Limit-Account" ).FirstOrDefault();
240-
string rateLimitState = res.Headers.GetValues( "X-Rate-Limit-Account-State" ).FirstOrDefault();
241-
string responseTime = res.Headers.GetValues( "Date" ).FirstOrDefault();
242-
RateLimit.DeserializeRateLimits( rateLimit, rateLimitState );
243-
RateLimit.DeserializeResponseSeconds( responseTime );
226+
using var content = res.Content;
227+
// get new rate limit values
228+
string rateLimit = res.Headers.GetValues( "X-Rate-Limit-Account" ).FirstOrDefault();
229+
string rateLimitState = res.Headers.GetValues( "X-Rate-Limit-Account-State" ).FirstOrDefault();
230+
string responseTime = res.Headers.GetValues( "Date" ).FirstOrDefault();
231+
RateLimit.DeserializeRateLimits( rateLimit, rateLimitState );
232+
RateLimit.DeserializeResponseSeconds( responseTime );
244233

245-
// deserialize response
246-
string resContent = await content.ReadAsStringAsync();
247-
var deserializedContent = JsonSerializer.Deserialize<ItemList>( resContent );
248-
i.ItemList = deserializedContent.items;
249-
i.Quad = deserializedContent.quadLayout;
234+
// deserialize response
235+
string resContent = await content.ReadAsStringAsync();
236+
var deserializedContent = JsonSerializer.Deserialize<ItemList>( resContent );
237+
i.ItemList = deserializedContent.items;
238+
i.Quad = deserializedContent.quadLayout;
250239

251-
i.CleanItemList();
252-
}
253-
}
254-
else
255-
{
256-
FetchError = true;
257-
_ = MessageBox.Show( res.ReasonPhrase, "Error fetching data", MessageBoxButton.OK, MessageBoxImage.Error );
258-
return false;
259-
}
240+
i.CleanItemList();
241+
}
242+
else
243+
{
244+
FetchError = true;
245+
_ = MessageBox.Show( res.ReasonPhrase, "Error fetching data", MessageBoxButton.OK, MessageBoxImage.Error );
246+
return false;
260247
}
261248
}
262249
}

EnhancePoE/Model/Coordinates.cs

Lines changed: 9 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,15 @@ private static bool CheckForHit( System.Windows.Point pt, System.Windows.Control
1717
int btnX = Convert.ToInt32( Math.Ceiling( pt.X + btn.ActualWidth + 1 ) );
1818
int btnY = Convert.ToInt32( Math.Ceiling( pt.Y + btn.ActualHeight + 1 ) );
1919

20-
if ( clickX > pt.X
20+
return clickX > pt.X
2121
&& clickY > pt.Y
2222
&& clickX < btnX
23-
&& clickY < btnY )
24-
{
25-
return true;
26-
}
27-
return false;
23+
&& clickY < btnY;
2824
}
2925

3026
private static System.Windows.Point GetCoordinates( System.Windows.Controls.Button item )
3127
{
32-
if ( item != null )
33-
{
34-
return item.PointToScreen( new System.Windows.Point( 0, 0 ) );
35-
}
36-
return new System.Windows.Point( 0, 0 );
28+
return item != null ? item.PointToScreen( new System.Windows.Point( 0, 0 ) ) : new System.Windows.Point( 0, 0 );
3729
}
3830

3931
private static bool CheckForHeaderHit( StashTab s )
@@ -49,14 +41,10 @@ private static bool CheckForHeaderHit( StashTab s )
4941

5042
int tabX = Convert.ToInt32( Math.Floor( pt.X + s.TabHeader.ActualWidth + 1 ) );
5143
int tabY = Convert.ToInt32( Math.Floor( pt.Y + s.TabHeader.ActualHeight + 1 ) );
52-
if ( clickX > pt.X
44+
return clickX > pt.X
5345
&& clickY > pt.Y
5446
&& clickX < tabX
55-
&& clickY < tabY )
56-
{
57-
return true;
58-
}
59-
return false;
47+
&& clickY < tabY;
6048
}
6149

6250
private static bool CheckForEditButtonHit( System.Windows.Controls.Button btn )
@@ -72,32 +60,20 @@ private static bool CheckForEditButtonHit( System.Windows.Controls.Button btn )
7260

7361
int btnX = Convert.ToInt32( Math.Floor( pt.X + btn.ActualWidth + 1 ) );
7462
int btnY = Convert.ToInt32( Math.Floor( pt.Y + btn.ActualHeight + 1 ) );
75-
if ( clickX > pt.X
63+
return clickX > pt.X
7664
&& clickY > pt.Y
7765
&& clickX < btnX
78-
&& clickY < btnY )
79-
{
80-
return true;
81-
}
82-
return false;
66+
&& clickY < btnY;
8367
}
8468

8569
private static System.Windows.Point GetTabHeaderCoordinates( System.Windows.Controls.TextBlock item )
8670
{
87-
if ( item != null )
88-
{
89-
return item.PointToScreen( new System.Windows.Point( 0, 0 ) );
90-
}
91-
return new System.Windows.Point( 0, 0 );
71+
return item != null ? item.PointToScreen( new System.Windows.Point( 0, 0 ) ) : new System.Windows.Point( 0, 0 );
9272
}
9373

9474
private static System.Windows.Point GetEditButtonCoordinates( System.Windows.Controls.Button button )
9575
{
96-
if ( button != null )
97-
{
98-
return button.PointToScreen( new System.Windows.Point( 0, 0 ) );
99-
}
100-
return new System.Windows.Point( 0, 0 );
76+
return button != null ? button.PointToScreen( new System.Windows.Point( 0, 0 ) ) : new System.Windows.Point( 0, 0 );
10177
}
10278

10379
private static List<Cell> GetAllActiveCells( int index )

EnhancePoE/Model/Data.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ private static bool AddItemToItemSet( ItemSet set, bool chaosItems = false, bool
9494
// TODO: crashes here after some time
9595
foreach ( var s in StashTabList.StashTabs )
9696
{
97-
foreach ( var i in ( (List<Item>)Utility.GetPropertyValue( s, listName ) ) )
97+
foreach ( var i in (List<Item>)Utility.GetPropertyValue( s, listName ) )
9898
{
9999
if ( set.GetNextItemClass() == i.ItemType || ( !honorOrder && set.IsValidItem( i ) ) )
100100
{
@@ -124,7 +124,7 @@ private static bool AddItemToItemSet( ItemSet set, bool chaosItems = false, bool
124124
nextItemType = "OneHandWeapons";
125125
foreach ( var s in StashTabList.StashTabs )
126126
{
127-
foreach ( var i in ( (List<Item>)Utility.GetPropertyValue( s, listName ) ) )
127+
foreach ( var i in (List<Item>)Utility.GetPropertyValue( s, listName ) )
128128
{
129129
if ( nextItemType == i.ItemType && set.GetItemDistance( i ) < minDistance )
130130
{

EnhancePoE/Model/EventArgs.cs

Lines changed: 0 additions & 14 deletions
This file was deleted.

EnhancePoE/Model/EventRaiser.cs

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)