Ajout du navigator. Création ce l'UCCompte (uniquement le fichier) pour vérifier le fonctionnement du navigator.

Navigator
Vincent ASTOLFI 2 years ago
parent a58a828e98
commit 9f0f85df25

@ -0,0 +1,64 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
namespace IHM
{
public class Navigator : INotifyPropertyChanged
{
public const string PART_COMPTE = "Compte";
public const string PART_OPERATION = "Opération";
public const string PART_ECHEANCIER = "Echéancier";
public const string PART_PLANNIFICATION = "Plannification";
public const string PART_STATISTIQUE = "Statistique";
public ReadOnlyDictionary<string, Func<UserControl>> WindowPart { get; private set; }
Dictionary<string, Func<UserControl>> windowPart { get; set; } = new Dictionary<string, Func<UserControl>>
{
[PART_COMPTE] = () => new UCCompte(),
// [PART_OPERATION] = () => new UCOperation(),
// [PART_ECHEANCIER] = () => new UCEcheancier(),
// [PART_PLANNIFICATION] = () => new UCPlannification(),
// [PART_STATISTIQUE] = () => new UCStatistique(),
};
public Navigator()
{
WindowPart = new ReadOnlyDictionary<string, Func<UserControl>>(windowPart);
SelectedUserControlCreator = windowPart.First();
}
public KeyValuePair<string, Func<UserControl>> SelectedUserControlCreator
{
get => SelectedUserControlCreator;
set
{
if (selectedUserControlCreator.Equals(value)) return;
selectedUserControlCreator = value;
OnPropertyChanged();
}
}
private KeyValuePair<string, Func<UserControl>> selectedUserControlCreator;
public event PropertyChangedEventHandler PropertyChanged;
void OnPropertyChanged([CallerMemberName] string propertyName = "")
=> PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
public void NavigateTo(string windowPartName)
{
if (WindowPart.ContainsKey(windowPartName))
{
selectedUserControlCreator = WindowPart.Single(kvp => kvp.Key == windowPartName);
}
}
}
}

@ -0,0 +1,12 @@
<UserControl x:Class="IHM.UCCompte"
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:local="clr-namespace:IHM"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid>
</Grid>
</UserControl>

@ -0,0 +1,28 @@
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 IHM
{
/// <summary>
/// Logique d'interaction pour UCCompte.xaml
/// </summary>
public partial class UCCompte : UserControl
{
public UCCompte()
{
InitializeComponent();
}
}
}
Loading…
Cancel
Save