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

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

P2PManager: Added a job distribution Expander in the QuickWatchPresentation
Bug fixes: Cyclic Register-Message-Sending, Allocating more than one job to each worker

File size: 6.1 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            this.PrgChunks.Width = 200;
81            this.PrgChunks.Height = 55;
82            Grid.SetRow(exp_chunk, 1);
83            this.Grid1.Children.Add(exp_chunk);
84
85            this.Expander_List.Background = blueBrush;
86            this.Expander_WorkerInfo.Background = grayBrush;
87        }
88
89        //void txtTotal_TextChanged(object sender, TextChangedEventArgs e)
90        //{
91        //    int iResult;
92        //    if (Int32.TryParse(this.txtTotal.Text, out iResult))
93        //    {
94        //        PrgChunks.JobCount = iResult;
95        //        PrgChunks[0] = Brushes.HotPink;
96        //        PrgChunks[iResult - 1] = Brushes.HotPink;
97        //    }
98        //}
99
100        void txtTotal_SizeChanged(object sender, SizeChangedEventArgs e)
101        {
102            FunnyResize();
103        }
104
105        void Expander_JobStatus_SizeChanged(object sender, SizeChangedEventArgs e)
106        {
107            FunnyResize();
108        }
109
110        void Expander_List_SizeChanged(object sender, SizeChangedEventArgs e)
111        {
112            FunnyResize();
113        }
114
115        void Expander_WorkerInfo_SizeChanged(object sender, SizeChangedEventArgs e)
116        {
117            FunnyResize();
118        }
119
120        void P2PManagerPresentation_SourceUpdated(object sender, DataTransferEventArgs e)
121        {
122            FunnyResize();
123        }
124
125        private void FunnyResize()
126        {
127            this.Canvas.RenderTransform = new ScaleTransform(this.ActualWidth / this.Grid1.ActualWidth,
128                                                       this.ActualHeight / this.Grid1.ActualHeight);
129        }
130
131        void ListView_SourceUpdated(object sender, DataTransferEventArgs e)
132        {
133            FunnyResize();
134        }       
135
136        public void P2PManagerPresentation_SizeChanged(object sender, SizeChangedEventArgs e)
137        {
138            FunnyResize();
139            //this.Grid.RenderTransform = new ScaleTransform(this.ActualWidth / this.Grid.ActualWidth,
140                                                       //this.ActualHeight / this.Grid.ActualHeight);
141        }
142
143        //void Grid_LayoutUpdated(object sender, EventArgs e)
144        //{
145        //    FunnyResize();
146        //}
147
148        //void Canvas_LayoutUpdated(object sender, EventArgs e)
149        //{
150        //    FunnyResize();
151        //}
152
153        //void ListView_SizeChanged(object sender, SizeChangedEventArgs e)
154        //{
155        //    FunnyResize();
156        //}
157
158        //void ListView_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
159        //{
160        //    FunnyResize();
161        //}
162
163        //void P2PManagerPresentation_LayoutUpdated(object sender, EventArgs e)
164        //{
165        //    FunnyResize();
166        //}
167    }
168}
Note: See TracBrowser for help on using the repository browser.