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

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

P2PManager: Design embellished and added an "estimated end time" information.
Samples: Output Boxes for KeySearcher Outputs

File size: 4.7 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        #endregion
47
48        public P2PManagerPresentation()
49        {
50            InitializeComponent();
51            this.SizeChanged += new SizeChangedEventHandler(P2PManagerPresentation_SizeChanged);
52            this.DataContext = entries;
53            // when you uncomment this line, you burn 70% of the whole CPU time for Resizing this view...
54            //this.LayoutUpdated += new EventHandler(P2PManagerPresentation_LayoutUpdated);
55            this.Expander_JobStatus.Expanded += new RoutedEventHandler(Expander_JobStatus_Expanded);
56            this.Expander_List.Expanded += new RoutedEventHandler(Expander_List_Expanded);
57            this.Expander_WorkerInfo.Expanded += new RoutedEventHandler(Expander_WorkerInfo_Expanded);
58            //this.ListView.DataContextChanged += new DependencyPropertyChangedEventHandler(ListView_DataContextChanged);
59            //this.ListView.SizeChanged += new SizeChangedEventHandler(ListView_SizeChanged);
60            this.ListView.SourceUpdated += new EventHandler<DataTransferEventArgs>(ListView_SourceUpdated);
61
62            LinearGradientBrush blueBrush = GetGradientBlue();
63
64            this.MngrMain.Background = blueBrush;
65            this.Expander_JobStatus.Background = blueBrush;
66            this.Expander_WorkerInfo.Background = blueBrush;
67            this.Expander_List.Background = GetGradientGray();
68        }
69
70        void Grid_LayoutUpdated(object sender, EventArgs e)
71        {
72            FunnyResize();
73        }
74
75        void Canvas_LayoutUpdated(object sender, EventArgs e)
76        {
77            FunnyResize();
78        }
79
80        void ListView_SourceUpdated(object sender, DataTransferEventArgs e)
81        {
82            FunnyResize();
83        }
84
85        void ListView_SizeChanged(object sender, SizeChangedEventArgs e)
86        {
87            FunnyResize();
88        }
89
90        void ListView_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
91        {
92            FunnyResize();
93        }
94
95        void Expander_WorkerInfo_Expanded(object sender, RoutedEventArgs e)
96        {
97            FunnyResize();
98        }
99
100        void Expander_List_Expanded(object sender, RoutedEventArgs e)
101        {
102            FunnyResize();
103        }
104
105        void Expander_JobStatus_Expanded(object sender, RoutedEventArgs e)
106        {
107            FunnyResize();
108        }
109
110        void P2PManagerPresentation_LayoutUpdated(object sender, EventArgs e)
111        {
112            FunnyResize();
113        }
114
115        public void P2PManagerPresentation_SizeChanged(object sender, SizeChangedEventArgs e)
116        {
117            FunnyResize();
118            //this.Grid.RenderTransform = new ScaleTransform(this.ActualWidth / this.Grid.ActualWidth,
119                                                       //this.ActualHeight / this.Grid.ActualHeight);
120        }
121
122        private void FunnyResize()
123        {
124            this.Canvas.RenderTransform = new ScaleTransform(this.ActualWidth / this.Grid.ActualWidth,
125                                                       this.ActualHeight / this.Grid.ActualHeight);
126        }
127    }
128}
Note: See TracBrowser for help on using the repository browser.