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
/** | |
* The <code>StreamTokenizer</code> class takes an input stream and | |
* parses it into "tokens", allowing the tokens to be | |
* Read one at a time. The parsing process is controlled by a table | |
* and a number of flags that can be set to various states. The | |
* stream tokenizer can recognize identifiers, numbers, quoted | |
* strings, and various comment styles. | |
* <p> | |
* Each byte Read from the input stream is regarded as a character | |
* in the range <code>'\u0000'</code> through <code>'\u00FF'</code>. |
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 panel will get focus as the original .NET panel always tries to get away from focus | |
public class FocusablePanel : Panel | |
{ | |
public FocusablePanel() | |
{ | |
this.SetStyle(ControlStyles.Selectable, true); | |
this.TabStop = true; | |
} | |
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
protected override CreateParams CreateParams | |
{ | |
get | |
{ | |
CreateParams cp = base.CreateParams; | |
cp.ExStyle |= 0x02000000; | |
return cp; | |
} | |
} |
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
//Combobox will handle mouse wheel event, but if you want to combobox which won't handle mouse wheel | |
//event, rather pass to the parent, use this class | |
public class UnscrollableComboBox : ComboBox | |
{ | |
protected override void WndProc(ref Message m) | |
{ | |
if (m.Msg == 0x20a && this.Parent != null) | |
{ | |
PostMessage(this.Parent.Handle, m.Msg, m.WParam, m.LParam); | |
} |
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.Drawing; | |
namespace PatternRecognition | |
{ | |
public class ConnectedComponentLabeling | |
{ | |
readonly int[,] board; | |
readonly int w; | |
readonly int h; |
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 struct NonNullable<T> where T : class | |
{ | |
private readonly T value; | |
public NonNullable(T value) | |
{ | |
if (value == null) | |
{ | |
throw new ArgumentNullException("value"); | |
} |
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 CSV | |
{ | |
public static string ToCSV(this DataTable table) | |
{ | |
var columnHeaders = (from DataColumn x in table.Columns | |
select x.ColumnName).ToArray(); | |
StringBuilder builder = new StringBuilder(String.Join(",", columnHeaders)); | |
builder.Append("\n"); | |
foreach (DataRow row in table.Rows) |
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> | |
/// Utilties for reflection | |
/// </summary> | |
public static class ReflectionUtils | |
{ | |
/// <summary> | |
/// Get all the fields of a class | |
/// </summary> | |
/// <param name="type">Type object of that class</param> | |
/// <returns></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
/// <summary> | |
/// Provides a description for an enumerated type. | |
/// </summary> | |
[AttributeUsage(AttributeTargets.Enum | AttributeTargets.Field, | |
AllowMultiple = false)] | |
public sealed class EnumDescriptionAttribute : Attribute | |
{ | |
private string description; | |
OlderNewer