-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #229 from jetelain/config-endpoints
Allow to change source locations
- Loading branch information
Showing
26 changed files
with
342 additions
and
70 deletions.
There are no files selected for viewing
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
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
30 changes: 30 additions & 0 deletions
30
GameRealisticMap.Studio/Modules/Main/Services/GrmConfigService.cs
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,30 @@ | ||
using System; | ||
using System.ComponentModel.Composition; | ||
using System.IO; | ||
using System.Threading.Tasks; | ||
using GameRealisticMap.Configuration; | ||
|
||
namespace GameRealisticMap.Studio.Modules.Main.Services | ||
{ | ||
[Export(typeof(IGrmConfigService))] | ||
internal class GrmConfigService : IGrmConfigService | ||
{ | ||
private ISourceLocations? sources; | ||
|
||
public ISourceLocations GetSources() | ||
{ | ||
return sources ?? new DefaultSourceLocations(); | ||
} | ||
|
||
public async Task Load() | ||
{ | ||
sources = await SourceLocations.Load(); | ||
} | ||
|
||
public async Task SetSources(ISourceLocations newSources) | ||
{ | ||
await SourceLocations.Save(newSources); | ||
sources = await SourceLocations.Load(); | ||
} | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
GameRealisticMap.Studio/Modules/Main/Services/IGrmConfigService.cs
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,14 @@ | ||
using System.Threading.Tasks; | ||
using GameRealisticMap.Configuration; | ||
|
||
namespace GameRealisticMap.Studio.Modules.Main.Services | ||
{ | ||
public interface IGrmConfigService | ||
{ | ||
ISourceLocations GetSources(); | ||
|
||
Task SetSources(ISourceLocations sources); | ||
|
||
Task Load(); | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
GameRealisticMap.Studio/Modules/Main/ViewModels/GrmSourcesViewModel.cs
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,51 @@ | ||
using System; | ||
using System.ComponentModel.Composition; | ||
using System.Threading.Tasks; | ||
using Caliburn.Micro; | ||
using GameRealisticMap.Configuration; | ||
using GameRealisticMap.Studio.Modules.Main.Services; | ||
using Gemini.Modules.Settings; | ||
|
||
namespace GameRealisticMap.Studio.Modules.Main.ViewModels | ||
{ | ||
[PartCreationPolicy(CreationPolicy.NonShared)] | ||
[Export(typeof(ISettingsEditorAsync))] | ||
internal class GrmSourcesViewModel : PropertyChangedBase, ISettingsEditorAsync, ISourceLocations | ||
{ | ||
private readonly IGrmConfigService configService; | ||
|
||
[ImportingConstructor] | ||
public GrmSourcesViewModel(IGrmConfigService configService) | ||
{ | ||
this.configService = configService; | ||
var sources = configService.GetSources(); | ||
MapToolkitSRTM15Plus = sources.MapToolkitSRTM15Plus; | ||
MapToolkitSRTM1 = sources.MapToolkitSRTM1; | ||
MapToolkitAW3D30 = sources.MapToolkitAW3D30; | ||
WeatherStats = sources.WeatherStats; | ||
OverpassApiInterpreter = sources.OverpassApiInterpreter; | ||
S2CloudlessBasePath = sources.S2CloudlessBasePath; | ||
} | ||
|
||
public string SettingsPageName => "Sources"; | ||
|
||
public string SettingsPagePath => "Game Realistic Map"; | ||
|
||
public Uri MapToolkitSRTM15Plus { get; set; } | ||
|
||
public Uri MapToolkitSRTM1 { get; set; } | ||
|
||
public Uri MapToolkitAW3D30 { get; set; } | ||
|
||
public Uri WeatherStats { get; set; } | ||
|
||
public Uri OverpassApiInterpreter { get; set; } | ||
|
||
public Uri S2CloudlessBasePath { get; set; } | ||
|
||
public async Task ApplyChangesAsync() | ||
{ | ||
await configService.SetSources(this); | ||
} | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
GameRealisticMap.Studio/Modules/Main/Views/GrmSourcesView.xaml
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,41 @@ | ||
<UserControl x:Class="GameRealisticMap.Studio.Modules.Main.Views.GrmSourcesView" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:b="clr-namespace:GameRealisticMap.Studio.Behaviors" | ||
xmlns:r="clr-namespace:GameRealisticMap.Studio" | ||
xmlns:local="clr-namespace:GameRealisticMap.Studio.Modules.Arma3Data.Views" | ||
mc:Ignorable="d" | ||
d:DesignHeight="450" d:DesignWidth="800"> | ||
<StackPanel> | ||
|
||
<StackPanel Orientation="Horizontal"> | ||
<Label Width="150">MapToolkit SRTM15Plus</Label> | ||
<TextBox Text="{Binding MapToolkitSRTM15Plus}" Width="450" /> | ||
</StackPanel> | ||
<StackPanel Orientation="Horizontal"> | ||
<Label Width="150">MapToolkit SRTM1</Label> | ||
<TextBox Text="{Binding MapToolkitSRTM1}" Width="450" /> | ||
</StackPanel> | ||
<StackPanel Orientation="Horizontal"> | ||
<Label Width="150">MapToolkit AW3D30</Label> | ||
<TextBox Text="{Binding MapToolkitAW3D30}" Width="450" /> | ||
</StackPanel> | ||
<StackPanel Orientation="Horizontal"> | ||
<Label Width="150">WeatherStats</Label> | ||
<TextBox Text="{Binding WeatherStats}" Width="450" /> | ||
</StackPanel> | ||
<StackPanel Orientation="Horizontal"> | ||
<Label Width="150">OverpassApi Interpreter</Label> | ||
<TextBox Text="{Binding OverpassApiInterpreter}" Width="450" /> | ||
</StackPanel> | ||
<StackPanel Orientation="Horizontal"> | ||
<Label Width="150">S2Cloudless Base Path</Label> | ||
<TextBox Text="{Binding S2CloudlessBasePath}" Width="450" /> | ||
</StackPanel> | ||
|
||
|
||
|
||
</StackPanel> | ||
</UserControl> |
Oops, something went wrong.