Free cookie consent management tool by TermsFeed Policy Generator

Changeset 4453


Ignore:
Timestamp:
09/20/10 15:08:50 (14 years ago)
Author:
mkommend
Message:

Refactored the Clipboard to handle IExecuteables and repositioned the label in the ViewHost (ticket #1155).

Location:
trunk/sources
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Core.Views/3.3/Clipboard.cs

    r4447 r4453  
    178178
    179179      int i = 0;
    180       var query = from item in itemListViewItemTable.Keys
    181                   let views = MainFormManager.MainForm.Views.OfType<IContentView>().Where(v => v.Content == item)
    182                   where !views.Any(v => v.Locked)
    183                   select item;
    184       T[] items = query.ToArray();
     180      T[] items = GetStorableItems(itemListViewItemTable.Keys);
    185181
    186182      foreach (T item in items) {
     
    198194      OnAllItemsSaved();
    199195    }
     196
    200197    private void OnItemSaved(T item, int progress) {
    201198      if (item != null) {
     
    223220        views.ForEach(v => v.Enabled = enabled);
    224221      }
     222    }
     223
     224    private static T[] GetStorableItems(IEnumerable<T> items) {
     225      var query = from item in items
     226                  let executeable = item as IExecutable
     227                  let views = MainFormManager.MainForm.Views.OfType<IContentView>().Where(v => v.Content == item)
     228                  where executeable == null || executeable.ExecutionState != ExecutionState.Started
     229                  where !views.Any(v => v.Locked)
     230                  select item;
     231      T[] itemArray = query.ToArray();
     232      return itemArray;
    225233    }
    226234    #endregion
     
    321329    }
    322330    private void saveButton_Click(object sender, EventArgs e) {
    323       var query = (from item in itemListViewItemTable.Keys
    324                    let views = MainFormManager.MainForm.Views.OfType<IContentView>().Where(v => v.Content == item)
    325                    where views.Any(v => v.Locked)
    326                    select item.ToString()).ToArray();
    327       if (query.Length != 0) {
    328         string itemNames = string.Join(Environment.NewLine, query);
    329         MessageBox.Show("Could not save the following items, because they are locked (e.g. used in a running algorithm). All other items will be saved." + Environment.NewLine + itemNames);
     331      IEnumerable<T> items = itemListViewItemTable.Keys.Except(GetStorableItems(itemListViewItemTable.Keys));
     332      if (items.Any()) {
     333        string itemNames = string.Join(Environment.NewLine, items.Select(item => item.ToString()).ToArray());
     334        MessageBox.Show("The following items could not be saved, because they are locked (e.g. used in a running algorithm). All other items will be saved." +
     335          Environment.NewLine + itemNames, "Could not save all items", MessageBoxButtons.OK, MessageBoxIcon.Warning);
    330336      }
    331337      Save();
  • trunk/sources/HeuristicLab.MainForm.WindowsForms/3.3/ViewHost.Designer.cs

    r4011 r4453  
    4646    private void InitializeComponent() {
    4747      this.components = new System.ComponentModel.Container();
     48      System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ViewHost));
    4849      this.messageLabel = new System.Windows.Forms.Label();
    4950      this.viewsLabel = new System.Windows.Forms.Label();
     
    6869      this.viewsLabel.Image = HeuristicLab.Common.Resources.VS2008ImageLibrary.Windows;
    6970      this.viewsLabel.Location = new System.Drawing.Point(211, 0);
    70       this.viewsLabel.Margin = new System.Windows.Forms.Padding(3);
     71      this.viewsLabel.Margin = new System.Windows.Forms.Padding(6, 3, 3, 3);
    7172      this.viewsLabel.Name = "viewsLabel";
    7273      this.viewsLabel.Size = new System.Drawing.Size(16, 16);
     
    7475      this.toolTip.SetToolTip(this.viewsLabel, "Double-click to open a new window of the current view.\r\nRight-click to change cur" +
    7576              "rent view.\r\nDrag icon to copy or link content to another view.");
    76       this.viewsLabel.MouseLeave += new System.EventHandler(this.viewsLabel_MouseLeave);
    7777      this.viewsLabel.DoubleClick += new System.EventHandler(this.viewsLabel_DoubleClick);
    7878      this.viewsLabel.MouseDown += new System.Windows.Forms.MouseEventHandler(this.viewsLabel_MouseDown);
     79      this.viewsLabel.MouseLeave += new System.EventHandler(this.viewsLabel_MouseLeave);
    7980      //
    8081      // viewContextMenuStrip
    8182      //
     83      this.viewContextMenuStrip.IgnoredViewTypes = System.Linq.Enumerable.Empty<System.Type>();
    8284      this.viewContextMenuStrip.Item = null;
    8385      this.viewContextMenuStrip.Name = "viewContextMenuStrip";
     
    9496      this.Size = new System.Drawing.Size(227, 184);
    9597      this.ResumeLayout(false);
     98
    9699    }
    97100
Note: See TracChangeset for help on using the changeset viewer.