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

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

1) Killed the LayoutUpdated-Event in WPF because it consumed 60-90% of the cpu load...
2) Changes Threading.Timer to Timers.Timer in P2PSubscriberBase.

File size: 3.5 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        public P2PManagerPresentation()
27        {
28            InitializeComponent();
29            this.SizeChanged += new SizeChangedEventHandler(P2PManagerPresentation_SizeChanged);
30            this.DataContext = entries;
31            // when you uncomment this line, you burn 70% of the whole CPU time for Resizing this view...
32            //this.LayoutUpdated += new EventHandler(P2PManagerPresentation_LayoutUpdated);
33            this.Expander_JobStatus.Expanded += new RoutedEventHandler(Expander_JobStatus_Expanded);
34            this.Expander_List.Expanded += new RoutedEventHandler(Expander_List_Expanded);
35            this.Expander_WorkerInfo.Expanded += new RoutedEventHandler(Expander_WorkerInfo_Expanded);
36            //this.ListView.DataContextChanged += new DependencyPropertyChangedEventHandler(ListView_DataContextChanged);
37            //this.ListView.SizeChanged += new SizeChangedEventHandler(ListView_SizeChanged);
38            this.ListView.SourceUpdated += new EventHandler<DataTransferEventArgs>(ListView_SourceUpdated);
39        }
40
41        void Grid_LayoutUpdated(object sender, EventArgs e)
42        {
43            FunnyResize();
44        }
45
46        void Canvas_LayoutUpdated(object sender, EventArgs e)
47        {
48            FunnyResize();
49        }
50
51        void ListView_SourceUpdated(object sender, DataTransferEventArgs e)
52        {
53            FunnyResize();
54        }
55
56        void ListView_SizeChanged(object sender, SizeChangedEventArgs e)
57        {
58            FunnyResize();
59        }
60
61        void ListView_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
62        {
63            FunnyResize();
64        }
65
66        void Expander_WorkerInfo_Expanded(object sender, RoutedEventArgs e)
67        {
68            FunnyResize();
69        }
70
71        void Expander_List_Expanded(object sender, RoutedEventArgs e)
72        {
73            FunnyResize();
74        }
75
76        void Expander_JobStatus_Expanded(object sender, RoutedEventArgs e)
77        {
78            FunnyResize();
79        }
80
81        void P2PManagerPresentation_LayoutUpdated(object sender, EventArgs e)
82        {
83            FunnyResize();
84        }
85
86        public void P2PManagerPresentation_SizeChanged(object sender, SizeChangedEventArgs e)
87        {
88            FunnyResize();
89            //this.Grid.RenderTransform = new ScaleTransform(this.ActualWidth / this.Grid.ActualWidth,
90                                                       //this.ActualHeight / this.Grid.ActualHeight);
91        }
92
93        private void FunnyResize()
94        {
95            this.Canvas.RenderTransform = new ScaleTransform(this.ActualWidth / this.Grid.ActualWidth,
96                                                       this.ActualHeight / this.Grid.ActualHeight);
97        }
98    }
99}
Note: See TracBrowser for help on using the repository browser.