Skip to content

Instantly share code, notes, and snippets.

View CheetahChrome's full-sized avatar

William Wegerson CheetahChrome

View GitHub Profile
@CheetahChrome
CheetahChrome / HTTPExtensions.cs
Last active May 9, 2022 13:32
C# Static Class Extensions
/// This is a repistory of many differen extensions I use throughout multiple projects.
/// A location here for ultimate move to other named extensions.
public static class HTTPExtensions
{
/// <summary>
/// Allow one to build a URL from its parts, similar to Path.Combine.
/// </summary>
/// <remarks>HMTL Extensions</Remarks>
/// <param name="baseUrl">Initial bitof the url</param>
@CheetahChrome
CheetahChrome / GenericFKCreateDrop.snippet
Created April 11, 2022 16:15
Visual Studio Snippet to add a FK Relationship with Drop FK
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>Generic FK Create/Drop</Title>
<Shortcut>FKMSTS</Shortcut>
<Description>Code snippet for Foreign Key Creation and Dropping</Description>
<Author>William Wegerson</Author>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
@CheetahChrome
CheetahChrome / CodeBehind.cs
Last active November 7, 2021 18:42
WPF Resize Text In Control MouseWheelScroll Event
private void MouseWheelScroll(object sender, MouseWheelEventArgs e)
{
if (Keyboard.Modifiers != ModifierKeys.Control)
return;
var delta = (e.Delta > 0) ? 2 : -2;
var change = VM.MainFontSize + delta;
if (change < 8)
change = 8;
VM.MainFontSize = change;
}
@CheetahChrome
CheetahChrome / CodeBehind.cs
Created November 7, 2021 18:32
WPF Drag And Drop for Files. Each Event at Miniumum
private void DNDEnter(object sender, DragEventArgs e)
{
if (!e.Data.GetDataPresent(DataFormats.FileDrop) ||
sender == e.Source)
{
e.Effects = DragDropEffects.None;
}
}
private void DNDFeedback(object sender, GiveFeedbackEventArgs e)
@CheetahChrome
CheetahChrome / MRU.cs
Last active November 12, 2021 11:44
WPF Menu and Submenu Styling as Blue Gradient Background
public class MRU
{
public string Name { get; set; }
public string Address { get; set; }
public string Data { get; set; }
public bool IsValid => !string.IsNullOrWhiteSpace(Name);
public bool IsFile => !string.IsNullOrWhiteSpace(Address);
@CheetahChrome
CheetahChrome / ErrorBox.xaml
Last active November 12, 2021 11:35
A WPF ErrorBox
<Window.Resources>
<BooleanToVisibilityConverter x:Key="BooleanToVisibility" /> <!-- System.Windows.Controls. -->
</Windown.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition Height="200*" />
<RowDefinition Height="auto" />
</Grid.RowDefinitions>
@CheetahChrome
CheetahChrome / ChasingCircles.Xaml
Last active February 12, 2021 04:14
Chasing Circles Xaml Vector Example
<Window.Resources>
<!--Vector Image Attribution: https://materialdesignicons.com/-->
<Path x:Key="ChasingCircles" Data="M12,6V9L16,5L12,1V4A8,8 0 0,0 4,12C4,13.57 4.46,15.03 5.24,16.26L6.7,14.8C6.25,13.97 6,13 6,12A6,6 0 0,1 12,6M18.76,7.74L17.3,9.2C17.74,10.04 18,11 18,12A6,6 0 0,1 12,18V15L8,19L12,23V20A8,8 0 0,0 20,12C20,10.43 19.54,8.97 18.76,7.74Z" />
<Style x:Key="ChasingCircleStyle"
TargetType="{x:Type Path}">
<Setter Property="Stretch"
Value="Uniform" />
<Setter Property="Data"
Value="{Binding Data, Source={StaticResource ChasingCircles}}" />
</Style>
public class OperationCommand : ICommand
{
#region Variables
private Func<object, bool> CanExecuteHandler { get; set; }
private Action<object> ExecuteActionHandler { get; set; }
public bool InSeparateThread { get; set; }
#endregion
@CheetahChrome
CheetahChrome / People.cs
Created February 14, 2020 00:59
ItemsControl which has the content control
public class People : List<Person> { }
public class Person
{
public string First { get; set; }
public string Last { get; set; }
public string Phone { get; set; }
}
@CheetahChrome
CheetahChrome / NotifiedProperty.snippet
Created June 27, 2019 18:04
Visual Studio Snippet to Work on a VM to add a Notified Property
<?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>NotifiedProperty</Title>
<Author>William Wegerson</Author>
<Description>Same as the propfull snippet except it adds OnPropertyChanged to the setter.