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

Last change on this file was 8983, checked in by kopal, 8 months ago

Complete CrypTool 2 project

  • renamed "Cryptool" namespace to "CrypTool" namespace
File size: 2.1 KB
Line 
1using System;
2using System.Windows;
3using System.Windows.Controls;
4using KeySearcher;
5using System.Globalization;
6using System.Threading.Tasks;
7using KeySearcher.CrypCloud;
8using CrypTool.CrypAnalysisViewControl;
9
10namespace KeySearcherPresentation.Controls
11{
12    [CrypTool.PluginBase.Attributes.Localization("KeySearcher.Properties.Resources")]
13    public partial class P2PQuickWatchPresentation : UserControl
14    {
15        public KeySearcher.KeySearcher.UpdateOutput UpdateOutputFromUserChoice { get; set; }
16
17        public static readonly DependencyProperty IsVerboseEnabledProperty = DependencyProperty.Register("IsVerboseEnabled", typeof(Boolean), typeof(P2PQuickWatchPresentation), new PropertyMetadata(false));
18        public Boolean IsVerboseEnabled
19        {
20            get { return (Boolean)GetValue(IsVerboseEnabledProperty); }
21            set { SetValue(IsVerboseEnabledProperty, value); }
22        }
23       
24        public NumberFormatInfo nfi = (NumberFormatInfo)CultureInfo.InvariantCulture.NumberFormat.Clone();
25
26        public TaskFactory UiContext { get; set; }
27        public P2PPresentationVM ViewModel { get; set; }
28     
29        public P2PQuickWatchPresentation() 
30        {
31            InitializeComponent();
32            ViewModel = DataContext as P2PPresentationVM;
33            try
34            {
35                UiContext = new TaskFactory(TaskScheduler.FromCurrentSynchronizationContext());
36            }
37            catch (Exception)
38            {
39                //do nothing
40            }
41            ViewModel.UiContext = UiContext;
42        }
43
44        public void UpdateSettings(KeySearcher.KeySearcher keySearcher, KeySearcherSettings keySearcherSettings)
45        {
46            ViewModel.UpdateSettings(keySearcher, keySearcherSettings);
47        }
48
49        private void HandleResultItemAction(ICrypAnalysisResultListEntry item)
50        {
51            if (item is KeyResultEntry resultItem)
52            {
53                UpdateOutputFromUserChoice(resultItem.Key, resultItem.Plaintext);
54            }
55        }
56    }
57}
Note: See TracBrowser for help on using the repository browser.