source: trunk/CrypPlugins/KeySearcher/Presentation/Controls/P2PQuickWatchPresentation.xaml.cs @ 2146

Last change on this file since 2146 was 2146, checked in by Sven Rech, 11 years ago

Added opencl presentation in KeySearcher

File size: 2.4 KB
Line 
1using System;
2using System.Numerics;
3using System.Windows;
4using System.Windows.Controls;
5using KeySearcher;
6using KeySearcher.KeyPattern;
7
8namespace KeySearcherPresentation.Controls
9{
10    public partial class P2PQuickWatchPresentation : UserControl
11    {
12        public static readonly DependencyProperty IsVerboseEnabledProperty = DependencyProperty.Register("IsVerboseEnabled", typeof(Boolean), typeof(P2PQuickWatchPresentation), new PropertyMetadata(false));
13        public Boolean IsVerboseEnabled
14        {
15            get { return (Boolean)GetValue(IsVerboseEnabledProperty); }
16            set { SetValue(IsVerboseEnabledProperty, value); }
17        }
18
19        public P2PQuickWatchPresentation()
20        {
21            InitializeComponent();
22        }
23
24        public static readonly DependencyProperty IsOpenCLEnabledProperty =
25            DependencyProperty.Register("IsOpenCLEnabled",
26                        typeof(Boolean),
27                        typeof(P2PQuickWatchPresentation), new PropertyMetadata(false));
28
29        public Boolean IsOpenCLEnabled
30        {
31            get { return (Boolean)GetValue(IsOpenCLEnabledProperty); }
32            set { SetValue(IsOpenCLEnabledProperty, value); }
33        }
34
35        public void UpdateSettings(KeySearcher.KeySearcher keySearcher, KeySearcherSettings keySearcherSettings)
36        {
37            IsVerboseEnabled = keySearcherSettings.VerbosePeerToPeerDisplay;
38
39            if (keySearcher.Pattern == null || !keySearcher.Pattern.testWildcardKey(keySearcherSettings.Key) || keySearcherSettings.ChunkSize == 0)
40            {
41                return;
42            }
43
44            var keyPattern = new KeyPattern(keySearcher.ControlMaster.getKeyPattern())
45                                 {WildcardKey = keySearcherSettings.Key};
46            var keysPerChunk = Math.Pow(2, keySearcherSettings.ChunkSize);
47            var keyPatternPool = new KeyPatternPool(keyPattern, new BigInteger(keysPerChunk));
48
49            if (keyPatternPool.Length > 9999999999)
50            {
51                TotalAmountOfChunks.Content = keyPatternPool.Length.ToString().Substring(0, 10) + "...";
52            }
53            else
54            {
55                TotalAmountOfChunks.Content = keyPatternPool.Length;
56            }
57
58            KeysPerChunk.Content = keysPerChunk;
59            TestedBits.Content = Math.Ceiling(Math.Log((double) keyPatternPool.Length*keysPerChunk, 2));
60        }
61    }
62}
Note: See TracBrowser for help on using the repository browser.