This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static int BinarySearch<T, U>(this TeaFile<T> tf, U target, Func<T, U> indexer) where T : struct | |
{ | |
var lo = 0; | |
var hi = (int)tf.Count - 1; | |
var comp = Comparer<U>.Default; | |
while(lo <= hi) | |
{ | |
var median = lo + (hi - lo >> 1); | |
var num = comp.Compare(indexer(tf.Items[median]), target); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
using System.Linq; | |
namespace System.Windows.Forms | |
{ | |
internal static class TreeViewExtensions | |
{ | |
internal static List<string> GetExpansionState(this TreeNodeCollection nodes) | |
{ | |
return nodes.Descendants() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class ZedGraphExtensions | |
{ | |
/// <summary> | |
/// Change the Y axes order | |
/// </summary> | |
/// <param name="list">YAxisList</param> | |
/// <param name="pane">GraphPane</param> | |
/// <param name="index">index</param> | |
/// <param name="relativePos">relative position</param> | |
/// <returns>new index</returns> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class Extensions | |
{ | |
public static string GetUniqueKey(this IEnumerable<string> keys, string prefix, StringComparison comparisonType = StringComparison.InvariantCultureIgnoreCase) | |
{ | |
int count = 0; | |
while (keys.FirstOrDefault(k => k.StartsWith(prefix + count, comparisonType)) != null) | |
count++; | |
return prefix + count; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Drawing; | |
using System.Windows.Forms; | |
namespace Graph.UI.Tools | |
{ | |
public class MultiSelectTreeview : TreeView | |
{ | |
#region Selected Node(s) Properties |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void Arrange(Control container, int horizontalGap, int verticalGap, float aspectRatio) | |
{ | |
var H = container.Height; | |
var W = container.Width; | |
var N = container.Controls.OfType<Control>().Count(c => c.Visible); | |
if (N == 0) | |
return; | |
var bestSizedItem = ( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Represents a wildcard running on the | |
/// <see cref="System.Text.RegularExpressions"/> engine. | |
/// </summary> | |
public class Wildcard : Regex | |
{ | |
/// <summary> | |
/// Initializes a wildcard with the given search pattern. | |
/// </summary> | |
/// <param name="pattern">The wildcard pattern to match.</param> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// http://www.codeproject.com/Tips/197531/Do-not-use-using-for-WCF-Clients | |
/// </summary> | |
public static class WcfExtensions | |
{ | |
public static void Using<T>(this T client, Action<T> work) | |
where T : ICommunicationObject | |
{ | |
try | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* This package contains a powerful, declarative command-line parsing system in a single .cs file. | |
* You can include this in any project with almost zero footprint and very easy/readable usage, | |
* as shown below. More switch types, including generic ones are coming soon. Visit the project | |
* page for a sample of how to use this handy package. Part of Code Blocks (http://codeblocks.codeplex.com) | |
*/ | |
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; |