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 / MahAppsButton.xaml
Created November 6, 2023 14:28
Custom MahApps Button Style
<Style x:Key="MahApps.Styles.Button.Custom" TargetType="{x:Type ButtonBase}" BasedOn="{StaticResource MahApps.Styles.Button}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ButtonBase}">
<Grid>
<mah:ClipBorder x:Name="Border"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding mah:ControlsHelper.CornerRadius}"
@punker76
punker76 / SampleView.xaml
Last active March 6, 2021 14:55
A ToolTipBehavior to show different ToolTip for enabled and disabled element.
<UserControl x:Class="SampleView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
xmlns:utilities="clr-namespace:Utilities"
xmlns:commands="clr-namespace:Commands"
mc:Ignorable="d">
@punker76
punker76 / build.cake
Created January 21, 2021 09:40
Build Delphi projects with Cake
///////////////////////////////////////////////////////////////////////////////
// TOOLS / ADDINS
///////////////////////////////////////////////////////////////////////////////
#tool "nuget:?package=GitVersion.CommandLine&version=5.6.3"
#addin "nuget:?package=Cake.Figlet&version=1.3.1"
#addin "nuget:?package=Cake.Incubator&version=5.1.0"
#addin "nuget:?package=Cake.FileHelpers&version=3.3.0"
///////////////////////////////////////////////////////////////////////////////
@punker76
punker76 / App.xaml.cs
Created August 11, 2020 20:48
Use Navy color as theme for MahApps
using System.Windows;
using System.Windows.Media;
using ControlzEx.Theming;
namespace WpfApp3
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
@punker76
punker76 / MyCustomDialog.cs
Created April 27, 2020 20:34
OwnerCanCloseWithDialog
...
var settings = new MetroDialogSettings { OwnerCanCloseWithDialog = true };
var dataContext = new AdvancedInstallViewModel(_chocolateyService.GetAvailableVersionsForPackageIdAsync(Id), Version);
customDialog.Content = new AdvancedChocolateyDialog { DataContext = dataContext };
await _dialogCoordinator.ShowMetroDialogAsync(this, customDialog, settings);
var result = await dataContext.WaitForClosingAsync();
@punker76
punker76 / MyCustomDialog.cs
Created April 27, 2020 20:11
IncludeRelease
public bool IncludeRelease
{
get { return _includeRelease; }
set
{
if (SetPropertyValue(ref _includeRelease, value))
{
_cts.Cancel();
@punker76
punker76 / MyCustomDialog.cs
Last active April 13, 2020 21:14
Custom Dialog sample with result
/// <summary>
/// Interaction logic for MyCustomDialog.xaml
/// </summary>
public partial class MyCustomDialog : CustomDialog
{
private TaskCompletionSource<bool> tcs;
public MyCustomDialog()
: this(null, null)
{
@punker76
punker76 / convert.cs
Created April 8, 2020 20:13
SkiaSharp Svg to Png
// memoryStream is the stream of the svg url
// imageStream is the converted png which will be converted with Splat.BitmapLoader to an IBitmap
var svg = new SkiaSharp.Extended.Svg.SKSvg();
svg.Load(memoryStream);
var imageInfo = new SKImageInfo((int)desiredSize.Width, (int)desiredSize.Height);
using (var surface = SKSurface.Create(imageInfo))
using (var canvas = surface.Canvas)
{
using System.Collections.Generic;
using System.Text.RegularExpressions;
namespace Ghostly.Utilities
{
// Emoji list borrowed from https://github.com/lunet-io/markdig/blob/25959174d521c7f4458fa7b340d58a4ac136fa30/src/Markdig/Extensions/Emoji/EmojiParser.cs
public static class EmojiReplacer
{
private static Regex _regex;
private static Dictionary<string, string> _lookup;