Changeset 11591


Ignore:
Timestamp:
11/27/14 09:35:43 (7 years ago)
Author:
jkarder
Message:

#2116: reverted to r10041

Location:
branches/Breadcrumbs
Files:
2 deleted
16 edited

Legend:

Unmodified
Added
Removed
  • branches/Breadcrumbs/HeuristicLab.Clients.Access.Administration/3.3/Views/RoleView.cs

    r10106 r11591  
    4747
    4848    private void roleNameTextBox_TextChanged(object sender, System.EventArgs e) {
    49       if (Content != null && Content.Name != roleNameTextBox.Text)
     49      if (Content.Name != roleNameTextBox.Text)
    5050        Content.Name = roleNameTextBox.Text;
    5151    }
  • branches/Breadcrumbs/HeuristicLab.Clients.Access.Administration/3.3/Views/UserGroupView.cs

    r10106 r11591  
    6969
    7070    private void groupNameTextBox_TextChanged(object sender, System.EventArgs e) {
    71       if (Content != null && Content.Name != this.groupNameTextBox.Text)
     71      if (Content.Name != this.groupNameTextBox.Text)
    7272        Content.Name = this.groupNameTextBox.Text;
    7373    }
  • branches/Breadcrumbs/HeuristicLab.Clients.Access.Administration/3.3/Views/UserView.cs

    r10106 r11591  
    7272
    7373    private void fullNameTextBox_TextChanged(object sender, System.EventArgs e) {
    74       if (Content != null && Content.FullName != fullNameTextBox.Text)
     74      if (Content.FullName != fullNameTextBox.Text)
    7575        Content.FullName = fullNameTextBox.Text;
    7676    }
    7777
    7878    private void userNameTextBox_TextChanged(object sender, System.EventArgs e) {
    79       if (Content != null && Content.UserName != userNameTextBox.Text)
     79      if (Content.UserName != userNameTextBox.Text)
    8080        Content.UserName = userNameTextBox.Text;
    8181    }
    8282
    8383    private void emailTextBox_TextChanged(object sender, System.EventArgs e) {
    84       if (Content != null && Content.Email != emailTextBox.Text)
     84      if (Content.Email != emailTextBox.Text)
    8585        Content.Email = emailTextBox.Text;
    8686    }
  • branches/Breadcrumbs/HeuristicLab.Core.Views/3.3/ItemCollectionView.cs

    r10103 r11591  
    140140        try {
    141141          return (T)typeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType();
    142         } catch (Exception ex) {
     142        }
     143        catch (Exception ex) {
    143144          ErrorHandling.ShowErrorDialog(this, ex);
    144145        }
     
    219220    #region ListView Events
    220221    protected virtual void itemsListView_SelectedIndexChanged(object sender, EventArgs e) {
    221       removeButton.Enabled = Content != null && !Content.IsReadOnly && !ReadOnly && itemsListView.SelectedItems.Count > 0;
     222      removeButton.Enabled = (Content != null) && !Content.IsReadOnly && !ReadOnly && itemsListView.SelectedItems.Count > 0;
    222223      AdjustListViewColumnSizes();
    223       if (itemsListView.SelectedItems.Count == 1) {
    224         var item = (T)itemsListView.SelectedItems[0].Tag;
    225         var mainForm = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>();
    226         var outermostViewHost = mainForm.ShowContentInOutermostViewHost(item, this, true);
    227         if (outermostViewHost == null || !outermostViewHost.HotlinkingEnabled) {
    228           if (showDetailsCheckBox.Checked) {
    229             detailsGroupBox.Enabled = true;
    230             viewHost.Content = item;
    231           } else {
    232             viewHost.Content = null;
    233             detailsGroupBox.Enabled = false;
    234           }
     224      if (showDetailsCheckBox.Checked) {
     225        if (itemsListView.SelectedItems.Count == 1) {
     226          T item = (T)itemsListView.SelectedItems[0].Tag;
     227          detailsGroupBox.Enabled = true;
     228          viewHost.Content = item;
     229        } else {
     230          viewHost.Content = null;
     231          detailsGroupBox.Enabled = false;
    235232        }
    236233      }
     
    249246    protected virtual void itemsListView_DoubleClick(object sender, EventArgs e) {
    250247      if (itemsListView.SelectedItems.Count == 1) {
    251         var item = (T)itemsListView.SelectedItems[0].Tag;
    252         var mainForm = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>();
    253         var outermostViewHost = mainForm.ShowContentInOutermostViewHost(item, this);
    254         if (outermostViewHost != null) {
    255           outermostViewHost.ActiveView.ReadOnly = ReadOnly;
    256           outermostViewHost.ActiveView.Locked = Locked;
     248        T item = itemsListView.SelectedItems[0].Tag as T;
     249        if (item != null) {
     250          IContentView view = MainFormManager.MainForm.ShowContent(item);
     251          if (view != null) {
     252            view.ReadOnly = ReadOnly;
     253            view.Locked = Locked;
     254          }
    257255        }
    258256      }
  • branches/Breadcrumbs/HeuristicLab.Core.Views/3.3/ItemListView.cs

    r10103 r11591  
    146146        try {
    147147          return (T)typeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType();
    148         } catch (Exception ex) {
     148        }
     149        catch (Exception ex) {
    149150          ErrorHandling.ShowErrorDialog(this, ex);
    150151        }
     
    242243                             (Content != null) && !Content.IsReadOnly && !ReadOnly;
    243244      AdjustListViewColumnSizes();
    244       if (itemsListView.SelectedItems.Count == 1) {
    245         var item = (T)itemsListView.SelectedItems[0].Tag;
    246         var mainForm = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>();
    247         var outermostViewHost = mainForm.ShowContentInOutermostViewHost(item, this, true);
    248         if (outermostViewHost != null && outermostViewHost.HotlinkingEnabled) {
    249           outermostViewHost.ActiveView.ReadOnly = ReadOnly;
    250           outermostViewHost.ActiveView.Locked = Locked;
     245
     246      if (showDetailsCheckBox.Checked) {
     247        if (itemsListView.SelectedItems.Count == 1) {
     248          T item = (T)itemsListView.SelectedItems[0].Tag;
     249          detailsGroupBox.Enabled = true;
     250          viewHost.Content = item;
    251251        } else {
    252           if (showDetailsCheckBox.Checked) {
    253             detailsGroupBox.Enabled = true;
    254             viewHost.Content = item;
    255           } else {
    256             viewHost.Content = null;
    257             detailsGroupBox.Enabled = false;
    258           }
     252          viewHost.Content = null;
     253          detailsGroupBox.Enabled = false;
    259254        }
    260255      }
     
    272267    protected virtual void itemsListView_DoubleClick(object sender, EventArgs e) {
    273268      if (itemsListView.SelectedItems.Count == 1) {
    274         var item = (T)itemsListView.SelectedItems[0].Tag;
    275         var mainForm = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>();
    276         var outermostViewHost = mainForm.ShowContentInOutermostViewHost(item, this);
    277         if (outermostViewHost != null) {
    278           outermostViewHost.ActiveView.ReadOnly = ReadOnly;
    279           outermostViewHost.ActiveView.Locked = Locked;
     269        T item = itemsListView.SelectedItems[0].Tag as T;
     270        if (item != null) {
     271          IContentView view = MainFormManager.MainForm.ShowContent(item);
     272          if (view != null) {
     273            view.ReadOnly = ReadOnly;
     274            view.Locked = Locked;
     275          }
    280276        }
    281277      }
  • branches/Breadcrumbs/HeuristicLab.Core.Views/3.3/ParameterCollectionView.cs

    r10103 r11591  
    2727using HeuristicLab.Collections;
    2828using HeuristicLab.MainForm;
    29 using HeuristicLab.MainForm.WindowsForms;
    3029
    3130namespace HeuristicLab.Core.Views {
     
    147146      }
    148147    }
    149     protected virtual void itemsListView_SelectedIndexChanged(object sender, EventArgs e) {
    150       removeButton.Enabled = Content != null && !Content.IsReadOnly && !ReadOnly && itemsListView.SelectedItems.Count > 0;
    151       AdjustListViewColumnSizes();
    152       if (itemsListView.SelectedItems.Count == 1) {
    153         var item = (IParameter)itemsListView.SelectedItems[0].Tag;
    154         var mainForm = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>();
    155         var outermostViewHost = mainForm.ShowContentInOutermostViewHost(item, this, true);
    156         if (outermostViewHost != null && outermostViewHost.HotlinkingEnabled) {
    157           outermostViewHost.ActiveView.ReadOnly = ReadOnly || (item.Hidden && !AllowEditingOfHiddenParameters);
    158           outermostViewHost.ActiveView.Locked = Locked;
    159         } else {
    160           if (showDetailsCheckBox.Checked) {
    161             detailsGroupBox.Enabled = true;
    162             viewHost.Content = item;
    163           } else {
    164             viewHost.Content = null;
    165             detailsGroupBox.Enabled = false;
    166           }
    167         }
    168       }
     148    protected override void itemsListView_SelectedIndexChanged(object sender, EventArgs e) {
     149      base.itemsListView_SelectedIndexChanged(sender, e);
     150      SetEnabledStateOfControls();
    169151    }
    170152    protected override void itemsListView_DoubleClick(object sender, EventArgs e) {
    171153      if (itemsListView.SelectedItems.Count == 1) {
    172         var item = (IParameter)itemsListView.SelectedItems[0].Tag;
    173         var mainForm = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>();
    174         var outermostViewHost = mainForm.ShowContentInOutermostViewHost(item, this);
    175         if (outermostViewHost != null) {
    176           outermostViewHost.ActiveView.ReadOnly = ReadOnly || (item.Hidden && !AllowEditingOfHiddenParameters);
    177           outermostViewHost.ActiveView.Locked = Locked;
     154        IParameter item = itemsListView.SelectedItems[0].Tag as IParameter;
     155        if (item != null) {
     156          IContentView view = MainFormManager.MainForm.ShowContent(item);
     157          if (view != null) {
     158            view.ReadOnly = ReadOnly || (item.Hidden && !AllowEditingOfHiddenParameters);
     159            view.Locked = Locked;
     160          }
    178161        }
    179162      }
  • branches/Breadcrumbs/HeuristicLab.MainForm.WindowsForms/3.3/Controls/ViewContextMenuStrip.cs

    r10042 r11591  
    3030    public ViewContextMenuStrip() {
    3131      InitializeComponent();
    32       menuItems = new Dictionary<Type, ToolStripMenuItem>();
    33       ignoredViewTypes = new List<Type>();
     32      this.menuItems = new Dictionary<Type, ToolStripMenuItem>();
     33      this.ignoredViewTypes = new List<Type>();
    3434    }
    3535
    3636    public ViewContextMenuStrip(IContainer container)
    3737      : base(container) {
    38       InitializeComponent();
    39       menuItems = new Dictionary<Type, ToolStripMenuItem>();
    40       ignoredViewTypes = new List<Type>();
    41       ShowBreadcrumbsToolStripMenuItem = new ToolStripMenuItem("Show Breadcrumbs");
    42       ShowBreadcrumbsToolStripMenuItem.Click += ShowBreadcrumbsToolStripMenuItem_Click;
    43       ShowBreadcrumbsToolStripMenuItem.CheckedChanged += ShowBreadcrumbsToolStripMenuItem_CheckedChanged;
     38        InitializeComponent();
     39      this.menuItems = new Dictionary<Type, ToolStripMenuItem>();
     40      this.ignoredViewTypes = new List<Type>();
    4441    }
    4542
    4643    private object item;
    4744    public object Item {
    48       get { return item; }
     45      get { return this.item; }
    4946      set {
    50         if (item != value) {
    51           item = value;
    52           RefreshMenuItems();
     47        if (this.item != value) {
     48          this.item = value;
     49          this.RefreshMenuItems();
    5350        }
    5451      }
     
    5754    private List<Type> ignoredViewTypes;
    5855    public IEnumerable<Type> IgnoredViewTypes {
    59       get { return ignoredViewTypes; }
    60       set { ignoredViewTypes = new List<Type>(value); RefreshMenuItems(); }
     56      get { return this.ignoredViewTypes; }
     57      set { this.ignoredViewTypes = new List<Type>(value); RefreshMenuItems(); }
    6158    }
    6259
    6360    private Dictionary<Type, ToolStripMenuItem> menuItems;
    6461    public IEnumerable<KeyValuePair<Type, ToolStripMenuItem>> MenuItems {
    65       get { return menuItems; }
     62      get { return this.menuItems; }
    6663    }
    67 
    68     public ToolStripMenuItem ShowBreadcrumbsToolStripMenuItem { get; private set; }
    6964
    7065    private void RefreshMenuItems() {
     
    7368        foreach (ToolStripMenuItem m in menuItems.Values)
    7469          m.Dispose();
    75         Items.Clear();
    76         menuItems.Clear();
     70        this.Items.Clear();
     71        this.menuItems.Clear();
    7772
    78         if (item != null) {
     73        if (this.item != null) {
    7974          ToolStripMenuItem menuItem;
    8075          IEnumerable<Type> types = MainFormManager.GetViewTypes(item.GetType(), true);
     
    8479            menuItem.Text = ViewAttribute.GetViewName(t);
    8580
    86             menuItems.Add(t, menuItem);
    87             Items.Add(menuItem);
     81            this.menuItems.Add(t, menuItem);
     82            this.Items.Add(menuItem);
    8883          }
    89           if (Items.Count > 0)
    90             Items.Add(new ToolStripSeparator());
    91           Items.Add(ShowBreadcrumbsToolStripMenuItem);
    9284        }
    9385      }
    9486    }
    95 
    96     public event EventHandler ShowBreadcrumbsChanged;
    97     private void OnShowBreadcrumbsChanged() {
    98       var handler = ShowBreadcrumbsChanged;
    99       if (handler != null) handler(this, EventArgs.Empty);
    100     }
    101 
    102     private void ShowBreadcrumbsToolStripMenuItem_CheckedChanged(object sender, EventArgs e) {
    103       OnShowBreadcrumbsChanged();
    104     }
    105 
    106     private void ShowBreadcrumbsToolStripMenuItem_Click(object sender, EventArgs e) {
    107       ShowBreadcrumbsToolStripMenuItem.Checked = !ShowBreadcrumbsToolStripMenuItem.Checked;
    108     }
    10987  }
    11088}
  • branches/Breadcrumbs/HeuristicLab.MainForm.WindowsForms/3.3/Controls/ViewHost.Designer.cs

    r10042 r11591  
    5252      this.configurationLabel = new System.Windows.Forms.Label();
    5353      this.helpLabel = new System.Windows.Forms.Label();
    54       this.breadcrumbControl = new HeuristicLab.MainForm.WindowsForms.BreadcrumbControl();
    5554      this.SuspendLayout();
    5655      //
     
    8786      this.viewContextMenuStrip.Name = "viewContextMenuStrip";
    8887      this.viewContextMenuStrip.Size = new System.Drawing.Size(61, 4);
    89       this.viewContextMenuStrip.ShowBreadcrumbsChanged += new System.EventHandler(this.viewContextMenuStrip_ShowBreadcrumbsChanged);
    9088      this.viewContextMenuStrip.ItemClicked += new System.Windows.Forms.ToolStripItemClickedEventHandler(this.viewContextMenuStrip_ItemClicked);
    9189      //
     
    116114      this.helpLabel.DoubleClick += new System.EventHandler(this.helpLabel_DoubleClick);
    117115      //
    118       // breadcrumbControl
    119       //
    120       this.breadcrumbControl.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    121             | System.Windows.Forms.AnchorStyles.Right)));
    122       this.breadcrumbControl.Location = new System.Drawing.Point(0, 0);
    123       this.breadcrumbControl.Name = "breadcrumbControl";
    124       this.breadcrumbControl.Size = new System.Drawing.Size(202, 15);
    125       this.breadcrumbControl.TabIndex = 4;
    126       this.breadcrumbControl.ViewHost = null;
    127       //
    128116      // ViewHost
    129117      //
     118      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    130119      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
    131       this.Controls.Add(this.breadcrumbControl);
    132120      this.Controls.Add(this.helpLabel);
    133121      this.Controls.Add(this.viewsLabel);
     
    136124      this.Name = "ViewHost";
    137125      this.Size = new System.Drawing.Size(227, 184);
    138       this.VisibleChanged += new System.EventHandler(this.ViewHost_VisibleChanged);
    139126      this.ResumeLayout(false);
    140127
     
    148135    private System.Windows.Forms.Label configurationLabel;
    149136    private System.Windows.Forms.Label helpLabel;
    150     private BreadcrumbControl breadcrumbControl;
    151137
    152138  }
  • branches/Breadcrumbs/HeuristicLab.MainForm.WindowsForms/3.3/Controls/ViewHost.cs

    r10106 r11591  
    3333      InitializeComponent();
    3434      startDragAndDrop = false;
    35       viewContextMenuStrip.IgnoredViewTypes = new List<Type> { typeof(ViewHost) };
     35      viewContextMenuStrip.IgnoredViewTypes = new List<Type>() { typeof(ViewHost) };
    3636
    3737      viewType = null;
     
    4141      viewsLabel.Visible = false;
    4242      viewsLabelVisible = true;
    43 
    44       breadcrumbControl.ViewHost = this;
    4543    }
    4644
     
    5351          viewsLabel.Visible = value;
    5452          View view = activeView as View;
    55           if (view != null) AdjustActiveViewSize();
    56         }
    57       }
    58     }
    59 
    60     public bool HotlinkingEnabled { get; set; }
     53          if (view != null) view.Dock = viewsLabelVisible ? DockStyle.None : DockStyle.Fill;
     54        }
     55      }
     56    }
    6157
    6258    private IContentView cachedView;
     
    9187            #endregion
    9288
    93             Caption = activeView.Caption;
     89            this.Caption = activeView.Caption;
    9490            viewType = activeView.GetType();
    9591            RegisterActiveViewEvents();
     
    9793            if (view != null) {
    9894              view.Visible = true;
    99               AdjustActiveViewSize();
     95              if (ViewsLabelVisible) {
     96                view.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right;
     97                view.Size = new Size(Width - this.viewsLabel.Width - this.viewsLabel.Margin.Left - this.viewsLabel.Margin.Right, this.Height);
     98              } else view.Dock = DockStyle.Fill;
    10099              if (!Controls.Contains((view))) Controls.Add(view);
    101100              view.OnShown(new ViewShownEventArgs(view, false));
     
    126125      }
    127126    }
    128 
    129     public bool ShowBreadcrumbs {
    130       get { return viewContextMenuStrip.ShowBreadcrumbsToolStripMenuItem.Checked; }
    131       set { viewContextMenuStrip.ShowBreadcrumbsToolStripMenuItem.Checked = value; }
    132     }
    133 
    134     public IEnumerable<IContent> Breadcrumbs { get { return breadcrumbControl.Breadcrumbs; } }
    135127
    136128    protected override void SetEnabledStateOfControls() {
     
    159151      UpdateLabels();
    160152      UpdateActiveMenuItem();
    161       UpdateBreadcrumbControl();
    162153    }
    163154
     
    210201      OnChanged();
    211202    }
    212     private void ViewHost_VisibleChanged(object sender, EventArgs e) {
    213       PerformOutermostViewHostDetection();
    214     }
    215     private void viewContextMenuStrip_ShowBreadcrumbsChanged(object sender, EventArgs e) {
    216       UpdateBreadcrumbControl();
    217       AdjustActiveViewSize();
    218     }
    219203
    220204    protected override void OnSizeChanged(EventArgs e) {
     
    279263    }
    280264
    281     private void UpdateBreadcrumbControl() {
    282       breadcrumbControl.Visible = ShowBreadcrumbs && Content != null;
    283       if (ShowBreadcrumbs)
    284         UpdateBreadcrumbTrail(breadcrumbControl.Breadcrumbs, BuildBreadcrumbTrail());
    285     }
    286 
    287265    private bool ViewCanShowContent(Type viewType, object content) {
    288266      if (content == null) // every view can display null
     
    296274      IContentView view = MainFormManager.MainForm.ShowContent(this.Content, this.ViewType);
    297275      if (view != null) {
    298         view.ReadOnly = ReadOnly;
    299         view.Locked = Locked;
     276        view.ReadOnly = this.ReadOnly;
     277        view.Locked = this.Locked;
    300278      }
    301279    }
     
    307285    private bool startDragAndDrop;
    308286    private void viewsLabel_MouseDown(object sender, MouseEventArgs e) {
    309       if (e.Button == MouseButtons.Right) {
     287      if (e.Button == System.Windows.Forms.MouseButtons.Right) {
    310288        Screen screen = Screen.FromControl(viewsLabel);
    311         int rightBorder = viewsLabel.PointToScreen(viewsLabel.Location).X + viewContextMenuStrip.Width;
     289        int rightBorder = viewsLabel.PointToScreen(viewsLabel.Location).X + viewContextMenuStrip.Width; //
    312290        rightBorder = rightBorder - screen.Bounds.X; //pixel position on active screen
    313291
     
    341319    }
    342320    #endregion
    343 
    344     #region Helpers
    345     private void AdjustActiveViewSize() {
    346       var view = activeView as View;
    347       if (view == null) return;
    348       int width = viewsLabelVisible ? Width - viewsLabel.Width - viewsLabel.Margin.Left - viewsLabel.Margin.Right : Width;
    349       int height = ShowBreadcrumbs ? Height - viewsLabel.Height - viewsLabel.Margin.Top - viewsLabel.Margin.Bottom : Height;
    350       view.Location = new Point(0, Height - height);
    351       view.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right;
    352       view.Size = new Size(width, height);
    353     }
    354 
    355     private IEnumerable<IContent> BuildBreadcrumbTrail() {
    356       var ll = new LinkedList<IContent>();
    357       for (var control = (Control)this; control != null; control = control.Parent) {
    358         var viewHost = control as ViewHost;
    359         if (viewHost != null && viewHost.Content != null)
    360           ll.AddFirst(viewHost.Content);
    361       }
    362       return ll;
    363     }
    364 
    365     public void UpdateBreadcrumbTrail(IEnumerable<IContent> oldCrumbs, IEnumerable<IContent> newCrumbs) {
    366       if (!newCrumbs.Any()) return;
    367       var ll = new LinkedList<IContent>();
    368       if (newCrumbs.Contains(oldCrumbs.LastOrDefault())) {
    369         foreach (var c in oldCrumbs) {
    370           if (c != newCrumbs.First())
    371             ll.AddLast(c);
    372           else break;
    373         }
    374       }
    375       foreach (var c in newCrumbs)
    376         ll.AddLast(c);
    377       breadcrumbControl.Breadcrumbs = ll;
    378     }
    379 
    380     private void PerformOutermostViewHostDetection() {
    381       var parentContentViews = GetParentViewsOfType<ContentView>();
    382       viewContextMenuStrip.ShowBreadcrumbsToolStripMenuItem.Checked = !parentContentViews.Any();
    383     }
    384     #endregion
    385321  }
    386322}
  • branches/Breadcrumbs/HeuristicLab.MainForm.WindowsForms/3.3/HeuristicLab.MainForm.WindowsForms-3.3.csproj

    r10042 r11591  
    120120  <ItemGroup>
    121121    <Compile Include="ActionUserInterfaceItem.cs" />
    122     <Compile Include="Controls\BreadcrumbControl.cs">
    123       <SubType>UserControl</SubType>
    124     </Compile>
    125     <Compile Include="Controls\BreadcrumbControl.Designer.cs">
    126       <DependentUpon>BreadcrumbControl.cs</DependentUpon>
    127     </Compile>
    128122    <Compile Include="Controls\DragOverTabControl.cs">
    129123      <SubType>Component</SubType>
  • branches/Breadcrumbs/HeuristicLab.MainForm.WindowsForms/3.3/MainForms/MainForm.cs

    r10103 r11591  
    223223    }
    224224
    225     public T GetOutermostControlOfType<T>(Control childControl) where T : Control {
    226       if (childControl == null) throw new ArgumentNullException("childControl", "ChildControl cannot be null.");
    227 
    228       T outermostControl = null;
    229       for (var control = childControl; control != null; control = control.Parent) {
    230         var c = control as T;
    231         if (c != null) outermostControl = c;
    232       }
    233       return outermostControl;
    234     }
    235 
    236225    public IContentView ShowContent(IContent content) {
    237226      if (content == null) throw new ArgumentNullException("Content cannot be null.");
     
    241230    }
    242231
    243     public IContentView ShowContent<T>(T content, bool reuseExistingView, IEqualityComparer<T> comparer = null) where T : class, IContent {
     232    public IContentView ShowContent<T>(T content, bool reuseExistingView, IEqualityComparer<T> comparer = null) where T : class,IContent {
    244233      if (content == null) throw new ArgumentNullException("Content cannot be null.");
    245234      if (!reuseExistingView) return ShowContent(content);
     
    273262        return view;
    274263      }
    275     }
    276 
    277     public ViewHost ShowContentInOutermostViewHost(IContent content, Control childControl, bool requireHotlinking = false) {
    278       if (content == null) throw new ArgumentNullException("content", "Content cannot be null.");
    279       if (childControl == null) throw new ArgumentNullException("childControl", "ChildControl cannot be null.");
    280 
    281       var outermostViewHost = GetOutermostControlOfType<ViewHost>(childControl);
    282       if (outermostViewHost == null) return null;
    283 
    284       if (!requireHotlinking || outermostViewHost.HotlinkingEnabled) {
    285         var oldCrumbs = outermostViewHost.Breadcrumbs;
    286         var newCrumbs = new LinkedList<IContent>();
    287         for (var control = childControl; control != null; control = control.Parent) {
    288           var vh = control as ViewHost;
    289           if (vh != null && vh.Content != null)
    290             newCrumbs.AddFirst(vh.Content);
    291         }
    292         bool showBreadcrumbs = outermostViewHost.ShowBreadcrumbs;
    293         outermostViewHost.Content = null;
    294         var viewType = MainFormManager.GetDefaultViewType(content.GetType());
    295         outermostViewHost.ViewType = viewType;
    296         outermostViewHost.Content = content;
    297         outermostViewHost.UpdateBreadcrumbTrail(oldCrumbs, newCrumbs.Concat(new[] { content }));
    298         outermostViewHost.ShowBreadcrumbs = showBreadcrumbs;
    299       }
    300       return outermostViewHost;
    301264    }
    302265
     
    587550      try {
    588551        ((IActionUserInterfaceItem)item.Tag).Execute();
    589       } catch (Exception ex) {
     552      }
     553      catch (Exception ex) {
    590554        ErrorHandling.ShowErrorDialog((Control)MainFormManager.MainForm, ex);
    591555      }
  • branches/Breadcrumbs/HeuristicLab.MainForm.WindowsForms/3.3/Views/View.cs

    r10106 r11591  
    2121
    2222using System;
    23 using System.Collections.Generic;
    2423using System.Linq;
    2524using System.Reflection;
     
    262261        ((Control)this).ResumeRepaint(refresh);
    263262    }
    264 
    265     public IEnumerable<T> GetParentViewsOfType<T>() where T : View {
    266       for (var view = Parent; view != null; view = view.Parent)
    267         if (view is View) yield return view as T;
    268     }
    269263  }
    270264}
  • branches/Breadcrumbs/HeuristicLab.Operators.Views.GraphVisualization.Views/3.3/OperatorGraphView.cs

    r10103 r11591  
    140140          if (shapeInfo != null) {
    141141            IOperator op = this.VisualizationInfo.GetOperatorForShapeInfo(shapeInfo);
    142             var mainForm = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>();
    143             var outermostViewHost = mainForm.ShowContentInOutermostViewHost(op, this);
    144             if (outermostViewHost != null) {
    145               outermostViewHost.ActiveView.ReadOnly = ReadOnly;
    146               outermostViewHost.ActiveView.Locked = Locked;
     142            IContentView view = MainFormManager.MainForm.ShowContent(op);
     143            if (view != null) {
     144              view.ReadOnly = this.ReadOnly;
     145              view.Locked = this.Locked;
    147146            }
    148147            HandledMouseEventArgs eventArgs = e as HandledMouseEventArgs;
     
    196195      if (shapeInfo != null) {
    197196        IOperator op = this.VisualizationInfo.GetOperatorForShapeInfo(shapeInfo);
    198         var mainForm = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>();
    199         var outermostViewHost = mainForm.ShowContentInOutermostViewHost(op, this);
    200         if (outermostViewHost != null) {
    201           outermostViewHost.ActiveView.ReadOnly = ReadOnly;
    202           outermostViewHost.ActiveView.Locked = Locked;
     197        IContentView view = MainFormManager.MainForm.ShowContent(op);
     198        if (view != null) {
     199          view.ReadOnly = this.ReadOnly;
     200          view.Locked = this.Locked;
    203201        }
    204202      }
  • branches/Breadcrumbs/HeuristicLab.Optimization.Views/3.3/ResultCollectionView.cs

    r10042 r11591  
    2020#endregion
    2121
     22using System;
    2223using HeuristicLab.Core;
    2324using HeuristicLab.Core.Views;
    2425using HeuristicLab.MainForm;
    25 using HeuristicLab.MainForm.WindowsForms;
    2626
    2727namespace HeuristicLab.Optimization.Views {
     
    3333    public override bool ReadOnly {
    3434      get { return true; }
    35       set { /* not needed because results are always readonly */}
     35      set { /*not needed because results are always readonly */}
    3636    }
    3737
     
    4545      return null;
    4646    }
     47
     48    protected override void itemsListView_DoubleClick(object sender, EventArgs e) {
     49      if (itemsListView.SelectedItems.Count == 1) {
     50        IResult result = itemsListView.SelectedItems[0].Tag as IResult;
     51        if (result != null) {
     52          IContentView view = MainFormManager.MainForm.ShowContent(result, typeof(ResultView));
     53          if (view != null) {
     54            view.ReadOnly = ReadOnly;
     55            view.Locked = Locked;
     56          }
     57        }
     58      }
     59    }
    4760  }
    4861}
  • branches/Breadcrumbs/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionView.cs

    r10103 r11591  
    237237    #region ListView Events
    238238    private void itemsListView_SelectedIndexChanged(object sender, EventArgs e) {
    239       removeButton.Enabled = Content != null && !Content.IsReadOnly && !ReadOnly && itemsListView.SelectedItems.Count > 0;
     239      removeButton.Enabled = itemsListView.SelectedItems.Count > 0 && (Content != null) && !Content.IsReadOnly && !ReadOnly;
    240240      // for performance reason (multiple selection fires this handler for every selected item)
    241241      if (itemsListView.SelectedIndices.Count <= 1)
    242242        AdjustListViewColumnSizes();
    243       if (itemsListView.SelectedItems.Count == 1) {
    244         var item = (IRun)itemsListView.SelectedItems[0].Tag;
    245         var mainForm = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>();
    246         var outermostViewHost = mainForm.ShowContentInOutermostViewHost(item, this, true);
    247         if (outermostViewHost != null && outermostViewHost.HotlinkingEnabled) {
    248           outermostViewHost.ActiveView.ReadOnly = ReadOnly;
    249           outermostViewHost.ActiveView.Locked = Locked;
     243      if (showDetailsCheckBox.Checked) {
     244        if (itemsListView.SelectedItems.Count == 1) {
     245          IRun item = (IRun)itemsListView.SelectedItems[0].Tag;
     246          detailsGroupBox.Enabled = true;
     247          viewHost.Content = item;
    250248        } else {
    251           if (showDetailsCheckBox.Checked) {
    252             detailsGroupBox.Enabled = true;
    253             viewHost.Content = item;
    254           } else {
    255             viewHost.Content = null;
    256             detailsGroupBox.Enabled = false;
    257           }
     249          viewHost.Content = null;
     250          detailsGroupBox.Enabled = false;
    258251        }
    259252      }
     
    273266    private void itemsListView_DoubleClick(object sender, EventArgs e) {
    274267      if (itemsListView.SelectedItems.Count == 1) {
    275         var item = (IRun)itemsListView.SelectedItems[0].Tag;
    276         var mainForm = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>();
    277         var outermostViewHost = mainForm.ShowContentInOutermostViewHost(item, this);
    278         if (outermostViewHost != null) {
    279           outermostViewHost.ActiveView.ReadOnly = ReadOnly;
    280           outermostViewHost.ActiveView.Locked = Locked;
     268        IRun item = itemsListView.SelectedItems[0].Tag as IRun;
     269        if (item != null) {
     270          IContentView view = MainFormManager.MainForm.ShowContent(item);
     271          if (view != null) {
     272            view.ReadOnly = ReadOnly;
     273            view.Locked = Locked;
     274          }
    281275        }
    282276      }
     
    391385      try {
    392386        RunCollection.Modify();
    393       } finally {
     387      }
     388      finally {
    394389        ReadOnly = false;
    395390      }
  • branches/Breadcrumbs/HeuristicLab.Optimization.Views/3.3/RunView.cs

    r10103 r11591  
    2626using HeuristicLab.Core.Views;
    2727using HeuristicLab.MainForm;
    28 using HeuristicLab.MainForm.WindowsForms;
    2928
    3029namespace HeuristicLab.Optimization.Views {
     
    128127
    129128    private void listView_SelectedIndexChanged(object sender, EventArgs e) {
    130       if (listView.SelectedItems.Count == 1) {
    131         var item = (IItem)listView.SelectedItems[0].Tag;
    132         var mainForm = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>();
    133         var outermostViewHost = mainForm.ShowContentInOutermostViewHost(item, this, true);
    134         if (outermostViewHost != null && outermostViewHost.HotlinkingEnabled) {
    135           outermostViewHost.ActiveView.ReadOnly = ReadOnly;
    136           outermostViewHost.ActiveView.Locked = Locked;
     129      if (showDetailsCheckBox.Checked) {
     130        if (listView.SelectedItems.Count == 1) {
     131          detailsGroupBox.Enabled = true;
     132          viewHost.Content = listView.SelectedItems[0].Tag as IContent;
    137133        } else {
    138           if (showDetailsCheckBox.Checked) {
    139             detailsGroupBox.Enabled = true;
    140             viewHost.Content = item;
    141           } else {
    142             viewHost.Content = null;
    143             detailsGroupBox.Enabled = false;
    144           }
     134          viewHost.Content = null;
     135          detailsGroupBox.Enabled = false;
    145136        }
    146137      }
     
    148139    private void listView_DoubleClick(object sender, EventArgs e) {
    149140      if (listView.SelectedItems.Count == 1) {
    150         var item = (IItem)listView.SelectedItems[0].Tag;
    151         var mainForm = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>();
    152         var outermostViewHost = mainForm.ShowContentInOutermostViewHost(item, this);
    153         if (outermostViewHost != null) {
    154           outermostViewHost.ActiveView.ReadOnly = ReadOnly;
    155           outermostViewHost.ActiveView.Locked = Locked;
     141        IItem item = (IItem)listView.SelectedItems[0].Tag;
     142        IContentView view = MainFormManager.MainForm.ShowContent(item);
     143        if (view != null) {
     144          view.ReadOnly = true;
     145          view.Locked = Locked;
    156146        }
    157147      }
Note: See TracChangeset for help on using the changeset viewer.