/// <summary>
        /// Gets the view to which the navigation request represented by <paramref name="navigationContext"/> applies.
        /// </summary>
        /// <param name="region">The region.</param>
        /// <param name="navigationContext">The context representing the navigation request.</param>
        /// <returns>
        /// The view to be the target of the navigation request.
        /// </returns>
        /// <remarks>
        /// If none of the views in the region can be the target of the navigation request, a new view
        /// is created and added to the region.
        /// </remarks>
        /// <exception cref="ArgumentException">when a new view cannot be created for the navigation request.</exception>
        public object LoadContent(IRegion region, NavigationContext navigationContext)
        {
            if (region == null)
                throw new ArgumentNullException(nameof(region));

            if (navigationContext == null)
                throw new ArgumentNullException(nameof(navigationContext));

            string candidateTargetContract = this.GetContractFromNavigationContext(navigationContext);

            var candidates = this.GetCandidatesFromRegion(region, candidateTargetContract);

            var acceptingCandidates =
                candidates.Where(
                    v =>
                    {
                        var navigationAware = v as INavigationAware;
                        if (navigationAware != null && !navigationAware.IsNavigationTarget(navigationContext))
                        {
                            return false;
                        }

                        var frameworkElement = v as FrameworkElement;
                        if (frameworkElement == null)
                        {
                            return true;
                        }

                        navigationAware = frameworkElement.DataContext as INavigationAware;
                        return navigationAware == null || navigationAware.IsNavigationTarget(navigationContext);
                    });


            var view = acceptingCandidates.FirstOrDefault();

            if (view != null)
            {
                return view;
            }

            view = this.CreateNewRegionItem(candidateTargetContract);

            region.Add(view);

            return view;
        }
Exemple #2
0
        public override void DoTask(int iters, object data)
        {
            Int32 localcnt = m_cnt;

            Interlocked.Increment(ref m_cnt);
            IDictionary <TKey, TVal> hmoc = new Dictionary <TKey, TVal>();

            lock (m_maps)
            {
                m_maps.Add(hmoc);
            }
            int  offset = Util.Rand(m_MaxKeys);
            int  count  = offset;
            TKey key    = default(TKey);

            Util.Log("EntryTask::DoTask: starting {0} iterations.", iters);
            while (Running && (iters-- != 0))
            {
                int idx = count % m_MaxKeys;
                key = (TKey)(object)("AAAAAA" + localcnt + idx.ToString("D10"));
                string opcode = FwkTest <TKey, TVal> .CurrentTest.GetStringValue("entryOps");

                if (opcode == null)
                {
                    opcode = "no-opcode";
                }
                if (opcode == "put")
                {
                    lock (CLASS_LOCK)
                    {
                        DeltaTestImpl newValue = null;
                        if (m_region.ContainsKey(key))
                        {
                            DeltaTestImpl oldValue = m_region[key] as DeltaTestImpl;
                            if (oldValue == null)
                            {
                                newValue      = getLatestDelta(key, localcnt, false);
                                m_region[key] = (TVal)(object)newValue;
                            }
                            else
                            {
                                newValue = new DeltaTestImpl(oldValue);
                                newValue.SetIntVar(oldValue.GetIntVar() + 1);
                                m_region[key] = (TVal)(object)newValue;
                            }
                            Interlocked.Increment(ref m_update);
                            //Util.BBSet("ToDeltaBB", key.ToString(), newValue.GetToDeltaCounter());
                        }
                        else
                        {
                            newValue = getLatestDelta(key, localcnt, true);
                            m_region.Add(key, (TVal)(object)newValue);
                            Interlocked.Increment(ref m_create);
                        }
                        //(m_maps[localcnt]).Add(key, newValue);
                        m_maps[localcnt][key] = (TVal)(object)newValue;
                    }
                }
                else if (opcode == "destroy")
                {
                    DeltaTestImpl oldValue = null;
                    if (m_region.ContainsKey(key))
                    {
                        if ((oldValue = m_region[key] as DeltaTestImpl) == null)
                        {
                            if (m_isDestroy)
                            {
                                m_region.Remove(key);
                                (m_maps[localcnt]).Remove(key);
                            }
                        }
                        else
                        {
                            m_maps[localcnt][key] = (TVal)(object)oldValue;
                            m_region.Remove(key);
                            //(m_maps[localcnt]).Remove(key);
                        }
                        Interlocked.Increment(ref m_destroy);
                    }
                }
                else if (opcode == "invalidate")
                {
                    DeltaTestImpl oldValue = null;
                    if (m_region.ContainsKey(key))
                    {
                        if ((oldValue = m_region[key] as DeltaTestImpl) != null)
                        {
                            m_maps[localcnt].Add(key, (TVal)(object)oldValue);
                            m_region.Invalidate(key);
                            Interlocked.Increment(ref m_invalidate);
                            m_maps[localcnt].Add(key, default(TVal));
                        }
                    }
                }
            }
            Interlocked.Add(ref m_iters, count - offset);
        }
