Skip to content

Instantly share code, notes, and snippets.

Avatar

L4rry Larry57

View GitHub Profile
@Larry57
Larry57 / LiangBarskyClippingHomogeneous.cs
Created Jan 12, 2020
Liang Barsky 3D clipping algorithm in homogeneous coordinates
View LiangBarskyClippingHomogeneous.cs
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 / awsh.cs
Created Nov 7, 2018
Awsh : undo manager
View awsh.cs
using System;
using System.Collections.Generic;
using System.Linq;
namespace OneFileTools {
/// <summary>
/// Awsh Undo helper
/// </summary>
@Larry57
Larry57 / MJPEGStream.cs
Last active Jun 1, 2018
*** 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.
View MJPEGStream.cs
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 Dec 21, 2016
My ludicrous and naive attempt to implement another Event hub for .NET : The Most Simple Possible Event Aggregator
View MSPEventAggregator
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
namespace MSPEventAggregator {
void sample_usage() {
var hub = new MessageHub();
@Larry57
Larry57 / GenericPointList.cs
Created Sep 29, 2016
Create a ZedGraph PointList that use a object collection as a DataSource
View GenericPointList.cs
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;
}
@Larry57
Larry57 / SimpleMJPEGDecoder.cs
Last active Feb 2, 2018
Simple, fast and stupid MJPEG decoder that works for real. Give this viewer a try : https://github.com/Larry57/SimpleMJPEGStreamViewer
View SimpleMJPEGDecoder.cs
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 / NameOf.cs
Last active Nov 19, 2015
Return the full path of a property name
View NameOf.cs
// Inspired by http://stackoverflow.com/q/301809/24472
public static string Property<TProp>(Expression<Func<T, TProp>> expression)
{
var s = expression.Body.ToString();
var p = s.Remove(0, s.IndexOf('.') + 1);
return p;
}
// Example:
@Larry57
Larry57 / ObjectExtensions.cs
Last active Oct 21, 2015
Get and Set properties values using a path with dots ("user.address.street"...)
View ObjectExtensions.cs
using System.Reflection;
namespace System
{
internal static class ObjectExtensions
{
public static PropertyInfo GetPropertyInfo(this Type type, string name)
{
string[] bits = name.Split('.');
for (int i = 0; i < bits.Length - 1; i++)
@Larry57
Larry57 / Zoom.cs
Created Sep 15, 2015
Calculate a zoom
View Zoom.cs
// sourceSize = source control size
// targetSize = target control size
// center of the zoom
// zoom radius
static Rectangle Zoom(Size sourceSize, Size targetSize, Point center, int radius)
{
var f = Math.Min((double)targetSize.Width / ((double)radius * 2d), (double)targetSize.Height / ((double)radius * 2d));
var loc = new Point((int)((-center.X + radius) * f), (int)((-center.Y + radius) * f));
@Larry57
Larry57 / AssemblyResolver.cs
Created Jan 21, 2015
Hook an AppDomain to a generic assembly resolver that accepts to several folders
View AssemblyResolver.cs
using System.IO;
using System.Linq;
using System.Reflection;
namespace System
{
public static class AssemblyResolver
{
internal static void Hook(params string[] folders)
{
You can’t perform that action at this time.