diff --git a/BookAStar/BookAStar/App.xaml.cs b/BookAStar/BookAStar/App.xaml.cs index cf691818..edd3a913 100644 --- a/BookAStar/BookAStar/App.xaml.cs +++ b/BookAStar/BookAStar/App.xaml.cs @@ -111,7 +111,7 @@ namespace BookAStar ViewFactory.Register(); ViewFactory.Register(); ViewFactory.Register(); - ViewFactory.Register(); + ViewFactory.Register(); ConfigManager = new XLabs.Settings.GenericConfigSettingsMgr(s => MainSettings.AppSettings.GetValueOrDefault(s, MainSettings.SettingsDefault), null); diff --git a/BookAStar/BookAStar/Attributes/CurrencyAttribute.cs b/BookAStar/BookAStar/Attributes/CurrencyAttribute.cs new file mode 100644 index 00000000..48ac81dc --- /dev/null +++ b/BookAStar/BookAStar/Attributes/CurrencyAttribute.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BookAStar.Attributes +{ + class CurrencyAttribute: Attribute + { + } +} diff --git a/BookAStar/BookAStar/Attributes/DisplayAttribute.cs b/BookAStar/BookAStar/Attributes/DisplayAttribute.cs new file mode 100644 index 00000000..aa8c11fc --- /dev/null +++ b/BookAStar/BookAStar/Attributes/DisplayAttribute.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BookAStar.Attributes +{ + class DisplayAttribute : Attribute + { + public string Name { get; set; } + public string Description { get; set; } + public DisplayAttribute() + { + + } + public DisplayAttribute(string name) + { + Name = name; + } + } +} diff --git a/BookAStar/BookAStar/BookAStar.csproj b/BookAStar/BookAStar/BookAStar.csproj index ec918cbb..e060e5e1 100644 --- a/BookAStar/BookAStar/BookAStar.csproj +++ b/BookAStar/BookAStar/BookAStar.csproj @@ -40,16 +40,20 @@ App.xaml + + + + diff --git a/BookAStar/BookAStar/Converters/EnumConverter.cs b/BookAStar/BookAStar/Converters/EnumConverter.cs new file mode 100644 index 00000000..bb430189 --- /dev/null +++ b/BookAStar/BookAStar/Converters/EnumConverter.cs @@ -0,0 +1,22 @@ +using System; +using System.Globalization; +using Xamarin.Forms; + +namespace BookAStar.Converters +{ + /// + /// When EnumType:int + /// + class EnumConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + return value.ToString(); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return (int) value; + } + } +} diff --git a/BookAStar/BookAStar/Extensions/EnumExtensions.cs b/BookAStar/BookAStar/Extensions/EnumExtensions.cs new file mode 100644 index 00000000..2ae54e39 --- /dev/null +++ b/BookAStar/BookAStar/Extensions/EnumExtensions.cs @@ -0,0 +1,43 @@ +using BookAStar.Attributes; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; + +namespace BookAStar.Extensions +{ + public static class EnumExtensions + { + public static string GetDescription(this Enum value) + { + var type = value.GetType(); + var typeInfo = type.GetTypeInfo(); + var declaredMember = typeInfo.DeclaredMembers.FirstOrDefault(i => i.Name == value.ToString()); + var attribute = declaredMember?.GetCustomAttribute(); + + return attribute == null ? value.ToString() : attribute.Description; + } + + public static IEnumerable GetDescriptions(Type type) + { + var values = Enum.GetValues(type).Cast(); + var descriptions = new List(); + + foreach (var value in values) + { + descriptions.Add(value.GetDescription()); + } + + return descriptions; + } + + public static Enum GetEnumFromDescription(string description, Type enumType) + { + var enumValues = Enum.GetValues(enumType).Cast(); + var descriptionToEnum = enumValues.ToDictionary(k => k.GetDescription(), v => v); + return descriptionToEnum[description]; + } + } +} diff --git a/BookAStar/BookAStar/Pages/BookQueryPage.xaml.cs b/BookAStar/BookAStar/Pages/BookQueryPage.xaml.cs index ae272ec1..4a4ee605 100644 --- a/BookAStar/BookAStar/Pages/BookQueryPage.xaml.cs +++ b/BookAStar/BookAStar/Pages/BookQueryPage.xaml.cs @@ -78,7 +78,7 @@ namespace BookAStar.Pages Description = "# **Hello Estimate!**" }; App.NavigationService.NavigateTo(true, - new EstimateViewModel(e)); + new EditEstimateViewModel(e)); } } diff --git a/BookAStar/BookAStar/Pages/EditBillingLinePage.xaml b/BookAStar/BookAStar/Pages/EditBillingLinePage.xaml index 9f8ad878..297171e6 100644 --- a/BookAStar/BookAStar/Pages/EditBillingLinePage.xaml +++ b/BookAStar/BookAStar/Pages/EditBillingLinePage.xaml @@ -16,8 +16,9 @@ + - + + + + - + + - - - - Jours - Heures - Minutes - - + + + + @@ -63,14 +67,15 @@ - + - - - \ No newline at end of file diff --git a/BookAStar/BookAStar/Pages/EditBillingLinePage.xaml.cs b/BookAStar/BookAStar/Pages/EditBillingLinePage.xaml.cs index 2a1d9f3d..c395d808 100644 --- a/BookAStar/BookAStar/Pages/EditBillingLinePage.xaml.cs +++ b/BookAStar/BookAStar/Pages/EditBillingLinePage.xaml.cs @@ -1,10 +1,6 @@ using BookAStar.ViewModels; using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Input; using Xamarin.Forms; namespace BookAStar.Pages @@ -13,12 +9,17 @@ namespace BookAStar.Pages { public EditBillingLinePage(BillingLineViewModel model) { - BindingContext = model; InitializeComponent(); - } + foreach + (string du in Enum.GetNames(typeof(BillingLineViewModel.DurationUnits))) + picker.Items.Add(du); + BindingContext = model; + } + public void OnValidateClicked (object sender, EventArgs e) { - OnBackButtonPressed(); + + this.Navigation.PopAsync(); } } } diff --git a/BookAStar/BookAStar/Pages/EditEstimatePage.xaml b/BookAStar/BookAStar/Pages/EditEstimatePage.xaml index bf4d86fe..cd085b30 100644 --- a/BookAStar/BookAStar/Pages/EditEstimatePage.xaml +++ b/BookAStar/BookAStar/Pages/EditEstimatePage.xaml @@ -36,17 +36,70 @@ Property=Width, Factor=1}" > - - - - + + + + + - - + + + + + + + + + + + + + + + + + +