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

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

some bug fixes.

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        #endregion
47
48        public P2PManagerPresentation()
49        {
50            InitializeComponent();
51            this.SizeChanged += new SizeChangedEventHandler(P2PManagerPresentation_SizeChanged);
52            this.DataContext = entries;
53            // when expanding Expanders, resize layout
54            this.Expander_JobStatus.MouseLeftButtonUp += new MouseButtonEventHandler(Expander_JobStatus_MouseLeftButtonUp);
55            this.Expander_List.MouseLeftButtonUp += new MouseButtonEventHandler(Expander_List_MouseLeftButtonUp);
56            this.Expander_WorkerInfo.MouseLeftButtonUp += new MouseButtonEventHandler(Expander_WorkerInfo_MouseLeftButtonUp);
57
58
59            this.SourceUpdated += new EventHandler<DataTransferEventArgs>(P2PManagerPresentation_SourceUpdated);
60            // when you uncomment this line, you burn 70% of the whole CPU time for Resizing this view...
61            //this.LayoutUpdated += new EventHandler(P2PManagerPresentation_LayoutUpdated);
62            this.Expander_JobStatus.Expanded += new RoutedEventHandler(Expander_JobStatus_Expanded);
63            this.Expander_List.Expanded += new RoutedEventHandler(Expander_List_Expanded);
64            this.Expander_WorkerInfo.Expanded += new RoutedEventHandler(Expander_WorkerInfo_Expanded);
65            //this.ListView.DataContextChanged += new DependencyPropertyChangedEventHandler(ListView_DataContextChanged);
66            //this.ListView.SizeChanged += new SizeChangedEventHandler(ListView_SizeChanged);
67            this.ListView.SourceUpdated += new EventHandler<DataTransferEventArgs>(ListView_SourceUpdated);
68
69            LinearGradientBrush blueBrush = GetGradientBlue();
70
71            this.MngrMain.Background = blueBrush;
72            this.Expander_JobStatus.Background = blueBrush;
73            this.Expander_WorkerInfo.Background = blueBrush;
74            this.Expander_List.Background = GetGradientGray();
75        }
76
77        void Expander_WorkerInfo_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
78        {
79            FunnyResize();
80        }
81
82        void Expander_List_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
83        {
84            FunnyResize();
85        }
86
87        void Expander_JobStatus_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
88        {
89            FunnyResize();
90        }
91
92        void txtTotal_TextChanged(object sender, TextChangedEventArgs e)
93        {
94            FunnyResize();
95        }
96
97        void P2PManagerPresentation_SourceUpdated(object sender, DataTransferEventArgs e)
98        {
99            FunnyResize();
100        }
101
102        private void FunnyResize()
103        {
104            this.Canvas.RenderTransform = new ScaleTransform(this.ActualWidth / this.Grid.ActualWidth,
105                                                       this.ActualHeight / this.Grid.ActualHeight);
106        }
107
108        void ListView_SourceUpdated(object sender, DataTransferEventArgs e)
109        {
110            FunnyResize();
111        }       
112
113        void Expander_WorkerInfo_Expanded(object sender, RoutedEventArgs e)
114        {
115            FunnyResize();
116        }
117
118        void Expander_List_Expanded(object sender, RoutedEventArgs e)
119        {
120            FunnyResize();
121        }
122
123        void Expander_JobStatus_Expanded(object sender, RoutedEventArgs e)
124        {
125            FunnyResize();
126        }
127
128        public void P2PManagerPresentation_SizeChanged(object sender, SizeChangedEventArgs e)
129        {
130            FunnyResize();
131            //this.Grid.RenderTransform = new ScaleTransform(this.ActualWidth / this.Grid.ActualWidth,
132                                                       //this.ActualHeight / this.Grid.ActualHeight);
133        }
134
135        //void Grid_LayoutUpdated(object sender, EventArgs e)
136        //{
137        //    FunnyResize();
138        //}
139
140        //void Canvas_LayoutUpdated(object sender, EventArgs e)
141        //{
142        //    FunnyResize();
143        //}
144
145        //void ListView_SizeChanged(object sender, SizeChangedEventArgs e)
146        //{
147        //    FunnyResize();
148        //}
149
150        //void ListView_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
151        //{
152        //    FunnyResize();
153        //}
154
155        //void P2PManagerPresentation_LayoutUpdated(object sender, EventArgs e)
156        //{
157        //    FunnyResize();
158        //}
159    }
160}
Note: See TracBrowser for help on using the repository browser.