Free cookie consent management tool by TermsFeed Policy Generator

Changeset 10042 for branches/Breadcrumbs


Ignore:
Timestamp:
10/15/13 16:11:27 (11 years ago)
Author:
jkarder
Message:

#2116: added prototype of a breadcrumb navigation

Location:
branches/Breadcrumbs
Files:
2 added
10 edited

Legend:

Unmodified
Added
Removed
  • branches/Breadcrumbs/HeuristicLab.Core.Views/3.3/ItemCollectionView.cs

    r9755 r10042  
    140140        try {
    141141          return (T)typeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType();
    142         }
    143         catch (Exception ex) {
     142        } catch (Exception ex) {
    144143          ErrorHandling.ShowErrorDialog(this, ex);
    145144        }
     
    246245    protected virtual void itemsListView_DoubleClick(object sender, EventArgs e) {
    247246      if (itemsListView.SelectedItems.Count == 1) {
    248         T item = itemsListView.SelectedItems[0].Tag as T;
     247        var item = itemsListView.SelectedItems[0].Tag as T;
    249248        if (item != null) {
    250           IContentView view = MainFormManager.MainForm.ShowContent(item);
    251           if (view != null) {
    252             view.ReadOnly = ReadOnly;
    253             view.Locked = Locked;
     249          ViewHost outmostViewHost = null;
     250          for (var control = Parent; control != null; control = control.Parent) {
     251            var vh = control as ViewHost;
     252            if (vh != null) outmostViewHost = vh;
     253          }
     254          if (outmostViewHost != null) {
     255            var oldCrumbs = outmostViewHost.Breadcrumbs;
     256            var newCrumbs = BuildBreadcrumbTrail();
     257            outmostViewHost.Content = null;
     258            var viewType = MainFormManager.GetDefaultViewType(item.GetType());
     259            outmostViewHost.ViewType = viewType;
     260            outmostViewHost.Content = item;
     261            outmostViewHost.UpdateBreadcrumbTrail(oldCrumbs, newCrumbs.Concat(new[] { item }));
     262            outmostViewHost.ActiveView.ReadOnly = ReadOnly;
     263            outmostViewHost.ActiveView.Locked = Locked;
    254264          }
    255265        }
     
    440450      }
    441451    }
     452    protected virtual IEnumerable<IContent> BuildBreadcrumbTrail() {
     453      var l = new LinkedList<IContent>();
     454      for (var control = (Control)this; control != null; control = control.Parent) {
     455        var vh = control as ViewHost;
     456        if (vh != null && vh.Content != null)
     457          l.AddFirst(vh.Content);
     458      }
     459      return l;
     460    }
    442461    #endregion
    443462  }
  • branches/Breadcrumbs/HeuristicLab.Core.Views/3.3/ItemListView.cs

    r9755 r10042  
    146146        try {
    147147          return (T)typeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType();
    148         }
    149         catch (Exception ex) {
     148        } catch (Exception ex) {
    150149          ErrorHandling.ShowErrorDialog(this, ex);
    151150        }
     
    267266    protected virtual void itemsListView_DoubleClick(object sender, EventArgs e) {
    268267      if (itemsListView.SelectedItems.Count == 1) {
    269         T item = itemsListView.SelectedItems[0].Tag as T;
     268        var item = itemsListView.SelectedItems[0].Tag as T;
    270269        if (item != null) {
    271           IContentView view = MainFormManager.MainForm.ShowContent(item);
    272           if (view != null) {
    273             view.ReadOnly = ReadOnly;
    274             view.Locked = Locked;
     270          ViewHost outmostViewHost = null;
     271          for (var control = Parent; control != null; control = control.Parent) {
     272            var vh = control as ViewHost;
     273            if (vh != null) outmostViewHost = vh;
     274          }
     275          if (outmostViewHost != null) {
     276            var oldCrumbs = outmostViewHost.Breadcrumbs;
     277            var newCrumbs = BuildBreadcrumbTrail();
     278            outmostViewHost.Content = null;
     279            var viewType = MainFormManager.GetDefaultViewType(item.GetType());
     280            outmostViewHost.ViewType = viewType;
     281            outmostViewHost.Content = item;
     282            outmostViewHost.UpdateBreadcrumbTrail(oldCrumbs, newCrumbs.Concat(new[] { item }));
     283            outmostViewHost.ActiveView.ReadOnly = ReadOnly;
     284            outmostViewHost.ActiveView.Locked = Locked;
    275285          }
    276286        }
     
    506516      }
    507517    }
     518    protected virtual IEnumerable<IContent> BuildBreadcrumbTrail() {
     519      var l = new LinkedList<IContent>();
     520      for (var control = (Control)this; control != null; control = control.Parent) {
     521        var vh = control as ViewHost;
     522        if (vh != null && vh.Content != null)
     523          l.AddFirst(vh.Content);
     524      }
     525      return l;
     526    }
    508527    #endregion
    509528  }
  • branches/Breadcrumbs/HeuristicLab.Core.Views/3.3/ParameterCollectionView.cs

    r9456 r10042  
    2727using HeuristicLab.Collections;
    2828using HeuristicLab.MainForm;
     29using HeuristicLab.MainForm.WindowsForms;
    2930
    3031namespace HeuristicLab.Core.Views {
     
    152153    protected override void itemsListView_DoubleClick(object sender, EventArgs e) {
    153154      if (itemsListView.SelectedItems.Count == 1) {
    154         IParameter item = itemsListView.SelectedItems[0].Tag as IParameter;
     155        var item = itemsListView.SelectedItems[0].Tag as IParameter;
    155156        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;
     157          ViewHost outmostViewHost = null;
     158          for (var control = Parent; control != null; control = control.Parent) {
     159            var vh = control as ViewHost;
     160            if (vh != null) outmostViewHost = vh;
     161          }
     162          if (outmostViewHost != null) {
     163            var oldCrumbs = outmostViewHost.Breadcrumbs;
     164            var newCrumbs = BuildBreadcrumbTrail();
     165            outmostViewHost.Content = null;
     166            var viewType = MainFormManager.GetDefaultViewType(item.GetType());
     167            outmostViewHost.ViewType = viewType;
     168            outmostViewHost.Content = item;
     169            outmostViewHost.UpdateBreadcrumbTrail(oldCrumbs, newCrumbs.Concat(new[] { item }));
     170            outmostViewHost.ActiveView.ReadOnly = ReadOnly;
     171            outmostViewHost.ActiveView.Locked = Locked;
    160172          }
    161173        }
  • branches/Breadcrumbs/HeuristicLab.MainForm.WindowsForms/3.3/Controls/ViewContextMenuStrip.cs

    r9456 r10042  
    3030    public ViewContextMenuStrip() {
    3131      InitializeComponent();
    32       this.menuItems = new Dictionary<Type, ToolStripMenuItem>();
    33       this.ignoredViewTypes = new List<Type>();
     32      menuItems = new Dictionary<Type, ToolStripMenuItem>();
     33      ignoredViewTypes = new List<Type>();
    3434    }
    3535
    3636    public ViewContextMenuStrip(IContainer container)
    3737      : base(container) {
    38         InitializeComponent();
    39       this.menuItems = new Dictionary<Type, ToolStripMenuItem>();
    40       this.ignoredViewTypes = new List<Type>();
     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;
    4144    }
    4245
    4346    private object item;
    4447    public object Item {
    45       get { return this.item; }
     48      get { return item; }
    4649      set {
    47         if (this.item != value) {
    48           this.item = value;
    49           this.RefreshMenuItems();
     50        if (item != value) {
     51          item = value;
     52          RefreshMenuItems();
    5053        }
    5154      }
     
    5457    private List<Type> ignoredViewTypes;
    5558    public IEnumerable<Type> IgnoredViewTypes {
    56       get { return this.ignoredViewTypes; }
    57       set { this.ignoredViewTypes = new List<Type>(value); RefreshMenuItems(); }
     59      get { return ignoredViewTypes; }
     60      set { ignoredViewTypes = new List<Type>(value); RefreshMenuItems(); }
    5861    }
    5962
    6063    private Dictionary<Type, ToolStripMenuItem> menuItems;
    6164    public IEnumerable<KeyValuePair<Type, ToolStripMenuItem>> MenuItems {
    62       get { return this.menuItems; }
     65      get { return menuItems; }
    6366    }
     67
     68    public ToolStripMenuItem ShowBreadcrumbsToolStripMenuItem { get; private set; }
    6469
    6570    private void RefreshMenuItems() {
     
    6873        foreach (ToolStripMenuItem m in menuItems.Values)
    6974          m.Dispose();
    70         this.Items.Clear();
    71         this.menuItems.Clear();
     75        Items.Clear();
     76        menuItems.Clear();
    7277
    73         if (this.item != null) {
     78        if (item != null) {
    7479          ToolStripMenuItem menuItem;
    7580          IEnumerable<Type> types = MainFormManager.GetViewTypes(item.GetType(), true);
     
    7984            menuItem.Text = ViewAttribute.GetViewName(t);
    8085
    81             this.menuItems.Add(t, menuItem);
    82             this.Items.Add(menuItem);
     86            menuItems.Add(t, menuItem);
     87            Items.Add(menuItem);
    8388          }
     89          if (Items.Count > 0)
     90            Items.Add(new ToolStripSeparator());
     91          Items.Add(ShowBreadcrumbsToolStripMenuItem);
    8492        }
    8593      }
    8694    }
     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    }
    87109  }
    88110}
  • branches/Breadcrumbs/HeuristicLab.MainForm.WindowsForms/3.3/Controls/ViewHost.Designer.cs

    r9920 r10042  
    5252      this.configurationLabel = new System.Windows.Forms.Label();
    5353      this.helpLabel = new System.Windows.Forms.Label();
     54      this.breadcrumbControl = new HeuristicLab.MainForm.WindowsForms.BreadcrumbControl();
    5455      this.SuspendLayout();
    5556      //
     
    8687      this.viewContextMenuStrip.Name = "viewContextMenuStrip";
    8788      this.viewContextMenuStrip.Size = new System.Drawing.Size(61, 4);
     89      this.viewContextMenuStrip.ShowBreadcrumbsChanged += new System.EventHandler(this.viewContextMenuStrip_ShowBreadcrumbsChanged);
    8890      this.viewContextMenuStrip.ItemClicked += new System.Windows.Forms.ToolStripItemClickedEventHandler(this.viewContextMenuStrip_ItemClicked);
    8991      //
     
    114116      this.helpLabel.DoubleClick += new System.EventHandler(this.helpLabel_DoubleClick);
    115117      //
     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      //
    116128      // ViewHost
    117129      //
    118       this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    119130      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
     131      this.Controls.Add(this.breadcrumbControl);
    120132      this.Controls.Add(this.helpLabel);
    121133      this.Controls.Add(this.viewsLabel);
     
    124136      this.Name = "ViewHost";
    125137      this.Size = new System.Drawing.Size(227, 184);
     138      this.VisibleChanged += new System.EventHandler(this.ViewHost_VisibleChanged);
    126139      this.ResumeLayout(false);
    127140
     
    135148    private System.Windows.Forms.Label configurationLabel;
    136149    private System.Windows.Forms.Label helpLabel;
     150    private BreadcrumbControl breadcrumbControl;
    137151
    138152  }
  • branches/Breadcrumbs/HeuristicLab.MainForm.WindowsForms/3.3/Controls/ViewHost.cs

    r9921 r10042  
    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;
    4345    }
    4446
     
    5153          viewsLabel.Visible = value;
    5254          View view = activeView as View;
    53           if (view != null) view.Dock = viewsLabelVisible ? DockStyle.None : DockStyle.Fill;
     55          if (view != null) AdjustActiveViewSize();
    5456        }
    5557      }
     
    8789            #endregion
    8890
    89             this.Caption = activeView.Caption;
     91            Caption = activeView.Caption;
    9092            viewType = activeView.GetType();
    9193            RegisterActiveViewEvents();
     
    9395            if (view != null) {
    9496              view.Visible = true;
    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;
     97              AdjustActiveViewSize();
    9998              if (!Controls.Contains((view))) Controls.Add(view);
    10099              view.OnShown(new ViewShownEventArgs(view, false));
     
    125124      }
    126125    }
     126
     127    public bool ShowBreadcrumbs {
     128      get { return viewContextMenuStrip.ShowBreadcrumbsToolStripMenuItem.Checked; }
     129      set { viewContextMenuStrip.ShowBreadcrumbsToolStripMenuItem.Checked = value; }
     130    }
     131
     132    private bool isOutmostViewHost;
     133    public IEnumerable<IContent> Breadcrumbs { get { return breadcrumbControl.Breadcrumbs; } }
    127134
    128135    protected override void SetEnabledStateOfControls() {
     
    151158      UpdateLabels();
    152159      UpdateActiveMenuItem();
     160      UpdateBreadcrumbControl();
    153161    }
    154162
     
    201209      OnChanged();
    202210    }
     211    private void ViewHost_VisibleChanged(object sender, EventArgs e) {
     212      PerformOuterViewHostDetection();
     213    }
     214    private void viewContextMenuStrip_ShowBreadcrumbsChanged(object sender, EventArgs e) {
     215      UpdateBreadcrumbControl();
     216      AdjustActiveViewSize();
     217    }
    203218
    204219    protected override void OnSizeChanged(EventArgs e) {
     
    263278    }
    264279
     280    private void UpdateBreadcrumbControl() {
     281      breadcrumbControl.Visible = ShowBreadcrumbs;
     282      if (ShowBreadcrumbs)
     283        UpdateBreadcrumbTrail(breadcrumbControl.Breadcrumbs, BuildBreadcrumbTrail());
     284    }
     285
    265286    private bool ViewCanShowContent(Type viewType, object content) {
    266287      if (content == null) // every view can display null
     
    274295      IContentView view = MainFormManager.MainForm.ShowContent(this.Content, this.ViewType);
    275296      if (view != null) {
    276         view.ReadOnly = this.ReadOnly;
    277         view.Locked = this.Locked;
     297        view.ReadOnly = ReadOnly;
     298        view.Locked = Locked;
    278299      }
    279300    }
     
    285306    private bool startDragAndDrop;
    286307    private void viewsLabel_MouseDown(object sender, MouseEventArgs e) {
    287       if (e.Button == System.Windows.Forms.MouseButtons.Right) {
     308      if (e.Button == MouseButtons.Right) {
    288309        Screen screen = Screen.FromControl(viewsLabel);
    289         int rightBorder = viewsLabel.PointToScreen(viewsLabel.Location).X + viewContextMenuStrip.Width; //
     310        int rightBorder = viewsLabel.PointToScreen(viewsLabel.Location).X + viewContextMenuStrip.Width;
    290311        rightBorder = rightBorder - screen.Bounds.X; //pixel position on active screen
    291312
     
    319340    }
    320341    #endregion
     342
     343    #region Helpers
     344    private void AdjustActiveViewSize() {
     345      var view = activeView as View;
     346      if (view == null) return;
     347      int width = viewsLabelVisible ? Width - viewsLabel.Width - viewsLabel.Margin.Left - viewsLabel.Margin.Right : Width;
     348      int height = ShowBreadcrumbs ? Height - viewsLabel.Height - viewsLabel.Margin.Top - viewsLabel.Margin.Bottom : Height;
     349      view.Location = new Point(0, Height - height);
     350      view.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right;
     351      view.Size = new Size(width, height);
     352    }
     353
     354    private IEnumerable<IContent> BuildBreadcrumbTrail() {
     355      var ll = new LinkedList<IContent>();
     356      for (var control = (Control)this; control != null; control = control.Parent) {
     357        var viewHost = control as ViewHost;
     358        if (viewHost != null && viewHost.Content != null)
     359          ll.AddFirst(viewHost.Content);
     360      }
     361      return ll;
     362    }
     363
     364    public void UpdateBreadcrumbTrail(IEnumerable<IContent> oldCrumbs, IEnumerable<IContent> newCrumbs) {
     365      if (!newCrumbs.Any()) return;
     366      var ll = new LinkedList<IContent>();
     367      foreach (var c in oldCrumbs) {
     368        if (c != newCrumbs.First())
     369          ll.AddLast(c);
     370        else break;
     371      }
     372      foreach (var c in newCrumbs)
     373        ll.AddLast(c);
     374      breadcrumbControl.Breadcrumbs = ll;
     375    }
     376
     377    private void PerformOuterViewHostDetection() {
     378      var outmostViewHost = this;
     379      for (var parent = Parent; parent != null; parent = parent.Parent) {
     380        var vh = parent as ViewHost;
     381        if (vh != null) outmostViewHost = vh;
     382      }
     383      isOutmostViewHost = outmostViewHost == this;
     384      viewContextMenuStrip.ShowBreadcrumbsToolStripMenuItem.Checked = isOutmostViewHost;
     385    }
     386    #endregion
    321387  }
    322388}
  • branches/Breadcrumbs/HeuristicLab.MainForm.WindowsForms/3.3/HeuristicLab.MainForm.WindowsForms-3.3.csproj

    r9915 r10042  
    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>
    122128    <Compile Include="Controls\DragOverTabControl.cs">
    123129      <SubType>Component</SubType>
  • branches/Breadcrumbs/HeuristicLab.Optimization.Views/3.3/ResultCollectionView.cs

    r9456 r10042  
    2020#endregion
    2121
    22 using System;
    2322using HeuristicLab.Core;
    2423using HeuristicLab.Core.Views;
    2524using HeuristicLab.MainForm;
     25using 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     }
    6047  }
    6148}
  • branches/Breadcrumbs/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionView.cs

    r9613 r10042  
    266266    private void itemsListView_DoubleClick(object sender, EventArgs e) {
    267267      if (itemsListView.SelectedItems.Count == 1) {
    268         IRun item = itemsListView.SelectedItems[0].Tag as IRun;
     268        var item = itemsListView.SelectedItems[0].Tag as IRun;
    269269        if (item != null) {
    270           IContentView view = MainFormManager.MainForm.ShowContent(item);
    271           if (view != null) {
    272             view.ReadOnly = ReadOnly;
    273             view.Locked = Locked;
     270          ViewHost outmostViewHost = null;
     271          for (var control = Parent; control != null; control = control.Parent) {
     272            var vh = control as ViewHost;
     273            if (vh != null) outmostViewHost = vh;
     274          }
     275          if (outmostViewHost != null) {
     276            var oldCrumbs = outmostViewHost.Breadcrumbs;
     277            var newCrumbs = BuildBreadcrumbTrail();
     278            outmostViewHost.Content = null;
     279            var viewType = MainFormManager.GetDefaultViewType(item.GetType());
     280            outmostViewHost.ViewType = viewType;
     281            outmostViewHost.Content = item;
     282            outmostViewHost.UpdateBreadcrumbTrail(oldCrumbs, newCrumbs.Concat(new[] { item }));
     283            outmostViewHost.ActiveView.ReadOnly = ReadOnly;
     284            outmostViewHost.ActiveView.Locked = Locked;
    274285          }
    275286        }
     
    385396      try {
    386397        RunCollection.Modify();
    387       }
    388       finally {
     398      } finally {
    389399        ReadOnly = false;
    390400      }
     
    500510      }
    501511    }
     512    private IEnumerable<IContent> BuildBreadcrumbTrail() {
     513      var l = new LinkedList<IContent>();
     514      for (var control = (Control)this; control != null; control = control.Parent) {
     515        var vh = control as ViewHost;
     516        if (vh != null && vh.Content != null)
     517          l.AddFirst(vh.Content);
     518      }
     519      return l;
     520    }
    502521    #endregion
    503522  }
  • branches/Breadcrumbs/HeuristicLab.Optimization.Views/3.3/RunView.cs

    r9456 r10042  
    2121
    2222using System;
     23using System.Collections.Generic;
     24using System.Linq;
    2325using System.Windows.Forms;
    2426using HeuristicLab.Common;
     
    2628using HeuristicLab.Core.Views;
    2729using HeuristicLab.MainForm;
     30using HeuristicLab.MainForm.WindowsForms;
    2831
    2932namespace HeuristicLab.Optimization.Views {
     
    139142    private void listView_DoubleClick(object sender, EventArgs e) {
    140143      if (listView.SelectedItems.Count == 1) {
    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;
     144        var item = listView.SelectedItems[0].Tag as IItem;
     145        if (item != null) {
     146          ViewHost outmostViewHost = null;
     147          for (var control = Parent; control != null; control = control.Parent) {
     148            var vh = control as ViewHost;
     149            if (vh != null) outmostViewHost = vh;
     150          }
     151          if (outmostViewHost != null) {
     152            var oldCrumbs = outmostViewHost.Breadcrumbs;
     153            var newCrumbs = BuildBreadcrumbTrail();
     154            outmostViewHost.Content = null;
     155            var viewType = MainFormManager.GetDefaultViewType(item.GetType());
     156            outmostViewHost.ViewType = viewType;
     157            outmostViewHost.Content = item;
     158            outmostViewHost.UpdateBreadcrumbTrail(oldCrumbs, newCrumbs.Concat(new[] { item }));
     159            outmostViewHost.ActiveView.ReadOnly = ReadOnly;
     160            outmostViewHost.ActiveView.Locked = Locked;
     161          }
    146162        }
    147163      }
     
    173189      }
    174190    }
     191    private IEnumerable<IContent> BuildBreadcrumbTrail() {
     192      var l = new LinkedList<IContent>();
     193      for (var control = (Control)this; control != null; control = control.Parent) {
     194        var vh = control as ViewHost;
     195        if (vh != null && vh.Content != null)
     196          l.AddFirst(vh.Content);
     197      }
     198      return l;
     199    }
    175200  }
    176201}
Note: See TracChangeset for help on using the changeset viewer.