Exemple #3
0
        protected override void InitializeModule()
        {
            IRegion region = RegionManager.Regions[RegionNames.ToolbarRegion];

            region.Add(Container.Resolve <CustomerToolbarView>());
        }
        private async void Navigate(object para)
        {
            string viewName = para as string;

            if (viewName == null)
            {
                return;
            }
            if (!this._regionManager.Regions.ContainsRegionWithName("MainTabRegion"))
            {
                return;
            }
            IRegion region = this._regionManager.Regions["MainTabRegion"];

            if (region.GetView(viewName) != null)
            {
                region.Activate(region.GetView(viewName));
                return;
            }
            object viewObj = null;

            if (viewName == "MenuServerSetting")
            {
                //viewObj = ServiceLocator.Current.GetInstance<ServerSetView>();
            }
            //else if (viewName == "MenuOnlineData")
            //{
            //    viewObj = ServiceLocator.Current.GetInstance<OnLineDataPageView>();
            //}
            else if (viewName == "MenuCollectorSetting")
            {
                viewObj = ServiceLocator.Current.GetInstance <PDASystemManageView>();
            }
            else if (viewName == "MenuUserManage")
            {
                viewObj = ServiceLocator.Current.GetInstance <UserSetView>();
            }
            else if (viewName == "MenuRoleManage")
            {
                viewObj = ServiceLocator.Current.GetInstance <RoleSetView>();
            }
            else if (viewName == "MenuMenuManage")
            {
                viewObj = ServiceLocator.Current.GetInstance <MenuSetView>();
            }
            else if (viewName == "MenuOrganizationManage")
            {
                viewObj = ServiceLocator.Current.GetInstance <OrganizationPrivilegeSetView>();
            }
            else if (viewName == "MenuManageLog")
            {
                viewObj = ServiceLocator.Current.GetInstance <OperateRecord>();
            }
            else if (viewName == "MenuOnlineDataOverview")
            {
                //viewObj = ServiceLocator.Current.GetInstance<OnlineDataOverviewView>();
            }
            else if (viewName == "MenuOnlineDataList")
            {
                viewObj = ServiceLocator.Current.GetInstance <CYSHDataListView>();
            }
            else if (viewName == "MenuOnlineDataTile")
            {
                //viewObj = ServiceLocator.Current.GetInstance<OnlineDataTileView>();
            }
            else if (viewName == "MenuOnlineDataDiagram")
            {
                //viewObj = ServiceLocator.Current.GetInstance<OnlineDataDiagramView>();
            }
            else if (viewName == "MenuHistoryDataList")
            {
                viewObj = ServiceLocator.Current.GetInstance <HistoryDataListView>();
            }
            else if (viewName == "MenuHistoryDataDiagram")
            {
                viewObj = ServiceLocator.Current.GetInstance <HistoryDataDiagramView>();
            }
            else if (viewName == "MenuHistoryData")
            {
                viewObj = ServiceLocator.Current.GetInstance <HistoryDataDiagramView>();
            }
            else if (viewName == "MenuRefreshData")
            {
                Status   = ViewModelStatus.Querying;
                WaitInfo = "刷新中";
                await _loginUserService.SetUserLogin();

                Status = ViewModelStatus.None;
                return;
            }
            else
            {
                return;
            }
            ICloseable view = viewObj as ICloseable;

            if (view != null)
            {
                view.Closer.RequestClose += () => region.Remove(view);
            }
            region.Add(view, viewName);
            region.Activate(view);
        }
        /// <summary>
        /// Display a module the specified region with the given view.
        /// </summary>
        /// <param name="loadInfo">module load descriptor</param>
        /// <exception cref="ArgumentNullException">Empty module name.</exception>
        public void DisplayModule(ModuleLoadInfo loadInfo)
        {
            string moduleName = loadInfo.ModuleName;
            string regionName = loadInfo.RegionName;
            string viewName   = loadInfo.ViewName ?? loadInfo.ModuleName;

            if (string.IsNullOrEmpty(moduleName))
            {
                throw new ArgumentNullException(moduleName, "Illegal module name to load.");
            }
            ModuleViewBase currentView;

            try
            {
                moduleManager.LoadModule(moduleName);
                IModulePresentation module = TryResolve <IModulePresentation>(moduleName);

                if (module != null)
                {
                    IRegion region = regionManager.Regions[regionName];
                    currentView = (ModuleViewBase)region.GetView(viewName);

                    if (currentView == null)
                    {
                        currentView = (ModuleViewBase)module.GetView(viewName);
                        if (currentView.ViewModel != null)
                        {
                            currentView.ViewModel.LoadInfo = loadInfo;
                        }
                        else
                        {
                            // TODO rerdelyi 100705: some action should be taken, e.g. throw exception
                        }
                        loadInfo.RenderedView = currentView;
                        region.Add(currentView, viewName);
                        region.Activate(currentView);
                        currentView.LoadData(loadInfo.LoadCommand, loadInfo.LoadParameter);
                    }
                    else
                    {
                        // TODO rerdelyi 100705: some action should be taken, e.g. throw exception
                    }

                    //string statusBarRegionName = regionName + STATUSBAR;
                    //string statusBarViewName = viewName + STATUSBAR;

                    //if (regionManager.Regions.ContainsRegionWithName(statusBarRegionName))
                    //{
                    //    IRegion statusBarRegion = regionManager.Regions[statusBarRegionName];
                    //    if (statusBarRegion != null && statusBarRegion.GetView(statusBarViewName) == null)
                    //    {
                    //        var statusBar = module.GetStatusBar(viewName);
                    //        statusBar.DataContext = currentView.ViewModel;
                    //        statusBarRegion.Add(statusBar, statusBarViewName);
                    //        statusBarRegion.Activate(statusBar);
                    //    }
                    //}
                }
                else
                {
                    throw new MissingMemberException(string.Format("Unable to display \"{0}\" module.", moduleName));
                }
            }

            catch (Exception ex)
            {
                throw new Exception(string.Format("Unable to display \"{0}\" module.", moduleName), ex);
            }
        }
 /// <summary>
 /// Adds a new view to the region.
 /// </summary>
 /// <param name="view">The view to add.</param>
 /// <returns>
 /// The <see cref="T:Microsoft.Practices.Composite.Regions.IRegionManager"/> that is set on the view if it is a <see cref="T:System.Windows.DependencyObject"/>. It will be the current region manager when using this overload.
 /// </returns>
 /// <overloads>Adds a new view to the region.</overloads>
 public IRegionManager Add(object view)
 {
     return(InnerRegion.Add(this.modelVisualizationRegistry.CreateVisualization(view)));
 }
 private void MainWindow_Loaded(object sender, RoutedEventArgs e)
 {
     _sidebarView = _container.Resolve <SideBar>();
     _region      = _regionManager.Regions["SideBarRegion"];
     _region.Add(_sidebarView);
 }
