Free cookie consent management tool by TermsFeed Policy Generator

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

#2116: reverted to r10041

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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}
Note: See TracChangeset for help on using the changeset viewer.