Skip to content

Instantly share code, notes, and snippets.

@sachintha81
sachintha81 / ExtractSubstring.cs
Created Jan 13, 2017
WPF + C# Extract a Substring from a String between two specified Parts
View ExtractSubstring.cs
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 Jan 13, 2017
C# Validating XML using Schemas
View ValidateXMLUsingSchema.cs
using System;
using System.IO;
using System.Xml.Linq;
using System.Xml.Schema;
namespace XmlValidation
{
class Program
{
static void Main(string[] args)
@sachintha81
sachintha81 / ReadInto2DArray.c
Created Jan 13, 2017
Reading a Text File into a 2D Array in C
View ReadInto2DArray.c
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
// Allocate memory for the array like this:
int** array;
array = malloc(n * sizeof(*array)); /* Assuming `n` is the number of rows */
@sachintha81
sachintha81 / ExtendedDisplay.cpp
Last active Jan 13, 2017
Set Display Settings to EXTEND mode in Windows 7 using C++
View ExtendedDisplay.cpp
public void main(int argc, char const *argv[])
{
// To identify the current configuration:
UINT32 PathArraySize = 0;
UINT32 ModeArraySize = 0;
DISPLAYCONFIG_PATH_INFO* PathArray;
DISPLAYCONFIG_MODE_INFO* ModeArray;
DISPLAYCONFIG_TOPOLOGY_ID CurrentTopology;
@sachintha81
sachintha81 / CustomControl.cs
Last active Jan 13, 2017
Drawing a Custom Control on C# WinForms
View CustomControl.cs
using System;
using System.Drawing;
using System.Windows.Forms;
namespace CustomControls
{
public class NodeControl : Control
{
private Graphics G = null;
@sachintha81
sachintha81 / MaskTextbox.cs
Created Jan 13, 2017
WPF TextBox Input Restrictions
View MaskTextbox.cs
/// <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 Jan 13, 2017
All Possible Combinations of a list of Values
View AllCombinations.cs
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 Jan 13, 2017
WPF + C# Move Multiple Items from one ListView to Another
View MoveListViewItems.cs
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 Jan 13, 2017
Indenting C# String Data with Tabs
View IndentStringWithTabs.cs
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 Jan 13, 2017
WPF + C# Color Handling
View ColorLibrary.cs
namespace ColorLibrary
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
You can’t perform that action at this time.