changement de candidat à l'investissement
This commit is contained in:
parent
8114c2409c
commit
be3087fff6
351 changed files with 359 additions and 497 deletions
|
|
@ -0,0 +1,42 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace BookAStar.Behaviors
|
||||
{
|
||||
public class DecimalValidatorBehavior : Behavior<Entry>
|
||||
{
|
||||
// Creating BindableProperties with Limited write access: http://iosapi.xamarin.com/index.aspx?link=M%3AXamarin.Forms.BindableObject.SetValue(Xamarin.Forms.BindablePropertyKey%2CSystem.Object)
|
||||
|
||||
static readonly BindablePropertyKey IsValidPropertyKey = BindableProperty.CreateReadOnly("IsValid", typeof(bool), typeof(DecimalValidatorBehavior), false);
|
||||
|
||||
public static readonly BindableProperty IsValidProperty = IsValidPropertyKey.BindableProperty;
|
||||
|
||||
public bool IsValid
|
||||
{
|
||||
get { return (bool)base.GetValue(IsValidProperty); }
|
||||
private set { base.SetValue(IsValidPropertyKey, value); }
|
||||
}
|
||||
|
||||
protected override void OnAttachedTo(Entry bindable)
|
||||
{
|
||||
bindable.TextChanged += bindable_TextChanged;
|
||||
}
|
||||
|
||||
private void bindable_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
decimal result;
|
||||
IsValid = decimal.TryParse(e.NewTextValue, NumberStyles.Currency,CultureInfo.InvariantCulture, out result);
|
||||
((Entry)sender).TextColor = IsValid ? Color.Default : Color.Red;
|
||||
}
|
||||
|
||||
protected override void OnDetachingFrom(Entry bindable)
|
||||
{
|
||||
bindable.TextChanged -= bindable_TextChanged;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,80 @@
|
|||
using System;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace BookAStar.Behaviors
|
||||
{
|
||||
public class EditorMaxLengthValidator : Behavior<Editor>
|
||||
{
|
||||
public static readonly BindableProperty MaxLengthProperty =
|
||||
BindableProperty.Create("MaxLength", typeof(int), typeof(EditorMaxLengthValidator), int.MaxValue);
|
||||
|
||||
public static readonly BindableProperty MinLengthProperty =
|
||||
BindableProperty.Create("MinLength", typeof(int), typeof(EditorMaxLengthValidator), 0);
|
||||
|
||||
public static readonly BindableProperty IsValidProperty =
|
||||
BindableProperty.Create("IsValid", typeof(bool), typeof(EditorMaxLengthValidator), false);
|
||||
|
||||
public static readonly BindableProperty ErrorProperty =
|
||||
BindableProperty.Create("Error", typeof(string), typeof(EditorMaxLengthValidator), null);
|
||||
|
||||
public int MaxLength
|
||||
{
|
||||
get { return (int) GetValue(MaxLengthProperty); }
|
||||
set { SetValue(MaxLengthProperty, value); }
|
||||
}
|
||||
|
||||
public int MinLength
|
||||
{
|
||||
get { return (int) GetValue(MinLengthProperty); }
|
||||
set { SetValue(MinLengthProperty, value); }
|
||||
}
|
||||
|
||||
protected override void OnAttachedTo(Editor bindable)
|
||||
{
|
||||
bindable.TextChanged += bindable_TextChanged;
|
||||
}
|
||||
|
||||
public bool IsValid {
|
||||
get { return (bool) GetValue(IsValidProperty); }
|
||||
set { SetValue(IsValidProperty, value);
|
||||
}
|
||||
}
|
||||
|
||||
public string Error
|
||||
{
|
||||
get
|
||||
{
|
||||
return (string) GetValue(ErrorProperty);
|
||||
}
|
||||
set
|
||||
{
|
||||
SetValue(ErrorProperty, value);
|
||||
}
|
||||
}
|
||||
private void bindable_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
if (e.NewTextValue != null && e.NewTextValue.Length >= MinLength)
|
||||
{
|
||||
if (e.NewTextValue.Length > MaxLength)
|
||||
{
|
||||
((Editor)sender).Text = e.NewTextValue.Substring(0, MaxLength);
|
||||
Error = Strings.YourTextWasTooLong;
|
||||
}
|
||||
else Error = "";
|
||||
IsValid = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Error = string.Format(Strings.MinMaxStringValidationError,
|
||||
MinLength, MaxLength);
|
||||
IsValid = false;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnDetachingFrom(Editor bindable)
|
||||
{
|
||||
bindable.TextChanged -= bindable_TextChanged;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace BookAStar.Behaviors
|
||||
{
|
||||
public class EmailValidatorBehavior : RegexValidatorBehavior
|
||||
{
|
||||
const string emailRegex = @"^(?("")("".+?(?<!\\)""@)|(([0-9a-z]((\.(?!\.))|[-!#\$%&'\*\+/=\?\^`\{\}\|~\w])*)(?<=[0-9a-z])@))" +
|
||||
@"(?(\[)(\[(\d{1,3}\.){3}\d{1,3}\])|(([0-9a-z][-\w]*[0-9a-z]*\.)+[a-z0-9][\-a-z0-9]{0,22}[a-z0-9]))$";
|
||||
|
||||
public EmailValidatorBehavior()
|
||||
{
|
||||
Regexp = emailRegex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
using Xamarin.Forms;
|
||||
|
||||
namespace BookAStar.Behaviors
|
||||
{
|
||||
public class IntegerEntryBehavior : Behavior<Entry>
|
||||
{
|
||||
public static readonly BindableProperty MinProperty = BindableProperty.Create("Min", typeof(int), typeof(IntegerEntryBehavior), 0);
|
||||
public static readonly BindableProperty MaxProperty = BindableProperty.Create("Max", typeof(int), typeof(IntegerEntryBehavior), 0);
|
||||
public static readonly BindableProperty IsValidProperty =
|
||||
BindableProperty.Create("IsValid", typeof(bool), typeof(IntegerEntryBehavior), false);
|
||||
public static readonly BindableProperty ErrorProperty =
|
||||
BindableProperty.Create("Error", typeof(string), typeof(IntegerEntryBehavior), null);
|
||||
public int Min
|
||||
{
|
||||
get { return (int)GetValue(MinProperty); }
|
||||
set { SetValue(MinProperty, value); }
|
||||
}
|
||||
|
||||
public int Max
|
||||
{
|
||||
get { return (int)GetValue(MaxProperty); }
|
||||
set { SetValue(MaxProperty, value); }
|
||||
}
|
||||
|
||||
protected override void OnAttachedTo(Entry bindable)
|
||||
{
|
||||
bindable.TextChanged += bindable_TextChanged;
|
||||
}
|
||||
|
||||
private void bindable_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
int val;
|
||||
if (int.TryParse(e.NewTextValue, out val))
|
||||
{
|
||||
IsValid = (Min > Max) || (Max >= val && val >= Min);
|
||||
Error = string.Format(Strings.MinMaxIntError, Min, Max);
|
||||
}
|
||||
else
|
||||
{
|
||||
IsValid = false;
|
||||
Error = "";
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnDetachingFrom(Entry bindable)
|
||||
{
|
||||
bindable.TextChanged -= bindable_TextChanged;
|
||||
|
||||
}
|
||||
public bool IsValid
|
||||
{
|
||||
get {
|
||||
return (bool) GetValue(IsValidProperty);
|
||||
}
|
||||
set
|
||||
{
|
||||
SetValue(IsValidProperty, value);
|
||||
}
|
||||
}
|
||||
public string Error
|
||||
{
|
||||
get
|
||||
{
|
||||
return (string) GetValue(ErrorProperty);
|
||||
}
|
||||
set
|
||||
{
|
||||
SetValue(ErrorProperty, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
using BookAStar.Views;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace BookAStar.Behaviors
|
||||
{
|
||||
public class MarkdownViewLengthValidator : Behavior<MarkdownView>
|
||||
{
|
||||
public static readonly BindableProperty MaxLengthProperty = BindableProperty.Create("MaxLength", typeof(int), typeof(MarkdownViewLengthValidator), 0);
|
||||
public static readonly BindableProperty MinLengthProperty = BindableProperty.Create("MinLength", typeof(int), typeof(MarkdownViewLengthValidator), 0);
|
||||
public int MaxLength
|
||||
{
|
||||
get { return (int)GetValue(MaxLengthProperty); }
|
||||
set { SetValue(MaxLengthProperty, value); }
|
||||
}
|
||||
public int MinLength
|
||||
{
|
||||
get { return (int)GetValue(MinLengthProperty); }
|
||||
set { SetValue(MinLengthProperty, value); }
|
||||
}
|
||||
protected override void OnAttachedTo(MarkdownView bindable)
|
||||
{
|
||||
bindable.Modified += bindable_TextChanged;
|
||||
}
|
||||
|
||||
public bool IsValid { get; set; }
|
||||
|
||||
private void bindable_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
IsValid = e.NewTextValue == null ? false : (e.NewTextValue.Length >= MinLength && e.NewTextValue.Length <= MaxLength);
|
||||
if (!IsValid) if (e.NewTextValue != null) if (e.NewTextValue.Length > MaxLength)
|
||||
((Editor)sender).Text = e.NewTextValue.Substring(0, MaxLength);
|
||||
}
|
||||
|
||||
protected override void OnDetachingFrom(MarkdownView bindable)
|
||||
{
|
||||
bindable.Modified -= bindable_TextChanged;
|
||||
}
|
||||
}
|
||||
}
|
||||
44
ZicMoove/ZicMoove/Converters/Behaviors/PickerBehavior.cs
Normal file
44
ZicMoove/ZicMoove/Converters/Behaviors/PickerBehavior.cs
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace BookAStar.Behaviors
|
||||
{
|
||||
public class PickerBehavior : Behavior<Picker>
|
||||
{
|
||||
// Creating BindableProperties with Limited write access: http://iosapi.xamarin.com/index.aspx?link=M%3AXamarin.Forms.BindableObject.SetValue(Xamarin.Forms.BindablePropertyKey%2CSystem.Object)
|
||||
|
||||
public static readonly BindablePropertyKey SelectedItemPropertyKey = BindableProperty.CreateReadOnly("SelectedItem", typeof(string), typeof(PickerBehavior), default(string));
|
||||
|
||||
public static readonly BindableProperty SelectedItemProperty = SelectedItemPropertyKey.BindableProperty;
|
||||
|
||||
public string SelectedItem
|
||||
{
|
||||
get { return (string)base.GetValue(SelectedItemProperty); }
|
||||
private set { base.SetValue(SelectedItemPropertyKey, value); }
|
||||
}
|
||||
|
||||
|
||||
protected override void OnAttachedTo(Picker bindable)
|
||||
{
|
||||
bindable.SelectedIndexChanged += bindable_SelectedIndexChanged;
|
||||
}
|
||||
|
||||
void bindable_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
var picker = (Picker)sender;
|
||||
if (picker.SelectedIndex <= 0 || picker.SelectedIndex > picker.Items.Count - 1)
|
||||
SelectedItem = null;
|
||||
else
|
||||
SelectedItem=picker.Items[picker.SelectedIndex];
|
||||
}
|
||||
|
||||
protected override void OnDetachingFrom(Picker bindable)
|
||||
{
|
||||
bindable.SelectedIndexChanged -= bindable_SelectedIndexChanged;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
using System;
|
||||
using System.Text.RegularExpressions;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace BookAStar.Behaviors
|
||||
{
|
||||
public class RegexValidatorBehavior : Behavior<Entry>
|
||||
{
|
||||
private string regexp = @"^([\d\w]+)$";
|
||||
// Creating BindableProperties with Limited write access: http://iosapi.xamarin.com/index.aspx?link=M%3AXamarin.Forms.BindableObject.SetValue(Xamarin.Forms.BindablePropertyKey%2CSystem.Object)
|
||||
|
||||
static readonly BindablePropertyKey IsValidPropertyKey = BindableProperty.CreateReadOnly("IsValid", typeof(bool), typeof(RegexValidatorBehavior), false);
|
||||
|
||||
public static readonly BindableProperty IsValidProperty = IsValidPropertyKey.BindableProperty;
|
||||
|
||||
public bool IsValid
|
||||
{
|
||||
get { return (bool)base.GetValue(IsValidProperty); }
|
||||
private set { base.SetValue(IsValidPropertyKey, value); }
|
||||
}
|
||||
|
||||
protected string Regexp
|
||||
{
|
||||
get
|
||||
{
|
||||
return regexp;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
regexp = value;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnAttachedTo(Entry bindable)
|
||||
{
|
||||
bindable.TextChanged += HandleTextChanged;
|
||||
}
|
||||
|
||||
|
||||
void HandleTextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
IsValid = (Regex.IsMatch(e.NewTextValue, regexp, RegexOptions.IgnoreCase, TimeSpan.FromMilliseconds(250)));
|
||||
((Entry)sender).TextColor = IsValid ? Color.Default : Color.Red;
|
||||
}
|
||||
|
||||
protected override void OnDetachingFrom(Entry bindable)
|
||||
{
|
||||
bindable.TextChanged -= HandleTextChanged;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
177
ZicMoove/ZicMoove/Converters/Behaviors/StarBehavior.cs
Normal file
177
ZicMoove/ZicMoove/Converters/Behaviors/StarBehavior.cs
Normal file
|
|
@ -0,0 +1,177 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace BookAStar.Behaviors
|
||||
{
|
||||
public class StarBehavior : Behavior<View>
|
||||
{
|
||||
TapGestureRecognizer tapRecognizer;
|
||||
static List<StarBehavior> defaultBehaviors = new List<StarBehavior>();
|
||||
static Dictionary<string, List<StarBehavior>> starGroups = new Dictionary<string, List<StarBehavior>>();
|
||||
|
||||
public static readonly BindableProperty GroupNameProperty =
|
||||
BindableProperty.Create("GroupName",
|
||||
typeof(string),
|
||||
typeof(StarBehavior),
|
||||
null,
|
||||
propertyChanged: OnGroupNameChanged);
|
||||
|
||||
public string GroupName
|
||||
{
|
||||
set { SetValue(GroupNameProperty, value); }
|
||||
get { return (string)GetValue(GroupNameProperty); }
|
||||
}
|
||||
|
||||
public static readonly BindableProperty RatingProperty =
|
||||
BindableProperty.Create("Rating",
|
||||
typeof(int),
|
||||
typeof(StarBehavior), default(int),
|
||||
BindingMode.TwoWay);
|
||||
|
||||
|
||||
public static event EventHandler<EventArgs> StarTapped;
|
||||
|
||||
public int Rating
|
||||
{
|
||||
set { SetValue(RatingProperty, value); }
|
||||
get { return (int)GetValue(RatingProperty); }
|
||||
}
|
||||
|
||||
static void OnGroupNameChanged(BindableObject bindable, object oldValue, object newValue)
|
||||
{
|
||||
StarBehavior behavior = (StarBehavior)bindable;
|
||||
string oldGroupName = (string)oldValue;
|
||||
string newGroupName = (string)newValue;
|
||||
|
||||
// Remove existing behavior from Group
|
||||
if (String.IsNullOrEmpty(oldGroupName))
|
||||
{
|
||||
defaultBehaviors.Remove(behavior);
|
||||
}
|
||||
else
|
||||
{
|
||||
List<StarBehavior> behaviors = starGroups[oldGroupName];
|
||||
behaviors.Remove(behavior);
|
||||
|
||||
if (behaviors.Count == 0)
|
||||
{
|
||||
starGroups.Remove(oldGroupName);
|
||||
}
|
||||
}
|
||||
|
||||
// Add New Behavior to the group
|
||||
if (String.IsNullOrEmpty(newGroupName))
|
||||
{
|
||||
defaultBehaviors.Add(behavior);
|
||||
}
|
||||
else
|
||||
{
|
||||
List<StarBehavior> behaviors = null;
|
||||
|
||||
if (starGroups.ContainsKey(newGroupName))
|
||||
{
|
||||
behaviors = starGroups[newGroupName];
|
||||
}
|
||||
else
|
||||
{
|
||||
behaviors = new List<StarBehavior>();
|
||||
starGroups.Add(newGroupName, behaviors);
|
||||
}
|
||||
|
||||
behaviors.Add(behavior);
|
||||
}
|
||||
}
|
||||
|
||||
public static readonly BindableProperty IsStarredProperty =
|
||||
BindableProperty.Create("IsStarred",
|
||||
typeof(bool),
|
||||
typeof(StarBehavior),
|
||||
false,
|
||||
propertyChanged: OnIsStarredChanged);
|
||||
|
||||
public bool IsStarred
|
||||
{
|
||||
set { SetValue(IsStarredProperty, value); }
|
||||
get { return (bool)GetValue(IsStarredProperty); }
|
||||
}
|
||||
|
||||
static void OnIsStarredChanged(BindableObject bindable, object oldValue, object newValue)
|
||||
{
|
||||
StarBehavior behavior = (StarBehavior)bindable;
|
||||
|
||||
|
||||
string groupName = behavior.GroupName;
|
||||
List<StarBehavior> behaviors = null;
|
||||
|
||||
if (string.IsNullOrEmpty(groupName))
|
||||
{
|
||||
behaviors = defaultBehaviors;
|
||||
}
|
||||
else
|
||||
{
|
||||
behaviors = starGroups[groupName];
|
||||
}
|
||||
|
||||
bool itemReached = false;
|
||||
int count = 0, position = 0;
|
||||
// all positions to left IsStarred = true and all position to the right is false
|
||||
foreach (var item in behaviors)
|
||||
{
|
||||
count++;
|
||||
if (item != behavior && !itemReached)
|
||||
{
|
||||
item.IsStarred = true;
|
||||
}
|
||||
if (item == behavior)
|
||||
{
|
||||
itemReached = true;
|
||||
// whould try to call this method again
|
||||
// Assert item.IsStarred == newValue;
|
||||
|
||||
// There are **6** positions, from 0 to five stars.
|
||||
if ((bool)newValue)
|
||||
position = count;
|
||||
else position = count - 1;
|
||||
}
|
||||
if (item != behavior && itemReached)
|
||||
item.IsStarred = false;
|
||||
|
||||
item.Rating = position;
|
||||
}
|
||||
// Assert count > 0
|
||||
behaviors[count - 1].Rating = position;
|
||||
|
||||
}
|
||||
|
||||
public StarBehavior()
|
||||
{
|
||||
defaultBehaviors.Add(this);
|
||||
}
|
||||
|
||||
protected override void OnAttachedTo(View view)
|
||||
{
|
||||
tapRecognizer = new TapGestureRecognizer();
|
||||
tapRecognizer.Tapped += OnTapRecognizerTapped;
|
||||
view.GestureRecognizers.Add(tapRecognizer);
|
||||
}
|
||||
|
||||
protected override void OnDetachingFrom(View view)
|
||||
{
|
||||
view.GestureRecognizers.Remove(tapRecognizer);
|
||||
tapRecognizer.Tapped -= OnTapRecognizerTapped;
|
||||
}
|
||||
|
||||
void OnTapRecognizerTapped(object sender, EventArgs args)
|
||||
{
|
||||
// Assert sender is mine
|
||||
bool currentIsStarred = (bool) GetValue(IsStarredProperty);
|
||||
IsStarred = !currentIsStarred;
|
||||
if (StarTapped!=null)
|
||||
StarTapped.Invoke(this, new EventArgs());
|
||||
}
|
||||
}
|
||||
}
|
||||
29
ZicMoove/ZicMoove/Converters/BooleanToObjectConverter.cs
Normal file
29
ZicMoove/ZicMoove/Converters/BooleanToObjectConverter.cs
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace BookAStar.Converters
|
||||
{
|
||||
public class BooleanToObjectConverter<T> : IValueConverter
|
||||
{
|
||||
public T FalseObject { set; get; }
|
||||
|
||||
public T TrueObject { set; get; }
|
||||
|
||||
public object Convert(object value, Type targetType,
|
||||
object parameter, CultureInfo culture)
|
||||
{
|
||||
return (bool)value ? this.TrueObject : this.FalseObject;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType,
|
||||
object parameter, CultureInfo culture)
|
||||
{
|
||||
return ((T)value).Equals(this.TrueObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
22
ZicMoove/ZicMoove/Converters/EnumConverter.cs
Normal file
22
ZicMoove/ZicMoove/Converters/EnumConverter.cs
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
using System;
|
||||
using System.Globalization;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace BookAStar.Converters
|
||||
{
|
||||
/// <summary>
|
||||
/// When EnumType:int
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
30
ZicMoove/ZicMoove/Converters/GenderConverter.cs
Normal file
30
ZicMoove/ZicMoove/Converters/GenderConverter.cs
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace BookAStar.Converters
|
||||
{
|
||||
class GenderConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
||||
{
|
||||
if (value == null)
|
||||
return string.Empty;
|
||||
|
||||
var gender = value.ToString();
|
||||
if (gender == "Mâle")
|
||||
return "Vous etes sédisant!";
|
||||
else if (gender == "Femelle")
|
||||
return "Vous etes une beauté!";
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
19
ZicMoove/ZicMoove/Converters/NotValueConverter.cs
Normal file
19
ZicMoove/ZicMoove/Converters/NotValueConverter.cs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
using System;
|
||||
using System.Globalization;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace BookAStar.Converters
|
||||
{
|
||||
public class NotValueConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return object.Equals(value, false);
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return object.Equals(value, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
37
ZicMoove/ZicMoove/Converters/RatingText.cs
Normal file
37
ZicMoove/ZicMoove/Converters/RatingText.cs
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace BookAStar.Converters
|
||||
{
|
||||
class RatingText : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
||||
{
|
||||
var rating = (int)value;
|
||||
if (rating == 0)
|
||||
return Strings.NoStar;
|
||||
if (rating == 1)
|
||||
return Strings.OneStar;
|
||||
if (rating == 2)
|
||||
return Strings.TwoStars;
|
||||
if (rating == 3)
|
||||
return Strings.ThreeStars;
|
||||
if (rating == 4)
|
||||
return Strings.ForStars;
|
||||
if (rating == 5)
|
||||
return Strings.FiveStars;
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
using Microsoft.AspNet.SignalR.Client;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace BookAStar.Converters
|
||||
{
|
||||
public class SignalRConnectionStateToObject<T> : IValueConverter
|
||||
{
|
||||
public T ConnectedObject { set; get; }
|
||||
|
||||
public T ConnectingObject { set; get; }
|
||||
|
||||
public T DisconnectedObject { set; get; }
|
||||
|
||||
public T ReconnectingObject { set; get; }
|
||||
|
||||
public object Convert(object value, Type targetType,
|
||||
object parameter, CultureInfo culture)
|
||||
{
|
||||
switch ((ConnectionState)value) {
|
||||
case ConnectionState.Connected: return ConnectedObject;
|
||||
case ConnectionState.Connecting: return ConnectingObject;
|
||||
case ConnectionState.Disconnected: return DisconnectedObject;
|
||||
case ConnectionState.Reconnecting: return ReconnectingObject;
|
||||
}
|
||||
Debug.Assert(false);
|
||||
return null;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType,
|
||||
object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue