new files, fixes recent refactorings and more

main
Paul Schneider 9 years ago
parent 36054f8b73
commit 41b245fd2d
14 changed files with 200 additions and 130 deletions

@ -40,7 +40,16 @@
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
</Compile>
<Compile Include="Behaviors\EmailValidatorBehavior.cs" />
<Compile Include="Behaviors\MaxLengthValidator.cs" />
<Compile Include="Behaviors\DecimalValidatorBehavior.cs" />
<Compile Include="Behaviors\PickerBehavior.cs" />
<Compile Include="Behaviors\StarBehavior.cs" />
<Compile Include="Constants.cs" />
<Compile Include="Converters\BooleanToObjectConverter.cs" />
<Compile Include="Converters\GenderConverter.cs" />
<Compile Include="Converters\RatingText.cs" />
<Compile Include="Extensions\ImageResourceExtension.cs" />
<Compile Include="Factories\ViewFactory.cs" />
<Compile Include="Helpers\DataManager.cs" />
<Compile Include="Helpers\ObservableString.cs" />
@ -50,7 +59,7 @@
<Compile Include="Helpers\PageHelpers.cs" />
<Compile Include="Helpers\PropertySupport.cs" />
<Compile Include="Helpers\RemoteEntityRO.cs" />
<Compile Include="Helpers\ServiceNotAvailable1.cs" />
<Compile Include="Helpers\ServiceNotAvailable.cs" />
<Compile Include="Helpers\Settings.cs" />
<Compile Include="Helpers\UserHelpers.cs" />
<Compile Include="Interfaces\IComponentContext.cs" />
@ -133,9 +142,6 @@
<Compile Include="ViewModels\EstimateViewModel.cs" />
<Compile Include="ViewModels\UserLoginViewModel.cs" />
<Compile Include="ViewModels\ViewModelBase.cs" />
<Compile Include="Views\CommandLineEditor.xaml.cs">
<DependentUpon>CommandLineEditor.xaml</DependentUpon>
</Compile>
<Compile Include="Views\MarkdownView.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Pages\SearchPage.xaml.cs">
@ -145,6 +151,9 @@
<DependentUpon>AccountChooserPage.xaml</DependentUpon>
</Compile>
<Compile Include="Model\Tag.cs" />
<Compile Include="Views\RatingView.xaml.cs">
<DependentUpon>RatingView.xaml</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="App.xaml">
@ -279,33 +288,39 @@
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Views\CommandLineEditor.xaml">
<SubType>Designer</SubType>
<EmbeddedResource Include="Pages\EditBillingLinePage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
<SubType>Designer</SubType>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Pages\EditBillingLinePage.xaml">
<EmbeddedResource Include="Pages\DashboardPage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
<SubType>Designer</SubType>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Pages\DashboardPage.xaml">
<EmbeddedResource Include="Images\Users\icon_add_user.png" />
<EmbeddedResource Include="Images\Users\icon_anon_user.png" />
<EmbeddedResource Include="Images\Users\icon_block_user.png" />
<EmbeddedResource Include="Images\Users\icon_remove_user.png" />
<EmbeddedResource Include="Images\Users\icon_user.png" />
<EmbeddedResource Include="Images\Users\icon_user_settings.png" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Pages\HomePage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
<SubType>Designer</SubType>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Images\icon_add_user.png" />
<EmbeddedResource Include="Images\icon_anon_user.png" />
<EmbeddedResource Include="Images\icon_block_user.png" />
<EmbeddedResource Include="Images\icon_remove_user.png" />
<EmbeddedResource Include="Images\icon_user.png" />
<EmbeddedResource Include="Images\icon_user_settings.png" />
<Content Include="Images\Validation\error.png" />
<Content Include="Images\Validation\star_outline.png" />
<Content Include="Images\Validation\star_selected.png" />
<Content Include="Images\Validation\success.png" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Pages\HomePage.xaml">
<EmbeddedResource Include="Views\RatingView.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
<SubType>Designer</SubType>
</EmbeddedResource>

