0
|
1 using System;
|
|
2 using System.Drawing;
|
|
3 using System.Collections;
|
|
4 using System.ComponentModel;
|
|
5 using System.Windows.Forms;
|
|
6
|
|
7 using IBBoard.Relic.RelicTools;
|
|
8
|
|
9 namespace IBBoard.Relic.IChunkyViewer
|
|
10 {
|
|
11 /// <summary>
|
|
12 /// Summary description for Progress.
|
|
13 /// </summary>
|
|
14 public class Progress : System.Windows.Forms.Form
|
|
15 {
|
|
16 private System.Windows.Forms.ProgressBar progressBar;
|
|
17 private System.Windows.Forms.Timer timer;
|
|
18 private System.Windows.Forms.Label lblProgress;
|
|
19 private System.ComponentModel.IContainer components;
|
|
20
|
|
21 Form1.ChunkyOpenedDelegate OnChunkyOpened = null;
|
|
22 Form1.ChunkyNodesCountedDelegate OnChunkyNodesCounted = null;
|
|
23 Form1.ChunkyNodeAddedDelegate OnChunkyNodeAdded = null;
|
|
24 Form1.ChunkyNodesAddedDelegate OnChunkyNodesAdded = null;
|
|
25 Form1.ChunkyOpenFailedDelegate OnChunkyOpenFailed = null;
|
|
26 Form1 parent;
|
|
27
|
|
28 public Progress(Form1 parent)
|
|
29 {
|
|
30 OnChunkyOpened = new Form1.ChunkyOpenedDelegate(chunkyOpened);
|
|
31 OnChunkyNodesCounted = new Form1.ChunkyNodesCountedDelegate(nodesCounted);
|
|
32 OnChunkyNodeAdded = new Form1.ChunkyNodeAddedDelegate(nodeAdded);
|
|
33 OnChunkyNodesAdded = new Form1.ChunkyNodesAddedDelegate(nodesAdded);
|
|
34 OnChunkyOpenFailed = new Form1.ChunkyOpenFailedDelegate(openFailed);
|
|
35
|
|
36 parent.OnChunkyOpened+= OnChunkyOpened;
|
|
37 parent.OnChunkyNodesCounted+= OnChunkyNodesCounted;
|
|
38 parent.OnChunkyNodeAdded+= OnChunkyNodeAdded;
|
|
39 parent.OnChunkyNodesAdded+= OnChunkyNodesAdded;
|
|
40 parent.OnChunkyOpenFailed+= OnChunkyOpenFailed;
|
|
41
|
|
42 InitializeComponent();
|
|
43
|
|
44 this.parent = parent;
|
|
45
|
|
46 timer.Enabled = true;
|
|
47 }
|
|
48
|
|
49 /// <summary>
|
|
50 /// Clean up any resources being used.
|
|
51 /// </summary>
|
|
52 protected override void Dispose( bool disposing )
|
|
53 {
|
|
54 parent.OnChunkyOpened-= OnChunkyOpened;
|
|
55 parent.OnChunkyNodesCounted-= OnChunkyNodesCounted;
|
|
56 parent.OnChunkyNodeAdded-= OnChunkyNodeAdded;
|
|
57 parent.OnChunkyNodesAdded-= OnChunkyNodesAdded;
|
|
58 parent.OnChunkyOpenFailed-= OnChunkyOpenFailed;
|
|
59
|
|
60 if( disposing )
|
|
61 {
|
|
62 if(components != null)
|
|
63 {
|
|
64 components.Dispose();
|
|
65 }
|
|
66 }
|
|
67 base.Dispose( disposing );
|
|
68 }
|
|
69
|
|
70 #region Windows Form Designer generated code
|
|
71 /// <summary>
|
|
72 /// Required method for Designer support - do not modify
|
|
73 /// the contents of this method with the code editor.
|
|
74 /// </summary>
|
|
75 private void InitializeComponent()
|
|
76 {
|
|
77 this.components = new System.ComponentModel.Container();
|
|
78 this.progressBar = new System.Windows.Forms.ProgressBar();
|
|
79 this.timer = new System.Windows.Forms.Timer(this.components);
|
|
80 this.lblProgress = new System.Windows.Forms.Label();
|
|
81 this.SuspendLayout();
|
|
82 //
|
|
83 // progressBar
|
|
84 //
|
|
85 this.progressBar.Location = new System.Drawing.Point(8, 8);
|
|
86 this.progressBar.Name = "progressBar";
|
|
87 this.progressBar.Size = new System.Drawing.Size(288, 23);
|
|
88 this.progressBar.TabIndex = 0;
|
|
89 //
|
|
90 // timer
|
|
91 //
|
|
92 this.timer.Interval = 40;
|
|
93 this.timer.Tick += new System.EventHandler(this.timer_Tick);
|
|
94 //
|
|
95 // lblProgress
|
|
96 //
|
|
97 this.lblProgress.Location = new System.Drawing.Point(8, 32);
|
|
98 this.lblProgress.Name = "lblProgress";
|
|
99 this.lblProgress.Size = new System.Drawing.Size(288, 23);
|
|
100 this.lblProgress.TabIndex = 1;
|
|
101 this.lblProgress.Text = "Loading Chunky file...";
|
|
102 this.lblProgress.TextAlign = System.Drawing.ContentAlignment.TopRight;
|
|
103 //
|
|
104 // Progress
|
|
105 //
|
|
106 this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
|
|
107 this.ClientSize = new System.Drawing.Size(304, 52);
|
|
108 this.ControlBox = false;
|
|
109 this.Controls.Add(this.lblProgress);
|
|
110 this.Controls.Add(this.progressBar);
|
|
111 this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
|
|
112 this.Name = "Progress";
|
|
113 this.ShowInTaskbar = false;
|
|
114 this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
|
115 this.Text = "Loading Relic Chunky file...";
|
|
116 this.ResumeLayout(false);
|
|
117
|
|
118 }
|
|
119 #endregion
|
|
120
|
|
121 private void timer_Tick(object sender, System.EventArgs e)
|
|
122 {
|
|
123 progressBar.PerformStep();
|
|
124 }
|
|
125
|
|
126 private void nodesCounted(int nodes)
|
|
127 {
|
|
128 lblProgress.Text = "Adding chunks...";
|
|
129 timer.Enabled = false;
|
|
130 progressBar.Step = 1;
|
|
131 progressBar.Value = 1;
|
|
132 progressBar.Minimum = 1;
|
|
133 progressBar.Maximum = nodes;
|
|
134 }
|
|
135
|
|
136 private void nodeAdded(ChunkyChunk chunk)
|
|
137 {
|
|
138 progressBar.PerformStep();
|
|
139 }
|
|
140
|
|
141 private void nodesAdded(bool rendered)
|
|
142 {
|
|
143 progressBar.Value = progressBar.Maximum;
|
|
144
|
|
145 if (rendered)
|
|
146 {
|
|
147 this.Close();
|
|
148 this.Dispose();
|
|
149 }
|
|
150 else
|
|
151 {
|
|
152 lblProgress.Text = "Displaying tree...";
|
|
153 }
|
|
154 }
|
|
155
|
|
156 private void chunkyOpened(string filename)
|
|
157 {
|
|
158 lblProgress.Text = "Counting chunks...";
|
|
159 }
|
|
160
|
|
161 private void openFailed()
|
|
162 {
|
|
163 timer.Enabled = false;
|
|
164 progressBar.Value = progressBar.Maximum;
|
|
165 this.Hide();
|
|
166 this.Close();
|
|
167 try
|
|
168 {
|
|
169 this.Dispose();
|
|
170 }
|
|
171 catch{}
|
|
172 }
|
|
173 }
|
|
174 }
|