Skip to content

Instantly share code, notes, and snippets.

View QiMata's full-sized avatar

Jared Rhodes QiMata

View GitHub Profile
@QiMata
QiMata / ContentViewRoundedCorners.cs
Created February 1, 2016 21:28
The shared control for creating the rounded corners
public class ContentViewRoundedCorners : ContentView
{
public static readonly BindableProperty CornerRaidusProperty =
BindableProperty.Create<ContentViewRoundedCorners, float>(x => x.CornerRadius, 0);
public float CornerRadius
{
get { return (float) GetValue(CornerRaidusProperty); }
set { SetValue(CornerRaidusProperty, value); }
}
@QiMata
QiMata / ContentViewRoundedCornersRenderer.cs
Created February 1, 2016 21:31
Only works for Android 4.2 or higher. The android renderer for the ContentViewRoundedCorners control.
class ContentViewRoundedCornersRenderer : VisualElementRenderer<ContentView>
{
private float _cornerRadius;
private RectF _bounds;
private Path _path;
protected override void OnElementChanged(ElementChangedEventArgs<ContentView> e)
{
base.OnElementChanged(e);
@QiMata
QiMata / ContentViewRoundedCornersRenderer.cs
Created February 1, 2016 21:33
The iOS renderer for ContentViewRoundedCorners control.
class ContentViewRoundedCornersRenderer : VisualElementRenderer<ContentView>
{
protected override void OnElementChanged(ElementChangedEventArgs<ContentView> e)
{
base.OnElementChanged(e);
if (e.OldElement != null)
{
return;
}
@QiMata
QiMata / ContentViewRoundedCornersExample.xaml
Created February 1, 2016 21:36
An example usage using XAML
<yournamespace:ContentViewRoundedCorners
CornerRadius="10">
<ContentView.Content>
<Label TextColor="Blue"
Text="Cool Demo Jared"
VerticalTextAlignment="Center" HorizontalTextAlignment="Center"></Label>
</ContentView.Content>
</yournamespace:ContentViewRoundedCorners>
[assembly:ExportRenderer(typeof(BaseNavigationPage),typeof(BaseNavigationPageRenderer))]
namespace yournamespace
{
class CustomNavigationPageRenderer : NavigationPageGradientHeaderRenderer
{
protected override void OnElementChanged(VisualElementChangedEventArgs e)
{
base.OnElementChanged(e);
if (e.OldElement != null)
@QiMata
QiMata / curl_client.cpp
Last active February 15, 2016 12:32
An http client (like .NET's) using folly and proxygen
#include "curl_client.hpp"
#include <folly/FileUtil.h>
#include <folly/String.h>
#include <proxygen/lib/http/HTTPCommonHeaders.h>
#include <proxygen/lib/http/HTTPMessage.h>
#include <proxygen/lib/http/session/HTTPUpstreamSession.h>
#include <proxygen/lib/ssl/SSLContextConfig.h>
using namespace folly;
[assembly:ExportRenderer(typeof(CustomNavigationPage),typeof(CustomNavigationPageRenderer))]
namespace Common.Controls.iOS
{
public class CustomNavigationPageRenderer : NavigationRenderer
{
protected override void OnElementChanged(VisualElementChangedEventArgs e)
{
base.OnElementChanged(e);
if (e.OldElement != null)
{
@QiMata
QiMata / Program.cs
Last active November 11, 2017 16:01
function.json for Function that reacts to azure
public static void Run(Stream myBlob, TraceWriter log)
{
log.Info($"C# Blob trigger function Processed blob\n Name:{name} \n Size: {myBlob.Length} Bytes");
}
@QiMata
QiMata / Program.cs
Created January 7, 2018 14:26
Function for receiving cloud to device messages
private static async void ReceiveC2dAsync()
{
Console.WriteLine("\nReceiving cloud to device messages from service");
while (true)
{
Message receivedMessage = await deviceClient.ReceiveAsync();
if (receivedMessage == null) continue;
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine("Received message: {0}", Encoding.ASCII.GetString(receivedMessage.GetBytes()));
@QiMata
QiMata / ValueConverterGroup.cs
Last active February 25, 2018 02:34
Reuse converters by chaining them together with a custom converter.
public class ValueConverterGroup : List<IValueConverter>, IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return this.Aggregate(value, (current, converter) => converter.Convert(current, targetType, parameter, culture));
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();