source: trunk/CrypPlugins/PeerToPeerManager_NEW/P2PManagerPresentation.xaml.cs @ 1199

Last change on this file since 1199 was 1199, checked in by arnold, 12 years ago

P2PManager

  • Enlarged KeyPatternSize range to 1.000, because the new DES/AES-Implementation runs so fast, that a KeyPattern with KeyPatternSize of 150 will be processed in approximately 40 seconds on a modern PC
  • Embellished Layout
  • Enhanced information display (total processing time)
  • Jobs in progress change their color every second between Yellow and LightGray

Samples:

  • Changed from CFB to CBC, because this modus is much faster than CFB!
  • Changed KeyPatternSize to 150, because the new DES/AES Implementation runs much faster
File size: 5.9 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using System.Windows;
6using System.Windows.Controls;
7using System.Windows.Data;
8using System.Windows.Documents;
9using System.Windows.Input;
10using System.Windows.Media;
11using System.Windows.Media.Imaging;
12using System.Windows.Navigation;
13using System.Windows.Shapes;
14using System.Collections.ObjectModel;
15using KeySearcher;
16
17namespace Cryptool.Plugins.PeerToPeer
18{
19    /// <summary>
20    /// Interaction logic for P2PManagerQuickWatch.xaml
21    /// </summary>
22    public partial class P2PManagerPresentation : UserControl
23    {
24        public ObservableCollection<ResultEntry> entries = new ObservableCollection<ResultEntry>();
25
26        #region Different radient brushes
27
28        public LinearGradientBrush GetGradientBlue()
29        {
30            LinearGradientBrush myBrush = new LinearGradientBrush();
31            myBrush.GradientStops.Add(new GradientStop(Colors.DodgerBlue, 0.0)); //CadetBlue
32            myBrush.GradientStops.Add(new GradientStop(Colors.CornflowerBlue, 0.5));
33            myBrush.GradientStops.Add(new GradientStop(Colors.AliceBlue, 1.0));
34            return myBrush;
35        }
36
37        public LinearGradientBrush GetGradientGray()
38        {
39            LinearGradientBrush myBrush = new LinearGradientBrush();
40            myBrush.GradientStops.Add(new GradientStop(Colors.DarkGray, 0.0));
41            myBrush.GradientStops.Add(new GradientStop(Colors.Gray, 0.5));
42            myBrush.GradientStops.Add(new GradientStop(Colors.WhiteSmoke, 1.0));
43            return myBrush;
44        }
45
46        public ProgressChunks PrgChunks = new ProgressChunks();
47
48        #endregion
49
50        public P2PManagerPresentation()
51        {
52            InitializeComponent();
53            this.SizeChanged += new SizeChangedEventHandler(P2PManagerPresentation_SizeChanged);
54            this.DataContext = entries;
55
56            this.txtTotal.SizeChanged += new SizeChangedEventHandler(txtTotal_SizeChanged);
57            //this.txtTotal.TextChanged += new TextChangedEventHandler(txtTotal_TextChanged);
58
59
60            this.Expander_WorkerInfo.SizeChanged += new SizeChangedEventHandler(Expander_WorkerInfo_SizeChanged);
61            this.Expander_List.SizeChanged += new SizeChangedEventHandler(Expander_List_SizeChanged);
62            this.Expander_JobStatus.SizeChanged += new SizeChangedEventHandler(Expander_JobStatus_SizeChanged);
63
64            this.SourceUpdated += new EventHandler<DataTransferEventArgs>(P2PManagerPresentation_SourceUpdated);
65            // when you uncomment this line, you burn 70% of the whole CPU time for Resizing this view...
66            //this.LayoutUpdated += new EventHandler(P2PManagerPresentation_LayoutUpdated);
67            this.ListView.SourceUpdated += new EventHandler<DataTransferEventArgs>(ListView_SourceUpdated);
68
69            LinearGradientBrush blueBrush = GetGradientBlue();
70            LinearGradientBrush grayBrush = GetGradientGray();
71
72            this.MngrMain.Background = blueBrush;
73            this.Expander_JobStatus.Background = blueBrush;
74           
75            Expander exp_chunk = new Expander();
76            exp_chunk.Content = PrgChunks;
77            exp_chunk.Header = "Visual Job Distribution";
78            exp_chunk.FontSize = 10;
79            exp_chunk.Background = grayBrush;
80            exp_chunk.SizeChanged += new SizeChangedEventHandler(exp_chunk_SizeChanged);
81            this.PrgChunks.Width = 200;
82            this.PrgChunks.Height = 55;
83            Grid.SetRow(exp_chunk, 1);
84            this.Grid1.Children.Add(exp_chunk);
85
86            this.Expander_List.Background = blueBrush;
87            this.Expander_WorkerInfo.Background = grayBrush;
88        }
89
90        void exp_chunk_SizeChanged(object sender, SizeChangedEventArgs e)
91        {
92            FunnyResize();
93        }
94
95        void txtTotal_SizeChanged(object sender, SizeChangedEventArgs e)
96        {
97            FunnyResize();
98        }
99
100        void Expander_JobStatus_SizeChanged(object sender, SizeChangedEventArgs e)
101        {
102            FunnyResize();
103        }
104
105        void Expander_List_SizeChanged(object sender, SizeChangedEventArgs e)
106        {
107            FunnyResize();
108        }
109
110        void Expander_WorkerInfo_SizeChanged(object sender, SizeChangedEventArgs e)
111        {
112            FunnyResize();
113        }
114
115        void P2PManagerPresentation_SourceUpdated(object sender, DataTransferEventArgs e)
116        {
117            FunnyResize();
118        }
119
120        private void FunnyResize()
121        {
122            this.Canvas.RenderTransform = new ScaleTransform(this.ActualWidth / this.Grid1.ActualWidth,
123                                                       this.ActualHeight / this.Grid1.ActualHeight);
124        }
125
126        void ListView_SourceUpdated(object sender, DataTransferEventArgs e)
127        {
128            FunnyResize();
129        }       
130
131        public void P2PManagerPresentation_SizeChanged(object sender, SizeChangedEventArgs e)
132        {
133            FunnyResize();
134            //this.Grid.RenderTransform = new ScaleTransform(this.ActualWidth / this.Grid.ActualWidth,
135                                                       //this.ActualHeight / this.Grid.ActualHeight);
136        }
137
138        //void Grid_LayoutUpdated(object sender, EventArgs e)
139        //{
140        //    FunnyResize();
141        //}
142
143        //void Canvas_LayoutUpdated(object sender, EventArgs e)
144        //{
145        //    FunnyResize();
146        //}
147
148        //void ListView_SizeChanged(object sender, SizeChangedEventArgs e)
149        //{
150        //    FunnyResize();
151        //}
152
153        //void ListView_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
154        //{
155        //    FunnyResize();
156        //}
157
158        //void P2PManagerPresentation_LayoutUpdated(object sender, EventArgs e)
159        //{
160        //    FunnyResize();
161        //}
162    }
163}
Note: See TracBrowser for help on using the repository browser.