forked from Grabacr07/KanColleViewer
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
312 additions
and
210 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Net; | ||
using System.Net.Http; | ||
using System.Threading.Tasks; | ||
using System.Windows.Media; | ||
using Codeplex.Data; | ||
|
||
namespace Grabacr07.KanColleViewer.Models | ||
{ | ||
public class SallyArea | ||
{ | ||
public int Area { get; private set; } | ||
|
||
public string Name { get; private set; } | ||
|
||
public Color Color { get; private set; } = Colors.Transparent; | ||
|
||
private SallyArea() { } | ||
|
||
public static SallyArea Default { get; } = new SallyArea(); | ||
|
||
public static async Task<SallyArea[]> GetAsync() | ||
{ | ||
using (var client = new HttpClient(Helper.GetProxyConfiguredHandler())) | ||
{ | ||
try | ||
{ | ||
var uri = new Uri(Properties.Settings.Default.SallyAreaSource); | ||
var response = await client.GetAsync(uri); | ||
if (response.IsSuccessStatusCode) | ||
{ | ||
var content = await response.Content.ReadAsStringAsync(); | ||
var json = DynamicJson.Parse(content); | ||
var result = ((object[])json) | ||
.Select(x => (dynamic)x) | ||
.Select(x => | ||
new SallyArea | ||
{ | ||
Area = (int)x.area, | ||
Name = (string)x.name, | ||
Color = Helper.StringToColor(x.color) | ||
}) | ||
.ToArray(); | ||
|
||
return result; | ||
} | ||
} | ||
catch (Exception ex) | ||
{ | ||
System.Diagnostics.Debug.WriteLine(ex); | ||
StatusService.Current.Notify("出撃海域の取得に失敗しました: " + ex); | ||
} | ||
} | ||
|
||
return new SallyArea[0]; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
source/Grabacr07.KanColleViewer/Properties/Settings.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.