Skip to content

Instantly share code, notes, and snippets.

@Jalalx
Jalalx / IranianSystemEncoding.cs
Created January 14, 2015 13:51
Iranian system encoding standard
class IranianSystemEncoding
{
static char[] ByteToChar;
static Byte[][] CharToByte;
static IranianSystemEncoding()
{
InitializeData();
}
/*
How to capture the whole screen:
var image = ScreenCapture.CaptureDesktop();
image.Save(@"C:\temp\snippetsource.jpg", ImageFormat.Jpeg);
How to capture the active window:
var image = ScreenCapture.CaptureActiveWindow();
image.Save(@"C:\temp\snippetsource.jpg", ImageFormat.Jpeg);
*/
public class ScreenCapture
{
@Jalalx
Jalalx / LevenshteinDistance.cs
Created February 4, 2015 19:07
The Levenshtein distance between two strings is defined as the minimum number of edits needed to transform one string into the other, with the allowable edit operations being insertion, deletion, or substitution of a single character.
using System;
/// <summary>
/// Contains approximate string matching
/// </summary>
static class LevenshteinDistance
{
/// <summary>
/// Compute the distance between two strings.
/// </summary>
using System.Collections.Generic;
using System.Linq;
 
namespace NumberToWordsLib
{
 /// <summary>
 /// Number to word languages
 /// </summary>
 public enum Language
 {
/// <summary>
/// Utilties for reflection
/// </summary>
public static class ReflectionExtensions
{
/// <summary>
/// Get all the fields of a class
/// </summary>
/// <param name="type">Type object of that class</param>
/// <returns></returns>
public abstract class BaseViewModel : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged(string propertyName)
{
PropertyChangedEventHandler handler = this.PropertyChanged;
if (handler != null)
{
handler(this, new PropertyChangedEventArgs(propertyName));
@Jalalx
Jalalx / ILoadAware.cs
Created April 22, 2015 12:44
LoadAwareRegionBehavior raise ViewLoaded/ViewUnloaded methods when View.Loaded/View.Unloaded events raise.
using System;
namespace Microsoft.Practices.Prism.Regions
{
/// <summary>
/// Represent ILoadAware functionality for View-Model classes.
/// </summary>
public interface ILoadAware
{
/// <summary>
/*
How use in View?
<PasswordBox>
<i:Interaction.Behaviors>
<local:PasswordBoxBindingBehavior Password="{Binding Password}"/>
</i:Interaction.Behaviors>
</PasswordBox>
How access to orginal string?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace System
{
public static class StringExtensions
{
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace System.Linq
{
public static class LinqExtensions