@ -18,7 +18,7 @@ namespace BookAStar.Pages
private void OnViewDetail(object sender, ItemTappedEventArgs e)
{
BookQueryData data = e.Item as BookQueryData;
App.CurrentApp.NavigationService.NavigateTo<BookQueryPage>(true,data);
App.NavigationService.NavigateTo<BookQueryPage>(true,data);
}
}
}

@ -77,7 +77,7 @@ namespace BookAStar.Pages
Id = 0,
Description = "# **Hello Estimate!**"
};
App.CurrentApp.NavigationService.NavigateTo<EditEstimatePage>(true,
App.NavigationService.NavigateTo<EditEstimatePage>(true,
new EstimateViewModel(e));
}

@ -1,6 +1,8 @@
<?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:local="clr-namespace:BookAStar;assembly=BookAStar"
xmlns:views="clr-namespace:BookAStar.Views;assembly=BookAStar"
x:Class="BookAStar.Pages.DashboardPage"
xmlns:lc="clr-namespace:XLabs.Forms.Controls;assembly=XLabs.Forms"
xmlns:lb="clr-namespace:XLabs.Forms.Behaviors;assembly=XLabs.Forms"
@ -23,16 +25,20 @@
</Label>
<lb:Gestures.Interests>
<lb:GestureCollection>
<lb:GestureInterest GestureType="LongPress" GestureCommand="{Binding UserNameGesture}" GestureParameter="LongPress" />
<lb:GestureInterest GestureType="LongPress"
GestureCommand="{Binding UserNameGesture}"
GestureParameter="LongPress" />
</lb:GestureCollection>
</lb:Gestures.Interests>
<Image Source="{Binding Avatar}" Aspect="AspectFit" VisualElement.HeightRequest="{StaticResource BigUserAvatarSize}" />
</Frame>
</lc:GesturesContentView>
<Label Text="{Binding UserName}" Style="{StaticResource LabelPageHeadingStyle}"
HorizontalTextAlignment="Center"
LineBreakMode="WordWrap" XAlign="Center"
></Label>
<views:RatingView Rating="{Binding Rating}"/>
</lb:Gestures.Interests>
</Frame>
</lc:GesturesContentView>
<Button Text="{Binding PerformerStatus}" Clicked="OnViewPerformerStatus" />
<Button Text="{Binding UserQueries}" Clicked="OnViewUserQueries" />
<StackLayout Orientation="Horizontal" >

@ -35,7 +35,7 @@ namespace BookAStar.Pages
private void ShowPage<T>(object [] args, bool animate=false) where T:Page
{
App.CurrentApp.NavigationService.NavigateTo<T>(animate, args);
App.NavigationService.NavigateTo<T>(animate, args);
App.MasterPresented = false;
}

@ -22,21 +22,21 @@
Style="{StaticResource InputLabelStyle}"></Label>
<StackLayout Orientation="Horizontal">
<Entry Placeholder="Durée" Keyboard="Numeric" Style="{StaticResource BigEntry}" />
<Picker x:Name="picker" SelectedIndex="1" Style="{StaticResource PickerStyle}" Title="Unité de temps">
<Picker x:Name="picker" SelectedIndex="{Binding UnitaryCost, Mode=TwoWay}" Style="{StaticResource PickerStyle}" Title="Unité de temps">
<Picker.Items>
<x:String>Heures</x:String>
<x:String>Jours</x:String>
<x:String>Heures</x:String>
<x:String>Minutes</x:String>
</Picker.Items>
</Picker>
</StackLayout>
<Label Text="Quantité facturée" Style="{StaticResource InputLabelStyle}"></Label>
<Entry Placeholder="Quantité" Text="1" Keyboard="Numeric" Style="{StaticResource BigEntry}"/>
<Entry Text="{Binding Count, Mode=TwoWay}" Placeholder="Quantité" Keyboard="Numeric" Style="{StaticResource BigEntry}"/>
<Label Text="Prix unitaire" Style="{StaticResource InputLabelStyle}"></Label>
<StackLayout Orientation="Horizontal">
<Entry Placeholder="Prix" Keyboard="Numeric" Style="{StaticResource BigEntry}"></Entry>
<Entry Text="{Binding UnitaryCostText, Mode=TwoWay}" Placeholder="Prix" Keyboard="Numeric" Style="{StaticResource BigEntry}"></Entry>
<Label Text="€" Style="{StaticResource BigLabel}" HorizontalTextAlignment="Start"/>
</StackLayout>
<Button Text="Valider cette ligne de facture" Command="{Binding ValidateCommand}"></Button>
<Button Text="Valider cette ligne de facture" Command="{Binding ValidateCommand}" Clicked="OnValidateClicked"></Button>
</StackLayout>
</ContentPage>

