Skip to content

Instantly share code, notes, and snippets.

View Larry57's full-sized avatar

L4rry Larry57

View GitHub Profile
@Larry57
Larry57 / ini.cs
Last active February 21, 2024 05:05
A single class to read and write INI files.
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
public class Ini
{
Dictionary<string, Dictionary<string, string>> ini = new Dictionary<string, Dictionary<string, string>>(StringComparer.InvariantCultureIgnoreCase);
string file;
@Larry57
Larry57 / LiangBarskyClippingHomogeneous.cs
Created January 12, 2020 21:14
Liang Barsky 3D clipping algorithm in homogeneous coordinates
using System;
using System.Numerics;
namespace Clipping {
// https://fr.mathworks.com/matlabcentral/fileexchange/51550-3d-and-2d-homogeneous-space-line-clipping-using-liang-barsky-algorithm
public class LiangBarskyClippingHomogeneous {
float _t0;
float _t1;
@Larry57
Larry57 / KeyboardHook.cs
Created April 11, 2013 18:08
A global Keyboard Hook that works in WPF and is also high CPU load proof. Credits: http://blogs.vertigo.com/personal/ralph/Blog/Lists/Posts/Post.aspx?ID=8
public class KeyboardHook
{
#region pinvoke details
private enum HookType : int
{
WH_JOURNALRECORD = 0,
WH_JOURNALPLAYBACK = 1,
WH_KEYBOARD = 2,
WH_GETMESSAGE = 3,
@Larry57
Larry57 / SimpleMJPEGDecoder.cs
Last active November 11, 2022 09:19
Simple, fast and stupid MJPEG decoder that works for real. Give this viewer a try : https://github.com/Larry57/SimpleMJPEGStreamViewer
using System;
using System.Drawing;
using System.IO;
using System.Net.Http;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace SimpleMJPEGStreamViewer {
static class SimpleMJPEGDecoder {
@Larry57
Larry57 / DataReaderLinq.cs
Last active April 10, 2020 19:29
Linq enumerate a DataReader
/* How to use with a DataReader: */
public void Test()
{
var Res =
from Dr in MyDataReader.Enumerate()
select new {
ID = (Guid)Dr["ID"],
Description = Dr["Desc"] as string
};
@Larry57
Larry57 / awsh.cs
Created November 7, 2018 10:45
Awsh : undo manager
using System;
using System.Collections.Generic;
using System.Linq;
namespace OneFileTools {
/// <summary>
/// Awsh Undo helper
/// </summary>
@Larry57
Larry57 / MJPEGStream.cs
Last active June 1, 2018 19:06
*** Credits goes to andrew.kirillov@gmail.com *** MJPEG stream decoder, adapted from AForge.NET so the NewFrame event gives an byte[] back instead of a Bitmap.
using System;
using System.IO;
using System.Net;
using System.Text;
using System.Threading;
// AForge Video Library
// AForge.NET framework
//
// Copyright © Andrew Kirillov, 2007-2008
@Larry57
Larry57 / MSPEventAggregator
Last active December 21, 2016 11:21
My ludicrous and naive attempt to implement another Event hub for .NET : The Most Simple Possible Event Aggregator
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
namespace MSPEventAggregator {
void sample_usage() {
var hub = new MessageHub();
@Larry57
Larry57 / AssemblyResolver.cs
Created January 21, 2015 15:45
Hook an AppDomain to a generic assembly resolver that accepts to several folders
using System.IO;
using System.Linq;
using System.Reflection;
namespace System
{
public static class AssemblyResolver
{
internal static void Hook(params string[] folders)
{
@Larry57
Larry57 / GenericPointList.cs
Created September 29, 2016 08:49
Create a ZedGraph PointList that use a object collection as a DataSource
public class GenericPointList<T> : IPointList {
List<T> innerList;
Func<T, double> ySelector;
Func<T, double> xSelector;
public GenericPointList(List<T> list, Func<T, double> xSelector, Func<T, double> ySelector) {
innerList = list;
this.xSelector = xSelector;
this.ySelector = ySelector;
}