Exemple #8
0
        protected override void InitViews()
        {
            IRegion workspaceRegion = GetWorkspaceRegion();

            workspaceRegion.Add(container.Resolve <ListeningsView>(), WorkspaceNameEnum.Listenings.ToString());
        }
Exemple #9
0
        private void InitTabRegion(long id)
        {
            IRegion tabRegion = regionManager.Regions[RegionNames.TabRegionFG];

            if (tabRegion == null)
            {
                return;
            }

            FGahuView ahuView = tabRegion.GetView("FGahuView") as FGahuView;
            FGfcuView fcuView = tabRegion.GetView("FGfcuView") as FGfcuView;

            if (ahuView == null && fcuView == null)
            {
                ahuView = this.container.Resolve <FGahuView>();
                fcuView = this.container.Resolve <FGfcuView>();

                tabRegion.Add(ahuView, "FGahuView");
                tabRegion.Add(fcuView, "FGfcuView");
            }
            //tabRegion.Activate(ahuView);

            #region Generic Composite Buttons

            FGahuViewModel ahuViewModel = ahuView.DataContext as FGahuViewModel;
            FGfcuViewModel fcuViewModel = fcuView.DataContext as FGfcuViewModel;

            var navView = this.container.Resolve <FGNavigationItemView>();
            navView.CloseViewRequested += delegate
            {
                _applicationCommands.ImportFGCommand.UnregisterCommand(ahuViewModel.ImportFGCommand);
                _applicationCommands.ExportFGCommand.UnregisterCommand(ahuViewModel.ExportFGCommand);
                _applicationCommands.PrintLblCommand.UnregisterCommand(ahuViewModel.PrintLblCommand);
                _applicationCommands.DeleteFGCommand.UnregisterCommand(ahuViewModel.DeleteFGCommand);
                _applicationCommands.OKCommand.UnregisterCommand(ahuViewModel.OKCommand);
                _applicationCommands.XOKCommand.UnregisterCommand(ahuViewModel.XOKCommand);

                _applicationCommands.ImportFGCommand.UnregisterCommand(fcuViewModel.ImportFGCommand);
                _applicationCommands.ExportFGCommand.UnregisterCommand(fcuViewModel.ExportFGCommand);
                _applicationCommands.PrintLblCommand.UnregisterCommand(fcuViewModel.PrintLblCommand);
                _applicationCommands.DeleteFGCommand.UnregisterCommand(fcuViewModel.DeleteFGCommand);
                _applicationCommands.OKCommand.UnregisterCommand(fcuViewModel.OKCommand);
                _applicationCommands.XOKCommand.UnregisterCommand(fcuViewModel.XOKCommand);
            };

            _applicationCommands.ImportFGCommand.RegisterCommand(ahuViewModel.ImportFGCommand);
            _applicationCommands.ExportFGCommand.RegisterCommand(ahuViewModel.ExportFGCommand);
            _applicationCommands.PrintLblCommand.RegisterCommand(ahuViewModel.PrintLblCommand);
            _applicationCommands.DeleteFGCommand.RegisterCommand(ahuViewModel.DeleteFGCommand);
            _applicationCommands.OKCommand.RegisterCommand(ahuViewModel.OKCommand);
            _applicationCommands.XOKCommand.RegisterCommand(ahuViewModel.XOKCommand);

            _applicationCommands.ImportFGCommand.RegisterCommand(fcuViewModel.ImportFGCommand);
            _applicationCommands.ExportFGCommand.RegisterCommand(fcuViewModel.ExportFGCommand);
            _applicationCommands.PrintLblCommand.RegisterCommand(fcuViewModel.PrintLblCommand);
            _applicationCommands.DeleteFGCommand.RegisterCommand(fcuViewModel.DeleteFGCommand);
            _applicationCommands.OKCommand.RegisterCommand(fcuViewModel.OKCommand);
            _applicationCommands.XOKCommand.RegisterCommand(fcuViewModel.XOKCommand);

            #endregion Generic Composite Buttons
        }
