Blueprint loading works
This commit is contained in:
10
EveCalc.Shared/AssemblyInfo.cs
Normal file
10
EveCalc.Shared/AssemblyInfo.cs
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
using System.Windows;
|
||||||
|
|
||||||
|
[assembly: ThemeInfo(
|
||||||
|
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
|
||||||
|
//(used if a resource is not found in the page,
|
||||||
|
// or application resource dictionaries)
|
||||||
|
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
|
||||||
|
//(used if a resource is not found in the page,
|
||||||
|
// app, or any theme specific resource dictionaries)
|
||||||
|
)]
|
||||||
19
EveCalc.Shared/Enums.cs
Normal file
19
EveCalc.Shared/Enums.cs
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace EveCalc.Shared
|
||||||
|
{
|
||||||
|
public enum Materials
|
||||||
|
{
|
||||||
|
Tritanium = 34,
|
||||||
|
Pyerite = 35,
|
||||||
|
Mexallon = 36,
|
||||||
|
Isogen = 37,
|
||||||
|
Nocxium = 38,
|
||||||
|
Zydrine = 39,
|
||||||
|
Megacyte = 40
|
||||||
|
}
|
||||||
|
}
|
||||||
25
EveCalc.Shared/EveCalc.Shared.csproj
Normal file
25
EveCalc.Shared/EveCalc.Shared.csproj
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Library</OutputType>
|
||||||
|
<TargetFramework>net5.0-windows</TargetFramework>
|
||||||
|
<UseWPF>true</UseWPF>
|
||||||
|
<StartupObject></StartupObject>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="ESI.NET" Version="2020.12.8" />
|
||||||
|
<PackageReference Include="Microsoft.Data.Sqlite" Version="5.0.2" />
|
||||||
|
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.705.50" />
|
||||||
|
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Remove="C:\Users\Dani\.nuget\packages\microsoft.web.webview2\1.0.705.50\build\\..\runtimes\win-arm\native\WebView2Loader.dll" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Remove="C:\Users\Dani\.nuget\packages\microsoft.web.webview2\1.0.705.50\build\\..\runtimes\win-x64\native\WebView2Loader.dll" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
201
EveCalc.Shared/Logic/EsiClientWrapper.cs
Normal file
201
EveCalc.Shared/Logic/EsiClientWrapper.cs
Normal file
@@ -0,0 +1,201 @@
|
|||||||
|
using ESI.NET;
|
||||||
|
using ESI.NET.Enumerations;
|
||||||
|
using ESI.NET.Models.SSO;
|
||||||
|
using EveCalc.Shared.ObjectModel;
|
||||||
|
using Microsoft.Extensions.Options;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace EveCalc.Shared.Logic
|
||||||
|
{
|
||||||
|
public partial class EsiClientWrapper
|
||||||
|
{
|
||||||
|
private readonly EsiClient client;
|
||||||
|
private AuthorizedCharacterData charData;
|
||||||
|
private string loginState = "guguseli123";
|
||||||
|
|
||||||
|
public EsiClientWrapper()
|
||||||
|
{
|
||||||
|
IOptions<EsiConfig> config = Options.Create(new EsiConfig()
|
||||||
|
{
|
||||||
|
EsiUrl = "https://esi.evetech.net/",
|
||||||
|
DataSource = DataSource.Tranquility,
|
||||||
|
ClientId = "f6892ca208364df1b0b8984773e16a2f",
|
||||||
|
SecretKey = "u5SqGF6ZkEdvjLBRn5rzU1Lz3oaFcpsGDX8Ki6Jn",
|
||||||
|
CallbackUrl = "https://localhost/evecalc",
|
||||||
|
UserAgent = "EveCalc.Test",
|
||||||
|
AuthVersion = AuthVersion.v2
|
||||||
|
});
|
||||||
|
|
||||||
|
this.client = new EsiClient(config);
|
||||||
|
|
||||||
|
// Init existsing token
|
||||||
|
if (File.Exists("token.json"))
|
||||||
|
{
|
||||||
|
var json = File.ReadAllText("token.json");
|
||||||
|
this.charData = JsonConvert.DeserializeObject<AuthorizedCharacterData>(json);
|
||||||
|
this.client.SetCharacterData(this.charData);
|
||||||
|
if (this.charData.ExpiresOn.AddHours(1) < DateTime.Now)
|
||||||
|
{
|
||||||
|
this.RefreshToken();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Init cache
|
||||||
|
this.LoadNameCache();
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetLoginUrl()
|
||||||
|
{
|
||||||
|
var scopes = new List<string>
|
||||||
|
{
|
||||||
|
"publicData",
|
||||||
|
//"esi-calendar.respond_calendar_events.v1",
|
||||||
|
//"esi-calendar.read_calendar_events.v1",
|
||||||
|
//"esi-location.read_location.v1",
|
||||||
|
//"esi-location.read_ship_type.v1",
|
||||||
|
//"esi-mail.organize_mail.v1",
|
||||||
|
//"esi-mail.read_mail.v1",
|
||||||
|
//"esi-mail.send_mail.v1",
|
||||||
|
//"esi-skills.read_skills.v1",
|
||||||
|
//"esi-skills.read_skillqueue.v1",
|
||||||
|
"esi-wallet.read_character_wallet.v1",
|
||||||
|
"esi-wallet.read_corporation_wallet.v1",
|
||||||
|
//"esi-search.search_structures.v1",
|
||||||
|
//"esi-clones.read_clones.v1",
|
||||||
|
//"esi-characters.read_contacts.v1",
|
||||||
|
"esi-universe.read_structures.v1",
|
||||||
|
//"esi-bookmarks.read_character_bookmarks.v1",
|
||||||
|
//"esi-killmails.read_killmails.v1",
|
||||||
|
"esi-corporations.read_corporation_membership.v1",
|
||||||
|
"esi-assets.read_assets.v1",
|
||||||
|
//"esi-planets.manage_planets.v1",
|
||||||
|
//"esi-fleets.read_fleet.v1",
|
||||||
|
//"esi-fleets.write_fleet.v1",
|
||||||
|
//"esi-ui.open_window.v1",
|
||||||
|
//"esi-ui.write_waypoint.v1",
|
||||||
|
//"esi-characters.write_contacts.v1",
|
||||||
|
//"esi-fittings.read_fittings.v1",
|
||||||
|
//"esi-fittings.write_fittings.v1",
|
||||||
|
"esi-markets.structure_markets.v1",
|
||||||
|
"esi-corporations.read_structures.v1",
|
||||||
|
//"esi-characters.read_loyalty.v1",
|
||||||
|
//"esi-characters.read_opportunities.v1",
|
||||||
|
//"esi-characters.read_chat_channels.v1",
|
||||||
|
//"esi-characters.read_medals.v1",
|
||||||
|
//"esi-characters.read_standings.v1",
|
||||||
|
//"esi-characters.read_agents_research.v1",
|
||||||
|
//"esi-industry.read_character_jobs.v1",
|
||||||
|
"esi-markets.read_character_orders.v1",
|
||||||
|
"esi-characters.read_blueprints.v1",
|
||||||
|
//"esi-characters.read_corporation_roles.v1",
|
||||||
|
//"esi-location.read_online.v1",
|
||||||
|
//"esi-contracts.read_character_contracts.v1",
|
||||||
|
//"esi-clones.read_implants.v1",
|
||||||
|
//"esi-characters.read_fatigue.v1",
|
||||||
|
//"esi-killmails.read_corporation_killmails.v1",
|
||||||
|
//"esi-corporations.track_members.v1",
|
||||||
|
"esi-wallet.read_corporation_wallets.v1",
|
||||||
|
//"esi-characters.read_notifications.v1",
|
||||||
|
//"esi-corporations.read_divisions.v1",
|
||||||
|
//"esi-corporations.read_contacts.v1",
|
||||||
|
"esi-assets.read_corporation_assets.v1",
|
||||||
|
//"esi-corporations.read_titles.v1",
|
||||||
|
"esi-corporations.read_blueprints.v1",
|
||||||
|
//"esi-bookmarks.read_corporation_bookmarks.v1",
|
||||||
|
//"esi-contracts.read_corporation_contracts.v1",
|
||||||
|
//"esi-corporations.read_standings.v1",
|
||||||
|
//"esi-corporations.read_starbases.v1",
|
||||||
|
//"esi-industry.read_corporation_jobs.v1",
|
||||||
|
"esi-markets.read_corporation_orders.v1",
|
||||||
|
//"esi-corporations.read_container_logs.v1",
|
||||||
|
//"esi-industry.read_character_mining.v1",
|
||||||
|
//"esi-industry.read_corporation_mining.v1",
|
||||||
|
//"esi-planets.read_customs_offices.v1",
|
||||||
|
//"esi-corporations.read_facilities.v1",
|
||||||
|
//"esi-corporations.read_medals.v1",
|
||||||
|
//"esi-characters.read_titles.v1",
|
||||||
|
//"esi-alliances.read_contacts.v1",
|
||||||
|
//"esi-characters.read_fw_stats.v1",
|
||||||
|
//"esi-corporations.read_fw_stats.v1",
|
||||||
|
//"esi-characterstats.read.v1"
|
||||||
|
};
|
||||||
|
return client.SSO.CreateAuthenticationUrl(scopes, this.loginState);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async void SetAuthCode(string code)
|
||||||
|
{
|
||||||
|
SsoToken token = await this.client.SSO.GetToken(GrantType.AuthorizationCode, code);
|
||||||
|
this.charData = await client.SSO.Verify(token);
|
||||||
|
this.client.SetCharacterData(this.charData);
|
||||||
|
|
||||||
|
var json = JsonConvert.SerializeObject(this.charData);
|
||||||
|
File.WriteAllText("token.json", json);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async void RefreshToken()
|
||||||
|
{
|
||||||
|
var token = await this.client.SSO.GetToken(GrantType.RefreshToken, this.charData.RefreshToken);
|
||||||
|
this.charData = await client.SSO.Verify(token);
|
||||||
|
this.client.SetCharacterData(this.charData);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async void Test()
|
||||||
|
{
|
||||||
|
var response = await client.Universe.Names(new List<long>()
|
||||||
|
{
|
||||||
|
1590304510,
|
||||||
|
99006319,
|
||||||
|
20000006
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<List<Blueprint>> GetCorpBlueprints()
|
||||||
|
{
|
||||||
|
var response = await this.client.Corporation.Blueprints();
|
||||||
|
|
||||||
|
var result = new List<Blueprint>();
|
||||||
|
foreach (var blueprint in response.Data)
|
||||||
|
{
|
||||||
|
var blueprint2 = new Blueprint(blueprint);
|
||||||
|
blueprint2.TypeName = await this.GetFromNameCache(blueprint2.TypeId);
|
||||||
|
result.Add(blueprint2);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<object> GetCorpMats()
|
||||||
|
{
|
||||||
|
var response = await this.client.Assets.ForCorporation();
|
||||||
|
|
||||||
|
//var result = new List<Blueprint>();
|
||||||
|
//foreach (var blueprint in response.Data)
|
||||||
|
//{
|
||||||
|
// var blueprint2 = new Blueprint(blueprint);
|
||||||
|
// blueprint2.TypeName = await this.GetFromNameCache(blueprint2.TypeId);
|
||||||
|
// result.Add(blueprint2);
|
||||||
|
//}
|
||||||
|
|
||||||
|
return response.Data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<Dictionary<long, string>> Search(string query)
|
||||||
|
{
|
||||||
|
var response = await this.client.Search.Query(SearchType.Public, query, SearchCategory.InventoryType);
|
||||||
|
var result = new Dictionary<long, string>();
|
||||||
|
|
||||||
|
foreach (var data in response.Data.InventoryTypes)
|
||||||
|
{
|
||||||
|
var name = await this.GetFromNameCache(data);
|
||||||
|
result.Add(data, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
67
EveCalc.Shared/Logic/NameCache.cs
Normal file
67
EveCalc.Shared/Logic/NameCache.cs
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace EveCalc.Shared.Logic
|
||||||
|
{
|
||||||
|
public partial class EsiClientWrapper
|
||||||
|
{
|
||||||
|
private static string nameCacheFileName = "namecache.json";
|
||||||
|
private Dictionary<long, string> nameCache = new Dictionary<long, string>();
|
||||||
|
|
||||||
|
public void LoadNameCache()
|
||||||
|
{
|
||||||
|
if (File.Exists(nameCacheFileName))
|
||||||
|
{
|
||||||
|
var json = File.ReadAllText(nameCacheFileName);
|
||||||
|
this.nameCache = JsonConvert.DeserializeObject<Dictionary<long, string>>(json);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddToNameCache(long id, string name)
|
||||||
|
{
|
||||||
|
if (this.nameCache.ContainsKey(id))
|
||||||
|
{
|
||||||
|
if (this.nameCache[id] != name)
|
||||||
|
{
|
||||||
|
this.nameCache[id] = name;
|
||||||
|
this.SaveCache();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.nameCache.Add(id, name);
|
||||||
|
this.SaveCache();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<string> GetFromNameCache(long id)
|
||||||
|
{
|
||||||
|
if (this.nameCache.ContainsKey(id))
|
||||||
|
{
|
||||||
|
return this.nameCache[id];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get from api
|
||||||
|
var response2 = await client.Universe.Names(new List<long> { id });
|
||||||
|
if (response2.Data != null && response2.Data.Count > 0)
|
||||||
|
{
|
||||||
|
var name = response2.Data[0].Name;
|
||||||
|
this.AddToNameCache(id, name);
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SaveCache()
|
||||||
|
{
|
||||||
|
var json = JsonConvert.SerializeObject(this.nameCache);
|
||||||
|
File.WriteAllText(nameCacheFileName, json);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
25
EveCalc.Shared/ObjectModel/Blueprint.cs
Normal file
25
EveCalc.Shared/ObjectModel/Blueprint.cs
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace EveCalc.Shared.ObjectModel
|
||||||
|
{
|
||||||
|
public class Blueprint : ESI.NET.Models.Corporation.Blueprint
|
||||||
|
{
|
||||||
|
public string TypeName { get; set; }
|
||||||
|
|
||||||
|
public Blueprint(ESI.NET.Models.Corporation.Blueprint blueprint) : base()
|
||||||
|
{
|
||||||
|
this.ItemId = blueprint.ItemId;
|
||||||
|
this.LocationFlag = blueprint.LocationFlag;
|
||||||
|
this.LocationId = blueprint.LocationId;
|
||||||
|
this.MaterialEfficiency = blueprint.MaterialEfficiency;
|
||||||
|
this.Quantity = blueprint.Quantity;
|
||||||
|
this.Runs = blueprint.Runs;
|
||||||
|
this.TimeEfficiency = blueprint.TimeEfficiency;
|
||||||
|
this.TypeId = blueprint.TypeId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
17
EveCalc.Shared/ObjectModel/BlueprintMaterial.cs
Normal file
17
EveCalc.Shared/ObjectModel/BlueprintMaterial.cs
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace EveCalc.Shared.ObjectModel
|
||||||
|
{
|
||||||
|
public class BlueprintMaterial
|
||||||
|
{
|
||||||
|
public long MaterialTypeId { get; set; }
|
||||||
|
|
||||||
|
public string MaterialTypeName { get; set; }
|
||||||
|
|
||||||
|
public long Quantity { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
51
EveCalc.Shared/StaticData/StaticDataProvider.cs
Normal file
51
EveCalc.Shared/StaticData/StaticDataProvider.cs
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
using EveCalc.Shared.ObjectModel;
|
||||||
|
using Microsoft.Data.Sqlite;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace EveCalc.Shared.StaticData
|
||||||
|
{
|
||||||
|
public class StaticDataProvider
|
||||||
|
{
|
||||||
|
public StaticDataProvider()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
public List<BlueprintMaterial> GetMaterialsForBlueprint(long id)
|
||||||
|
{
|
||||||
|
var result = new List<BlueprintMaterial>();
|
||||||
|
|
||||||
|
using (var connection = new SqliteConnection("Data Source=StaticData\\staticdata.sqlite"))
|
||||||
|
{
|
||||||
|
connection.Open();
|
||||||
|
|
||||||
|
var command = connection.CreateCommand();
|
||||||
|
command.CommandText = @"select materialTypeID, invTypes.typename, quantity "
|
||||||
|
+ "from industryActivityMaterials "
|
||||||
|
+ "inner join invTypes on invTypes.typeID=industryActivityMaterials.materialTypeID "
|
||||||
|
+ "where blueprintTypeID=$id";
|
||||||
|
command.Parameters.AddWithValue("id", id);
|
||||||
|
|
||||||
|
using (var reader = command.ExecuteReader())
|
||||||
|
{
|
||||||
|
while (reader.Read())
|
||||||
|
{
|
||||||
|
var material = new BlueprintMaterial();
|
||||||
|
material.MaterialTypeId = reader.GetInt64(0);
|
||||||
|
material.MaterialTypeName = reader.GetString(1);
|
||||||
|
material.Quantity = reader.GetInt64(2);
|
||||||
|
result.Add(material);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
connection.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
EveCalc.Shared/StaticData/staticdata.sqlite
Normal file
BIN
EveCalc.Shared/StaticData/staticdata.sqlite
Normal file
Binary file not shown.
18
EveCalc.Shared/Views/BrowserView.xaml
Normal file
18
EveCalc.Shared/Views/BrowserView.xaml
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<Window
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:wpf="clr-namespace:Microsoft.Web.WebView2.Wpf;assembly=Microsoft.Web.WebView2.Wpf"
|
||||||
|
x:Class="EveCalc.Shared.Views.BrowserView"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
Title="BrowserView" Height="450" Width="800">
|
||||||
|
<Grid>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
<RowDefinition Height="*"/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<TextBox x:Name="TxtUrl" Grid.Row="0" Height="25"/>
|
||||||
|
<wpf:WebView2 x:Name="WbrBrowser" Grid.Row="1" NavigationStarting="WbrBrowser_NavigationStarting"/>
|
||||||
|
|
||||||
|
</Grid>
|
||||||
|
</Window>
|
||||||
48
EveCalc.Shared/Views/BrowserView.xaml.cs
Normal file
48
EveCalc.Shared/Views/BrowserView.xaml.cs
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Data;
|
||||||
|
using System.Windows.Documents;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Media.Imaging;
|
||||||
|
using System.Windows.Shapes;
|
||||||
|
|
||||||
|
namespace EveCalc.Shared.Views
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Interaction logic for BrowserView.xaml
|
||||||
|
/// </summary>
|
||||||
|
public partial class BrowserView : Window
|
||||||
|
{
|
||||||
|
public string AuthCode { get; private set; }
|
||||||
|
public BrowserView()
|
||||||
|
{
|
||||||
|
this.InitializeComponent();
|
||||||
|
//this.WbrBrowser.EnsureCoreWebView2Async().Wait();
|
||||||
|
}
|
||||||
|
|
||||||
|
public BrowserView(string url) : this()
|
||||||
|
{
|
||||||
|
this.WbrBrowser.Source = new Uri(url);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void WbrBrowser_NavigationStarting(object sender, Microsoft.Web.WebView2.Core.CoreWebView2NavigationStartingEventArgs e)
|
||||||
|
{
|
||||||
|
this.TxtUrl.Text = e.Uri.ToString();
|
||||||
|
|
||||||
|
if (this.TxtUrl.Text.StartsWith("https://localhost/evecalc?code="))
|
||||||
|
{
|
||||||
|
// Habemus login
|
||||||
|
var split = this.TxtUrl.Text.Split(new[] { "code=", "&state=" }, StringSplitOptions.None);
|
||||||
|
this.AuthCode = split[1];
|
||||||
|
this.DialogResult = true;
|
||||||
|
this.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
9
EveCalc.Tests/App.xaml
Normal file
9
EveCalc.Tests/App.xaml
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<Application x:Class="EveCalc.Tests.App"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:local="clr-namespace:EveCalc.Tests"
|
||||||
|
StartupUri="MainWindow.xaml">
|
||||||
|
<Application.Resources>
|
||||||
|
|
||||||
|
</Application.Resources>
|
||||||
|
</Application>
|
||||||
17
EveCalc.Tests/App.xaml.cs
Normal file
17
EveCalc.Tests/App.xaml.cs
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Configuration;
|
||||||
|
using System.Data;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows;
|
||||||
|
|
||||||
|
namespace EveCalc.Tests
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Interaction logic for App.xaml
|
||||||
|
/// </summary>
|
||||||
|
public partial class App : Application
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
10
EveCalc.Tests/AssemblyInfo.cs
Normal file
10
EveCalc.Tests/AssemblyInfo.cs
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
using System.Windows;
|
||||||
|
|
||||||
|
[assembly: ThemeInfo(
|
||||||
|
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
|
||||||
|
//(used if a resource is not found in the page,
|
||||||
|
// or application resource dictionaries)
|
||||||
|
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
|
||||||
|
//(used if a resource is not found in the page,
|
||||||
|
// app, or any theme specific resource dictionaries)
|
||||||
|
)]
|
||||||
13
EveCalc.Tests/EveCalc.Tests.csproj
Normal file
13
EveCalc.Tests/EveCalc.Tests.csproj
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>WinExe</OutputType>
|
||||||
|
<TargetFramework>net5.0-windows</TargetFramework>
|
||||||
|
<UseWPF>true</UseWPF>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\EveCalc.Shared\EveCalc.Shared.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
21
EveCalc.Tests/MainWindow.xaml
Normal file
21
EveCalc.Tests/MainWindow.xaml
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<Window x:Class="EveCalc.Tests.MainWindow"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:local="clr-namespace:EveCalc.Tests"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
Title="MainWindow" Height="450" Width="800">
|
||||||
|
<Grid>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
<RowDefinition Height="*"/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
|
<StackPanel>
|
||||||
|
<Button Grid.Row="0" Height="25" Width="100" Content="Login" Click="Button_Click"/>
|
||||||
|
<Button Grid.Row="0" Height="25" Width="100" Content="Get Token" Click="Button_Click_1"/>
|
||||||
|
</StackPanel>
|
||||||
|
<TextBox x:Name="TxtResponse" Grid.Row="1"/>
|
||||||
|
</Grid>
|
||||||
|
</Window>
|
||||||
51
EveCalc.Tests/MainWindow.xaml.cs
Normal file
51
EveCalc.Tests/MainWindow.xaml.cs
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
using EveCalc.Shared;
|
||||||
|
using EveCalc.Shared.Logic;
|
||||||
|
using EveCalc.Shared.StaticData;
|
||||||
|
using EveCalc.Shared.Views;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Data;
|
||||||
|
using System.Windows.Documents;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Media.Imaging;
|
||||||
|
using System.Windows.Navigation;
|
||||||
|
using System.Windows.Shapes;
|
||||||
|
|
||||||
|
namespace EveCalc.Tests
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Interaction logic for MainWindow.xaml
|
||||||
|
/// </summary>
|
||||||
|
public partial class MainWindow : Window
|
||||||
|
{
|
||||||
|
private readonly EsiClientWrapper client = new EsiClientWrapper();
|
||||||
|
|
||||||
|
public MainWindow()
|
||||||
|
{
|
||||||
|
this.InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Button_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
var url = this.client.GetLoginUrl();
|
||||||
|
var browser = new BrowserView(url);
|
||||||
|
if (browser.ShowDialog() == true)
|
||||||
|
{
|
||||||
|
this.client.SetAuthCode(browser.AuthCode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void Button_Click_1(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
//var result = await this.client.GetCorpMats();
|
||||||
|
//var bla = await this.client.Search("tritanium");
|
||||||
|
var bla = new StaticDataProvider();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
@@ -6,4 +6,8 @@
|
|||||||
<UseWPF>true</UseWPF>
|
<UseWPF>true</UseWPF>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\EveCalc.Shared\EveCalc.Shared.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -7,6 +7,49 @@
|
|||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
Title="MainWindow" Height="450" Width="800">
|
Title="MainWindow" Height="450" Width="800">
|
||||||
<Grid>
|
<Grid>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
<RowDefinition Height="*"/>
|
||||||
|
<RowDefinition Height="*"/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="2*"/>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
|
<Menu Grid.Row="0" Grid.ColumnSpan="2">
|
||||||
|
<Menu.Items>
|
||||||
|
<MenuItem Header="Daten">
|
||||||
|
<MenuItem Header="Login..." Click="MnuLogin_Click"/>
|
||||||
|
<MenuItem Header="Blueprints laden" Click="MnuLoadBlueprints_Click"/>
|
||||||
|
<MenuItem Header="Vorhandene Materialien laden" Click="MnuLoadMats_Click"/>
|
||||||
|
</MenuItem>
|
||||||
|
</Menu.Items>
|
||||||
|
</Menu>
|
||||||
|
|
||||||
|
<ListView x:Name="LvwBlueprints" Grid.Row="1" ItemsSource="{Binding CorpBlueprints, UpdateSourceTrigger=PropertyChanged}">
|
||||||
|
<ListView.View>
|
||||||
|
<GridView>
|
||||||
|
<GridView.Columns>
|
||||||
|
<GridViewColumn Header="Name" Width="150" DisplayMemberBinding="{Binding TypeName}"/>
|
||||||
|
<GridViewColumn Header="Quanity" Width="47" DisplayMemberBinding="{Binding Quantity}"/>
|
||||||
|
<GridViewColumn Header="Runs" Width="30" DisplayMemberBinding="{Binding Runs}"/>
|
||||||
|
<GridViewColumn Header="Mat Eff" Width="50" DisplayMemberBinding="{Binding MaterialEfficiency}"/>
|
||||||
|
<GridViewColumn Header="Time Eff" Width="50" DisplayMemberBinding="{Binding TimeEfficiency}"/>
|
||||||
|
</GridView.Columns>
|
||||||
|
</GridView>
|
||||||
|
</ListView.View>
|
||||||
|
</ListView>
|
||||||
|
|
||||||
|
<ListView x:Name="LvwMats" Grid.Row="1" Grid.Column="1" ItemsSource="{Binding CorpBlueprints, UpdateSourceTrigger=PropertyChanged}">
|
||||||
|
<ListView.View>
|
||||||
|
<GridView>
|
||||||
|
<GridView.Columns>
|
||||||
|
<GridViewColumn Header="Name" Width="150" DisplayMemberBinding="{Binding TypeName}"/>
|
||||||
|
<GridViewColumn Header="Quantity" Width="50" DisplayMemberBinding="{Binding Quantity}"/>
|
||||||
|
</GridView.Columns>
|
||||||
|
</GridView>
|
||||||
|
</ListView.View>
|
||||||
|
</ListView>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Window>
|
</Window>
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
using System;
|
using EveCalc.Shared.Logic;
|
||||||
|
using EveCalc.Shared.ObjectModel;
|
||||||
|
using EveCalc.Shared.Views;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@@ -20,9 +24,52 @@ namespace EveCalc.UI
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class MainWindow : Window
|
public partial class MainWindow : Window
|
||||||
{
|
{
|
||||||
|
private readonly EsiClientWrapper client = new EsiClientWrapper();
|
||||||
|
|
||||||
public MainWindow()
|
public MainWindow()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ObservableCollection<Blueprint> CorpBlueprints = new ObservableCollection<Blueprint>();
|
||||||
|
public ObservableCollection<object> CorpMats = new ObservableCollection<object>();
|
||||||
|
|
||||||
|
private void MnuLogin_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
var url = this.client.GetLoginUrl();
|
||||||
|
var browser = new BrowserView(url);
|
||||||
|
if (browser.ShowDialog() == true)
|
||||||
|
{
|
||||||
|
this.client.SetAuthCode(browser.AuthCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
MessageBox.Show("Login ok");
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void MnuLoadBlueprints_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
this.CorpBlueprints.Clear();
|
||||||
|
var result = await this.client.GetCorpBlueprints();
|
||||||
|
foreach (var blueprint in result)
|
||||||
|
{
|
||||||
|
this.CorpBlueprints.Add(blueprint);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.LvwBlueprints.ItemsSource = null;
|
||||||
|
this.LvwBlueprints.ItemsSource = this.CorpBlueprints;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void MnuLoadMats_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
this.CorpMats.Clear();
|
||||||
|
var result = await this.client.GetCorpMats();
|
||||||
|
//foreach (var mat in result)
|
||||||
|
//{
|
||||||
|
// this.CorpMats.Add(mat);
|
||||||
|
//}
|
||||||
|
|
||||||
|
this.LvwMats.ItemsSource = null;
|
||||||
|
this.LvwMats.ItemsSource = this.CorpMats;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
12
EveCalc.sln
12
EveCalc.sln
@@ -5,6 +5,10 @@ VisualStudioVersion = 16.0.30907.101
|
|||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EveCalc.UI", "EveCalc.UI\EveCalc.UI.csproj", "{48C3E1AC-0478-44AF-AC1B-0E694DCBF9AD}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EveCalc.UI", "EveCalc.UI\EveCalc.UI.csproj", "{48C3E1AC-0478-44AF-AC1B-0E694DCBF9AD}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EveCalc.Tests", "EveCalc.Tests\EveCalc.Tests.csproj", "{7DE99FF6-50BF-4F90-A23A-F6438B133BEF}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EveCalc.Shared", "EveCalc.Shared\EveCalc.Shared.csproj", "{2A2A249E-0FA3-4BE9-B5EC-A6FDEC04F4A9}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@@ -15,6 +19,14 @@ Global
|
|||||||
{48C3E1AC-0478-44AF-AC1B-0E694DCBF9AD}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{48C3E1AC-0478-44AF-AC1B-0E694DCBF9AD}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{48C3E1AC-0478-44AF-AC1B-0E694DCBF9AD}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{48C3E1AC-0478-44AF-AC1B-0E694DCBF9AD}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{48C3E1AC-0478-44AF-AC1B-0E694DCBF9AD}.Release|Any CPU.Build.0 = Release|Any CPU
|
{48C3E1AC-0478-44AF-AC1B-0E694DCBF9AD}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{7DE99FF6-50BF-4F90-A23A-F6438B133BEF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{7DE99FF6-50BF-4F90-A23A-F6438B133BEF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{7DE99FF6-50BF-4F90-A23A-F6438B133BEF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{7DE99FF6-50BF-4F90-A23A-F6438B133BEF}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{2A2A249E-0FA3-4BE9-B5EC-A6FDEC04F4A9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{2A2A249E-0FA3-4BE9-B5EC-A6FDEC04F4A9}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{2A2A249E-0FA3-4BE9-B5EC-A6FDEC04F4A9}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{2A2A249E-0FA3-4BE9-B5EC-A6FDEC04F4A9}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|||||||
Reference in New Issue
Block a user