Skip to content

Instantly share code, notes, and snippets.

View dotMorten's full-sized avatar
:octocat:

Morten Nielsen dotMorten

:octocat:
View GitHub Profile
@dotMorten
dotMorten / XF3.4-3.5.md
Last active February 9, 2019 00:43
What's new in Xamarin.Forms between 3.4.0.1008975 and 3.5.0.129452
namespace Xamarin.Forms
{
    public class Xamarin.Xamarin.Forms.BackButtonBehavior : BindableObject
    {
        public BackButtonBehavior();
        public ICommand Command { get; set;  }
        public object CommandParameter { get; set;  }
        public ImageSource IconOverride { get; set;  }
 public bool IsEnabled { get; set; }
@dotMorten
dotMorten / GraphicsTelemetry.cs
Created March 30, 2019 00:00
GraphicsTelemetry.cs
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using Microsoft.ApplicationInsights.Channel;
using Microsoft.ApplicationInsights.Extensibility;
namespace TelemetryClientSample.Telemetry
{
class GraphicsTelemetry : ITelemetryInitializer
{
@dotMorten
dotMorten / Geolocation.cs
Last active August 2, 2019 21:05
Wraps the WinRT Geolocation APIs in reflection-based calls so no dependency on Win10 is needed
using System;
using System.Reflection;
using System.Threading.Tasks;
namespace Windows.Devices.Geolocation
{
internal sealed class Geolocator
{
private readonly object locatorInstance;
internal static Type WinRTType { get; } = Type.GetType("Windows.Devices.Geolocation.Geolocator, Windows, ContentType=WindowsRuntime");
// Requires the following nuget packages:
// NuGet.Packaging
// OpenVsixSignTool.Core
// And built on .NET Framework 4.7.2+
using NuGet.Packaging;
using NuGet.Packaging.Signing;
using System;
using System.Collections.Generic;
using System.IO;
{
"acrylicOpacity": 0.5,
"background": "#012456",
"closeOnExit": true,
"colorScheme": "Campbell",
"commandline": "%comspec% /k \"C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise\\Common7\\Tools\\VsDevCmd.bat\"",
"cursorColor": "#FFFFFF",
"cursorShape": "bar",
"fontFace": "Consolas",
"fontSize": 10,
@dotMorten
dotMorten / CacheHttpHandler.cs
Created November 17, 2019 07:41
Quick and dirty implementation of etag and cache control: Note: threading issues! Don't use as is
using System;
using System.IO;
using System.Net.Http;
using System.Security.Cryptography;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace HttpCacheClient
{
@dotMorten
dotMorten / ConvertXliffToResx.targets
Created June 20, 2020 01:13
Converting xliff to resx/resw as a build task
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="UpdateRuntimeResources">
<ItemGroup>
<XLiffResources Include="$(MSBuildThisFileDirectory)\xliff_resources\**\*.xliff" />
</ItemGroup>
<ImportResourceFiles XliffFiles="@(XLiffResources)" OutputDirectory="$(MSBuildThisFileDirectory)\LocalizedStrings" IsUWP="False" />
</Target>
<UsingTask TaskName="ImportResourceFiles" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
@dotMorten
dotMorten / App.xaml
Last active March 27, 2025 22:45
Doing dark/light mode resources in WPF
<Application x:Class="MyWPFStuff.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:MyWPFStuff"
StartupUri="MainWindow.xaml">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<local:ThemeResourceDictionary >