Skip to content

Instantly share code, notes, and snippets.

View jamesmcroft's full-sized avatar
👨‍💻
Coding From Anywhere

James Croft jamesmcroft

👨‍💻
Coding From Anywhere
View GitHub Profile
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
var getDataProcess = new GetJsonNetworkProcess(
client: new HttpClient(),
queueId: "GetData",
retryOnFail: true,
retryLimit: 3,
headers: new Dictionary<string, string> { { "YourHeader", "YourHeaderValue" } })
@jamesmcroft
jamesmcroft / CreateNetworkProcess.cs
Created November 11, 2016 17:11
Demonstrates how to create a network process using the WinUX library
var getDataProcess = new GetJsonNetworkProcess(client: new HttpClient(), queueId: "GetData")
{
Url = "http://www.myapi.com/api/getdata?q=test"
};
public MainPage()
{
// Initialization of page and inking inputs...
this.myCanvas.InkPresenter.ActivateCustomDrying();
this.myCanvas.InkPresenter.SetPredefinedConfiguration(InkPresenterPredefinedConfiguration.SimpleMultiplePointer); // This turns on multi pointer input.
}
public MainPage()
{
this.InitializeComponent();
this.myCanvas.InkPresenter.InputDeviceTypes = Windows.UI.Core.CoreInputDeviceTypes.Pen; // Enables only pen.
this.myCanvas.InkPresenter.InputDeviceTypes = Windows.UI.Core.CoreInputDeviceTypes.Pen | Windows.UI.Core.CoreInputDeviceTypes.Touch; // Enables pen and touch.
}
@jamesmcroft
jamesmcroft / ValidatingTextBox.xaml
Created May 6, 2016 12:13
Example of how to use the ValidatingTextBox
<Grid>
<Grid.Resources>
<validation:ValidationRules x:Key="UrlSample">
<validation:ValidationRules.Rules>
<rules:UrlValidationRule />
</validation:ValidationRules.Rules>
</validation:ValidationRules>
</Grid.Resources>
<controls:ValidatingTextBox IsMandatory="True" Header="Website" Text="http://www.jamescroft.co.uk" MaxLength="50" ValidationRules="{StaticResource UrlSample}" />
@jamesmcroft
jamesmcroft / App.xaml.cs
Last active November 15, 2016 13:39
Using WinUX AppDiagnostics to handle event logging and exceptions
protected override async void OnLaunched(LaunchActivatedEventArgs e)
{
...
// Starts the WinUX app exception handler with auto-logging.
// Calling a method from WinUX.Diagnostics.Tracing.Logger.Current will also log out.
await WinUX.Diagnostics.AppDiagnostics.Current.StartListeningAsync();
...
<UserControl
x:Name="ControlRoot"
x:Class="WinUX.Xaml.Controls.Inking.DrawingCanvas"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignWidth="500"
d:DesignHeight="200">
namespace WinUX.Extensions
{
using System;
using System.Threading.Tasks;
using Windows.Foundation;
using Windows.Graphics.DirectX;
using Windows.Graphics.Display;
using Windows.Graphics.Imaging;
using Windows.Storage;
Windows.UI.Core.SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible;
Windows.UI.Core.SystemNavigationManager.GetForCurrentView().BackRequested += this.OnBackRequested;
...
private void OnBackRequested(object sender, BackRequestedEventArgs e)
{
// Handle frame navigation
}
if(ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons"))
{
Windows.Phone.UI.Input.HardwareButtons.BackPressed += this.OnHardwareBackPressed;
}