Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/26/14 16:38:08 (11 years ago)
Author:
abeham
Message:

#2136: merged r10359, r10391, r10401, r10506 to stable

Location:
stable
Files:
3 edited
1 copied

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.HLScript.Views/3.3

    • Property svn:global-ignores set to
      bin
      obj
      Plugin.cs
  • stable/HeuristicLab.HLScript.Views/3.3/VariableStoreView.cs

    r10358 r10891  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2525using System.Drawing;
    2626using System.Linq;
     27using System.Text.RegularExpressions;
    2728using System.Windows.Forms;
    2829using HeuristicLab.Collections;
     
    3637using HeuristicLab.PluginInfrastructure;
    3738
    38 namespace HeuristicLab.HLScript.Views {
     39namespace HeuristicLab.Scripting.Views {
    3940  [View("ItemCollection View")]
    4041  [Content(typeof(VariableStore), true)]
     
    114115        removeButton.Enabled = !Locked && !ReadOnly && variableListView.SelectedItems.Count > 0;
    115116        variableListView.Enabled = true;
     117        variableListView.LabelEdit = !Locked && !ReadOnly;
    116118      }
    117119    }
     
    287289    }
    288290
     291    private readonly Regex SafeVariableNameRegex = new Regex("^[@]?[_a-zA-Z][_a-zA-Z0-9]*$");
    289292    private void variableListView_AfterLabelEdit(object sender, LabelEditEventArgs e) {
    290       if (!string.IsNullOrEmpty(e.Label)) {
     293      string name = e.Label;
     294      if (!string.IsNullOrEmpty(name) && SafeVariableNameRegex.IsMatch(name)) {
    291295        var variable = (KeyValuePair<string, object>)variableListView.Items[e.Item].Tag;
    292         if (!Content.ContainsKey(e.Label)) {
     296        if (!Content.ContainsKey(name)) {
    293297          Content.Remove(variable.Key);
    294           Content.Add(e.Label, variable.Value);
     298          Content.Add(name, variable.Value);
    295299        }
    296300      }
     
    389393    }
    390394    protected virtual void AdjustListViewColumnSizes() {
    391       if (variableListView.Items.Count > 0) {
    392         for (int i = 0; i < variableListView.Columns.Count; i++)
    393           variableListView.Columns[i].AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent);
    394       }
     395      foreach (ColumnHeader ch in variableListView.Columns)
     396        ch.Width = -2;
    395397    }
    396398    protected virtual void RebuildImageList() {
Note: See TracChangeset for help on using the changeset viewer.