Changeset 10358 for branches/HLScript/HeuristicLab.HLScript.Views
- Timestamp:
- 01/20/14 17:33:22 (10 years ago)
- Location:
- branches/HLScript
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HLScript
- Property svn:mergeinfo changed
/trunk/sources (added) merged: 10346,10348,10355
- Property svn:mergeinfo changed
-
branches/HLScript/HeuristicLab.HLScript.Views/3.3/HLScriptView.Designer.cs
r10332 r10358 45 45 /// </summary> 46 46 private void InitializeComponent() { 47 this.components = new System.ComponentModel.Container();48 47 this.compilationLabel = new System.Windows.Forms.Label(); 49 48 this.showCodeButton = new System.Windows.Forms.Button(); 50 49 this.startStopButton = new System.Windows.Forms.Button(); 51 this.toolTip = new System.Windows.Forms.ToolTip(this.components);52 50 this.errorListView = new System.Windows.Forms.ListView(); 53 51 this.categoryColumnHeader = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); … … 63 61 this.outputTabPage = new System.Windows.Forms.TabPage(); 64 62 this.outputTextBox = new System.Windows.Forms.TextBox(); 63 this.viewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost(); 65 64 this.variableStoreView = new HeuristicLab.HLScript.Views.VariableStoreView(); 66 this.viewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();65 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit(); 67 66 ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); 68 67 this.splitContainer1.Panel1.SuspendLayout(); … … 78 77 this.SuspendLayout(); 79 78 // 79 // nameTextBox 80 // 81 this.errorProvider.SetIconAlignment(this.nameTextBox, System.Windows.Forms.ErrorIconAlignment.MiddleLeft); 82 this.errorProvider.SetIconPadding(this.nameTextBox, 2); 83 this.nameTextBox.Location = new System.Drawing.Point(60, 0); 84 this.nameTextBox.Size = new System.Drawing.Size(750, 20); 85 // 86 // infoLabel 87 // 88 this.infoLabel.Location = new System.Drawing.Point(816, 4); 89 // 80 90 // compilationLabel 81 91 // 82 92 this.compilationLabel.AutoSize = true; 83 93 this.compilationLabel.ForeColor = System.Drawing.SystemColors.ControlDarkDark; 84 this.compilationLabel.Location = new System.Drawing.Point(63, 9);94 this.compilationLabel.Location = new System.Drawing.Point(63, 32); 85 95 this.compilationLabel.Name = "compilationLabel"; 86 96 this.compilationLabel.Size = new System.Drawing.Size(69, 13); … … 91 101 // 92 102 this.showCodeButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.PrintPreview; 93 this.showCodeButton.Location = new System.Drawing.Point(33, 3);103 this.showCodeButton.Location = new System.Drawing.Point(33, 26); 94 104 this.showCodeButton.Name = "showCodeButton"; 95 105 this.showCodeButton.Size = new System.Drawing.Size(24, 24); … … 103 113 // 104 114 this.startStopButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Play; 105 this.startStopButton.Location = new System.Drawing.Point(3, 3);115 this.startStopButton.Location = new System.Drawing.Point(3, 26); 106 116 this.startStopButton.Name = "startStopButton"; 107 117 this.startStopButton.Size = new System.Drawing.Size(24, 24); … … 126 136 this.errorListView.Location = new System.Drawing.Point(3, 3); 127 137 this.errorListView.Name = "errorListView"; 128 this.errorListView.Size = new System.Drawing.Size(623, 83);138 this.errorListView.Size = new System.Drawing.Size(623, 79); 129 139 this.errorListView.TabIndex = 0; 130 140 this.errorListView.UseCompatibleStateImageBehavior = false; … … 161 171 this.codeEditor.Name = "codeEditor"; 162 172 this.codeEditor.Prefix = ""; 163 this.codeEditor.Size = new System.Drawing.Size(637, 4 47);173 this.codeEditor.Size = new System.Drawing.Size(637, 428); 164 174 this.codeEditor.Suffix = ""; 165 175 this.codeEditor.TabIndex = 0; … … 169 179 // splitContainer1 170 180 // 171 this.splitContainer1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 172 | System.Windows.Forms.AnchorStyles.Left) 181 this.splitContainer1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 182 | System.Windows.Forms.AnchorStyles.Left) 173 183 | System.Windows.Forms.AnchorStyles.Right))); 174 this.splitContainer1.Location = new System.Drawing.Point(3, 33);184 this.splitContainer1.Location = new System.Drawing.Point(3, 56); 175 185 this.splitContainer1.Name = "splitContainer1"; 176 186 // … … 183 193 this.splitContainer1.Panel2.Controls.Add(this.variableStoreView); 184 194 this.splitContainer1.Panel2.Controls.Add(this.viewHost); 185 this.splitContainer1.Size = new System.Drawing.Size(829, 5 66);195 this.splitContainer1.Size = new System.Drawing.Size(829, 543); 186 196 this.splitContainer1.SplitterDistance = 637; 187 197 this.splitContainer1.TabIndex = 7; … … 201 211 // 202 212 this.splitContainer2.Panel2.Controls.Add(this.tabControl1); 203 this.splitContainer2.Size = new System.Drawing.Size(637, 5 66);204 this.splitContainer2.SplitterDistance = 4 47;213 this.splitContainer2.Size = new System.Drawing.Size(637, 543); 214 this.splitContainer2.SplitterDistance = 428; 205 215 this.splitContainer2.TabIndex = 5; 206 216 // … … 213 223 this.tabControl1.Name = "tabControl1"; 214 224 this.tabControl1.SelectedIndex = 0; 215 this.tabControl1.Size = new System.Drawing.Size(637, 11 5);225 this.tabControl1.Size = new System.Drawing.Size(637, 111); 216 226 this.tabControl1.TabIndex = 1; 217 227 // … … 222 232 this.errorListTabPage.Name = "errorListTabPage"; 223 233 this.errorListTabPage.Padding = new System.Windows.Forms.Padding(3); 224 this.errorListTabPage.Size = new System.Drawing.Size(629, 8 9);234 this.errorListTabPage.Size = new System.Drawing.Size(629, 85); 225 235 this.errorListTabPage.TabIndex = 0; 226 236 this.errorListTabPage.Text = "Error List"; … … 233 243 this.outputTabPage.Name = "outputTabPage"; 234 244 this.outputTabPage.Padding = new System.Windows.Forms.Padding(3); 235 this.outputTabPage.Size = new System.Drawing.Size(629, 8 9);245 this.outputTabPage.Size = new System.Drawing.Size(629, 85); 236 246 this.outputTabPage.TabIndex = 1; 237 247 this.outputTabPage.Text = "Output"; … … 247 257 this.outputTextBox.ReadOnly = true; 248 258 this.outputTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Both; 249 this.outputTextBox.Size = new System.Drawing.Size(623, 83);259 this.outputTextBox.Size = new System.Drawing.Size(623, 79); 250 260 this.outputTextBox.TabIndex = 0; 251 261 this.outputTextBox.WordWrap = false; 252 //253 // variableStoreView254 //255 this.variableStoreView.Caption = "ItemCollection View";256 this.variableStoreView.Content = null;257 this.variableStoreView.Dock = System.Windows.Forms.DockStyle.Fill;258 this.variableStoreView.Location = new System.Drawing.Point(0, 0);259 this.variableStoreView.Name = "variableStoreView";260 this.variableStoreView.ReadOnly = false;261 this.variableStoreView.Size = new System.Drawing.Size(188, 566);262 this.variableStoreView.TabIndex = 0;263 262 // 264 263 // viewHost … … 271 270 this.viewHost.Name = "viewHost"; 272 271 this.viewHost.ReadOnly = false; 273 this.viewHost.Size = new System.Drawing.Size(188, 5 66);272 this.viewHost.Size = new System.Drawing.Size(188, 543); 274 273 this.viewHost.TabIndex = 0; 275 274 this.viewHost.ViewsLabelVisible = true; 276 275 this.viewHost.ViewType = null; 276 // 277 // variableStoreView 278 // 279 this.variableStoreView.Caption = "ItemCollection View"; 280 this.variableStoreView.Content = null; 281 this.variableStoreView.Dock = System.Windows.Forms.DockStyle.Fill; 282 this.variableStoreView.Location = new System.Drawing.Point(0, 0); 283 this.variableStoreView.Name = "variableStoreView"; 284 this.variableStoreView.ReadOnly = false; 285 this.variableStoreView.Size = new System.Drawing.Size(188, 543); 286 this.variableStoreView.TabIndex = 0; 277 287 // 278 288 // HLScriptView … … 285 295 this.Name = "HLScriptView"; 286 296 this.Size = new System.Drawing.Size(835, 602); 297 this.Controls.SetChildIndex(this.showCodeButton, 0); 298 this.Controls.SetChildIndex(this.compilationLabel, 0); 299 this.Controls.SetChildIndex(this.startStopButton, 0); 300 this.Controls.SetChildIndex(this.splitContainer1, 0); 301 this.Controls.SetChildIndex(this.nameLabel, 0); 302 this.Controls.SetChildIndex(this.nameTextBox, 0); 303 this.Controls.SetChildIndex(this.infoLabel, 0); 304 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit(); 287 305 this.splitContainer1.Panel1.ResumeLayout(false); 288 306 this.splitContainer1.Panel2.ResumeLayout(false); … … 307 325 private System.Windows.Forms.Label compilationLabel; 308 326 private System.Windows.Forms.Button startStopButton; 309 private System.Windows.Forms.ToolTip toolTip;310 327 private System.Windows.Forms.ListView errorListView; 311 328 private System.Windows.Forms.ColumnHeader descriptionColumnHeader; -
branches/HLScript/HeuristicLab.HLScript.Views/3.3/HLScriptView.cs
r10332 r10358 36 36 [View("HLScript View")] 37 37 [Content(typeof(HLScript), true)] 38 public partial class HLScriptView : ItemView {38 public partial class HLScriptView : NamedItemView { 39 39 private bool running; 40 40 … … 69 69 } 70 70 private void Content_ScriptExecutionStarted(object sender, EventArgs e) { 71 ReadOnly= true;71 Locked = true; 72 72 startStopButton.Image = VSImageLibrary.Stop; 73 73 } 74 74 private void Content_ScriptExecutionFinished(object sender, EventArgs e) { 75 ReadOnly= false;75 Locked = false; 76 76 startStopButton.Image = VSImageLibrary.Play; 77 77 running = false; … … 92 92 } else { 93 93 codeEditor.UserCode = Content.Code; 94 foreach (var asm in Content.GetAssemblies()) 95 codeEditor.AddAssembly(asm); 94 96 variableStoreView.Content = Content.VariableStore; 95 97 if (Content.CompileErrors == null) { … … 108 110 protected override void SetEnabledStateOfControls() { 109 111 base.SetEnabledStateOfControls(); 110 startStopButton.Enabled = Content != null ;112 startStopButton.Enabled = Content != null && !Locked; 111 113 showCodeButton.Enabled = Content != null && !string.IsNullOrEmpty(Content.CompilationUnitCode); 112 codeEditor.Enabled = Content != null && ! ReadOnly;114 codeEditor.Enabled = Content != null && !Locked && !ReadOnly; 113 115 } 114 116 … … 137 139 protected override bool ProcessCmdKey(ref Message msg, Keys keyData) { 138 140 if (keyData == Keys.F5) { 139 if (Content == null || ReadOnly)141 if (Content == null || Locked) 140 142 return base.ProcessCmdKey(ref msg, keyData); 141 143 outputTextBox.Clear(); … … 144 146 outputTextBox.Clear(); 145 147 Content.Execute(); 148 running = true; 146 149 } 147 150 return true; … … 156 159 private bool Compile() { 157 160 ReadOnly = true; 161 Locked = true; 158 162 errorListView.Items.Clear(); 159 163 outputTextBox.Clear(); … … 170 174 OnContentChanged(); 171 175 ReadOnly = false; 176 Locked = false; 172 177 } 173 178 } -
branches/HLScript/HeuristicLab.HLScript.Views/3.3/HeuristicLab.HLScript.Views-3.3.csproj
r10332 r10358 115 115 <Private>False</Private> 116 116 </ProjectReference> 117 <ProjectReference Include="..\..\HeuristicLab.Persistence\3.3\HeuristicLab.Persistence-3.3.csproj"> 118 <Project>{102BC7D3-0EF9-439C-8F6D-96FF0FDB8E1B}</Project> 119 <Name>HeuristicLab.Persistence-3.3</Name> 120 <Private>False</Private> 121 </ProjectReference> 117 122 <ProjectReference Include="..\..\HeuristicLab.PluginInfrastructure\3.3\HeuristicLab.PluginInfrastructure-3.3.csproj"> 118 123 <Project>{94186a6a-5176-4402-ae83-886557b53cca}</Project> -
branches/HLScript/HeuristicLab.HLScript.Views/3.3/Plugin.cs.frame
r10332 r10358 34 34 [PluginDependency("HeuristicLab.MainForm", "3.3")] 35 35 [PluginDependency("HeuristicLab.MainForm.WindowsForms", "3.3")] 36 [PluginDependency("HeuristicLab.Persistence", "3.3")] 36 37 public class HeuristicLabHLScriptViewsPlugin : PluginBase { 37 38 } -
branches/HLScript/HeuristicLab.HLScript.Views/3.3/VariableStoreView.Designer.cs
r10332 r10358 61 61 this.valueColumnHeader, 62 62 this.typeColumnHeader}); 63 this.variableListView.FullRowSelect = true; 63 64 this.variableListView.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; 64 65 this.variableListView.HideSelection = false; -
branches/HLScript/HeuristicLab.HLScript.Views/3.3/VariableStoreView.cs
r10332 r10358 23 23 using System.Collections; 24 24 using System.Collections.Generic; 25 using System.Drawing; 25 26 using System.Linq; 26 27 using System.Windows.Forms; … … 31 32 using HeuristicLab.MainForm; 32 33 using HeuristicLab.MainForm.WindowsForms; 34 using HeuristicLab.Persistence.Core; 35 using HeuristicLab.Persistence.Default.Xml; 33 36 using HeuristicLab.PluginInfrastructure; 34 37 … … 53 56 InitializeComponent(); 54 57 itemListViewItemMapping = new Dictionary<string, ListViewItem>(); 58 variableListView.SmallImageList.Images.AddRange(new Image[] { 59 HeuristicLab.Common.Resources.VSImageLibrary.Error, 60 HeuristicLab.Common.Resources.VSImageLibrary.Object, 61 HeuristicLab.Common.Resources.VSImageLibrary.Nothing 62 }); 55 63 } 56 64 … … 101 109 variableListView.Enabled = false; 102 110 } else { 103 addButton.Enabled = /*!Content.IsReadOnly &&*/!ReadOnly;111 addButton.Enabled = !Locked && !ReadOnly; 104 112 sortAscendingButton.Enabled = variableListView.Items.Count > 1; 105 113 sortDescendingButton.Enabled = variableListView.Items.Count > 1; 106 removeButton.Enabled = /*!Content.IsReadOnly &&*/!ReadOnly && variableListView.SelectedItems.Count > 0;114 removeButton.Enabled = !Locked && !ReadOnly && variableListView.SelectedItems.Count > 0; 107 115 variableListView.Enabled = true; 108 116 } … … 130 138 string value = (variable.Value ?? "null").ToString(); 131 139 string type = variable.Value == null ? "null" : variable.Value.GetType().ToString(); 132 var listViewItem = new ListViewItem(new[] { variable.Key, value, type }) { ToolTipText = GetToolTipText(variable), Tag = variable }; 133 variableListView.SmallImageList.Images.Add(HeuristicLab.Common.Resources.VSImageLibrary.Object); 134 listViewItem.ImageIndex = variableListView.SmallImageList.Images.Count - 1; 140 bool serializable = IsSerializable(variable); 141 var listViewItem = new ListViewItem(new[] { variable.Key, value, type }) { ToolTipText = GetToolTipText(variable, serializable), Tag = variable }; 142 if (serializable) { 143 listViewItem.ImageIndex = variable.Value == null ? 2 : 1; 144 } else listViewItem.ImageIndex = 0; 135 145 variableListView.Items.Add(listViewItem); 136 146 itemListViewItemMapping[variable.Key] = listViewItem; … … 160 170 string value = (variable.Value ?? "null").ToString(); 161 171 string type = variable.Value == null ? "null" : variable.Value.GetType().ToString(); 172 bool serializable = IsSerializable(variable); 173 if (serializable) { 174 listViewItem.ImageIndex = variable.Value == null ? 2 : 1; 175 } else listViewItem.ImageIndex = 0; 162 176 listViewItem.SubItems[1].Text = value; 163 177 listViewItem.SubItems[2].Text = type; 164 listViewItem.ToolTipText = GetToolTipText(variable );178 listViewItem.ToolTipText = GetToolTipText(variable, serializable); 165 179 listViewItem.Tag = variable; 166 180 } else throw new ArgumentException("A variable with the specified name does not exist.", "variable"); … … 169 183 #region ListView Events 170 184 protected virtual void variableListView_SelectedIndexChanged(object sender, EventArgs e) { 171 removeButton.Enabled = (Content != null) /*&& !Content.IsReadOnly*/&& !ReadOnly && variableListView.SelectedItems.Count > 0;185 removeButton.Enabled = (Content != null) && !Locked && !ReadOnly && variableListView.SelectedItems.Count > 0; 172 186 AdjustListViewColumnSizes(); 173 187 } 174 188 protected virtual void variableListView_KeyDown(object sender, KeyEventArgs e) { 175 189 if (e.KeyCode == Keys.Delete) { 176 if ((variableListView.SelectedItems.Count > 0) /*&& !Content.IsReadOnly*/&& !ReadOnly) {190 if ((variableListView.SelectedItems.Count > 0) && !Locked && !ReadOnly) { 177 191 foreach (ListViewItem item in variableListView.SelectedItems) 178 192 Content.Remove(item.Text); … … 207 221 if (items.Count == 1) data.SetData(HeuristicLab.Common.Constants.DragDropDataFormat, items[0]); 208 222 else data.SetData(HeuristicLab.Common.Constants.DragDropDataFormat, items); 209 if ( /*Content.IsReadOnly ||*/ReadOnly) {223 if (ReadOnly) { 210 224 DoDragDrop(data, DragDropEffects.Copy | DragDropEffects.Link); 211 225 } else { … … 220 234 protected virtual void variableListView_DragEnter(object sender, DragEventArgs e) { 221 235 validDragOperation = false; 222 if ( /*!Content.IsReadOnly &&*/!ReadOnly && (e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat) is object)) {236 if (!Locked && !ReadOnly && (e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat) is object)) { 223 237 validDragOperation = true; 224 } else if ( /*!Content.IsReadOnly &&*/!ReadOnly && (e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat) is IEnumerable)) {238 } else if (!Locked && !ReadOnly && (e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat) is IEnumerable)) { 225 239 validDragOperation = true; 226 240 IEnumerable items = (IEnumerable)e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat); … … 361 375 item.SubItems[1].Text = value; 362 376 item.SubItems[2].Text = variable.Value.Value.GetType().ToString(); 363 item.ToolTipText = GetToolTipText(variable.Value );377 item.ToolTipText = GetToolTipText(variable.Value, item.ImageIndex == 0); 364 378 return; 365 379 } … … 382 396 protected virtual void RebuildImageList() { 383 397 variableListView.SmallImageList.Images.Clear(); 398 variableListView.SmallImageList.Images.AddRange(new Image[] { 399 HeuristicLab.Common.Resources.VSImageLibrary.Error, 400 HeuristicLab.Common.Resources.VSImageLibrary.Object, 401 HeuristicLab.Common.Resources.VSImageLibrary.Nothing 402 }); 384 403 foreach (ListViewItem listViewItem in variableListView.Items) { 385 object item = listViewItem.Tag as object; 386 variableListView.SmallImageList.Images.Add(item == null ? HeuristicLab.Common.Resources.VSImageLibrary.Nothing : HeuristicLab.Common.Resources.VSImageLibrary.Object);//item.ItemImage); 387 listViewItem.ImageIndex = variableListView.SmallImageList.Images.Count - 1; 388 } 389 } 390 391 private string GetToolTipText(KeyValuePair<string, object> variable) { 404 var variable = (KeyValuePair<string, object>)listViewItem.Tag; 405 bool serializable = IsSerializable(variable); 406 if (serializable) { 407 listViewItem.ImageIndex = variable.Value == null ? 2 : 1; 408 } else listViewItem.ImageIndex = 0; 409 } 410 } 411 412 private string GetToolTipText(KeyValuePair<string, object> variable, bool serializable) { 392 413 if (string.IsNullOrEmpty(variable.Key)) throw new ArgumentException("The variable must have a name.", "variable"); 393 414 string value = (variable.Value ?? "null").ToString(); 415 string type = variable.Value == null ? "null" : variable.Value.GetType().ToString(); 394 416 string[] lines = { 395 417 "Name: " + variable.Key, 396 418 "Value: " + value, 397 "Type: " + variable.Value.GetType()419 "Type: " + type 398 420 }; 399 return string.Join(Environment.NewLine, lines); 421 string toolTipText = string.Join(Environment.NewLine, lines); 422 if (!serializable) 423 toolTipText += Environment.NewLine + "CAUTION: Type is not serializable!"; 424 return toolTipText; 400 425 } 401 426 … … 411 436 return defaultName; 412 437 } 438 439 private bool IsSerializable(KeyValuePair<string, object> variable) { 440 var ser = new Serializer(variable, ConfigurationService.Instance.GetDefaultConfig(new XmlFormat()), "ROOT", true); 441 try { 442 return ser.Count() > 0; 443 } catch (PersistenceException) { 444 return false; 445 } 446 } 413 447 #endregion 414 448 }
Note: See TracChangeset
for help on using the changeset viewer.