WPF Scrollable + Zoomable + Dragable Control

Unluckily there is no standard control to zoom, drag and scroll your content. My implementation is based on following tutorial. With this implementation you are able to zoom, drag and scroll arbitrary controls. Showcase ScrollDragZoomControl.xaml <UserControl x:Class=”MinimalMonitoringClient.Controls.ScrollDragZoomControl” xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation” xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml” Background=”Transparent”> <UserControl.Template> <ControlTemplate TargetType=”UserControl”> <ScrollViewer x:Name=”scrollViewer” Loaded=”scrollViewer_Loaded” HorizontalScrollBarVisibility=”Visible” VerticalScrollBarVisibility=”Visible”> <Grid Name=”grid” RenderTransformOrigin=”0.5,0.5″> <Grid.LayoutTransform> <TransformGroup> <ScaleTransform x:Name=”scaleTransform” /> …

Windows Phone 8.1 WinRT Json Serialize + DeSerialize

private static string JSON_MARK_FILE_NAME = “markJsonData.json”; Serialize object to a storage file StorageFolder localFolder = ApplicationData.Current.LocalFolder; StorageFile textFile = await localFolder.CreateFileAsync(JSON_MARK_FILE_NAME, CreationCollisionOption.ReplaceExisting); using (Stream stream = await textFile.OpenStreamForWriteAsync()) { string content = await Newtonsoft.Json.JsonConvert.SerializeObjectAsync(grades); using (StreamWriter streamWriter = new StreamWriter(stream)) await streamWriter.WriteAsync(content); } DeSerialize a storage file to a object StorageFolder localFolder = ApplicationData.Current.LocalFolder; StorageFile …

Rabin-Karp

internal override SearchResult Search(string text, string pattern) { if (pattern.Length > text.Length) return SearchResult.Empty(); SearchResult searchResult = new SearchResult() { Matches = new List<Match>() }; int patternHashValue = pattern.GetHashCode(); for(int index = 0; index + pattern.Length < text.Length; index++) { string indexString = text.Substring(index, pattern.Length); int indexHashValue = indexString.GetHashCode(); if(patternHashValue == indexHashValue) if (string.CompareOrdinal(pattern, indexString) …

Heapsort

internal class Heap : StorageObjectSort { private object[] items; public int Size { get; set; } = 0; public override IEnumerable<T> Sort<T>(IComparer<T> sortFunction, IEnumerable<T> collection) { List<T> objectList = collection.ToList(); Initialize(objectList.Count); objectList.ForEach(o => Insert(o, sortFunction)); objectList.Clear(); while (Size > 0) objectList.Add((T)Remove(sortFunction)); return objectList; } protected override void Insert<T>(object item, IComparer<T> sortFunction) { items[Size] = item; …

Combosort

public override IEnumerable<T> Sort<T>(IComparer<T> sortFunction, IEnumerable<T> collection) { List<T> objectList = collection.ToList(); //Calculate an efficient step size. //Ofc it depends on many factors and it won’t be perfect in every case. int divideValue = (int)Math.Pow(objectList.Count, 1 / 3); for (int partCount = divideValue; partCount > 0; partCount–) { //Split the objectList up into smaller lists …

Shellsort

public override IEnumerable<T> Sort<T>(IComparer<T> sortFunction, IEnumerable<T> collection) { List<T> objectList = collection.ToList(); //Calculate an efficient step size. //Ofc it depends on many factors and it won’t be perfect in every case. int divideValue = (int)Math.Pow(objectList.Count, 1 / 3); for (int partCount = divideValue; partCount > 0; partCount–) { //Split the objectList up into smaller lists …

Inserationsort

internal class Insertion : ObjectSort { public override IEnumerable<T> Sort<T>(IComparer<T> sortFunction, IEnumerable<T> collection) { List<T> objectList = collection.ToList(); for (int currentIndex = 1; currentIndex < objectList.Count; currentIndex++) { //Put the current object into a buffer. T objectBuffer = objectList[currentIndex]; //The index we have to shift. int shiftIndex = 0; //Shift all from 0 to the …

Iteration performance – Vergleich

Es gibt viele Möglichkeiten eine Ansammlung von Daten mithilfe einer Iteration zu durchlaufen. Die verwendete Iteration hängt meistens von der Sachlage ab. Wird ein Index benötigt. Auf wie viel Objektvariablen wird zugegriffen. Muss das Objekt noch convertiert oder gecastet werden. … Jedoch welche Iterationsmethode ist die performanteste? Welcher Durchlauf ist am schnellsten? Zur Auswahl steht ForEach …