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
public MainPage()
{
// Initialization of page and inking inputs...
this.myCanvas.InkPresenter.ActivateCustomDrying();
this.myCanvas.InkPresenter.SetPredefinedConfiguration(InkPresenterPredefinedConfiguration.SimpleMultiplePointer); // This turns on multi pointer input.
}
@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"
};
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" } })
this.NetworkManager.Start();
@jamesmcroft
jamesmcroft / OpenNewWindow.cs
Last active December 14, 2016 17:18
Opens a page as a new window
private async void OnOpenWindowClicked(object sender, RoutedEventArgs e)
{
await WindowHelper.CreateNewWindowForPageAsync(typeof(WindowHelperPageOne));
await WindowHelper.CreateNewWindowForPageAsync(typeof(WindowHelperPageOne), new Size(640, 480));
await WindowHelper.CreateNewWindowForPageAsync(typeof(WindowHelperPageOne), new MainPageViewModel());
await WindowHelper.CreateNewWindowForPageAsync(typeof(WindowHelperPageOne), new MainPageViewModel(), new Size(640, 480));
// Also available with type name string.
await WindowHelper.CreateNewWindowForPageAsync("WinUX.Pages.WindowHelperPageOne, WinUX");
}
@jamesmcroft
jamesmcroft / BaseTest.cs
Last active June 27, 2020 21:26
A base test class for Windows app UI testing with Legerity
namespace MyAppTests
{
using Legerity;
using Legerity.Windows;
using Microsoft.VisualStudio.TestTools.UnitTesting;
public abstract class BaseTest
{
[TestInitialize]
@jamesmcroft
jamesmcroft / HomepageTests.cs
Created June 28, 2020 16:06
An example test showing how to reference Legerity elements in a test
namespace MyAppTests
{
using System.Threading;
using Legerity;
using Legerity.Windows;
using Legerity.Windows.Elements.Core;
using Legerity.Windows.Extensions;
using Microsoft.VisualStudio.TestTools.UnitTesting;
@jamesmcroft
jamesmcroft / MyProject.UnitTests.csproj
Created July 4, 2020 13:57
A sample test project file with coverlet installed
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="coverlet.msbuild" Version="2.9.0">
@jamesmcroft
jamesmcroft / test-example-pipelines.yml
Last active September 9, 2020 14:07
A snippet of the pipelines YAML for running tests and generated coverage
- task: DotNetCoreCLI@2
displayName: 'Run unit tests'
inputs:
command: 'test'
arguments: '/p:CollectCoverage=true /p:CoverletOutputFormat=cobertura'
projects: '**/*UnitTests*.csproj'
testRunTitle: 'Unit Tests'
- task: DotNetCoreCLI@2
displayName: 'Run functional tests'
@jamesmcroft
jamesmcroft / coverage-example-pipelines.yml
Last active September 9, 2020 14:07
A snippet of a pipelines YAML showing the ReportGenerator tool in use
- task: reportgenerator@4
inputs:
reports: '$(Build.SourcesDirectory)/**/*.cobertura.xml'
targetdir: '$(Build.SourcesDirectory)/CoverageResults'
- task: PublishCodeCoverageResults@1
displayName: 'Publish code coverage'
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: '$(Build.SourcesDirectory)/CoverageResults/Cobertura.xml'