Exemple #10
0
        public void Initialize()
        {
            IRegion mainRegion = this.regionManager.Regions["MainRegion"];

            mainRegion.Add(new HelloWorldView());
        }
Exemple #11
0
 private void CreateControlLine()
 {
     _controlLineRegion.Add(new ControlChangeLine(_viewModel.ControlChangeParameters, _viewModel.SelectedChannel), null, true);
 }
Exemple #12
0
        private void RenderHelloWorldView()
        {
            IRegion mainRegion = this.regionManager.Regions["MainRegion"];

            mainRegion.Add(new HelloWorldView());
        }
Exemple #13
0
 private void SideBar_Loaded(object sender, RoutedEventArgs e)
 {
     _dashboard = _container.Resolve <Dashboard>();
     _region    = _regionManager.Regions["ContentRegion"];
     _region.Add(_dashboard);
 }
Exemple #14
0
        private void InitViews()
        {
            IRegion mainRegion = GetMainRegion();

            mainRegion.Add(container.Resolve <MainView>(), ViewNames.MainView);
        }
Exemple #15
0
        /// <summary>
        /// Gets the view to which the navigation request represented by <paramref name="navigationContext"/> applies.
        /// </summary>
        /// <param name="region">The region.</param>
        /// <param name="navigationContext">The context representing the navigation request.</param>
        /// <returns>
        /// The view to be the target of the navigation request.
        /// </returns>
        /// <remarks>
        /// If none of the views in the region can be the target of the navigation request, a new view
        /// is created and added to the region.
        /// </remarks>
        /// <exception cref="ArgumentException">when a new view cannot be created for the navigation request.</exception>
        public object LoadContent(IRegion region, NavigationContext navigationContext)
        {
            if (region == null)
            {
                throw new ArgumentNullException("region");
            }
            if (navigationContext == null)
            {
                throw new ArgumentNullException("navigationContext");
            }

            string candidateTargetContract = this.GetContractFromNavigationContext(navigationContext);

            var candidates = this.GetCandidatesFromRegion(region, candidateTargetContract);

            var acceptingCandidates =
                candidates.Where(
                    v =>
            {
                var navigationAware = v as INavigationAware;
                if (navigationAware != null && !navigationAware.IsNavigationTarget(navigationContext))
                {
                    return(false);
                }

                var frameworkElement = v as FrameworkElement;
                if (frameworkElement == null)
                {
                    return(true);
                }

                navigationAware = frameworkElement.DataContext as INavigationAware;
                return(navigationAware == null || navigationAware.IsNavigationTarget(navigationContext));
            });


            var view = acceptingCandidates.FirstOrDefault();

            if (view != null)
            {
                return(view);
            }
            string viewName = string.Empty;

            if (navigationContext.Parameters.Count() > 0)
            {
                viewName = navigationContext.Parameters[DefaultViewName] as string;
            }

            view = this.CreateNewRegionItem(candidateTargetContract);

            if (!string.IsNullOrEmpty(viewName))
            {
                Type currentType     = view.GetType();
                var  currentProperty = currentType.GetProperty("Header");
                if (currentProperty != null)
                {
                    currentProperty.SetValue(view, viewName);
                }

                var context = currentType.GetProperty("DataContext");
                if (context != null)
                {
                    var dataContext = context.GetValue(view);
                    var info        = dataContext.GetType().GetProperty("Header");
                    if (info != null)
                    {
                        info.SetValue(dataContext, viewName);
                    }
                }

                /*
                 * if (view != null)
                 * {
                 *  Type currentType = view.GetType();
                 *
                 *  var currentProperty = currentType.GetProperty("Header");
                 *  if (currentProperty != null)
                 *  {
                 *      currentProperty.SetValue(view, viewName);
                 *  }
                 *  var context = currentType.GetProperty("DataContext");
                 *  if (context != null)
                 *  {
                 *      var dataContext = context.GetValue(view);
                 *      var info = dataContext.GetType().GetProperty("Header");
                 *      if (info != null)
                 *      {
                 *          info.SetValue(dataContext, viewName);
                 *      }
                 *
                 *  }
                 *
                 * }
                 */
            }


            if (string.IsNullOrEmpty(viewName))
            {
                region.Add(view, null, CreateRegionManagerScope(view));
            }
            else
            {
                // here is slow.
                Stopwatch start = new Stopwatch();
                start.Start();
                ///region.Add(view, viewName, false);
                region.Add(view, viewName, CreateRegionManagerScope(view));
                start.Stop();
                var elapsedTome = start.ElapsedMilliseconds;
            }

            if (view is UserControl control)
            {
                control.Focus();
            }
            // Stopwatch start = new Stopwatch();
//            start.Start();

            //  region.Add(view, null, CreateRegionManagerScope(view));
            //   start.Stop();
            //  var el = start.ElapsedMilliseconds;
            //  var k = 1;
            return(view);
        }