@ -13,9 +13,12 @@ namespace BookAStar.Pages
{
public EditBillingLinePage(BillingLineViewModel model)
{
InitializeComponent();
BindingContext = model;
InvalidateMeasure();
InitializeComponent();
}
public void OnValidateClicked (object sender, EventArgs e)
{
OnBackButtonPressed();
}
}
}

@ -43,10 +43,18 @@ namespace BookAStar.Pages
protected void OnNewCommanLine(object sender, EventArgs e)
{
var com = new BillingLine();
App.CurrentApp.NavigationService.NavigateTo<EditBillingLinePage>(
var com = new BillingLine() { Count = 1, UnitaryCost = 0.01m };
var lineView = new BillingLineViewModel(com)
{
ValidateCommand = new Command(() => {
((EstimateViewModel)BindingContext).Bill.
Add(com);
})
};
App.NavigationService.NavigateTo<EditBillingLinePage>(
true,
new object[] { new BillingLineViewModel(((EstimateViewModel)this.BindingContext).Data,com) } );
new object[] { lineView } );
}
}

@ -1,6 +1,7 @@
using BookAStar.Interfaces;
using BookAStar.Model.Workflow;
using System;
using System.Globalization;
using System.Windows.Input;
using Xamarin.Forms;
using XLabs.Forms.Mvvm;
@ -10,18 +11,12 @@ namespace BookAStar.ViewModels
public class BillingLineViewModel : ViewModel, IBillingLine
{
BillingLine data;
public Estimate Billing { protected set; get; }
public BillingLineViewModel(Estimate billing, BillingLine data)
public BillingLineViewModel( BillingLine data)
{
this.data = (data == null) ? new BillingLine() : data;
Billing = billing;
ValidateCommand =
new Command(
() => {
Billing.Bill.Add(data);
Validated.Invoke(this, new EventArgs());
});
// sets durationValue & unit
Duration = data.Duration;
}
protected int count;
@ -29,12 +24,13 @@ namespace BookAStar.ViewModels
{
get
{
return count;
return data.Count;
}
set
{
SetProperty<int>(ref count, value, "Count");
data.Count = count;
}
}
protected string description;
@ -42,45 +38,129 @@ namespace BookAStar.ViewModels
{
get
{
return description;
return data.Description;
}
set
{
SetProperty<string>(ref description, value, "Description");
data.Description = value;
}
}
protected TimeSpan duration;
public TimeSpan Duration
protected int durationValue;
public int DurationValue
{
get
{
return duration;
return durationValue;
}
set
{
SetProperty<int>(ref durationValue, value, "DurationValue");
data.Duration = this.Duration;
}
}
public enum DurationUnits:int
{
Jours=0,
Heures=1,
Minutes=2
}
private DurationUnits durationUnit;
public DurationUnits DurationUnit
{
get {
return durationUnit;
}
set
{
SetProperty<TimeSpan>(ref duration, value, "Duration");
SetProperty<DurationUnits>(ref durationUnit, value, "DurationUnit");
data.Duration = this.Duration;
}
}
protected decimal unitaryCost;
public decimal UnitaryCost
public static readonly string unitCostFormat = "0,.00";
public string UnitaryCostText
{
get
{
return unitaryCost;
return unitaryCost.ToString(unitCostFormat, CultureInfo.InvariantCulture);
}
set
{
SetProperty<decimal>(ref unitaryCost, value, "UnitaryCost");
decimal newValue;
if (decimal.TryParse(value, NumberStyles.Currency,
CultureInfo.InvariantCulture,
out newValue))
{
SetProperty<decimal>(ref unitaryCost, newValue, "UnitaryCostText");
SetProperty<bool>(ref invalidCost, false, "InvalidCost");
}
else
SetProperty<bool>(ref invalidCost, true, "InvalidCost");
}
}
bool invalidCost;
public bool InvalidCost
{
get { return invalidCost; }
}
public ICommand ValidateCommand { set; get; }
public TimeSpan Duration
{
get
{
switch (DurationUnit)
{
case DurationUnits.Heures:
return new TimeSpan(DurationValue, 0, 0);
case DurationUnits.Jours:
return new TimeSpan(DurationValue*24, 0, 0);
case DurationUnits.Minutes:
return new TimeSpan(0, DurationValue, 0);
// Assert(false); since all units are treated bellow
default:
return new TimeSpan(0, 0, DurationValue);
}
}
public ICommand ValidateCommand { protected set; get; }
set
{
double days = value.TotalDays;
if (days >= 1.0)
{
DurationValue = (int) days;
DurationUnit = DurationUnits.Jours;
return;
}
double hours = value.TotalHours;
if (hours >= 1.0)
{
DurationValue = (int) hours;
DurationUnit = DurationUnits.Jours;
return;
}
DurationValue = (int) value.TotalMinutes;
DurationUnit = DurationUnits.Minutes;
}
}
public event EventHandler<EventArgs> Validated;
public decimal UnitaryCost
{
get
{
return decimal.Parse(this.UnitaryCostText,CultureInfo.InvariantCulture);
}
set
{
UnitaryCostText = value.ToString(unitCostFormat, CultureInfo.InvariantCulture);
}
}
}
}

