1
0
Fork 0
mirror of https://github.com/Nioux/AideDeJeu.git synced 2025-10-29 14:35:45 +00:00

Merge branch 'test_shell2'

This commit is contained in:
Yan Maniez 2019-09-30 10:09:02 +02:00
commit 08135c06eb
21 changed files with 11823 additions and 11289 deletions

File diff suppressed because it is too large Load diff

View file

@ -158,6 +158,9 @@
<EmbeddedResource Update="Views\Library\DeepSearchPage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Update="Views\Library\ItemPage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Update="Views\MainNavigationPage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>

View file

@ -4,6 +4,7 @@ using AideDeJeu.ViewModels.Library;
using AideDeJeu.ViewModels.PlayerCharacter;
using AideDeJeu.Views;
using AideDeJeuLib;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Xamarin.Forms;
@ -29,11 +30,14 @@ namespace AideDeJeu
var bgtan = (Color)Resources["HDWhite"];
//MainPage = new MainShell();
var mainNavigationPage = new MainNavigationPage();
vm.Navigator = new Navigator(mainNavigationPage.Navigation);
MainPage = mainNavigationPage;
mainNavigationPage.Navigation.PushAsync(new MainPage());
MainPage = new MainShell();
//var mainNavigationPage = new MainNavigationPage();
//vm.Navigator = new Navigator(mainNavigationPage.Navigation);
vm.Navigator = new Navigator(Shell.Current.Navigation);
Routing.RegisterRoute("item", typeof(Views.Library.ItemPage));
//MainPage = mainNavigationPage;
//mainNavigationPage.Navigation.PushAsync(new MainPage());
}

View file

