Skip to content

Instantly share code, notes, and snippets.

View peterfoot's full-sized avatar

Peter Foot peterfoot

View GitHub Profile
using System;
namespace InTheHand
{
/// <summary>
/// Helper class for DateTimeOffset.
/// </summary>
public static class DateTimeOffsetHelper
{
private static DateTimeOffset dt = new DateTimeOffset(1970, 1, 1, 0, 0, 0, TimeSpan.Zero);
namespace InTheHand.Net
{
/// <summary>
/// Helper network-order conversion functions for the Universal Windows Platform.
/// </summary>
public static class IPAddress
{
/// <summary>
/// Converts a short value from network byte order to host byte order.
/// </summary>
@peterfoot
peterfoot / OnPlatform2.cs
Created October 13, 2015 19:25
Replacement for Xamarin.Forms.OnPlatform which supports the Windows (WinRT) platforms.
namespace InTheHand.Forms
{
/// <summary>
/// Replacement for Xamarin.Forms.OnPlatform which supports the Windows (WinRT) platforms.
/// </summary>
/// <typeparam name="T"></typeparam>
public sealed class OnPlatform2<T>
{
public OnPlatform2()
{
using System;
namespace Xamarin.Forms.Platform.WinRT
{
public static class ColorExtensions
{
public static Windows.UI.Color ToWindows(this Xamarin.Forms.Color color)
{
return Windows.UI.Color.FromArgb(Convert.ToByte(color.A * 255), Convert.ToByte(color.R * 255), Convert.ToByte(color.G * 255), Convert.ToByte(color.B * 255));
}
@peterfoot
peterfoot / SingleTapButtonRender.cs
Created May 5, 2016 19:38
Single Tap Xamarin Forms Button Renderer for Android
using Android.Views;
[assembly: Xamarin.Forms.ExportRenderer(typeof(Xamarin.Forms.Button), typeof(InTheHand.Forms.Platform.Android.SingleTapButtonRenderer))]
namespace InTheHand.Forms.Platform.Android
{
public sealed class SingleTapButtonRenderer : Xamarin.Forms.Platform.Android.ButtonRenderer
{
bool justClicked = false;
public override bool OnFilterTouchEventForSecurity(MotionEvent e)
@peterfoot
peterfoot / MainPage.xaml
Created November 11, 2016 00:34
DialASketch
<Page
x:Class="DialASketch.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:DialASketch"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Page.TopAppBar>
<CommandBar>
@peterfoot
peterfoot / MainPage.xaml
Created March 1, 2017 22:17
MediaPlayerSample
<?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:MediaPlayerSample"
xmlns:forms="clr-namespace:InTheHand.Forms;assembly=InTheHand.Forms"
x:Class="MediaPlayerSample.MainPage">
<StackLayout>
<forms:MediaElement HorizontalOptions="Fill" VerticalOptions="Center" HeightRequest="240" x:Name="Media" AreTransportControlsEnabled="true" Source="http://video.ch9.ms/ch9/334f/891b78a5-642d-40b4-8d02-ff40ffdd334f/LoginToLinkedinUSingXamarinAuth_mid.mp4"/>
</StackLayout>
</ContentPage>
@peterfoot
peterfoot / BluetoothImagingMinorClass.cs
Created March 27, 2017 21:08
Get the minor Class of Device value for a Bluetooth Imaging device.
using System;
using Windows.Devices.Bluetooth;
namespace InTheHand.Devices.Bluetooth
{
/// <summary>
/// Defines missing values in the <see cref="BluetoothMinorClass"/> enumeration for devices with a <see cref="BluetoothClassOfDevice.MajorClass"/> of Imaging.
/// </summary>
[Flags]
public enum BluetoothImagingMinorClass
@peterfoot
peterfoot / BrightnessHelper.cs
Last active July 23, 2023 22:09
Set the display brightness from a Win32 application
public static class BrightnessHelper
{
public static void SetBrightness(uint brightness)
{
if (brightness > 100)
{
throw new ArgumentOutOfRangeException("brightness");
}
// get handle to primary display
@peterfoot
peterfoot / App.xaml.cs
Created May 26, 2017 14:56
iBeacons in UWP
public App()
{
this.InitializeComponent();
this.Suspending += OnSuspending;
_watcher = new BluetoothLEAdvertisementWatcher();
_watcher.Received += _watcher_Received;
_watcher.Start();
}