Skip to content

Instantly share code, notes, and snippets.

View KlausLoeffelmann's full-sized avatar

Klaus Löffelmann KlausLoeffelmann

View GitHub Profile
@KlausLoeffelmann
KlausLoeffelmann / MS-BlogPost-NuGet-25-04-28-Prompt-the-Prompt.md
Last active April 29, 2025 07:01
MS-BlogPost-NuGet-25-04-28-Prompt-the-Prompt.md

Could you assist in writing a prompt, which purpose is to write more detailed instructions to create a Custom Control in WinForms. You are strongly encourage to amend important facts or instructions and could help to improve the result.

Some base information about creating custom controls in WinForms:

  • We talk about a "custom control", so, not designable, no code-behind file, not derived from UserControl.
  • Properties needs to have some sort of serialization control (DefaultValue, ShouldSerialize, DesignerSerialization)
  • Include infos for the PropertyGrid.
  • Include XML.

The actual control in this case should satisfy the following:

@KlausLoeffelmann
KlausLoeffelmann / MS-BlogPost-NuGet-25-04-28-ChatGPTCopyRightDiscussion.md
Created April 28, 2025 17:53
ChatGPT copyright discussion about ownership for a Copilot template photo

User:
I have a copyright question.
If I want to write a blog post about how to create a WinForms control for a chronograph/clock/stop watch control, and I want to show that by providing a photo as a template, the LLM could generate a respective prompt for Copilot to create such a control. And if I then bought the watch you see here, and took the photo myself for publishing—would I violate any copyright?


Assistant:
Good news: as long as you’re shooting your own photo of a watch you legally bought, you’re in the clear on copyright. Here’s why:

  1. First‐sale doctrine + your own photo
@KlausLoeffelmann
KlausLoeffelmann / EventTrackerTest.vb
Last active December 7, 2023 21:57
Test scenarios for the WinForms Out-Of-Proc Designer EventHandler Tracker (f.k.a. as HandlesClauseManager)
Public Class VbEventTestForm
Private WithEvents myTimer As Timer
Private WithEvents myButton As Button
Private Sub DisplayMessageBoxWithDebugInfo(Message As String,
<CallerMemberName> Optional callerName As String = Nothing,
<CallerLineNumber> Optional callerLienNumber As String = Nothing)
Dim msg As String = $"{callerName}() called from line {callerLienNumber} with message: {Message}"
@KlausLoeffelmann
KlausLoeffelmann / gist:304611e5da1a0ab43483f77d73cc97a1
Created November 18, 2023 22:49
ChatGPT 4 generated VBA script for addition variations in cells
Sub GenerateCombinations()
Dim inputRange As Range
Dim cell As Range
Dim combinations As Collection
Dim sumInfo As Variant
Dim r As Integer
Dim totalCombinations As Integer
' Define the input range in column A
Set inputRange = Range("A1", Range("A1").End(xlDown))
@KlausLoeffelmann
KlausLoeffelmann / OpenPictureFile
Created August 29, 2022 22:05
Show OpenFileDialog for loading picture
private void OpenToolStripMenuItem_Click(object sender, EventArgs e)
{
OpenFileDialog openFileDialog = new();
openFileDialog.DefaultExt = "bmp";
openFileDialog.Filter =
"BMP files (*.bmp)|*.bmp|" +
"PNG files (*.png)|*.png|" +
"JPG files (*.jpg)|*.jpg|" +
"All files (*.*)|*.*";
@KlausLoeffelmann
KlausLoeffelmann / Application.Designer.HighDpi.vb
Created January 8, 2022 01:43
HighDpiMode event patch for .NET 5 Visual Basic WinForms App. Turn on 'All files' in Solution explorer and copy this file into the 'My Project' folder.
Option Strict On
Option Explicit On
'This constant indicates whether the Application Framework is in use.
#Const APPLICATION_FRAMEWORK = True
#If APPLICATION_FRAMEWORK Then
#If NET5_0 And Not NET6_0 Then
@KlausLoeffelmann
KlausLoeffelmann / ProductItem.cs
Created November 5, 2021 00:16
Simple products demo data generator (Using CsvHelper package by Josh Close).
using CsvHelper;
using CsvHelper.Configuration;
using CsvHelper.Configuration.Attributes;
using System.Diagnostics;
using System.Globalization;
namespace MiniEra.Service
{
public class ProductItem
{
@KlausLoeffelmann
KlausLoeffelmann / UsState.cs
Last active November 2, 2021 21:55
UsStates Data Generator
namespace CsSimpleDataService
{
public class UsState
{
private static UsState[]? s_stateCache;
private static readonly Random s_random = new(DateTime.Now.Millisecond);
public UsState(string stateName, string stateAbbrevation, string stateShortName)
{
StateName = stateName;
@KlausLoeffelmann
KlausLoeffelmann / Control.InvokeAsync.cs
Created November 7, 2020 09:41
First draft for InvokeAsync for WinForms
public async Task<T> InvokeAsync<T>(
Func<T> invokeDelegate,
object state=null,
CancellationToken cancellationToken=default(CancellationToken),
TimeSpan timeOutSpan=default(TimeSpan),
params object[] args)
{
var tokenRegistration = default(CancellationTokenRegistration);
RegisteredWaitHandle registeredWaitHandle = null;
@KlausLoeffelmann
KlausLoeffelmann / PartOfProject.cs
Last active July 14, 2020 17:58
Samples: Putting a resource into a differrent namespace with a LogicalName.
<ItemGroup>
<EmbeddedResource Include="Resources\BackgroundWorker.bmp">
<LogicalName>WinFormsSurface.Designers.%(Filename)%(Extension)</LogicalName>
</EmbeddedResource>
<EmbeddedResource Include="Resources\InheritedGlyph.bmp">
<LogicalName>WinFormsSurface.Services.%(Filename)%(Extension)</LogicalName>
</EmbeddedResource>
</ItemGroup>