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” /> …

ABP – Alpha-Beta Pruning

private BiPredicate<Integer, Node> searchLimitingPredicate; private int depth; public AlphaBetaSearch(BiPredicate<Integer, Node> searchLimitingPredicate) { this.searchLimitingPredicate = searchLimitingPredicate; } public Pair<Node, Double> search(Node start, Function<Node, Double> evalFunction) { Node winner = start; double value = Double.NEGATIVE_INFINITY; double alpha = Double.NEGATIVE_INFINITY; double beta = Double.POSITIVE_INFINITY; for (Node n : start.adjacent()) { double temp = min(n, evalFunction, alpha, beta); if …

DLS – Depth-Limited Search

private StackWithFastContains<Node> path; private int limit; public DLDFS(int limit) { this.limit = limit; } public Node search(Node start, Predicate<Node> endPredicate) { //Initial the stackWithFastContains path = new StackWithFastContains<>(); return searchForNode(start, endPredicate, limit); } private Node searchForNode(Node currentNode, Predicate<Node> toSearchFor, int depth){ path.push(currentNode); if (depth >= 0) { //As long as we are depth > or …

GBFS – Greedy Best-First Search

private Function<Node, Double> heuristic; public GBFS(Function<Node, Double> heuristic) { this.heuristic = heuristic; } public Node search(Node start, Predicate<Node> endPredicate) { //Check if the start node is the endPredicate if (endPredicate.test(start)) return start; //The queue containing all the nodes we have to search for StablePriorityQueue<Double, Node> nodeQueue = new StablePriorityQueue<>(); //Add the start node as the …

MM – MinMax Search

private BiPredicate<Integer, Node> searchLimitingPredicate; private int depth; /** * To limit the extent of the search, this implementation should honor a * limiting predicate. The predicate returns ‘true’ as long as we are below * the limit, and ‘false’, if we exceed the limit. * * @param searchLimitingPredicate */ public MinMaxSearch(BiPredicate<Integer, Node> slp) { this.searchLimitingPredicate …