Skip to content

Instantly share code, notes, and snippets.

@redawgts
redawgts / GridDefinitions WPF AttachedProperty
Last active January 13, 2025 04:39
GridDefinitions WPF AttachedProperty
using System.Windows;
using System.Windows.Controls;
public class GridDefinitions : UIElement
{
#region RowDefinitions
public static string GetRows(Grid obj)
{
return (string)obj.GetValue(RowsProperty);
:root {--dull-red: #c0504d;--blue: #4f81bd;--dark-gray: #808080;}
body {text-align: justify;margin: 2%;adobe-hyphenate: none;}
div {font-variant: small-caps;text-transform: capitalize;font-weight: bold;}
pre {font-size: x-small;}
sml {font-size: small;}
h1,h2,h3,h4,h5,h6 {font-family: 'Cambria';text-align: center;font-variant: small-caps;text-transform: capitalize;color: var(--dull-red);}
hr {background-image: linear-gradient(to right, #00191f2d, #ccc, #00191f2d);border: 0;width: 50vh;height: 2px;}
img {display: block;border-radius: 8px;max-width: 90%;max-height: 400px;margin-left: auto;margin-right: auto;}
.center {position: absolute;top: 50%; right: 50%;transform: translate(50%, -50%);}
.CI {text-align: center;margin-top: 0px;margin-bottom: 0px;padding: 0px;}
@redawgts
redawgts / test_controller.py
Created September 9, 2022 07:32 — forked from sturdy-robot/test_controller.py
Testing pygame controllers using Pygame._SDL2 controller API
import sys
import pygame
import pygame._sdl2
from pygame._sdl2.controller import Controller
pygame.init()
window = pygame.display.set_mode((1200, 800))
pygame.display.set_caption("Testing controllers")
@redawgts
redawgts / state_engine.py
Last active September 1, 2022 23:28 — forked from iminurnamez/state_engine.py
Simple state engine example
#This code is licensed as CC0 1.0 (https://creativecommons.org/publicdomain/zero/1.0/legalcode).
import sys
import pygame as pg
class Game(object):
"""
A single instance of this class is responsible for
managing which individual game state is active
@redawgts
redawgts / MultiSelectListBox.cs
Created February 18, 2022 17:06
A ListBox that exposes SelectedItemsList as a bindable property.
using System.Windows;
using System.Windows.Controls;
namespace [InsertNamespaceHere]
public class MultiSelectListBox : ListBox
{
public MultiSelectListBox() : base()
{
SelectionMode = SelectionMode.Extended;
@redawgts
redawgts / VideoBox.cs
Last active February 25, 2022 14:36 — forked from ArXen42/VideoBox.cs
VideoBox.cs
/// <inheritdoc />
/// <summary>
/// Wrapper control around VlcControl. Provides basic UI for video playback.
/// </summary>
public partial class VideoBox : UserControl
{
private static readonly String[] MediaOptions = {":avcodec-hw=dxva2"}; //Should enable GPU acceleration
private readonly Dispatcher _dispatcher;
private Boolean _isChangingPosition; //Prevents (sometimes) unwanted feedback
private Video3D _video;
@redawgts
redawgts / CommandBase.cs
Last active February 25, 2022 14:32
Implementation of ICommand
using System.Windows.Input;
public abstract class CommandBase : ICommand
{
public event EventHandler CanExecuteChanged;
protected void OnCanExecuteChanged() => CanExecuteChanged?.Invoke(this, EventArgs.Empty);
public virtual bool CanExecute(object parameter) => true;