Exemple #16
0
 /// <summary>
 /// Adds the view to the region.
 /// </summary>
 /// <param name="region">The region to add the view to</param>
 /// <param name="view">The view to add to the region</param>
 protected virtual void AddViewToRegion(IRegion region, object view)
 {
     region.Add(view);
 }
Exemple #17
0
 public static void AddToRegionScopedRMAware(this IRegion region, object item)
 {
     region.Add(item, null, true).SetRMAware(item);
     region.Activate(item);
 }
        /// <summary>
        /// Gets the view to which the navigation request represented by <paramref name="navigationContext"/> applies.
        /// </summary>
        /// <param name="region">The region.</param>
        /// <param name="navigationContext">The context representing the navigation request.</param>
        /// <returns>The view to be the target of the navigation request.</returns>
        /// <exception cref="ArgumentException">When a new view cannot be created for the navigation request.</exception>
        public virtual object LoadContent( IRegion region, NavigationContext navigationContext )
        {
            if ( region == null )
            {
                throw new ArgumentNullException ( "region" );
            }
            if ( navigationContext == null )
            {
                throw new ArgumentNullException ( "navigationContext" );
            }
            _logger.Debug ( "Navigation request - Region: {0} - Uri: {1}", region.Name, navigationContext.Uri );

            var candidateTargetContract = GetContractFromNavigationContext ( navigationContext );

            var candidates = GetCandidatesFromRegion ( region, candidateTargetContract );

            var acceptingCandidates =
                candidates.Where (
                    v =>
                        {
                            var navigationAware = v as INavigationAware;
                            if ( navigationAware != null && !navigationAware.IsNavigationTarget ( navigationContext ) )
                            {
                                return false;
                            }

                            var frameworkElement = v as FrameworkElement;
                            if ( frameworkElement == null )
                            {
                                return true;
                            }

                            navigationAware = frameworkElement.DataContext as INavigationAware;
                            return navigationAware == null || navigationAware.IsNavigationTarget ( navigationContext );
                        } );

            var view = acceptingCandidates.FirstOrDefault ();

            if ( view != null )
            {
                return view;
            }

            view = CreateNewRegionItem ( candidateTargetContract );

            var createScopedRegion = region.Behaviors.ContainsKey ( "CreateScopedRegionBehavior" );
            var regionManager = region.Add ( view, null, createScopedRegion );

            TrySetRegionManager ( view, regionManager );

            return view;
        }
Exemple #19
0
 private void MainWindow_Loaded(object sender, RoutedEventArgs e)
 {
     viewB   = _container.Resolve <ViewB>();
     _region = _regionManager.Regions["ABRegion"];
     _region.Add(viewB);
 }