Skip to content

Instantly share code, notes, and snippets.

View ScottIsAFool's full-sized avatar

Scott Lovegrove ScottIsAFool

View GitHub Profile
@ScottIsAFool
ScottIsAFool / App.cs
Last active March 10, 2017 18:35
Cimbalino Navigation for Xamarin.Forms
// This is an example of the usage
private static INavigationService Navigation => SimpleIoc.Default.GetInstance<INavigationService>();
public App(IContainer container)
{
container.Create();
SetNavigationHomePage();
}
@ScottIsAFool
ScottIsAFool / DropFileBehaviour.cs
Last active August 29, 2016 14:32
DropFileBehaviour and its usage
using System;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Input;
using Windows.ApplicationModel.DataTransfer;
using Windows.Storage;
using Windows.UI.Xaml;
using ScottIsAFool.Model;
using Microsoft.Xaml.Interactivity;
@ScottIsAFool
ScottIsAFool / PathIconButton.xaml
Created August 10, 2016 09:04
A button control template that accepts path data as its content.
<Page
x:Class="App4.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:App4"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Page.Resources>
@ScottIsAFool
ScottIsAFool / IListType.cs
Last active August 29, 2015 14:27
Files needed to do inline ads/reviews/whatever
namespace ScottIsAFool.Windows.Core.ViewModel
{
public interface IListType
{
ListType ListType { get; }
}
}
@ScottIsAFool
ScottIsAFool / UriExtensions.cs
Created January 16, 2015 17:38
UriExtension returning IDictionary<string, string>
public static class UriExtensions
{
/// <summary>
/// Gets a collection of query string values.
/// </summary>
/// <param name="uri">The current uri.</param>
/// <returns>A collection that contains the query string values.</returns>
public static IDictionary<string, string> QueryString(this Uri uri)
{
var uriString = uri.IsAbsoluteUri ? uri.AbsoluteUri : uri.OriginalString;
@ScottIsAFool
ScottIsAFool / CustomCommandBar.cs
Created October 23, 2014 09:42
Example of custom CommandBar
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Media;
using MyApp.Extensions;
namespace MyApp.Controls
{
public class CustomCommandBar : CommandBar
{
public CustomCommandBar()
@ScottIsAFool
ScottIsAFool / Style.xaml
Created August 18, 2014 14:27
EmptyButtonStyle with Tilt
<Style x:Key="EmptyButtonStyle"
TargetType="ButtonBase">
<Setter Property="Background"
Value="Transparent" />
<Setter Property="Padding"
Value="0" />
<Setter Property="HorizontalContentAlignment"
Value="Stretch" />
<Setter Property="HorizontalAlignment"
Value="Stretch" />
@ScottIsAFool
ScottIsAFool / YLAD.xml
Created May 27, 2014 12:44
YLAD custom control
<Item Title="built by"
Type="xaml">
<scott:FerretLabs xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:scott="clr-namespace:ScottIsAFool.WindowsPhone;assembly=ScottIsAFool.WindowsPhone"
HorizontalAlignment="Stretch"
VerticalAlignment="Top"/>
</Item>
@ScottIsAFool
ScottIsAFool / TileService.cs
Created May 19, 2014 20:29
Save UserControl for tile
private async Task ToImage(UIElement element, string filename, double height, double width)
{
element.UpdateLayout();
element.Measure(new Size(width, height));
element.UpdateLayout();
element.Arrange(new Rect { Height = height, Width = width });
var bitmap = new WriteableBitmap((int)width, (int)height);
bitmap.Render(element, null);
bitmap.Invalidate();
@ScottIsAFool
ScottIsAFool / AttributeExtensions.cs
Created April 3, 2014 09:29
Get Attribute Extension
public static class AttributeExtensions
{
public static string GetDescription(this object en)
{
var type = en.GetType();
var memInfo = type.GetTypeInfo().DeclaredMembers;
var attrs = memInfo.FirstOrDefault(x => x.Name == en.ToString());
if (attrs != null)
{