Skip to content

Instantly share code, notes, and snippets.

Console.WriteLine("Starting on thread ".PadLeft(26) + Thread.CurrentThread.ManagedThreadId.ToString());
Func<Unit> writeLineAndReturnUnit = () =>
{
Console.WriteLine($"Inside Return on thread ".PadLeft(26) + Thread.CurrentThread.ManagedThreadId.ToString());
return Unit.Default;
};
Observable.Return(writeLineAndReturnUnit(), TaskPoolScheduler.Default)
.Do(_ => Console.WriteLine("Passing through on thread ".PadLeft(26) + Thread.CurrentThread.ManagedThreadId.ToString()))
.Subscribe(_ => Console.WriteLine($"Received on thread ".PadLeft(26) + Thread.CurrentThread.ManagedThreadId));
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
namespace SupportTool.Controls
{
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
<Title>Property with INPC</Title>
<Author>Jon Stødle</Author>
<Description>Inserts a property which implements INotifyPropertyChanged</Description>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.Foundation;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
namespace KodeFisk.Panels
protected override Size ArrangeOverride(Size finalSize)
{
var posY = 0d;
var currentRow = new List<UIElement>();
var rowHeight = 0d;
foreach (var child in Children)
{
if (currentRow.Sum(x => x.DesiredSize.Width) + child.DesiredSize.Width <= finalSize.Width)
protected override Size MeasureOverride(Size availableSize)
{
var finalSize = new Size { Width = availableSize.Width };
var rowHeight = 0d;
var posX = 0d;
foreach (var child in Children)
{
child.Measure(availableSize);
@jonstodle
jonstodle / AutoUniformWidthWrapPanel.cs
Created October 29, 2015 18:54
A panel which arranges as many children as possible into one row and stretches them to uniformly consume the whole width
using System;
using System.Collections.Generic;
using System.Linq;
using Windows.Foundation;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
namespace KodeFisk
{
public class AutoUniformWidthWrapPanel : Panel
@jonstodle
jonstodle / UniformWidthWrapPanel.cs
Last active April 13, 2019 21:48
A panel which arranges it's children into the specified amount of columns and stretches them to uniformly consume the whole width
using System;
using Windows.Foundation;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
namespace KodeFisk
{
public class UniformWidthWrapPanel : Panel
{
public UniformWidthWrapPanel()
protected override Size ArrangeOverride(Size finalSize)
{
var columnWidth = finalSize.Width / MaximumColumns;
var posY = 0d;
var rowHeight = 0d;
var rowChildCount = 0;
foreach (var child in Children)
{
if (rowChildCount >= MaximumColumns)
protected override Size MeasureOverride(Size availableSize)
{
// Set it to use whole available width
var finalSize = new Size { Width = availableSize.Width };
var columnWidth = availableSize.Width / MaximumColumns;
var rowHeight = 0d;
var rowChildCount = 0;
foreach (var child in Children)
{