Merge branch 'vnext' of github.com:pazof/yavsc into vnext

This commit is contained in:
2016-11-14 17:42:53 +01:00
5 changed files with 503 additions and 339 deletions

File diff suppressed because it is too large Load Diff

View File

@ -58,9 +58,7 @@ namespace BookAStar
app.Suspended += OnSuspended;
MainSettings.UserChanged += MainSettings_UserChanged;
CrossConnectivity.Current.ConnectivityChanged += (conSender, args) =>
{
App.IsConnected = args.IsConnected;
};
{ App.IsConnected = args.IsConnected; };
SetupHubConnection();
if (CrossConnectivity.Current.IsConnected)
StartHubConnection();
@ -229,6 +227,26 @@ namespace BookAStar
this.MainPage = masterDetail;
NavigationService = new NavigationService(masterDetail.Detail.Navigation);
}
public static Task<string> DisplayActionSheet(string title, string cancel, string destruction, string [] buttons)
{
var currentPage = ((NavigationPage)Current.MainPage).CurrentPage;
return currentPage.DisplayActionSheet(title, cancel, destruction, buttons);
}
public static Task<bool> DisplayAlert(string title, string message, string yes = "OK", string no = null)
{
var currentPage = ((NavigationPage)Current.MainPage).CurrentPage;
if (no == null)
{
return currentPage.DisplayAlert(title, message, yes).ContinueWith(task => true);
}
else
{
return currentPage.DisplayAlert(title, message, yes, no);
}
}
private void TiPubChat_Clicked(object sender, EventArgs e)
{

View File

@ -0,0 +1,35 @@
using System.Collections.Generic;
using System.Linq;
using Xamarin.Forms;
namespace BookAStar.Model.Settings
{
class SignatureSettings
{
public static readonly Dictionary<string, Color> ColorPairs = new Dictionary<string, Color>
{
{ "<Accent Color>", Color.Accent },
{ "Aqua", Color.Aqua },
{ "Black", Color.Black },
{ "Blue", Color.Blue },
{ "Fuchsia", Color.Fuchsia },
{ "Gray", Color.Gray },
{ "Green", Color.Green },
{ "Lime", Color.Lime },
{ "Maroon", Color.Maroon },
{ "Navy", Color.Navy },
{ "Olive", Color.Olive },
{ "Pink", Color.Pink },
{ "Purple", Color.Purple },
{ "Red", Color.Red },
{ "Silver", Color.Silver },
{ "Teal", Color.Teal },
{ "White", Color.White },
{ "Yellow", Color.Yellow },
};
public static List<Color> Colors => ColorPairs.Values.ToList();
public static List<string> ColorNames => ColorPairs.Keys.ToList();
}
}

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<ContentView xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="BookAStar.Views.MDSigningView"
xmlns:signature="clr-namespace:SignaturePad.Forms;assembly=SignaturePad.Forms"
xmlns:views="clr-namespace:BookAStar.Views;assembly=BookAStar">
<ContentView.Content>
<views:MarkdownView Markdown="{Binging Doc}" Editable="false" />
<signature:SignaturePadView x:Name="padView"
HeightRequest="150" WidthRequest="240"
BackgroundColor="White"
CaptionText="Caption This" CaptionTextColor="Black"
ClearText="Efface moi!" ClearTextColor="Red"
PromptText="Prompt Here" PromptTextColor="Red"
SignatureLineColor="Aqua" StrokeColor="Black" StrokeWidth="2" />
<Button Clicked="OnChangeTheme" Text="Changer le Theme" />
<Button Clicked="OnGetStats" Text="Obtenir les stats de la signature " />
</ContentView.Content>
</ContentView>

View File

@ -0,0 +1,63 @@
using SignaturePad.Forms;
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 MDSigningView : ContentView
{
public MDSigningView()
{
InitializeComponent();
}
private async void OnChangeTheme(object sender, EventArgs e)
{
var action = await App.DisplayActionSheet(
"Change Theme", "Cancel", null,
new string[] { "White", "Black", "Aqua" } );
switch (action)
{
case "White":
padView.BackgroundColor = Color.White;
padView.StrokeColor = Color.Black;
padView.ClearTextColor = Color.Black;
padView.ClearText = "Clear Markers";
break;
case "Black":
padView.BackgroundColor = Color.Black;
padView.StrokeColor = Color.White;
padView.ClearTextColor = Color.White;
padView.ClearText = "Clear Chalk";
break;
case "Aqua":
padView.BackgroundColor = Color.Aqua;
padView.StrokeColor = Color.Red;
padView.ClearTextColor = Color.Black;
padView.ClearText = "Clear The Aqua";
break;
}
}
private async void OnGetStats(object sender, EventArgs e)
{
var points = padView.Points.ToArray();
var image = await padView.GetImageStreamAsync(SignatureImageFormat.Png);
var pointCount = points.Count();
var imageSize = image.Length / 1000;
var linesCount = points.Count(p => p == Point.Zero) + (points.Length > 0 ? 1 : 0);
image.Dispose();
await App.DisplayAlert("Stats", $"The signature has {linesCount} lines or {pointCount} points, and is {imageSize:#,###.0}KB (in memory) when saved as a PNG.", "Cool");
}
}
}