@ -239,6 +239,8 @@ namespace AideDeJeu.ViewModels
public async Task NavigateToLinkAsync(string s)
{
await Navigation.PushAsync(new ItemPage(s), true);//.GoToAsync($"item?path={Uri.EscapeDataString(s)}");
return;
if (s != null)
{
var regex = new Regex("/?(?<file>.*?)(_with_(?<with>.*))?\\.md(#(?<anchor>.*))?");

View file

@ -0,0 +1,48 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:tools="clr-namespace:AideDeJeu.Tools"
xmlns:mdview="clr-namespace:Xam.Forms.Markdown"
x:Class="AideDeJeu.Views.Library.ItemPage"
Title="{Binding Title}"
Icon="spell_book.png"
x:Name="This">
<ContentPage.Resources>
<ResourceDictionary>
<tools:MonsterMarkdownTheme x:Key="MonsterMarkdownTheme" />
<tools:NullToFalseConverter x:Key="NullToFalseConverter" />
</ResourceDictionary>
</ContentPage.Resources>
<ContentPage.ToolbarItems>
<ToolbarItem Name="AddToFavorites" Text="Ajouter aux favoris" Order="Primary" Icon="round_star.png" Command="{Binding Main.Navigator.AddToFavoritesCommand}" />
<ToolbarItem Name="Print" Text="Générer un PDF" Order="Primary" Icon="scroll_unfurled.png" Command="{Binding Main.Navigator.GeneratePDFCommand}" CommandParameter="{Binding Item.Markdown}" />
</ContentPage.ToolbarItems>
<Grid>
<ScrollView Orientation="Vertical" BackgroundColor="{StaticResource HDWhite}">
<mdview:MarkdownView
Theme="{StaticResource MonsterMarkdownTheme}"
Markdown="{Binding Item.Item.Markdown}"
NavigateToLinkCommand="{Binding Main.Navigator.NavigateToLinkCommand}"
/>
</ScrollView>
<ActivityIndicator
VerticalOptions="StartAndExpand"
HorizontalOptions="End"
Color="{StaticResource HDRed}"
IsRunning="{Binding Main.IsLoading}"
IsVisible="{Binding Main.IsLoading}">
<ActivityIndicator.WidthRequest>
<OnPlatform x:TypeArguments="x:Double">
<On Platform="UWP" Value="400" />
<On Platform="iOS, Android" Value="50" />
</OnPlatform>
</ActivityIndicator.WidthRequest>
<ActivityIndicator.HeightRequest>
<OnPlatform x:TypeArguments="x:Double">
<On Platform="UWP" Value="10" />
<On Platform="iOS, Android" Value="50" />
</OnPlatform>
</ActivityIndicator.HeightRequest>
</ActivityIndicator>
</Grid>
</ContentPage>

View file

@ -0,0 +1,147 @@

using AideDeJeu.ViewModels;
using AideDeJeu.ViewModels.Library;
using AideDeJeuLib;
using SkiaSharp;
using SkiaSharp.Views.Forms;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
namespace AideDeJeu.Views.Library
{
[XamlCompilation(XamlCompilationOptions.Compile)]
[QueryProperty("Path", "path")]
public partial class ItemPage : ContentPage, INotifyPropertyChanged
{
public MainViewModel Main
{
get
{
return DependencyService.Get<MainViewModel>();
}
}
private ItemDetailViewModel _Item = null;
public ItemDetailViewModel Item
{
get
{
return _Item;
}
set
{
SetProperty(ref _Item, value);
}
}
public ItemPage()
{
BindingContext = this;
InitializeComponent();
}
public ItemPage(string id)
{
BindingContext = this;
InitializeComponent();
Path = id;
//LoadPageAsync();
}
//protected override void OnAppearing()
//{
// base.OnAppearing();
// LoadPageAsync();
//}
private string _Path { get; set; } = null; //"index.md";
public string Path
{
get
{
return _Path;
}
set
{
_Path = value;
LoadPageAsync();
}
}
private async Task LoadPageAsync()
{
if (Path == null) return;
var regex = new Regex("/?(?<file>.*?)(_with_(?<with>.*))?\\.md(#(?<anchor>.*))?");
var match = regex.Match(Uri.UnescapeDataString(Path));
var file = match.Groups["file"].Value;
var anchor = match.Groups["anchor"].Value;
var with = match.Groups["with"].Value;
Item item = null;
try
{
Main.IsBusy = true;
Main.IsLoading = true;
item = await Task.Run(async () => await Main.Store.GetItemFromDataAsync(file, anchor));
}
finally
{
Main.IsBusy = false;
Main.IsLoading = false;
}
if (item != null)
{
var items = item; // as Items;
var filterViewModel = items.GetNewFilterViewModel();
var itemsViewModel = new ItemDetailViewModel() { Item = items };
this.Item = itemsViewModel;
//SwitchToMainTab();
//if (filterViewModel == null)
//{
// await GotoItemsPageAsync(itemsViewModel);
//}
//else
//{
// await GotoFilteredItemsPageAsync(itemsViewModel);
//}
}
else
{
//await App.Current.MainPage.DisplayAlert("Lien invalide", s, "OK");
}
}
protected bool SetProperty<T>(ref T backingStore, T value,
[CallerMemberName]string propertyName = "",
Action onChanged = null)
{
if (EqualityComparer<T>.Default.Equals(backingStore, value))
return false;
backingStore = value;
onChanged?.Invoke();
CallOnPropertyChanged(propertyName);
return true;
}
#region INotifyPropertyChanged
public event PropertyChangedEventHandler PropertyChanged;
protected void CallOnPropertyChanged([CallerMemberName] string propertyName = "")
{
var changed = PropertyChanged;
if (changed == null)
return;
changed.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
#endregion
}
}

View file

@ -4,7 +4,33 @@
xmlns:local="clr-namespace:AideDeJeu.Views"
xmlns:pc="clr-namespace:AideDeJeu.Views.PlayerCharacter"
xmlns:library="clr-namespace:AideDeJeu.Views.Library"
x:Class="AideDeJeu.Views.MainShell">
x:Class="AideDeJeu.Views.MainShell"
BackgroundColor="{DynamicResource HDWhite}"
FlyoutBackgroundColor="{DynamicResource HDWhite}"
Shell.ForegroundColor="{DynamicResource HDRed}"
Shell.TitleColor="{DynamicResource HDBlack}"
Shell.UnselectedColor="{DynamicResource HDLightGrey}"
>
<Shell.Resources>
<ResourceDictionary>
<Color x:Key="NavigationPrimary">#2196F3</Color>
<Style x:Key="BaseStyle" TargetType="Element">
<Setter Property="Shell.BackgroundColor" Value="#ffff00" />
<Setter Property="Shell.ForegroundColor" Value="White" />
<Setter Property="Shell.TitleColor" Value="Red" />
<Setter Property="Shell.DisabledColor" Value="#B4FFFFFF" />
<Setter Property="Shell.UnselectedColor" Value="#95FFFFFF" />
<Setter Property="Shell.TabBarBackgroundColor" Value="Yellow" />
<Setter Property="Shell.TabBarForegroundColor" Value="Blue"/>
<Setter Property="Shell.TabBarUnselectedColor" Value="#95FFFFFF"/>
<Setter Property="Shell.TabBarTitleColor" Value="Violet"/>
</Style>
<Style TargetType="TabBar" BasedOn="{StaticResource BaseStyle}" />
</ResourceDictionary>
</Shell.Resources>
<Shell.FlyoutHeader>
<Label Text="{Binding HeaderTitle}" />
</Shell.FlyoutHeader>
<ShellItem Title="Accueil">
<ShellContent Title="Accueil" ContentTemplate="{DataTemplate local:MainPage}" />
@ -15,8 +41,20 @@
<ShellItem Title="Dés" FlyoutIcon="d20.png">
<ShellContent Title="Dés" ContentTemplate="{DataTemplate local:DicesPage}" />
</ShellItem>
<ShellItem Title="Bibliothèque" FlyoutIcon="spell_book.png" Route="data">
<ShellContent Title="Bibliothèque" Icon="spell_book.png" Route="item" ContentTemplate="{DataTemplate library:ItemDetailPage}" />
<ShellItem Title="Bibliothèque" FlyoutIcon="spell_book.png">
<!--<ShellContent Title="Bibliothèque" Icon="spell_book.png" ContentTemplate="{DataTemplate library:ItemPage}" />-->
<ShellContent Title="Bibliothèque" Icon="spell_book.png">
<ShellContent.ContentTemplate>
<DataTemplate>
<library:ItemPage>
<x:Arguments>
<x:String>index.md</x:String>
</x:Arguments>
</library:ItemPage>
</DataTemplate>
</ShellContent.ContentTemplate>
</ShellContent>
</ShellItem>
<!--<FlyoutItem Title="Héros &amp; Dragons">
<ShellContent Title="Héros &amp; Dragons" ContentTemplate="{DataTemplate library:ItemDetailPage}" />
@ -45,42 +83,102 @@
<FlyoutItem Title="SRD">
<ShellContent Title="SRD" ContentTemplate="{DataTemplate library:ItemDetailPage}" />
</FlyoutItem>-->
<ShellItem Title="Manuel des Règles">
<ShellContent>
<ShellContent.ContentTemplate>
<DataTemplate>
<library:ItemPage>
<x:Arguments>
<x:String>index_mdr.md</x:String>
</x:Arguments>
</library:ItemPage>
</DataTemplate>
</ShellContent.ContentTemplate>
</ShellContent>
</ShellItem>
<ShellItem Title="Cadre de Campagne">
<ShellContent>
<ShellContent.ContentTemplate>
<DataTemplate>
<library:ItemPage>
<x:Arguments>
<x:String>index_cdc.md</x:String>
</x:Arguments>
</library:ItemPage>
</DataTemplate>
</ShellContent.ContentTemplate>
</ShellContent>
</ShellItem>
<ShellItem Title="Créatures et Oppositions">
<ShellContent>
<ShellContent.ContentTemplate>
<DataTemplate>
<library:ItemPage>
<x:Arguments>
<x:String>index_ceo.md</x:String>
</x:Arguments>
</library:ItemPage>
</DataTemplate>
</ShellContent.ContentTemplate>
</ShellContent>
</ShellItem>
<ShellItem Title="Les Cinq Royaumes">
<ShellSection>
<ShellContent Title="test1">
<ShellContent.ContentTemplate>
<DataTemplate>
<library:ItemsPage>
<x:Arguments>
<x:String>l5r_index_hd.md</x:String>
</x:Arguments>
</library:ItemsPage>
</DataTemplate>
</ShellContent.ContentTemplate>
</ShellContent>
<ShellContent Title="test2">
<ShellContent.ContentTemplate>
<DataTemplate>
<library:ItemsPage>
<x:Arguments>
<x:String>l5r_index_hd.md</x:String>
</x:Arguments>
</library:ItemsPage>
</DataTemplate>
</ShellContent.ContentTemplate>
</ShellContent>
<ShellContent Title="test3">
<ShellContent.ContentTemplate>
<DataTemplate>
<library:ItemsPage>
<x:Arguments>
<x:String>l5r_index_hd.md</x:String>
</x:Arguments>
</library:ItemsPage>
</DataTemplate>
</ShellContent.ContentTemplate>
</ShellContent>
</ShellSection>
<ShellContent>
<ShellContent.ContentTemplate>
<DataTemplate>
<library:ItemPage>
<x:Arguments>
<x:String>l5r_index_hd.md</x:String>
</x:Arguments>
</library:ItemPage>
</DataTemplate>
</ShellContent.ContentTemplate>
</ShellContent>
</ShellItem>
<ShellItem Title="Livre des Monstres">
<ShellContent>
<ShellContent.ContentTemplate>
<DataTemplate>
<library:ItemPage>
<x:Arguments>
<x:String>tome_of_beasts.md</x:String>
</x:Arguments>
</library:ItemPage>
</DataTemplate>
</ShellContent.ContentTemplate>
</ShellContent>
</ShellItem>
<ShellItem Title="Monstrueusement Mignons">
<ShellContent>
<ShellContent.ContentTemplate>
<DataTemplate>
<library:ItemPage>
<x:Arguments>
<x:String>baby_bestiary.md</x:String>
</x:Arguments>
</library:ItemPage>
</DataTemplate>
</ShellContent.ContentTemplate>
</ShellContent>
</ShellItem>
<ShellItem Title="SRD">
<ShellContent>
<ShellContent.ContentTemplate>
<DataTemplate>
<library:ItemPage>
<x:Arguments>
<x:String>index_srd.md</x:String>
</x:Arguments>
</library:ItemPage>
</DataTemplate>
</ShellContent.ContentTemplate>
</ShellContent>
</ShellItem>
<ShellItem Title="Favoris">
<ShellContent Title="Favoris" ContentTemplate="{DataTemplate library:BookmarksPage}" FlyoutIcon="stars_stack.png" />
</ShellItem>
<ShellItem Title="Recherche">
<ShellContent Title="Recherche" ContentTemplate="{DataTemplate library:DeepSearchPage}" FlyoutIcon="crystal_ball.png" />
</ShellItem>
<!--Command="{Binding ShellNavigateCommand}"
CommandParameter="//data/item?path=l5r_index_hd.md"

View file

@ -1,6 +1,9 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
@ -10,7 +13,7 @@ using Xamarin.Forms.Xaml;
namespace AideDeJeu.Views
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class MainShell : Shell
public partial class MainShell : Shell, INotifyPropertyChanged
{
public MainShell()
{
@ -29,5 +32,50 @@ namespace AideDeJeu.Views
{
await Shell.Current.GoToAsync(path);
}
private string _HeaderTitle = string.Empty;
public string HeaderTitle
{
get
{
return _HeaderTitle;
}
set
{
SetProperty(ref _HeaderTitle, value);
}
}
protected override void OnNavigated(ShellNavigatedEventArgs args)
{
base.OnNavigated(args);
Debug.WriteLine(this.CurrentItem.CurrentItem.CurrentItem);
HeaderTitle = this.CurrentItem.CurrentItem.CurrentItem.Route;
}
protected bool SetProperty<T>(ref T backingStore, T value,
[CallerMemberName]string propertyName = "",
Action onChanged = null)
{
if (EqualityComparer<T>.Default.Equals(backingStore, value))
return false;
backingStore = value;
onChanged?.Invoke();
CallOnPropertyChanged(propertyName);
return true;
}
#region INotifyPropertyChanged
public event PropertyChangedEventHandler PropertyChanged;
protected void CallOnPropertyChanged([CallerMemberName] string propertyName = "")
{
var changed = PropertyChanged;
if (changed == null)
return;
changed.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
#endregion
}
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

12
Data/HD/index_cdc.md Normal file
View file

@ -0,0 +1,12 @@
# Cadre de campagne
## [Objets magiques](hd_magicitems.md)
### [Objets magiques de A à Z](hd_magicitems_az.md)
### [Objets magiques intelligents](hd_sentient_magicitems.md)
### [Artefacts](hd_artifacts.md)
## [Jouer dans un multivers](hd_planes.md)

14
Data/HD/index_ceo.md Normal file
View file

@ -0,0 +1,14 @@
# Créatures et oppositions
## [Créatures](hd_monsters.md)
## [Pièges](hd_traps.md)
## [Maladies](hd_diseases.md)
## [Folie](hd_madness.md)
## [Objets](hd_objects.md)
## [Poisons](hd_poisons.md)

28
Data/HD/index_mdr.md Normal file
View file

@ -0,0 +1,28 @@
# Manuel des règles
## [Création du personnage](hd_beyond1stlevel.md)
## [Races](hd_races.md)
## [Personnalité et Historique](hd_personnality_background.md)
## [Classes](hd_classes.md)
## [Équipement](hd_equipment.md)
## [Options de personnalisation](hd_custom_options.md)
## [Utiliser les Caractéristiques](hd_abilities.md)
## [Partir à l'aventure](hd_adventure.md)
## [Combattre](hd_combat.md)
## [Gérer la santé](hd_manage_health.md)
## [Lancer des sorts](hd_spellcasting.md)
## [Description des Sorts](hd_spells.md)
## [Panthéons](hd_pantheons.md)

8
Data/HD/index_srd.md Normal file
View file

@ -0,0 +1,8 @@
# SRD
## [Conditions](srd_conditions.md)
## [Spells](srd_spells.md)
## [Monsters, Animals and NPC](srd_monsters.md)

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

16
Data/index_cdc.md Normal file
View file

@ -0,0 +1,16 @@
<!--GenericItem-->
# <!--Name-->Cadre de campagne<!--/Name-->
## [Objets magiques](magicitems_hd.md)
### [Objets magiques de A à Z](magicitems_az_hd.md)
### [Objets magiques intelligents](sentient_magicitems_hd.md)
### [Artefacts](artifacts_hd.md)
## [Jouer dans un multivers](planes_hd.md)
<!--/GenericItem-->

18
Data/index_ceo.md Normal file
View file

@ -0,0 +1,18 @@
<!--GenericItem-->
# <!--Name-->Créatures et oppositions<!--/Name-->
## [Créatures](monsters_hd.md)
## [Pièges](traps_hd.md)
## [Maladies](diseases_hd.md)
## [Folie](madness_hd.md)
## [Objets](objects_hd.md)
## [Poisons](poisons_hd.md)
<!--/GenericItem-->

32
Data/index_mdr.md Normal file
View file

@ -0,0 +1,32 @@
<!--GenericItem-->
# <!--Name-->Manuel des règles<!--/Name-->
## [Création du personnage](beyond1stlevel_hd.md)
## [Races](races_hd.md)
## [Personnalité et Historique](personnality_background_hd.md)
## [Classes](classes_hd.md)
## [Équipement](equipment_hd.md)
## [Options de personnalisation](custom_options_hd.md)
## [Utiliser les Caractéristiques](abilities_hd.md)
## [Partir à l'aventure](adventure_hd.md)
## [Combattre](combat_hd.md)
## [Gérer la santé](manage_health_hd.md)
## [Lancer des sorts](spellcasting_hd.md)
## [Description des Sorts](spells_hd.md)
## [Panthéons](pantheons_hd.md)
<!--/GenericItem-->

12
Data/index_srd.md Normal file
View file

@ -0,0 +1,12 @@
<!--GenericItem-->
# <!--Name-->SRD<!--/Name-->
## [Conditions](conditions_vo.md)
## [Spells](spells_vo.md)
## [Monsters, Animals and NPC](monsters_vo.md)
<!--/GenericItem-->

Binary file not shown.