@ -12,6 +12,7 @@ using XLabs.Platform.Services;
namespace BookAStar.ViewModels
{
internal class DashboardViewModel : ViewModel
{
public string UserId

@ -1,25 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentView xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:BookAStar;assembly=BookAStar"
x:Class="BookAStar.Views.CommandLineEditor"
BackgroundColor="{x:Static local:Constants.BackgroundColor}"
>
<StackLayout>
<Label Text="Description de la ligne de facture"></Label>
<Editor ></Editor>
<StackLayout Orientation="Horizontal">
<Entry Placeholder="Durée de la prestation" Keyboard="Numeric"></Entry>
<Picker>
<Picker.Items>
<x:String>Heures</x:String>
<x:String>Jours</x:String>
<x:String>Minutes</x:String>
</Picker.Items>
</Picker>
</StackLayout>
<Entry Placeholder="Quantité" Text="1"/>
<Entry Placeholder="Prix unitaire" ></Entry>
<Button Text="Valider cette ligne de facture"></Button>
</StackLayout>
</ContentView>

@ -1,18 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
namespace BookAStar.Views
{
public partial class CommandLineEditor : ContentView
{
public CommandLineEditor()
{
InitializeComponent();
}
}
}

@ -1,6 +1,7 @@
using BookAStar.Interfaces;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Reflection.Emit;
using System.Text;
@ -15,19 +16,18 @@ namespace BookAStar.Views
"Markdown", typeof(string), typeof(MarkdownView), null, BindingMode.TwoWay
);
private string markdown;
public string Markdown
{
get
{
return markdown;
return GetValue(MarkdownProperty) as string;
}
set
{
if (markdown != value)
if (Markdown != value)
{
markdown = value;
SetValue(MarkdownProperty, value);
if (Modified != null)
{
Modified.Invoke(this, new EventArgs());
@ -45,10 +45,10 @@ namespace BookAStar.Views
double height = heightConstraint;
if (MinimumWidthRequest>0)
width = widthConstraint > 80 ? widthConstraint < double.MaxValue ? widthConstraint : MinimumWidthRequest : MinimumWidthRequest;
width = widthConstraint > MinimumWidthRequest ? widthConstraint < double.MaxValue ? widthConstraint : MinimumWidthRequest : MinimumWidthRequest;
if (MinimumHeightRequest > 0)
height = heightConstraint > 160 ? heightConstraint < double.MaxValue ? heightConstraint : MinimumHeightRequest : MinimumHeightRequest;
height = heightConstraint > MinimumHeightRequest ? heightConstraint < double.MaxValue ? heightConstraint : MinimumHeightRequest : MinimumHeightRequest;
return base.OnMeasure(width, height);
}

Loading…