Skip to content

Instantly share code, notes, and snippets.

Avatar

William Wegerson CheetahChrome

View GitHub Profile
@CheetahChrome
CheetahChrome / HTTPExtensions.cs
Last active May 9, 2022
C# Static Class Extensions
View HTTPExtensions.cs
/// 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 Apr 11, 2022
Visual Studio Snippet to add a FK Relationship with Drop FK
View GenericFKCreateDrop.snippet
<?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 Nov 7, 2021
WPF Resize Text In Control MouseWheelScroll Event
View CodeBehind.cs
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 Nov 7, 2021
WPF Drag And Drop for Files. Each Event at Miniumum
View CodeBehind.cs
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 Nov 12, 2021
WPF Menu and Submenu Styling as Blue Gradient Background
View MRU.cs
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);
View ErrorBox.xaml
<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 Feb 12, 2021
Chasing Circles Xaml Vector Example
View ChasingCircles.Xaml
<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>
View OperationCommand.cs
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 Feb 14, 2020
ItemsControl which has the content control
View People.cs
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 Jun 27, 2019
Visual Studio Snippet to Work on a VM to add a Notified Property
View NotifiedProperty.snippet
<?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.