Skip to content

Instantly share code, notes, and snippets.

View punker76's full-sized avatar
☮️
#PEACE

Jan Karger ツ ☀ punker76

☮️
#PEACE
View GitHub Profile
@punker76
punker76 / GameHost.cs
Created November 29, 2017 09:49 — forked from Vanlalhriata/GameHost.cs
Host Unity game in WPF
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Interop;
namespace KinectRun.Host.Controls
{
// GameHost is a FrameworkElement and can be added to controls like so:
// var gameHost = new GameHost(container.ActualWidth, container.ActualHeight);
<StackPanel Margin="20" VerticalAlignment="Center">
<Slider IsSelectionRangeEnabled="True"
Style="{x:Null}"
Maximum="100"
Minimum="0"
SelectionEnd="60"
SelectionStart="30"
TickFrequency="10"
TickPlacement="TopLeft"
Value="50" />
@punker76
punker76 / Taskbar.cs
Created March 15, 2018 13:00 — forked from franzalex/Taskbar.cs
Class to get the taskbar's position, size and other properties.
/******************************************************************************
* Name: Taskbar.cs
* Description: Class to get the taskbar's position, size and other properties.
* Author: Franz Alex Gaisie-Essilfie
* based on code from https://winsharp93.wordpress.com/2009/06/29/find-out-size-and-position-of-the-taskbar/
*
* Change Log:
* Date | Description
* -------------|--------------------------------------------------------------
* 2017-05-16 | Initial design
@punker76
punker76 / gist:7d554d1e02eb17e1646a5f8fe79058d7
Last active March 26, 2018 15:34
Custom WindowCommands
<controls:MetroWindow.Resources>
<ControlTemplate x:Key="WindowCommandsButtonTemplate" TargetType="{x:Type Button}">
<Grid x:Name="RootGrid" Background="{TemplateBinding Background}">
<controls:ContentControlEx x:Name="PART_ContentControlEx"
Padding="{TemplateBinding Padding}"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
Content="{TemplateBinding Content}"
ContentCharacterCasing="{Binding RelativeSource={RelativeSource AncestorType={x:Type controls:WindowCommands}}, Path=(controls:ControlsHelper.ContentCharacterCasing)}"
@punker76
punker76 / App.config
Last active April 6, 2018 13:45
Show SVG at MahApps IconTemplate with SkiaSharp.Svg
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="SkiaSharp" publicKeyToken="0738eb9f132ed756" culture="neutral" />
@punker76
punker76 / gist:556299e9c25b8e6f1af98f6056a97599
Created April 25, 2018 21:40
dependencyProperty R# template
/// <summary>
/// Identifies the <see cref="$propertyName$"/> dependency property.
/// </summary>
public static readonly $dependencyProperty$ $propertyName$Property
= $dependencyProperty$.Register(nameof($propertyName$), typeof($propertyType$), typeof($containingType$), new PropertyMetadata(default($propertyType$)));
/// <summary>
/// Get or sets the $propertyName$ property.
/// </summary>
public $propertyType$ $propertyName$
@punker76
punker76 / ScrollSynchronizer.cs
Created July 30, 2018 14:15
ListBox scroll syncronisation
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Threading;
namespace ListBoxScrollSync
{
@punker76
punker76 / BubbleScrollEvent.cs
Created September 18, 2018 13:25
BubbleScrollEvent
using System.Windows;
using System.Windows.Input;
using System.Windows.Interactivity;
namespace ExtraBehaviors
{
/// <summary>
/// The BubbleScrollEvent behavior can be used to prevent the mousewheel scrolling on a scrollable control.
/// The event will be bubble up to the parent control.
/// This behavior can be prevent with the left Shift key.
@punker76
punker76 / MainWindow.xaml
Created February 6, 2019 20:36
Detecting Windows 10 Dark/Light mode
<Window x:Class="WpfApp1.MainWindow"
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"
xmlns:local="clr-namespace:WpfApp1"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
@punker76
punker76 / ItemsControlWithScrollViewer.xaml
Created February 7, 2019 10:10
ItemsControl with ScrollViewer inside Template
<Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:dd="urn:gong-wpf-dragdrop">
<Grid>
<ItemsControl x:Name="pnlBilder"
HorizontalAlignment="Center"
Width="300" Height="100"
dd:DragDrop.IsDragSource="True"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"