private void ExecuteRemoveSelectedViewCommand() { if (selectedViewName == null) { return; } var view = region.Views.FirstOrDefault(v => v.ToString() == selectedViewName); if (view != null) { // try deactivate var activeView = region.ActiveViews.FirstOrDefault(v => v == view); if (activeView != null) { region.Deactivate(view); } region.Remove(view); // try activate last if (region.Views.Count() > 0) { region.Activate(region.Views.Last()); } } }
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; } }
/// <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); }
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)); }
private void LogonCommand_Execute(PasswordBox pBox) { Debug.WriteLine("Logon command received: User = {0} Pass = {1}", Logon, pBox.Password); String apiKey = ""; BaseURLHelper.BaseURL = BaseURL; try { Task <String> authTask = HttpHelper.Authenticate(Logon, pBox.Password); authTask.Wait(); apiKey = authTask.Result; } catch (Exception e) { Debug.WriteLine("Exception caught during authentication: {0}", e.Message, null); } if (apiKey == "") { string messageBoxText = "Authentication failed."; string caption = "CA Live API Creator Demo"; MessageBoxButton button = MessageBoxButton.OK; MessageBoxImage icon = MessageBoxImage.Warning; MessageBox.Show(messageBoxText, caption, button, icon); pBox.Clear(); return; } Debug.WriteLine("ApiKey {0} returned for User {1} Pass {2} for baseURL {3}", apiKey, Logon, pBox.Password, _baseurl); ApiHelper.ApiKey = apiKey; IRegionManager regionManager = ServiceLocator.Current.GetInstance <IRegionManager>(); if (regionManager != null) { IRegion region = regionManager.Regions["MainWindow"]; if (region != null) { region.Remove(region.GetView("LogonView")); region.Add(new CustomerSummary(), "CustomerSummaryView"); region.Add(new OrderDetailsView(), "OrderDetailsView"); region.Add(new InvoiceView(), "InvoiceView"); region.Deactivate(region.GetView("OrderDetailsView")); region.Deactivate(region.GetView("InvoiceView")); } } }
private void ViewOrderCommandExecute() { Debug.WriteLine("View Order Command executed."); IRegionManager regionManager = ServiceLocator.Current.GetInstance <IRegionManager>(); if (regionManager != null) { IRegion region = regionManager.Regions["MainWindow"]; if (region != null) { OrderDetailsView odv = region.GetView("OrderDetailsView") as OrderDetailsView; OrderDetailsViewModel odvm = odv.DataContext as OrderDetailsViewModel; odvm.CustomerName = CurrentCustomer.CompanyName; odvm.Address = CurrentCustomer.Address; odvm.City = CurrentCustomer.City; odvm.PostalCode = CurrentCustomer.PostalCode; odvm.Phone = CurrentCustomer.Phone; odvm.CurrentOrder = SelectedOrder; odvm.OrderDate = SelectedOrder.OrderDate; odvm.RequiredDate = SelectedOrder.RequiredDate; odvm.ShippedDate = SelectedOrder.ShippedDate; region.Deactivate(region.GetView("CustomerSummaryView")); region.Activate(odv); } } }
private void DeactivateAllActiveViewToRegion(IRegion region) { foreach (object view in region.ActiveViews) { region.Deactivate(view); } }
public void Initialize() { //IRegion region = _regionManager.Regions[RegionNames.ToolbarRegion]; //region.Add(_container.Resolve(typeof (ToolbarView))); _container.RegisterType <ToolbarView>(); _container.RegisterType <IContentView, ContentView>(); _container.RegisterType <IContentViewViewModel, ContentViewViewModel>(); _regionManager.RegisterViewWithRegion(RegionNames.ToolbarRegion, typeof(ToolbarView)); var vm = _container.Resolve <IContentViewViewModel>(); vm.Message = "First View"; IRegion region = _regionManager.Regions[RegionNames.ContentRegion]; region.Add(vm.View); var vm2 = _container.Resolve <IContentViewViewModel>(); vm2.Message = "Second View"; region = _regionManager.Regions[RegionNames.ContentRegion]; region.Deactivate(vm.View); region.Add(vm2.View); }
public async Task InitializeApplication() { if (IsInitilized) { return; } tcRegion = regionManager.Regions["TopContentRegion"]; rtRegion = regionManager.Regions["RootContentRegion"]; topContent = containerExtension.Resolve <TopContent>(); mainPage = containerExtension.Resolve <MainPage>(); loginPage = containerExtension.Resolve <LoginPage>(); tcRegion.Add(topContent); rtRegion.Add(loginPage); rtRegion.Add(mainPage); tcRegion.Deactivate(topContent); IMenuRegistryProvider menu = containerExtension.Resolve <IMenuRegistryProvider>(); if (menu != null) { eventAggregator.GetEvent <MenuCreationEvent>().Publish(menu.GetMenuItemViews()); } cpRegion = regionManager.Regions["ContentPaneRegion"]; IsInitilized = true; await Task.Delay(1000); }
public AboutViewWindow() { Region = ServiceLocator.Current.GetInstance <IRegionManager>().Regions[RegionNames.Modal]; InitializeComponent(); Region.ActiveViews.ToList().ForEach(vw => Region.Deactivate(vw)); }
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); }
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 OnSelectionChanged(object sender, SelectionChangedEventArgs e) { IRegion region = GetRegion(); Selector selector = GetSelector(); if (region == null || selector == null || selector.ItemsSource != region.Views) { Detach(); } else { if (selector == e.OriginalSource) { foreach (object item in e.RemovedItems) { if (region.ActiveViews.Contains(item)) { region.Deactivate(item); } } foreach (object item in e.AddedItems) { region.Activate(item); } } } }
public static void ClearActiveViews(this IRegion region) { foreach (var v in region.ActiveViews) { region.Deactivate(v); } }
/// <summary> /// Deactivates the views that belongs to the <paramref name="viewModel"/> instance. /// </summary> /// <param name="viewModel"> /// The view model instance. /// </param> /// <exception cref="ArgumentException"> /// If <paramref name="viewModel"/> is <c>null</c>. /// </exception> /// <exception cref="InvalidOperationException"> /// If the <paramref name="viewModel"/> was no show at least one time in a <see cref="IRegion"/>. /// </exception> private static void Deactivate(IViewModel viewModel) { Argument.IsNotNull("viewModel", viewModel); IViewInfo viewInfo = ViewInfoCacheStorage[viewModel.UniqueIdentifier]; if (viewInfo == null) { throw new InvalidOperationException(ActivationRequiredInvalidOperationErrorMessage); } FrameworkElement view = viewInfo.View; IRegion region = viewInfo.Region; var dispatcherService = viewModel.GetService <IDispatcherService>(); dispatcherService.Invoke(() => { region.Deactivate(view); if (viewModel.IsClosed) { ViewInfoCacheStorage.Remove(viewModel.UniqueIdentifier, () => region.Remove(view)); } }); }
public static void Deactivate([NotNull] this IRegion region) { foreach (var view in region.ActiveViews) { region.Deactivate(view); } }
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); }
public void RemoveToolBarGroup(int uid) { m_Logger.Log(@"RemoveToolBarGroup", Category.Debug, Priority.Medium); #if DEBUG if (!Dispatcher.CheckAccess()) { Debugger.Break(); } #endif IRegion targetRegion = m_RegionManager.Regions[RegionNames.MainToolbar]; var viewsToRemove = new List <object>(); int count = 0; object view; while ((view = targetRegion.GetView(uid + @"_" + count++)) != null) { viewsToRemove.Add(view); } foreach (var obj in viewsToRemove) { targetRegion.Deactivate(obj); targetRegion.Remove(obj); } }
/// <summary> /// Adapts a <see cref="ContentPresenter"/> to a <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, ContentPresenter regionTarget) { if (regionTarget == null) { throw new ArgumentNullException(nameof(regionTarget)); } bool contentIsSet = regionTarget.Content != null; contentIsSet = contentIsSet || (BindingOperations.GetBinding(regionTarget, ContentPresenter.ContentProperty) != null); if (contentIsSet) { throw new InvalidOperationException("ContentPresenter'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) { foreach (object activeView in region.ActiveViews) { region.Deactivate(activeView); } region.Activate(e.NewItems[0]); } }; }
private void CancelSettings(IRegion region) { var view = region.ActiveViews.ToList().First(); region.Deactivate(view); view = region.Views.ToList().Single(x => x.GetType() == typeof(MainView)); region.Activate(view); }
private void closeView() { var useableView = _region.ActiveViews.ToList(); if (useableView.Count > 0) { _region.Deactivate(useableView[0]); } }
protected void DeActivateAllViews(string regionName) { IRegion region = regionManager.Regions[regionName]; foreach (object activeView in region.ActiveViews) { region.Deactivate(activeView); } }
private void CancelSettings() { IRegion region = regionManager.Regions["MainRegion"]; var view = region.ActiveViews.ToList().First(); region.Deactivate(view); view = region.Views.ToList().Single(x => x.GetType() == typeof(MainView)); region.Activate(view); }
private async Task CloseExistingTarget(IRegion region, ReactiveViewModel navigationTarget, INavigationParameters parameters) { await Observable.Start(() => navigationTarget.Close(parameters), RxApp.TaskpoolScheduler).ToTask().ConfigureAwait(false); await Observable.Start(() => { region.Deactivate(navigationTarget); region.Remove(navigationTarget); }, RxApp.MainThreadScheduler).ToTask().ConfigureAwait(false); }
public async Task LogingApplication(object loggedUser) { if (loggedUser is ILoggedUserProvider provider) { containerExtension.RegisterInstance(provider); rtRegion.Deactivate(loginPage); rtRegion.Activate(mainPage); } await Task.Delay(1000); }
private void window_Deactivated(object sender, EventArgs e) { IRegion region = _regionWeakReference.Target as IRegion; Window window = sender as Window; if (window != null) { region.Deactivate(window.Content); } }
private void btn_DeactivateView(object sender, RoutedEventArgs e) { //_region = _regionManager.Regions["ABRegion"]; //foreach (var item in _region.Views) //{ // _region.Deactivate(item); //} _region.Deactivate(viewB); }
//Manually add and remove views using View Injection private void Button_Click(object sender, RoutedEventArgs e) { var view = _container.Resolve <ViewB>(); IRegion region = _regionManager.Regions["ContentRegion"]; //region.RemoveAll(); // remove any previous view _region.Deactivate(_viewA); region.Add(view); }
/// <summary> /// Marks the specified view as inactive. /// </summary> /// <param name="view">The view to deactivate.</param> public void Deactivate(object view) { var innerView = FindView(view); if (innerView == null) { throw new ArgumentException("View does not exist."); } InnerRegion.Deactivate(view); }
public static void DeactivateWorkitemInRegion(this IRegionManagerExtension regionManager, IRegion region, IWorkItem workItem) { foreach (DependencyObject view in region.Views.OfType <DependencyObject>()) { IWorkItem owner = WorkitemManager.GetOwner(view); if (workItem.Equals(owner)) { region.Deactivate(view); } } }
private static void ClearRegionActiveViews(IRegion region) { foreach (var v in region.ActiveViews) { region.Deactivate(v); } }