Changeset 2916 for trunk/sources/HeuristicLab.Core.Views/3.3
- Timestamp:
- 03/03/10 03:14:37 (14 years ago)
- Location:
- trunk/sources/HeuristicLab.Core.Views/3.3
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Core.Views/3.3/Auxiliary.cs
r2818 r2916 55 55 /// <param name="ex">The exception to format.</param> 56 56 /// <returns>The formated message.</returns> 57 private static string BuildErrorMessage(Exception ex) { 57 public static string BuildErrorMessage(Exception ex) { 58 string nl = Environment.NewLine; 58 59 StringBuilder sb = new StringBuilder(); 59 sb.Append("Sorry, but something went wrong! \n\n" + ex.Message + "\n\n"+ ex.StackTrace);60 sb.Append("Sorry, but something went wrong!" + nl + ex.Message + nl + ex.StackTrace); 60 61 61 62 while (ex.InnerException != null) { 62 63 ex = ex.InnerException; 63 sb.Append( "\n\n-----\n\n" + ex.Message + "\n\n"+ ex.StackTrace);64 sb.Append(nl + "-----" + nl + ex.Message + nl + ex.StackTrace); 64 65 } 65 66 return sb.ToString(); -
trunk/sources/HeuristicLab.Core.Views/3.3/EngineView.Designer.cs
r2834 r2916 33 33 protected override void Dispose(bool disposing) { 34 34 if (disposing) { 35 if (typeSelectorDialog != null) typeSelectorDialog.Dispose();36 35 if (components != null) components.Dispose(); 37 36 } … … 49 48 this.executionTimeTextBox = new System.Windows.Forms.TextBox(); 50 49 this.executionTimeLabel = new System.Windows.Forms.Label(); 51 this.scopeView = new HeuristicLab.Core.Views.ScopeView();52 this.resetButton = new System.Windows.Forms.Button();53 50 this.stopButton = new System.Windows.Forms.Button(); 54 51 this.startButton = new System.Windows.Forms.Button(); 55 52 this.toolTip = new System.Windows.Forms.ToolTip(this.components); 56 this.newOperatorGraphButton = new System.Windows.Forms.Button(); 57 this.openOperatorGraphButton = new System.Windows.Forms.Button(); 58 this.saveOperatorGraphButton = new System.Windows.Forms.Button(); 59 this.tabControl = new System.Windows.Forms.TabControl(); 60 this.operatorGraphTabPage = new System.Windows.Forms.TabPage(); 61 this.operatorGraphViewHost = new HeuristicLab.Core.Views.ViewHost(); 62 this.globalScopeTabPage = new System.Windows.Forms.TabPage(); 63 this.openFileDialog = new System.Windows.Forms.OpenFileDialog(); 64 this.saveFileDialog = new System.Windows.Forms.SaveFileDialog(); 65 this.tabControl.SuspendLayout(); 66 this.operatorGraphTabPage.SuspendLayout(); 67 this.globalScopeTabPage.SuspendLayout(); 53 this.logTextBox = new System.Windows.Forms.TextBox(); 68 54 this.SuspendLayout(); 69 55 // … … 86 72 this.executionTimeLabel.TabIndex = 4; 87 73 this.executionTimeLabel.Text = "&Execution Time:"; 88 //89 // scopeView90 //91 this.scopeView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)92 | System.Windows.Forms.AnchorStyles.Left)93 | System.Windows.Forms.AnchorStyles.Right)));94 this.scopeView.Caption = "Scope";95 this.scopeView.Content = null;96 this.scopeView.Location = new System.Drawing.Point(6, 6);97 this.scopeView.Name = "scopeView";98 this.scopeView.Size = new System.Drawing.Size(782, 572);99 this.scopeView.TabIndex = 0;100 //101 // resetButton102 //103 this.resetButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));104 this.resetButton.Image = HeuristicLab.Common.Resources.VS2008ImageLibrary.Restart;105 this.resetButton.Location = new System.Drawing.Point(60, 616);106 this.resetButton.Name = "resetButton";107 this.resetButton.Size = new System.Drawing.Size(24, 24);108 this.resetButton.TabIndex = 3;109 this.toolTip.SetToolTip(this.resetButton, "Reset Engine");110 this.resetButton.UseVisualStyleBackColor = true;111 this.resetButton.Click += new System.EventHandler(this.resetButton_Click);112 74 // 113 75 // stopButton … … 136 98 this.startButton.Click += new System.EventHandler(this.startButton_Click); 137 99 // 138 // newOperatorGraphButton100 // logTextBox 139 101 // 140 this.newOperatorGraphButton.Image = HeuristicLab.Common.Resources.VS2008ImageLibrary.NewDocument; 141 this.newOperatorGraphButton.Location = new System.Drawing.Point(6, 6); 142 this.newOperatorGraphButton.Name = "newOperatorGraphButton"; 143 this.newOperatorGraphButton.Size = new System.Drawing.Size(24, 24); 144 this.newOperatorGraphButton.TabIndex = 0; 145 this.toolTip.SetToolTip(this.newOperatorGraphButton, "Create New Operator Graph"); 146 this.newOperatorGraphButton.UseVisualStyleBackColor = true; 147 this.newOperatorGraphButton.Click += new System.EventHandler(this.newOperatorGraphButton_Click); 148 // 149 // openOperatorGraphButton 150 // 151 this.openOperatorGraphButton.Image = HeuristicLab.Common.Resources.VS2008ImageLibrary.Open; 152 this.openOperatorGraphButton.Location = new System.Drawing.Point(36, 6); 153 this.openOperatorGraphButton.Name = "openOperatorGraphButton"; 154 this.openOperatorGraphButton.Size = new System.Drawing.Size(24, 24); 155 this.openOperatorGraphButton.TabIndex = 1; 156 this.toolTip.SetToolTip(this.openOperatorGraphButton, "Open Operator Graph"); 157 this.openOperatorGraphButton.UseVisualStyleBackColor = true; 158 this.openOperatorGraphButton.Click += new System.EventHandler(this.openOperatorGraphButton_Click); 159 // 160 // saveOperatorGraphButton 161 // 162 this.saveOperatorGraphButton.Image = HeuristicLab.Common.Resources.VS2008ImageLibrary.Save; 163 this.saveOperatorGraphButton.Location = new System.Drawing.Point(66, 6); 164 this.saveOperatorGraphButton.Name = "saveOperatorGraphButton"; 165 this.saveOperatorGraphButton.Size = new System.Drawing.Size(24, 24); 166 this.saveOperatorGraphButton.TabIndex = 2; 167 this.toolTip.SetToolTip(this.saveOperatorGraphButton, "Save Operator Graph"); 168 this.saveOperatorGraphButton.UseVisualStyleBackColor = true; 169 this.saveOperatorGraphButton.Click += new System.EventHandler(this.saveOperatorGraphButton_Click); 170 // 171 // tabControl 172 // 173 this.tabControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 102 this.logTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 174 103 | System.Windows.Forms.AnchorStyles.Left) 175 104 | System.Windows.Forms.AnchorStyles.Right))); 176 this.tabControl.Controls.Add(this.operatorGraphTabPage); 177 this.tabControl.Controls.Add(this.globalScopeTabPage); 178 this.tabControl.Location = new System.Drawing.Point(0, 0); 179 this.tabControl.Name = "tabControl"; 180 this.tabControl.SelectedIndex = 0; 181 this.tabControl.Size = new System.Drawing.Size(802, 610); 182 this.tabControl.TabIndex = 3; 183 // 184 // operatorGraphTabPage 185 // 186 this.operatorGraphTabPage.Controls.Add(this.operatorGraphViewHost); 187 this.operatorGraphTabPage.Controls.Add(this.saveOperatorGraphButton); 188 this.operatorGraphTabPage.Controls.Add(this.openOperatorGraphButton); 189 this.operatorGraphTabPage.Controls.Add(this.newOperatorGraphButton); 190 this.operatorGraphTabPage.Location = new System.Drawing.Point(4, 22); 191 this.operatorGraphTabPage.Name = "operatorGraphTabPage"; 192 this.operatorGraphTabPage.Padding = new System.Windows.Forms.Padding(3); 193 this.operatorGraphTabPage.Size = new System.Drawing.Size(794, 584); 194 this.operatorGraphTabPage.TabIndex = 0; 195 this.operatorGraphTabPage.Text = "Operator Graph"; 196 this.operatorGraphTabPage.UseVisualStyleBackColor = true; 197 // 198 // operatorGraphViewHost 199 // 200 this.operatorGraphViewHost.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 201 | System.Windows.Forms.AnchorStyles.Left) 202 | System.Windows.Forms.AnchorStyles.Right))); 203 this.operatorGraphViewHost.Content = null; 204 this.operatorGraphViewHost.Location = new System.Drawing.Point(6, 36); 205 this.operatorGraphViewHost.Name = "operatorGraphViewHost"; 206 this.operatorGraphViewHost.Size = new System.Drawing.Size(782, 542); 207 this.operatorGraphViewHost.TabIndex = 3; 208 this.operatorGraphViewHost.ViewType = null; 209 // 210 // globalScopeTabPage 211 // 212 this.globalScopeTabPage.Controls.Add(this.scopeView); 213 this.globalScopeTabPage.Location = new System.Drawing.Point(4, 22); 214 this.globalScopeTabPage.Name = "globalScopeTabPage"; 215 this.globalScopeTabPage.Padding = new System.Windows.Forms.Padding(3); 216 this.globalScopeTabPage.Size = new System.Drawing.Size(794, 584); 217 this.globalScopeTabPage.TabIndex = 1; 218 this.globalScopeTabPage.Text = "Global Scope"; 219 this.globalScopeTabPage.UseVisualStyleBackColor = true; 220 // 221 // openFileDialog 222 // 223 this.openFileDialog.DefaultExt = "hl"; 224 this.openFileDialog.FileName = "Item"; 225 this.openFileDialog.Filter = "HeuristicLab Files|*.hl|All Files|*.*"; 226 this.openFileDialog.Title = "Open File"; 227 // 228 // saveFileDialog 229 // 230 this.saveFileDialog.DefaultExt = "hl"; 231 this.saveFileDialog.FileName = "Item"; 232 this.saveFileDialog.Filter = "Uncompressed HeuristicLab Files|*.hl|HeuristicLab Files|*.hl|All Files|*.*"; 233 this.saveFileDialog.FilterIndex = 2; 234 this.saveFileDialog.Title = "Save File"; 105 this.logTextBox.Location = new System.Drawing.Point(0, 0); 106 this.logTextBox.Multiline = true; 107 this.logTextBox.Name = "logTextBox"; 108 this.logTextBox.ReadOnly = true; 109 this.logTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Both; 110 this.logTextBox.Size = new System.Drawing.Size(802, 610); 111 this.logTextBox.TabIndex = 6; 112 this.logTextBox.WordWrap = false; 235 113 // 236 114 // EngineView … … 238 116 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 239 117 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 240 this.Controls.Add(this. tabControl);118 this.Controls.Add(this.logTextBox); 241 119 this.Controls.Add(this.executionTimeTextBox); 242 120 this.Controls.Add(this.stopButton); 243 121 this.Controls.Add(this.executionTimeLabel); 244 this.Controls.Add(this.resetButton);245 122 this.Controls.Add(this.startButton); 246 123 this.Name = "EngineView"; 247 124 this.Size = new System.Drawing.Size(802, 640); 248 this.tabControl.ResumeLayout(false);249 this.operatorGraphTabPage.ResumeLayout(false);250 this.globalScopeTabPage.ResumeLayout(false);251 125 this.ResumeLayout(false); 252 126 this.PerformLayout(); … … 258 132 protected System.Windows.Forms.TextBox executionTimeTextBox; 259 133 protected System.Windows.Forms.Label executionTimeLabel; 260 protected System.Windows.Forms.Button resetButton;261 134 protected System.Windows.Forms.Button stopButton; 262 135 protected System.Windows.Forms.Button startButton; 263 protected HeuristicLab.Core.Views.ScopeView scopeView;264 136 protected System.Windows.Forms.ToolTip toolTip; 265 protected System.Windows.Forms.TabControl tabControl; 266 protected System.Windows.Forms.TabPage globalScopeTabPage; 267 protected System.Windows.Forms.OpenFileDialog openFileDialog; 268 protected System.Windows.Forms.SaveFileDialog saveFileDialog; 269 protected System.Windows.Forms.TabPage operatorGraphTabPage; 270 protected System.Windows.Forms.Button saveOperatorGraphButton; 271 protected System.Windows.Forms.Button openOperatorGraphButton; 272 protected System.Windows.Forms.Button newOperatorGraphButton; 273 protected ViewHost operatorGraphViewHost; 137 protected System.Windows.Forms.TextBox logTextBox; 274 138 275 139 } -
trunk/sources/HeuristicLab.Core.Views/3.3/EngineView.cs
r2834 r2916 21 21 22 22 using System; 23 using System.Windows.Forms;24 23 using HeuristicLab.Common; 25 24 using HeuristicLab.MainForm; 26 using HeuristicLab.Persistence.Default.Xml;27 25 28 26 namespace HeuristicLab.Core.Views { … … 33 31 [Content(typeof(IEngine), false)] 34 32 public partial class EngineView : ItemView { 35 protected TypeSelectorDialog typeSelectorDialog;36 33 private int executionTimeCounter; 37 34 … … 61 58 /// <remarks>Calls <see cref="ViewBase.RemoveItemEvents"/> of base class <see cref="ViewBase"/>.</remarks> 62 59 protected override void DeregisterContentEvents() { 63 Content.OperatorGraphChanged -= new EventHandler(Content_OperatorGraphChanged);64 60 Content.Prepared -= new EventHandler(Content_Prepared); 65 61 Content.Started -= new EventHandler(Content_Started); … … 76 72 protected override void RegisterContentEvents() { 77 73 base.RegisterContentEvents(); 78 Content.OperatorGraphChanged += new EventHandler(Content_OperatorGraphChanged);79 74 Content.Prepared += new EventHandler(Content_Prepared); 80 75 Content.Started += new EventHandler(Content_Started); … … 91 86 base.OnContentChanged(); 92 87 stopButton.Enabled = false; 88 logTextBox.Clear(); 93 89 if (Content == null) { 94 newOperatorGraphButton.Enabled = openOperatorGraphButton.Enabled = saveOperatorGraphButton.Enabled = false; 95 operatorGraphViewHost.Enabled = false; 96 scopeView.Enabled = false; 97 startButton.Enabled = resetButton.Enabled = false; 90 logTextBox.Enabled = false; 91 startButton.Enabled = false; 98 92 executionTimeTextBox.Enabled = false; 99 93 } else { 100 newOperatorGraphButton.Enabled = openOperatorGraphButton.Enabled = saveOperatorGraphButton.Enabled = true; 101 operatorGraphViewHost.Content = Content.OperatorGraph; 102 operatorGraphViewHost.Enabled = true; 103 scopeView.Content = Content.GlobalScope; 104 scopeView.Enabled = true; 94 logTextBox.Enabled = true; 105 95 startButton.Enabled = !Content.Finished; 106 resetButton.Enabled = true;107 96 UpdateExecutionTimeTextBox(); 108 97 executionTimeTextBox.Enabled = true; … … 111 100 112 101 #region Content Events 113 protected virtual void Content_OperatorGraphChanged(object sender, EventArgs e) {114 if (InvokeRequired)115 Invoke(new EventHandler(Content_OperatorGraphChanged), sender, e);116 else117 operatorGraphViewHost.Content = Content.OperatorGraph;118 }119 102 protected virtual void Content_Prepared(object sender, EventArgs e) { 120 103 if (InvokeRequired) 121 104 Invoke(new EventHandler(Content_Prepared), sender, e); 122 105 else { 123 newOperatorGraphButton.Enabled = openOperatorGraphButton.Enabled = saveOperatorGraphButton.Enabled = true;124 operatorGraphViewHost.Enabled = true;125 scopeView.Enabled = true;126 106 startButton.Enabled = !Content.Finished; 127 107 stopButton.Enabled = false; 128 resetButton.Enabled = true;129 108 UpdateExecutionTimeTextBox(); 109 logTextBox.Clear(); 110 Log("Engine prepared"); 130 111 } 131 112 } … … 135 116 Invoke(new EventHandler(Content_Started), sender, e); 136 117 else { 137 newOperatorGraphButton.Enabled = openOperatorGraphButton.Enabled = saveOperatorGraphButton.Enabled = false;138 operatorGraphViewHost.Enabled = false;139 scopeView.Enabled = false;140 118 startButton.Enabled = false; 141 119 stopButton.Enabled = true; 142 resetButton.Enabled = false;143 120 UpdateExecutionTimeTextBox(); 121 Log("Engine started"); 144 122 } 145 123 } … … 148 126 Invoke(new EventHandler(Content_Stopped), sender, e); 149 127 else { 150 newOperatorGraphButton.Enabled = openOperatorGraphButton.Enabled = saveOperatorGraphButton.Enabled = true;151 operatorGraphViewHost.Enabled = true;152 scopeView.Enabled = true;153 128 startButton.Enabled = !Content.Finished; 154 129 stopButton.Enabled = false; 155 resetButton.Enabled = true;156 130 UpdateExecutionTimeTextBox(); 131 if (Content.Finished) Log("Engine finished"); 132 else Log("Engine stopped"); 157 133 } 158 134 } … … 168 144 Invoke(new EventHandler<EventArgs<Exception>>(Content_ExceptionOccurred), sender, e); 169 145 else 170 Auxiliary.ShowErrorMessageBox(e.Value);146 Log(Auxiliary.BuildErrorMessage(e.Value)); 171 147 } 172 148 #endregion 173 149 174 150 #region Button events 175 protected void newOperatorGraphButton_Click(object sender, EventArgs e) {176 Content.OperatorGraph = new OperatorGraph();177 }178 protected void openOperatorGraphButton_Click(object sender, EventArgs e) {179 openFileDialog.Title = "Open Operator Graph";180 if (openFileDialog.ShowDialog(this) == DialogResult.OK) {181 OperatorGraph operatorGraph = null;182 try {183 operatorGraph = XmlParser.Deserialize(openFileDialog.FileName) as OperatorGraph;184 }185 catch (Exception ex) {186 Auxiliary.ShowErrorMessageBox(ex);187 }188 if (operatorGraph == null)189 MessageBox.Show(this, "Selected file does not contain an operator graph.", "Invalid File", MessageBoxButtons.OK, MessageBoxIcon.Error);190 else191 Content.OperatorGraph = operatorGraph;192 }193 }194 protected void saveOperatorGraphButton_Click(object sender, EventArgs e) {195 saveFileDialog.Title = "Save Operator Graph";196 if (saveFileDialog.ShowDialog(this) == DialogResult.OK) {197 try {198 if (saveFileDialog.FilterIndex == 1)199 XmlGenerator.Serialize(Content.OperatorGraph, saveFileDialog.FileName, 0);200 else201 XmlGenerator.Serialize(Content.OperatorGraph, saveFileDialog.FileName, 9);202 }203 catch (Exception ex) {204 Auxiliary.ShowErrorMessageBox(ex);205 }206 }207 }208 151 protected virtual void startButton_Click(object sender, EventArgs e) { 209 152 Content.Start(); … … 211 154 protected virtual void stopButton_Click(object sender, EventArgs e) { 212 155 Content.Stop(); 213 }214 protected virtual void resetButton_Click(object sender, EventArgs e) {215 Content.Prepare();216 156 } 217 157 #endregion … … 224 164 executionTimeTextBox.Text = Content.ExecutionTime.ToString(); 225 165 } 166 protected virtual void Log(string message) { 167 if (InvokeRequired) 168 Invoke(new Action<string>(Log), message); 169 else { 170 message = DateTime.Now.ToString() + "\t" + message; 171 string[] newLines = message.Split(new string[] { Environment.NewLine }, StringSplitOptions.None); 172 string[] lines = new string[logTextBox.Lines.Length + newLines.Length]; 173 logTextBox.Lines.CopyTo(lines, 0); 174 newLines.CopyTo(lines, logTextBox.Lines.Length); 175 logTextBox.Lines = lines; 176 } 177 } 226 178 #endregion 227 179 } -
trunk/sources/HeuristicLab.Core.Views/3.3/NamedItemView.cs
r2870 r2916 92 92 93 93 protected virtual void nameTextBox_Validating(object sender, CancelEventArgs e) { 94 if ( Content.CanChangeName) {94 if ((Content != null) && (Content.CanChangeName)) { 95 95 Content.Name = nameTextBox.Text; 96 96 -
trunk/sources/HeuristicLab.Core.Views/3.3/ViewHost.Designer.cs
r2841 r2916 82 82 this.viewsLabel.Size = new System.Drawing.Size(16, 16); 83 83 this.viewsLabel.TabIndex = 0; 84 this.toolTip.SetToolTip(this.viewsLabel, "Double-click to open a new window of the current view. \r\nRight-click to change current view.");84 this.toolTip.SetToolTip(this.viewsLabel, "Double-click to open a new window of the current view." + System.Environment.NewLine + "Right-click to change current view."); 85 85 this.viewsLabel.DoubleClick += new System.EventHandler(this.viewsLabel_DoubleClick); 86 86 //
Note: See TracChangeset
for help on using the changeset viewer.