Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.GrammaticalOptimization/WpfTestSvgSample/ScaleToPercentConverter.cs @ 13348

Last change on this file since 13348 was 12762, checked in by aballeit, 9 years ago

#2283 GUI updates, Tree-chart, MCTS Version 2 (prune leaves)

File size: 1.1 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using System.Windows.Data;
6using System.Globalization;
7
8namespace WpfTestSvgSample
9{
10    /// <summary>
11    /// Used in MainWindow.xaml to converts a scale value to a percentage.
12    /// It is used to display the 50%, 100%, etc that appears underneath the zoom and pan control.
13    /// </summary>
14    public class ScaleToPercentConverter : IValueConverter
15    {
16        /// <summary>
17        /// Convert a fraction to a percentage.
18        /// <returns></returns>
19        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
20        {
21            // Round to an integer value whilst converting.
22            return (double)(int)((double)value * 100.0);
23        }
24
25        /// <summary>
26        /// Convert a percentage back to a fraction.
27        /// <returns></returns>
28        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
29        {
30            return (double)value / 100.0;
31        }
32    }
33}
Note: See TracBrowser for help on using the repository browser.