Skip to content

Instantly share code, notes, and snippets.

View BYJRK's full-sized avatar
🍋
Juicy

ColdWind BYJRK

🍋
Juicy
View GitHub Profile
@BYJRK
BYJRK / Advanced.cs
Last active January 19, 2023 09:47
#region GUI
var ffmpeg = new FFmpeg();
ffmpeg.UI.Dump();
#endregion
class FFmpeg
{
TimeSpan duration;
@BYJRK
BYJRK / puzzle-poster.py
Created December 20, 2022 14:36
Puzzle Poster
from PIL import Image
import numpy as np
from pathlib import Path
from rich.progress import track
from scipy.spatial import KDTree
folder = Path('avatar')
def calc_all_colors():
@BYJRK
BYJRK / SelectedItemBehavior.cs
Created January 8, 2023 13:10
SelectedItemBehavior
using Microsoft.Xaml.Behaviors;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
namespace WpfTutorials.RadioButtonBindings.Behaviors;
/// <summary>
@BYJRK
BYJRK / MainWindow.xaml
Last active March 6, 2023 08:38
A simple WPF Window whose controls, styles, triggers, event, etc. are written in code-behind only
<Window ...>
<Window.Resources>
<local:BrightnessToBoolConverter x:Key="conv" />
<Style TargetType="Button">
<Setter Property="FontSize" Value="16" />
<Setter Property="Foreground" Value="Black" />
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
<EventSetter Event="Click" Handler="OnButtonClicked" />
<Style.Triggers>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Background, Converter={StaticResource conv}}" Value="False">
@BYJRK
BYJRK / CollectionItemIndexConverter.cs
Created March 16, 2023 08:59
Two WPF converters used to get the item's index inside a ItemsControl
using System.Collections;
using System.Globalization;
using System.Windows.Data;
class ElementIndexConverter : IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
if (values.Length == 2 && values[0] is not null && values[1] is IList items)
return (items.IndexOf(values[0]) + 1).ToString();
@BYJRK
BYJRK / ToysAlgo.py
Created June 4, 2023 05:32
Child Toy Analysis
from collections import Counter
from itertools import permutations
from matplotlib import pyplot as plt
COLS = 5
ROWS = 6
x1 = 10
x2 = 10
@BYJRK
BYJRK / ValueConverters.NET.Demo.xaml
Created June 28, 2023 13:41
ValueConverters.NET 工具包简单演示代码
<Window x:Class="WpfTutorials.NuGetValueConverters.Views.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:conv="clr-namespace:ValueConverters;assembly=ValueConverters"
Title="登录"
Width="800"
Height="600"
WindowStartupLocation="CenterScreen"
@BYJRK
BYJRK / MultiSelectorHelper.cs
Last active August 2, 2023 14:06
Binding SelectedItems
using System;
using System.Collections;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
namespace DataGridView
{
public class MultiSelectorHelper
{
@BYJRK
BYJRK / ModifyPropValue.cs
Created November 14, 2023 13:07
Ref Object.Property
var demo = new Demo();
demo.FieldValue = 10;
demo.PropValue = 10;
// 修改字段的值
ModifyFieldValue(ref demo.FieldValue, 42);
demo.FieldValue.Dump("Field Value");
// 修改属性的值
// ModifyFieldValue(ref demo.PropValue, 42);
@BYJRK
BYJRK / base.user.css
Created December 1, 2023 06:37
Typora 1.8 New feature "GitHub Style Alerts" Custom Style
.md-alert-text {
font-size: 1rem;
font-weight: 600;
}
.md-alert-text-container::after {
text-transform: uppercase;
position: relative;
bottom: 1px;
}