public void OnInitialized(IContainerProvider containerProvider) { //_regionManager.RegisterViewWithRegion("ContentRegion", typeof(ViewA)); IRegion region = _regionManager.Regions["ContentRegion"]; var view1 = containerProvider.Resolve <ViewA>(); region.Add(view1); var view2 = containerProvider.Resolve <ViewA>(); view2.Content = new TextBlock() { Text = "Hello from view 2", HorizontalAlignment = System.Windows.HorizontalAlignment.Center, VerticalAlignment = System.Windows.VerticalAlignment.Center }; region.Add(view2); region.Activate(view2); region.Activate(view1); region.Deactivate(view1); region.Activate(view2); region.Remove(view2); region.Activate(view1); }
/// <summary> /// Activates and deactivates the view. /// </summary> private void activateView() { IRegion ribbonRegion = regionManager.Regions[RegionNames.RibbonRegion]; object dview = ribbonRegion.GetView("dashboardView"); ribbonRegion.Deactivate(dview); object cview = ribbonRegion.GetView("contributionAnalyzerView"); ribbonRegion.Activate(cview); IRegion dockingRegion = regionManager.Regions[RegionNames.DockingRegion]; object accountsview1 = dockingRegion.GetView("accountsView"); dockingRegion.Deactivate(accountsview1); object stockview = dockingRegion.GetView("stocklistView"); dockingRegion.Deactivate(stockview); object chartview1 = dockingRegion.GetView("historychartView"); dockingRegion.Deactivate(chartview1); object accountsview = dockingRegion.GetView("accountsView"); dockingRegion.Activate(accountsview); object gridview = dockingRegion.GetView("portfoliogridView"); dockingRegion.Activate(gridview); object chartview = dockingRegion.GetView("countrysectorchartView"); dockingRegion.Activate(chartview); }
private void UsingViewInjection(IContainerProvider containerProvider) { IRegion region = _regionManager.Regions["ContentRegion"]; var view1 = containerProvider.Resolve <TabView>(); region.Add(view1); var view2 = containerProvider.Resolve <TabView>(); view2.Content = new TextBlock() { Text = "Hello from View 2", HorizontalAlignment = System.Windows.HorizontalAlignment.Center, VerticalAlignment = System.Windows.VerticalAlignment.Center }; region.Add(view2); region.Activate(view2); region.Activate(view1); region.Deactivate(view1); region.Activate(view2); region.Remove(view2); region.Activate(view1); }
private void Button_Click(object sender, RoutedEventArgs e) { if (!(sender is Button button)) { return; } switch (button.Name) { case "deactivateregionA": _region.Deactivate(_viewA); break; case "activateregionA": _region.Activate(_viewA); break; case "deactivateregionB": _region.Deactivate(_viewB); break; case "activateregionB": _region.Activate(_viewB); break; default: AddViewToDynamicRegion(); break; } }
public object GotoTab <T>(string viewName) { if (!this._regionManager.Regions.ContainsRegionWithName("MainTabRegion")) { return(null); } IRegion region = this._regionManager.Regions["MainTabRegion"]; if (region.GetView(viewName) != null) { region.Activate(region.GetView(viewName)); return(region.GetView(viewName)); } Object viewObj = ServiceLocator.Current.GetInstance <T>(); ICloseable view = viewObj as ICloseable; if (view != null) { view.Closer.RequestClose += () => { var disposable = view as IDisposable; if (disposable != null) { disposable.Dispose(); } region.Remove(view); }; } region.Add(view, viewName); region.Activate(view); return(viewObj); }
private void DemoTabAsRegion(object obj) { var tabItem = new RibbonTabAsRegion(); ribbonRegion.Add(tabItem); ribbonRegion.Activate(tabItem); }
public void OnInitialized(IContainerProvider containerProvider) { var regionManager = containerProvider.Resolve <IRegionManager>(); IRegion region = regionManager.Regions["CameraTabRegion"]; // Basler 카메라 검색 UpdateBaslerDeviceList(); // 추후 다른 카메라 추가되면 검색 메소드 추가할 자리 // Create TabControl if (CAMs.Count == 0) { var tab = containerProvider.Resolve <ViewNone>(); (tab.DataContext as ViewNoneViewModel).Name = "None"; region.Add(tab); region.Activate(tab); } else { foreach (var cam in CAMs) { if (cam.CAMType == CAMTYPE.BASLER) { var tab = containerProvider.Resolve <ViewBasler>(); (tab.DataContext as ViewBaslerViewModel).Name = cam.Name; (tab.DataContext as ViewBaslerViewModel).Tag = (ICameraInfo)cam.Tag; region.Add(tab); region.Activate(tab); } } } }
private void Map_ItemClick(object sender, RoutedEventArgs e) { //var view = _container.Resolve<MapView>(); //IRegion region = _regionManager.Regions["ContentMap"]; //region.Add(view); _region.Activate(_mapView); _region.Deactivate(_chartView); _region.Deactivate(_cameraView); }
public void onRegionNeedChangeEvent(string views) { IRegion region = RegionManager.Regions[RegionNames.RightPanelName]; region.Deactivate(region.ActiveViews.FirstOrDefault()); region.Activate(UnityContainer.Resolve <IViewRightRegion>(views)); region = RegionManager.Regions[RegionNames.LeftPanelName]; region.Deactivate(region.ActiveViews.FirstOrDefault()); region.Activate(UnityContainer.Resolve <IViewLeftRegion>(views)); }
public void Initialize() { IRegion region = regionManager.Regions["ClothesListRegion"]; object newView = container.Resolve <Views.ClothesListView>(); region.Add(newView); region.Activate(newView); region = regionManager.Regions["ClothesFilteringRegion"]; object newFilterView = container.Resolve <Views.ClothesFilteringView>(); region.Add(newFilterView); region.Activate(newFilterView); }
public virtual void OnEmployeeSelected(BusinessEntities.Employee employee) { // We are still using Push based composition here, to show the usage of scoped regionmanagers. // When an employee gets selected, we are creating a new instance of the EmployeeDetailsView and are pushing it in the region. // this would be hard to do with the 'out of the box' functionality of the pull based composition, because we // have a requirement where we want to push a view into the region at a specific point in time, and not when // the region decides it needs to pull a view into it. IRegion detailsRegion = regionManager.Regions[RegionNames.DetailsRegion]; object existingView = detailsRegion.GetView(employee.EmployeeId.ToString(CultureInfo.InvariantCulture)); // See if the view already exists in the region. if (existingView == null) { // the view does not exist yet. Create it and push it into the region IEmployeesDetailsPresenter detailsPresenter = this.container.Resolve <IEmployeesDetailsPresenter>(); detailsPresenter.SetSelectedEmployee(employee); // the details view should receive it's own scoped region manager, therefore Add overload using 'true' (see notes below). detailsRegion.Add(detailsPresenter.View, employee.EmployeeId.ToString(CultureInfo.InvariantCulture), true); detailsRegion.Activate(detailsPresenter.View); } else { // The view already exists. Just show it. detailsRegion.Activate(existingView); } //************************************************************************************************ // Note on using Scoped Regionmanagers: // Scoped regionmanagers are used to have multiple instances of the same region in memory at the same time. // Since a region gets registered with a regionmanager, the name has to be unique. // In this example, we are keeping several instances of the EmployeeDetailsView in memory. Each view has it's own TabRegion, // so each view needs it's own regionmanager. This is still hard to do with pull based composition. //************************************************************************************************ //************************************************************************************************ // Note on Push based vs Pull based composition. // Prism V2 is going to support both Push based (V1 style) and Pull based (New in V2) composition. // // In pull based composition, as soon as the region get's added to the visual tree, it will be populated with new instances of // registered views. In Pull based composition, you get less control over when views are added (only on load of the region) // but this allows for an easier programming model. // // In push based composition, you have to write some code that, at a certain point in time, finds a region that's already // created (might not be visible yet) and adds views to it. Using Push based composition, you have more control over when // you want to add views to a particular region, but at the expense of more complexity. //************************************************************************************************ }
/// <summary> /// 循环检测是否登录了 /// </summary> private void LoopLoginCheck(IEventAggregator ea, IRegion region, QRCodeView qrView, HeadView headView, ErrorView errorView) { LoginService ls = new LoginService(); object login_result = null; //循环判断手机扫描二维码结果 while (true) { login_result = ls.LoginCheck(); //已扫描 未登录 if (login_result is ImageSource) { ea.GetEvent <UpdateHeadImageEvent>().Publish(login_result as ImageSource); Application.Current.Dispatcher.BeginInvoke(new Action(() => { region.Activate(headView); })); } //已完成登录 if (login_result is string) { //访问登录跳转URL if (ls.GetSidUid(login_result as string, out string errorMsg)) { Application.Current.Dispatcher.BeginInvoke(new Action(() => { region.RemoveAll(); ea.GetEvent <LoginSuccessfulEvent>().Publish(); })); break; } else { ea.GetEvent <ShowErrorMsgEvent>().Publish(errorMsg); Application.Current.Dispatcher.BeginInvoke(new Action(() => { region.Activate(errorView); })); break; } } ////超时 if (login_result is int) { ea.GetEvent <UpdateQRCodeEvent>().Publish(); } } }
private void InjectViewToRegionBy(Type viewType) { if (viewType == null) { return; } IRegion region = regionManger.Regions[RegionNames.TabItemRegion]; string viewName = viewType.Name; TabItem tab = region.GetView(viewName) as TabItem; if (tab == null) { tab = unityContainer.Resolve(viewType) as TabItem; tab.IsSelected = true; (tab.DataContext as BaseTabViewModel).InitializeData(); region.Add(tab, viewName); } else { tab.IsSelected = true; } region.Activate(tab); }
private void DisplayAbout() { IRegion region = _regionManager.Regions["PluginRegion"]; var view = region.GetView("AboutView"); region.Activate(view); }
/// <summary> /// Adapts a <see cref="ScrollView"/> to an <see cref="IRegion"/>. /// </summary> /// <param name="region">The new region being used.</param> /// <param name="regionTarget">The object to adapt.</param> protected override void Adapt(IRegion region, ScrollView regionTarget) { if (regionTarget == null) { throw new ArgumentNullException(nameof(regionTarget)); } // No binding check required as the ContentProperty is not Bindable bool contentIsSet = regionTarget.Content != null; if (contentIsSet) { throw new InvalidOperationException(Resources.ScrollViewHasContentException); } region.ActiveViews.CollectionChanged += delegate { regionTarget.Content = region.ActiveViews.FirstOrDefault() as View; }; region.Views.CollectionChanged += (sender, e) => { if (e.Action == NotifyCollectionChangedAction.Add && region.ActiveViews.Count() == 0) { region.Activate(e.NewItems[0] as VisualElement); } }; }
protected override void Adapt(IRegion region, SlidingContentControl regionTarget) { if (regionTarget == null) { throw new ArgumentNullException("regionTarget"); } bool contentIsSet = regionTarget.Content != null; contentIsSet = contentIsSet | (BindingOperations.GetBinding(regionTarget, ContentControl.ContentProperty) != null); if (contentIsSet) { throw new InvalidOperationException(); } region.ActiveViews.CollectionChanged += (_, __) => { regionTarget.Content = region.ActiveViews.FirstOrDefault(); }; region.Views.CollectionChanged += (_, e) => { if (e.Action.Equals(NotifyCollectionChangedAction.Add) & region.ActiveViews.Count() == 0) { region.Activate(e.NewItems[0]); } }; }
protected override void Adapt(IRegion region, DialogHost regionTarget) { if (regionTarget == null) { throw new ArgumentNullException(nameof(regionTarget)); } bool contentIsSet = regionTarget.DialogContent is object; if (contentIsSet) { throw new InvalidOperationException("Content is already set"); } region.ActiveViews.CollectionChanged += (s, e) => { regionTarget.DialogContent = region.ActiveViews.FirstOrDefault(); }; region.Views.CollectionChanged += (s, e) => { if (e.Action is NotifyCollectionChangedAction.Add && !region.ActiveViews.Any()) { region.Activate(e.NewItems[0]); } }; }
protected override void Adapt(IRegion region, LayoutAnchorable regionTarget) { if (regionTarget == null) { throw new ArgumentNullException("regionTarget"); } if (regionTarget.Content != null) { throw new InvalidOperationException(); } region.ActiveViews.CollectionChanged += delegate { regionTarget.Content = region.ActiveViews.FirstOrDefault(); }; region.Views.CollectionChanged += (sender, e) => { if (e.Action == NotifyCollectionChangedAction.Add && region.ActiveViews.Count() == 0) { region.Activate(e.NewItems[0]); } }; }
protected override void Adapt(IRegion region, TransitioningContentControl regionTarget) { if (regionTarget == null) { throw new ArgumentNullException("regionTarget"); } if ((regionTarget.Content != null) || (BindingOperations.GetBinding(regionTarget, ContentControl.ContentProperty) != null)) { throw new InvalidOperationException("ContentControlHasContentException"); } region.ActiveViews.CollectionChanged += delegate { regionTarget.Content = region.ActiveViews.FirstOrDefault <object>(); }; region.Views.CollectionChanged += delegate(object sender, NotifyCollectionChangedEventArgs e) { if ((e.Action == NotifyCollectionChangedAction.Add) && (!region.ActiveViews.Any())) { region.Activate(e.NewItems[0]); } }; }
private void EmployeeSelected(string id) { if (string.IsNullOrEmpty(id)) { return; } Employee selectedEmployee = _dataService.GetEmployees().FirstOrDefault(item => item.Id == id); IRegion mainRegion = _regionManager.Regions[RegionNames.MainRegion]; if (mainRegion == null) { return; } EmployeeSummaryView view = mainRegion.GetView(nameof(EmployeeSummaryView)) as EmployeeSummaryView; if (view == null) { view = _container.Resolve <EmployeeSummaryView>(); mainRegion.Add(view, nameof(EmployeeSummaryView)); } else { mainRegion.Activate(view); } if (view.DataContext is EmployeeSummaryViewModel viewModel) { viewModel.CurrentEmployee = selectedEmployee; } }
private void GameModeSelected(String gameModeName) { if (String.IsNullOrEmpty(gameModeName)) { return; } GameModeInfo gameMode = _service.GetGameModeInfos().FirstOrDefault(gamemode => gamemode.Name == gameModeName); IRegion regionGameModeDetails = _regionManager.Regions[RegionNames.RegionGameModeDetails]; if (regionGameModeDetails == null) { return; } GameModeDetails view = regionGameModeDetails.GetView(ViewNames.GameModeDetails) as GameModeDetails; if (view == null) { view = _container.Resolve <GameModeDetails>(); regionGameModeDetails.Add(view, ViewNames.GameModeDetails); } else { regionGameModeDetails.Activate(view); } GameModeDetailsViewModel viewModel = view.DataContext as GameModeDetailsViewModel; if (viewModel != null) { viewModel.CurrentGameModeInfo = gameMode; } }
private void ChangeContent(UserControl view) { try { dispatcher.BeginInvoke(() => { if (contentRegion == null) { contentRegion = this.regionManager.Regions[RegionContainer.Content]; } if (currentView != null) { if (currentView.ToString() == view.ToString()) { return; } } currentView = view; contentRegion.Add(view); contentRegion.Activate(view); Animation.SwitchToPage(); }); } catch (Exception ex) { Utility.DisplayMessage(ex.Message); } }
private void ChangeMenu(UserControl view) { try { dispatcher.BeginInvoke(() => { if (menuRegion == null) { menuRegion = this.regionManager.Regions[RegionContainer.SubMenu]; } if (currentView != null) { if (currentView.ToString() == view.ToString()) { return; } } currentView = view; menuRegion.Add(view); menuRegion.Activate(view); }); } catch (Exception ex) { Utility.DisplayMessage(ex.Message); } }
private void SwitchView(UserControl view) { dispatcher.BeginInvoke(() => { //if (contentRegion == null) //{ //contentRegion = null; contentRegion = this.regionManager.Regions["ContentRegion"]; //} //contentRegion = container.Resolve<> if (currentView != null) { if (currentView.ToString() == view.ToString()) { return; } } currentView = view; contentRegion.Add(view); contentRegion.Activate(view); //Animation.SwitchToPage(); //eventAggregator.GetEvent<UserEvent>().Publish(LoggedInUser); }); }
public virtual void ShowDialog() { // Check to see if the region exists. if (RegionManager.Regions.ContainsRegionWithName(DialogRegionName)) { IRegion region = RegionManager.Regions[DialogRegionName]; object currentView = region.GetView(DialogViewName); if (currentView != null) { region.Deactivate(currentView); if (IsModaless) { // If the view exists in the region remove it. region.Remove(currentView); } } if (currentView == null || IsModaless) { var newView = CompositionContainer.GetInstance <object>(DialogViewName); dynamic view = newView; view.DataContext = this; region.Add(newView, DialogViewName); currentView = newView; } region.Activate(currentView); } }
private void PropertiesCommandExecute() { IRegion region = _regionManager.Regions["ContentRegion"]; object ordersView = region.Views.FirstOrDefault(v => v.GetType().IsEquivalentTo(typeof(LoginView))); region.Activate(ordersView); }
/// <summary> /// Adapts a <see cref="ContentControl"/> to an <see cref="IRegion"/>. /// </summary> /// <param name="region">The new region being used.</param> /// <param name="regionTarget">The object to adapt.</param> protected override void Adapt(IRegion region, ContentControl regionTarget) { if (regionTarget == null) { throw new ArgumentNullException(nameof(regionTarget)); } bool contentIsSet = regionTarget.Content != null; contentIsSet = contentIsSet || regionTarget.HasBinding(ContentControl.ContentProperty); if (contentIsSet) { throw new InvalidOperationException("ContentControl's Content property is not empty. This control is being associated with a region, but the control is already bound to something else. If you did not explicitly set the control's Content property, this exception may be caused by a change in the value of the inherited RegionManager attached property."); } region.ActiveViews.CollectionChanged += delegate { regionTarget.Content = region.ActiveViews.FirstOrDefault(); }; region.Views.CollectionChanged += (sender, e) => { if (e.Action == NotifyCollectionChangedAction.Add && region.ActiveViews.Count() == 0) { region.Activate(e.NewItems[0]); } }; }
public void OpenDownloadTaskWindow(IRegionManager regionManager, IDialogService dialogService) { if (Application.Current is not PrismApplication app) { return; } IContainerProvider container = app.Container; if (this._localState.IsTaskWindowOpen && this._settingHandler.GetBoolSetting(SettingsEnum.SingletonWindows)) { return; } if (this._settingHandler.GetBoolSetting(SettingsEnum.ShowTasksAsTab)) { IRegion region = regionManager.Regions[LocalConstant.TopTabRegionName]; var view = container.Resolve <DownloadTasksWindows>(); region.Add(view); region.Activate(view); this._localState.IsTaskWindowOpen = true; } else { dialogService.Show(nameof(DownloadTasksWindows)); } }
private void AlbumSelected(int obj) { IRegion mainRegion = this.regionManager.Regions[RegionNames.AlbumRightRegion]; if (mainRegion == null) { return; } // Check to see if we need to create an instance of the view. var view = mainRegion.GetView("AlbumDetailsView") as AlbumDetailsView; if (view == null) { // Create a new instance of the EmployeeDetailsView using the Unity container. view = this.container.Resolve <AlbumDetailsView>(); // Add the view to the main region. This automatically activates the view too. mainRegion.Add(view, "AlbumDetailsView"); } else { // The view has already been added to the region so just activate it. mainRegion.Activate(view); } }
/// <summary> /// Adapts a <see cref="ContentControl"/> to an <see cref="IRegion"/>. /// </summary> /// <param name="region">The new region being used.</param> /// <param name="regionTarget">The object to adapt.</param> protected override void Adapt(IRegion region, ContentControl regionTarget) { if (regionTarget == null) { throw new ArgumentNullException(nameof(regionTarget)); } bool contentIsSet = regionTarget.Content != null; contentIsSet = contentIsSet || (BindingOperations.GetBinding(regionTarget, ContentControl.ContentProperty) != null); if (contentIsSet) { throw new InvalidOperationException(Resources.ContentControlHasContentException); } region.ActiveViews.CollectionChanged += delegate { regionTarget.Content = region.ActiveViews.FirstOrDefault(); }; region.Views.CollectionChanged += (sender, e) => { if (e.Action == NotifyCollectionChangedAction.Add && region.ActiveViews.Count() == 0) { region.Activate(e.NewItems[0]); } }; }
private void OnKataFinished(ICodingDojo codingDojo) { _mainRegion = _regionManager.Regions[MainRegion]; _mainRegion.Activate(_mainRegion.Views.OfType<DigestView>().First()); }
private void OnResetKata(object obj) { _mainRegion = _regionManager.Regions[MainRegion]; _mainRegion.Activate(_mainRegion.Views.OfType<ConfigView>().First()); }
private void OnShowAdvancedConfigEvent(object obj) { _mainRegion = _regionManager.Regions[MainRegion]; _mainRegion.Activate(_mainRegion.Views.OfType<AdvancedConfigView>().First()); }
private void OnStartKata(object obj) { _mainRegion = _regionManager.Regions[MainRegion]; _mainRegion.Activate(_mainRegion.Views.OfType<DojoView>().First()); }