Skip to content

Instantly share code, notes, and snippets.

View sachintha81's full-sized avatar

Sach sachintha81

View GitHub Profile
@sachintha81
sachintha81 / ExtractSubstring.cs
Created January 13, 2017 21:07
WPF + C# Extract a Substring from a String between two specified Parts
using System;
using System.Collections.Generic;
using System.Windows;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Windows.Input;
using System.Xml.Linq;
namespace StringProgram
@sachintha81
sachintha81 / ValidateXMLUsingSchema.cs
Created January 13, 2017 21:08
C# Validating XML using Schemas
using System;
using System.IO;
using System.Xml.Linq;
using System.Xml.Schema;
namespace XmlValidation
{
class Program
{
static void Main(string[] args)
@sachintha81
sachintha81 / MaskTextbox.cs
Created January 13, 2017 21:16
WPF TextBox Input Restrictions
/// <summary>
/// Provides masking behavior for any TextBox
/// </summary>
public static class Masking
{
private static readonly DependencyPropertyKey _maskExpressionPropertyKey = DependencyProperty.RegisterAttachedReadOnly(""MaskExpression"",
typeof(Regex),
typeof(Masking),
new FrameworkPropertyMetadata());
@sachintha81
sachintha81 / AllCombinations.cs
Created January 13, 2017 21:18
All Possible Combinations of a list of Values
namespace Combinations
{
public class Combinations
{
public static void Main(string[] args)
{
GetCombination(new List<int> { 1, 2, 3 });
}
public static void GetCombination(List<int> list)
@sachintha81
sachintha81 / MoveListViewItems.cs
Created January 13, 2017 21:26
WPF + C# Move Multiple Items from one ListView to Another
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
namespace ListViewOperations.SOURCE.GUI
{
public partial class ListViewOperations : Window
{
@sachintha81
sachintha81 / IndentStringWithTabs.cs
Created January 13, 2017 21:30
Indenting C# String Data with Tabs
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StringIndent
{
public class StringIndent
@sachintha81
sachintha81 / ColorLibrary.cs
Created January 13, 2017 21:32
WPF + C# Color Handling
namespace ColorLibrary
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
@sachintha81
sachintha81 / DragDropToTextBox.cs
Created January 13, 2017 21:33
C# - Drag Drop a File/Folder into a TextBox
using System;
using System.Collections.Generic;
using System.Windows;
using System.Collections.ObjectModel;
namespace TextBoxDragDrop
{
public partial class TextBoxDragDrop : Window
{
private void txtPath_PreviewDragOver(object sender, DragEventArgs e)
@sachintha81
sachintha81 / FileHashRetriever.cs
Created January 23, 2017 19:51
C# - Retrieve MD5 Hash of a File
using System;
using System.IO;
using System.Security.Cryptography;
namespace FileHashCompare
{
class Program
{
static void Main(string[] args)
{
@sachintha81
sachintha81 / deleteall.bat
Created June 9, 2017 20:26
Batch script to delete all files in current and sub folders excluding certain extensions.
@echo off
forfiles /s /c "cmd /c (if NOT @ext==\"bat\" del /s /q @path)"