Skip to content

Instantly share code, notes, and snippets.

newValue = easeFunction(
elapsedTime,
initialValue,
totalChange,
totalDuration
);
@begedin
begedin / Lambda.cs
Created May 15, 2013 11:28
This is Lambda
x => x.Name == "Bob"
@begedin
begedin / LINQ2.cs
Created May 15, 2013 11:26
This is also LINQ
var _Persons = _PersonList.Where(x => x.Name == "Bob");
@begedin
begedin / LINQ1.cs
Created May 15, 2013 11:24
This is LINQ
var _Persons = from person in _PersonList
where person.Name == "Bob"
select person;
@begedin
begedin / main.cs
Created May 7, 2013 14:32
Run single instance process from console.
[STAThread()]
static void Main(string[] args)
{
Console.Title = "Call App";
// hide the console window
setConsoleWindowVisibility(false, Console.Title);
// look for all running instances of the app
var runningProcessByName = Process.GetProcessesByName("notepad");
if (runningProcessByName.Length == 0)
@begedin
begedin / setforegroundwindwo.cs
Created May 7, 2013 14:30
Import SetForegroundWindow
[DllImport("User32.dll")]
private static extern bool SetForegroundWindow(IntPtr hWnd);
@begedin
begedin / runsingle.cs
Created May 7, 2013 14:29
Run notepad if it isn't running.
var runningProcessByName = Process.GetProcessesByName("notepad");
if (runningProcessByName.Length == 0)
{
Process.Start("notepad.exe");
}
Console.Title = "Call App";
// hide the console window
setConsoleWindowVisibility(false, Console.Title);
@begedin
begedin / setConsoleWindowVisibility.cs
Created May 7, 2013 14:27
Function to set console window visibility.
public static void setConsoleWindowVisibility(bool visible, string title)
{
IntPtr hWnd = FindWindow(null, title);
if (hWnd != IntPtr.Zero)
{
if (!visible)
//Hide the window
ShowWindow(hWnd, 0); // 0 = SW_HIDE
else
//Show window again
[DllImport("user32.dll")]
public static extern IntPtr FindWindow(
string lpClassName,string lpWindowName);
[DllImport("user32.dll")]
static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);