private void LoadView(Type viewType) { if (!viewCollection.ContainsKey(viewType.FullName) || (currentView == viewCollection[viewType.FullName])) { IView newView = Activator.CreateInstance(viewType) as IView; BaseView newViewControl = newView as BaseView; newViewControl.ParentWindow = this; if (newView == null || newViewControl == null) { throw new InvalidOperationException("Invalid view type - does not inherit from UserControl and extend IView"); } newView.MessageReceived += new EventHandler <MessageReceivedEventArgs>(newView_MessageReceived); newView.ConfigureView(sharedViewData); uxMainCanvas.Children.Add(newViewControl); viewCollection[viewType.FullName] = newView; } if (currentView != null) { ((UserControl)currentView).Visibility = System.Windows.Visibility.Collapsed; currentView.DeactivateView(); } IView view = viewCollection[viewType.FullName]; view.ActivateView(); ((UserControl)view).Visibility = System.Windows.Visibility.Visible; currentView = view; }
private void ChangeView(IView futureView) { ChangeViewSingle(this.headerView, futureView == this.viewerWindow); ChangeViewSingle(this.headerBrowse, futureView == this.browseWindow); ChangeViewSingle(this.headerFavourite, futureView == this.favouriteWindow); currentView.DeactivateView(); futureView.ActivateView(); currentView = futureView; }