|
1 /* |
|
2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * |
|
5 * Redistribution and use in source and binary forms, with or without |
|
6 * modification, are permitted provided that the following conditions are met: |
|
7 * |
|
8 * - Redistributions of source code must retain the above copyright notice, |
|
9 * this list of conditions and the following disclaimer. |
|
10 * - Redistributions in binary form must reproduce the above copyright notice, |
|
11 * this list of conditions and the following disclaimer in the documentation |
|
12 * and/or other materials provided with the distribution. |
|
13 * - Neither the name of Nokia Corporation nor the names of its contributors |
|
14 * may be used to endorse or promote products derived from this software |
|
15 * without specific prior written permission. |
|
16 * |
|
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
|
18 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
|
21 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
|
22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
|
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
|
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
|
25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
|
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|
27 * POSSIBILITY OF SUCH DAMAGE. |
|
28 * |
|
29 * Initial Contributors: |
|
30 * Nokia Corporation - initial contribution. |
|
31 * |
|
32 * Contributors: |
|
33 * |
|
34 * Description: |
|
35 * |
|
36 */ |
|
37 |
|
38 using System; |
|
39 using System.Drawing; |
|
40 using System.Collections; |
|
41 using System.ComponentModel; |
|
42 using System.Windows.Forms; |
|
43 using HeapLib; |
|
44 using HeapLib.Reconstructor; |
|
45 using SymbianUtils; |
|
46 |
|
47 namespace HeapUiLib.Dialogs |
|
48 { |
|
49 public class HeapExportToHTMLProgressDialog : Form |
|
50 { |
|
51 #region Windows Form Designer generated code |
|
52 private IContainer components; |
|
53 private Timer iTimer_OpStart; |
|
54 private System.Windows.Forms.ProgressBar iProgressBar; |
|
55 #endregion |
|
56 |
|
57 #region Constructors & destructor |
|
58 public HeapExportToHTMLProgressDialog( HeapReconstructor aReconstructor, string aOutputDirectory ) |
|
59 { |
|
60 InitializeComponent(); |
|
61 // |
|
62 iReconstructor = aReconstructor; |
|
63 // |
|
64 iConverter = new HeapToHTMLConverter( aReconstructor, aOutputDirectory ); |
|
65 iConverter.Observer += new HeapToHTMLConverter.EventHandler( Converter_Observer ); |
|
66 // |
|
67 iTimer_OpStart.Start(); |
|
68 } |
|
69 |
|
70 protected override void Dispose( bool disposing ) |
|
71 { |
|
72 if( disposing ) |
|
73 { |
|
74 if(components != null) |
|
75 { |
|
76 components.Dispose(); |
|
77 } |
|
78 } |
|
79 base.Dispose( disposing ); |
|
80 } |
|
81 #endregion |
|
82 |
|
83 #region Windows Form Designer generated code |
|
84 private void InitializeComponent() |
|
85 { |
|
86 this.components = new System.ComponentModel.Container(); |
|
87 this.iProgressBar = new System.Windows.Forms.ProgressBar(); |
|
88 this.iTimer_OpStart = new System.Windows.Forms.Timer( this.components ); |
|
89 this.SuspendLayout(); |
|
90 // |
|
91 // iProgressBar |
|
92 // |
|
93 this.iProgressBar.Location = new System.Drawing.Point(8, 8); |
|
94 this.iProgressBar.Name = "iProgressBar"; |
|
95 this.iProgressBar.Size = new System.Drawing.Size(376, 23); |
|
96 this.iProgressBar.TabIndex = 0; |
|
97 // |
|
98 // iTimer_OpStart |
|
99 // |
|
100 this.iTimer_OpStart.Interval = 10; |
|
101 this.iTimer_OpStart.Tick += new System.EventHandler( this.iTimer_OpStart_Tick ); |
|
102 // |
|
103 // HeapExportToHTMLProgressDialog |
|
104 // |
|
105 this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); |
|
106 this.ClientSize = new System.Drawing.Size(392, 39); |
|
107 this.ControlBox = false; |
|
108 this.Controls.Add(this.iProgressBar); |
|
109 this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; |
|
110 this.MaximizeBox = false; |
|
111 this.MinimizeBox = false; |
|
112 this.Name = "HeapExportToHTMLProgressDialog"; |
|
113 this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; |
|
114 this.Text = " Preparing HTML Output"; |
|
115 this.ResumeLayout(false); |
|
116 |
|
117 } |
|
118 #endregion |
|
119 |
|
120 #region Converter observer |
|
121 private void Converter_Observer( HeapToHTMLConverter.TEvent aEvent ) |
|
122 { |
|
123 if ( InvokeRequired ) |
|
124 { |
|
125 HeapToHTMLConverter.EventHandler observer = new HeapToHTMLConverter.EventHandler( Converter_Observer ); |
|
126 this.BeginInvoke( observer, new object[] { aEvent } ); |
|
127 } |
|
128 else |
|
129 { |
|
130 switch (aEvent) |
|
131 { |
|
132 case HeapToHTMLConverter.TEvent.EEventStarted: |
|
133 iProgressBar.Maximum = 100; //% |
|
134 iProgressBar.Minimum = 0; //% |
|
135 iProgressBar.Value = 0; |
|
136 break; |
|
137 case HeapToHTMLConverter.TEvent.EEventProgress: |
|
138 iProgressBar.Value = iConverter.Progress; |
|
139 break; |
|
140 case HeapToHTMLConverter.TEvent.EEventComplete: |
|
141 Close(); |
|
142 break; |
|
143 } |
|
144 } |
|
145 } |
|
146 #endregion |
|
147 |
|
148 #region Event handlers |
|
149 private void iTimer_OpStart_Tick( object sender, EventArgs e ) |
|
150 { |
|
151 iTimer_OpStart.Stop(); |
|
152 iTimer_OpStart.Enabled = false; |
|
153 // |
|
154 iConverter.Convert( TSynchronicity.EAsynchronous ); |
|
155 } |
|
156 #endregion |
|
157 |
|
158 #region Data members |
|
159 private readonly HeapReconstructor iReconstructor; |
|
160 private readonly HeapToHTMLConverter iConverter; |
|
161 #endregion |
|
162 } |
|
163 } |