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

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

P2P Manager: Made IV-Input optional with a dirty hack (internal a 8 byte IV with 0...0 will be created)

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        private void FunnyResize()
71        {
72            this.Canvas.RenderTransform = new ScaleTransform(this.ActualWidth / this.Grid.ActualWidth,
73                                                       this.ActualHeight / this.Grid.ActualHeight);
74        }
75
76        void ListView_SourceUpdated(object sender, DataTransferEventArgs e)
77        {
78            FunnyResize();
79        }       
80
81        void Expander_WorkerInfo_Expanded(object sender, RoutedEventArgs e)
82        {
83            FunnyResize();
84        }
85
86        void Expander_List_Expanded(object sender, RoutedEventArgs e)
87        {
88            FunnyResize();
89        }
90
91        void Expander_JobStatus_Expanded(object sender, RoutedEventArgs e)
92        {
93            FunnyResize();
94        }
95
96        public void P2PManagerPresentation_SizeChanged(object sender, SizeChangedEventArgs e)
97        {
98            FunnyResize();
99            //this.Grid.RenderTransform = new ScaleTransform(this.ActualWidth / this.Grid.ActualWidth,
100                                                       //this.ActualHeight / this.Grid.ActualHeight);
101        }
102
103        //void Grid_LayoutUpdated(object sender, EventArgs e)
104        //{
105        //    FunnyResize();
106        //}
107
108        //void Canvas_LayoutUpdated(object sender, EventArgs e)
109        //{
110        //    FunnyResize();
111        //}
112
113        //void ListView_SizeChanged(object sender, SizeChangedEventArgs e)
114        //{
115        //    FunnyResize();
116        //}
117
118        //void ListView_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
119        //{
120        //    FunnyResize();
121        //}
122
123        //void P2PManagerPresentation_LayoutUpdated(object sender, EventArgs e)
124        //{
125        //    FunnyResize();
126        //}
127    }
128}
Note: See TracBrowser for help on using the repository browser.