Beispiel #1
0
        public async Task <IViewComponentResult> InvokeAsync(string currentPageName = null)
        {
            NavManage navObj = new NavManage();

            //var navString = CacheManage.GetNavCache();
            //if (navString == null)
            //{
            //    navString = ViewHelper.RenderPartialViewToString(this, "_navTemplate");
            //    CacheManage.SetNavCache(navString);
            //}
            var navString = await viewRenderService.RenderToStringAsync(this.ViewContext, "_NavTemplate", currentPageName);

            //var navString = ViewHelper.RenderPartialViewToString(this, "_navTemplate");

            navObj.Read(navString);
            List <Nav> navList = navObj.ToViewList();

            //ViewBag.CurrentPageName  = currentPageName;

            var sidebarModel = new SidebarViewModel
            {
                Menu            = navList,
                CurrentPageName = currentPageName
            };

            return(View("Default", sidebarModel));
        }
Beispiel #2
0
        public async Task <IViewComponentResult> InvokeAsync()
        {
            var user = await _userManager.GetUserAsync(UserClaimsPrincipal);

            var model = new SidebarViewModel
            {
                HealthPoints         = user.HealthPoints,
                MaxHealthPoints      = user.MaxHealthPoints,
                HealthPointsProgress = (int)(((float)user.HealthPoints / user.MaxHealthPoints) * 100),
                ActionPoints         = user.ActionPoints,
                MaxActionPoints      = user.MaxActionPoints,
                ActionPointsProgress = (int)(((float)user.ActionPoints / user.MaxActionPoints) * 100),
                Level                    = user.Level,
                ExperiencePoints         = user.ExperiencePoints,
                MaxExperiencePoints      = user.MaxExperiencePoints,
                ExperiencePointsProgress = (int)(((float)user.ExperiencePoints / user.MaxExperiencePoints) * 100),
                Gold         = user.Gold,
                Strength     = user.Strength,
                Dexterity    = user.Dexterity,
                Stamina      = user.Stamina,
                Intelligence = user.Intelligence,
                SkillPoints  = user.SkillPoints
            };

            return(View(model));
        }
Beispiel #3
0
        private void AssembleMainWindow()
        {
            MainWindow = new MainWindow();

            //Initialize all the various modules here

            var dataPlotView  = (FrameworkElement)MainWindow.FindName("DataPlot");
            var chartView     = (ICustomChart)dataPlotView.FindName("theChart");
            var dataPlotModel = new DataPlotModel(chartView);
            //var dataPlotModel = new DataPlotModel();
            var dataPlotViewModel = new DataPlotViewModel(dataPlotModel, dataPlotView);

            dataPlotView.DataContext = dataPlotViewModel;

            var windowFactory     = new PieFactory();
            var dataSeriesFactory = new DataSeriesFactory();

            FMI.DataSeriesFactory     = dataSeriesFactory;
            Fingrid.DataSeriesFactory = dataSeriesFactory;

            var sidebarModel     = new SidebarModel(dataPlotModel, windowFactory);
            var sidebarViewModel = new SidebarViewModel(sidebarModel);
            var sidebarView      = ((FrameworkElement)MainWindow.FindName("Sidebar"));

            sidebarView.DataContext = sidebarViewModel;

            MainWindow.Show();
        }
Beispiel #4
0
        public IViewComponentResult Invoke(string subName, Guid?subId, bool showSearch, bool showCreateSub, bool showSubmit)
        {
            var model = new SidebarViewModel();

            model.ShowSearch    = showSearch;
            model.ShowCreateSub = showCreateSub;
            model.ShowSubmit    = showSubmit;

            var currentUser = _userContext.CurrentUser;

            if (subId.HasValue)
            {
                model.CurrentSub = _subWrapper.Wrap(_subDao.GetSubById(subId.Value), _userContext.CurrentUser);
            }
            else if (!string.IsNullOrEmpty(subName))
            {
                model.CurrentSub = _subWrapper.Wrap(_subDao.GetSubByName(subName), _userContext.CurrentUser);
            }

            if (model.CurrentSub != null)
            {
                if (_userContext.CurrentUser != null)
                {
                    model.Permissions = _moderationDao.GetUserPermissionsForSub(_userContext.CurrentUser, model.CurrentSub.Sub.Id);
                }

                if (!model.IsModerator)
                {
                    // we only show list of mods if the requesting user is not a mod of this sub
                    model.Moderators = _membershipDao.GetUsersByIds(_moderationDao.GetAllModsForSub(model.CurrentSub.Sub.Id).Select(x => x.UserId).ToList());
                }

                // get the number of active users currently viewing this sub.
                // for normal users, this number may be fuzzed (if low enough) for privacy reasons.
                if (_userContext.CurrentUser != null && _userContext.CurrentUser.IsAdmin)
                {
                    model.NumberOfActiveUsers = _subActivityDao.GetActiveNumberOfUsersForSub(model.CurrentSub.Sub.Id);
                }
                else
                {
                    bool wasFuzzed;
                    model.NumberOfActiveUsers         = _subActivityDao.GetActiveNumberOfUsersForSubFuzzed(model.CurrentSub.Sub.Id, out wasFuzzed);
                    model.IsNumberOfActiveUsersFuzzed = wasFuzzed;
                }
            }

            if (model.ShowCreateSub)
            {
                if (currentUser != null)
                {
                    var age = Common.CurrentTime() - currentUser.CreatedDate;
                    if (currentUser.IsAdmin || age.TotalDays >= _subSettings.Settings.MinUserAgeCreateSub)
                    {
                        model.CanCreateSub = true;
                    }
                }
            }

            return(View(model));
        }
Beispiel #5
0
        public ActionResult Index()
        {
            var model = new SidebarViewModel();

            model.RecentPosts = this.Cache.Get(
                "RecentBlogPosts",
                () =>
                this.blogPosts.All()
                .OrderByDescending(x => x.CreatedOn)
                .Project()
                .To <RecentBlogPostViewModel>()
                .Take(5)
                .ToList(),
                600);

            model.Tags = this.tags.All().Project().To <TagViewModel>().OrderByDescending(x => x.PostsCount).ToList();

            model.RecentVideos = this.Cache.Get(
                "RecentVideos",
                () =>
            {
                if (string.IsNullOrWhiteSpace(ConfigurationManager.AppSettings["YouTubeApiKey"]))
                {
                    return(new List <VideoListItemViewModel>());
                }

                return
                (new LatestVideosProvider(ConfigurationManager.AppSettings["YouTubeApiKey"]).GetLatestVideos(
                     5,
                     "UULC-vbm7OWvpbqzXaoAMGGw").Project().To <VideoListItemViewModel>().ToList());
            },
                7200);

            return(this.PartialView("_SidebarPartial", model));
        }
Beispiel #6
0
        public RootViewModel(
            IKernel kernel,
            IEventAggregator eventAggregator,
            ISettingsService settingsService,
            ICoreService coreService,
            IWindowManager windowManager,
            IDebugService debugService,
            IRegistrationService builtInRegistrationService,
            IMessageService messageService,
            SidebarViewModel sidebarViewModel)
        {
            _kernel                     = kernel;
            _eventAggregator            = eventAggregator;
            _settingsService            = settingsService;
            _coreService                = coreService;
            _windowManager              = windowManager;
            _debugService               = debugService;
            _builtInRegistrationService = builtInRegistrationService;
            _messageService             = messageService;
            _sidebarViewModel           = sidebarViewModel;
            _frameTimeUpdateTimer       = new Timer(500);

            _windowSize = _settingsService.GetSetting <WindowSize>("UI.RootWindowSize");
            _sidebarViewModel.ConductWith(this);

            ActiveItem      = sidebarViewModel.SelectedItem;
            ActiveItemReady = true;
            PinSidebar      = _settingsService.GetSetting("UI.PinSidebar", false);

            AssemblyInformationalVersionAttribute versionAttribute = typeof(RootViewModel).Assembly.GetCustomAttribute <AssemblyInformationalVersionAttribute>();

            WindowTitle = $"Artemis {versionAttribute?.InformationalVersion} build {Constants.BuildInfo.BuildNumberDisplay}";
        }
Beispiel #7
0
        public RootViewModel(
            IEventAggregator eventAggregator,
            ISettingsService settingsService,
            ICoreService coreService,
            IDebugService debugService,
            IRegistrationService builtInRegistrationService,
            ISnackbarMessageQueue snackbarMessageQueue,
            SidebarViewModel sidebarViewModel)
        {
            SidebarViewModel            = sidebarViewModel;
            _eventAggregator            = eventAggregator;
            _coreService                = coreService;
            _debugService               = debugService;
            _builtInRegistrationService = builtInRegistrationService;
            _snackbarMessageQueue       = snackbarMessageQueue;

            _frameTimeUpdateTimer = new Timer(500);

            _colorScheme = settingsService.GetSetting("UI.ColorScheme", ApplicationColorScheme.Automatic);
            _windowSize  = settingsService.GetSetting <WindowSize>("UI.RootWindowSize");

            _themeWatcher = new ThemeWatcher();
            ApplyColorSchemeSetting();

            ActiveItem      = SidebarViewModel.SelectedItem;
            ActiveItemReady = true;

            AssemblyInformationalVersionAttribute?versionAttribute = typeof(RootViewModel).Assembly.GetCustomAttribute <AssemblyInformationalVersionAttribute>();

            WindowTitle = $"Artemis {versionAttribute?.InformationalVersion}";
        }
 public IViewComponentResult Invoke(SidebarViewModel model)
 {
     SetPinnedUserToolsEnabme();
     SetScrambleToolsEnable(model.CategoryID);
     _model.SetOverallVisibility();
     return(View(_model));
 }
Beispiel #9
0
        public async Task <IViewComponentResult> InvokeAsync(string currentPageName = null)
        {
            var sidebarModel = new SidebarViewModel
            {
                Menu            = await _userNavigationManager.GetMenuAsync(AppAreaNameNavigationProvider.MenuName, _abpSession.ToUserIdentifier()),
                CurrentPageName = currentPageName
            };

            if (AbpSession.TenantId == null)
            {
                return(View(sidebarModel));
            }

            var tenant = await _tenantManager.GetByIdAsync(AbpSession.TenantId.Value);

            if (tenant.EditionId.HasValue)
            {
                return(View(sidebarModel));
            }

            var subscriptionManagement = FindMenuItemOrNull(sidebarModel.Menu.Items, AppAreaNamePageNames.Tenant.SubscriptionManagement);

            if (subscriptionManagement != null)
            {
                subscriptionManagement.IsVisible = false;
            }

            return(View(sidebarModel));
        }
Beispiel #10
0
        public IViewComponentResult Invoke()
        {
            SidebarViewModel model = new SidebarViewModel();

            model.RecentPosts      = _postRepository.GetRecentPosts(10);
            model.ActiveCategories = _categoryRepository.GetAllWithPosts();
            return(View(model));
        }
Beispiel #11
0
        public ActionResult EditSidebar()
        {
            SidebarViewModel sidebar;
            var sidebarDto = _context.Sidebars.Find(1);

            sidebar = new SidebarViewModel(sidebarDto);
            return(View(sidebar));
        }
Beispiel #12
0
        /// <summary>
        /// Adds all items to the navigation sidebar
        /// </summary>
        public async Task AddAllItemsToSidebar()
        {
            await SidebarControl.SideBarItemsSemaphore.WaitAsync();

            if (IconResources is null)
            {
                IconResources = (await SidebarViewModel.LoadSidebarIconResources())?.ToList();
            }

            homeSection = new LocationItem()
            {
                Text              = "SidebarHome".GetLocalized(),
                Section           = SectionType.Home,
                Font              = MainViewModel.FontName,
                IsDefaultLocation = true,
                Icon              = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri("ms-appx:///Assets/FluentIcons/Home.png")),
                Path              = "Home",
                ChildItems        = new ObservableCollection <INavigationControlItem>()
            };
            favoriteSection = new LocationItem()
            {
                Text             = "SidebarFavorites".GetLocalized(),
                Section          = SectionType.Favorites,
                SelectsOnInvoked = false,
                Icon             = UIHelpers.GetImageForIconOrNull(IconResources?.FirstOrDefault(x => x.Index == Constants.Shell32.QuickAccess).Image),
                Font             = MainViewModel.FontName,
                ChildItems       = new ObservableCollection <INavigationControlItem>()
            };
            try
            {
                SidebarControl.SideBarItems.BeginBulkOperation();

                if (homeSection != null)
                {
                    AddItemToSidebarAsync(homeSection);
                }

                for (int i = 0; i < FavoriteItems.Count(); i++)
                {
                    string path = FavoriteItems[i];
                    await AddItemToSidebarAsync(path);
                }

                if (!SidebarControl.SideBarItems.Contains(favoriteSection))
                {
                    SidebarControl.SideBarItems.Add(favoriteSection);
                }

                SidebarControl.SideBarItems.EndBulkOperation();
            }
            finally
            {
                SidebarControl.SideBarItemsSemaphore.Release();
            }

            await ShowHideRecycleBinItemAsync(App.AppSettings.PinRecycleBinToSideBar);
        }
 public ActionResult EditSidebar()
 {
     using (Db db = new Db())
     {
         SidebarDto       dto   = db.Sidebars.Find(1);
         SidebarViewModel model = new SidebarViewModel(dto);
         return(View(model));
     }
 }
        public void Call_For_Data_When_Constructed()
        {
            // Arrange
            var dataReader = new FakeReader();
            var viewModel  = new SidebarViewModel(dataReader);

            // Assert
            Assert.AreEqual(true, viewModel.FetchDataOnConstruction);
        }
        public IViewComponentResult Invoke()
        {
            var model = new SidebarViewModel
            {
                Ads = this.adRepo.All().OrderByDescending(x => x.CreatedOn).To <AdViewModel>().Take(5).ToList(),
            };

            return(this.View(model));
        }
        public SidebarViewModel GetViewModelForArticlePage(ArticlePage composition)
        {
            var viewModel = new SidebarViewModel()
            {
                PrimaryCallToActionButton = _navigationItemService.GetViewModel(composition.SidebarPrimaryCallToActionButton),
                SeeAlsoLinks = _navigationItemService.GetViewModels(composition.SidebarSeeAlsoLinks)
            };

            return(viewModel);
        }
Beispiel #17
0
        public ActionResult EditSidebar([FromBody] SidebarViewModel model)
        {
            SidebarViewModel sidebar;
            var sidebarDto = _context.Sidebars.Find(1);

            sidebarDto.Body = model.Body;
            _context.SaveChanges();
            TempData["SM"] = "Edytowałeś pasek boczny";
            return(RedirectToAction(nameof(EditSidebar)));
        }
Beispiel #18
0
        //[ChildActionOnly] //这里不注释的话就会报错The action 'Sidebar' is accessible only by a child request.
        public JsonResult Sidebar(string currentPageName = "")
        {
            var sidebarModel = new SidebarViewModel
            {
                Menu            = AsyncHelper.RunSync(() => _userNavigationManager.GetMenuAsync(SystemInfoNavigationProvider.MenuName, new Abp.UserIdentifier(AbpSession.TenantId, AbpSession.GetUserId()))),
                CurrentPageName = currentPageName
            };

            return(Json(sidebarModel));
        }
Beispiel #19
0
        public PartialViewResult Sidebar(string currentPageName = "")
        {
            var sidebarModel = new SidebarViewModel
            {
                Menu            = AsyncHelper.RunSync(() => _userNavigationManager.GetMenuAsync(MpaNavigationProvider.MenuName, AbpSession.ToUserIdentifier())),
                CurrentPageName = currentPageName
            };

            return(PartialView("_Sidebar", sidebarModel));
        }
Beispiel #20
0
        public PartialViewResult Sidebar()
        {
            var model = new SidebarViewModel
            {
                User = UserManager.FindById(User.Identity.GetUserId()),
                Role = UserManager.GetRoles(User.Identity.GetUserId()).FirstOrDefault()
            };

            return(PartialView("_Sidebar", model));
        }
        public async Task <IViewComponentResult> InvokeAsync(string currentPageName = null)
        {
            var sidebarModel = new SidebarViewModel
            {
                Menu            = await _userNavigationManager.GetMenuAsync(AdminNavigationProvider.MenuName, _abpSession.ToUserIdentifier()),
                CurrentPageName = currentPageName
            };

            return(View(sidebarModel));
        }
Beispiel #22
0
        public Sidebar(IContainerExtension container, IRegionManager regionManager, SidebarViewModel viewModel)
        {
            InitializeComponent();
            this.DataContext   = viewModel;
            this.container     = container;
            this.regionManager = regionManager;
            this.viewModel     = viewModel;

            this.Loaded += Sidebar_Loaded;
        }
Beispiel #23
0
        public async Task <IViewComponentResult> InvokeAsync()
        {
            var currentUserId = Request.HttpContext.User.FindFirstValue(ClaimTypes.NameIdentifier);

            var sidebarVm = new SidebarViewModel()
            {
                UserId = currentUserId
            };

            return(View("Default", sidebarVm));
        }
Beispiel #24
0
        // GET: Admin/Pages/EditSidebar
        public ActionResult EditSidebar()
        {
            SidebarViewModel sidebarViewModel;

            using (var db = new Db())
            {
                SidebarDto dto = db.Sidebar.Find(1);
                sidebarViewModel = new SidebarViewModel(dto);
            }
            return(View(sidebarViewModel));
        }
        public ActionResult SidebarPartial()
        {
            SidebarViewModel sidebarViewModel;

            using (Db db = new Db())
            {
                sidebarViewModel = new SidebarViewModel(db.Sidebar.Find(1));
            }

            return(PartialView(sidebarViewModel));
        }
Beispiel #26
0
        public ActionResult Sidebar()
        {
            SidebarViewModel model = new SidebarViewModel
            {
                LatestNews     = _newsRepository.GetAll().OrderByDescending(x => x.CreatedDate).Take(4),
                LatestComments = _commentRepository.GetAll().OrderByDescending(x => x.CreatedDate).Take(4),
                PopularNews    = _newsRepository.GetAll().OrderByDescending(x => x.Reads).Take(4),
            };

            return(View(model));
        }
        public ActionResult SidebarPartial()
        {
            SidebarViewModel sdbVM;

            using (Db db = new Db())
            {
                SideBar sd = db.sidebar.Find(1);
                sdbVM = new SidebarViewModel(sd);
            }
            return(PartialView(sdbVM));
        }
        public ActionResult EditSidebar()
        {
            SidebarViewModel model;

            using (Db db = new Db())
            {
                SideBar sidebar = db.sidebar.Find(1);
                model = new SidebarViewModel(sidebar);
            }
            return(View(model));
        }
        public void SidebarViewModel_onStart_Gets_FilteredStocks()
        {
            // Arrange
            IStockReader     dataReader = new FakeReader();
            SidebarViewModel viewModel  = new SidebarViewModel(dataReader);

            Thread.Sleep(1000);

            // Assert
            Assert.IsNotNull(viewModel.FilteredStocks);
            Assert.AreEqual(2, viewModel.FilteredStocks.Count);
        }
        public void FilterStockSymbols_Are_Filtered()
        {
            //Arrange
            IStockReader     dataReader = new FakeReader();
            SidebarViewModel viewModel  = new SidebarViewModel(dataReader);

            //Act
            viewModel.FilterStockSymbols("abb");

            //Assert
            Assert.IsNotNull(viewModel.FilteredStocks);
        }
Beispiel #31
0
        public PartialViewResult Index()
        {
            var recentPosts = this.Data.Posts
                .All()
                .OrderByDescending(p => p.CreatedOn)
                .To<RecentPostViewModel>()
                .Take(5);

            var model = new SidebarViewModel
            {
                RecentPosts = recentPosts.ToList()
            };

            return this.PartialView(model);
        }
        public ActionResult SideBar(string subName, Guid? subId, bool showSearch = true, bool showCreateSub = true, bool showSubmit = true)
        {
            var model = new SidebarViewModel();
            model.ShowSearch = showSearch;
            model.ShowCreateSub = showCreateSub;
            model.ShowSubmit = showSubmit;

            var currentUser = _userContext.CurrentUser;

            if (subId.HasValue)
                model.CurrentSub = _subWrapper.Wrap(_subDao.GetSubById(subId.Value), _userContext.CurrentUser);
            else if (!string.IsNullOrEmpty(subName))
                model.CurrentSub = _subWrapper.Wrap(_subDao.GetSubByName(subName), _userContext.CurrentUser);

            if (model.CurrentSub != null)
            {
                if (_userContext.CurrentUser != null)
                    model.Permissions = _subModerationDao.GetUserPermissionsForSub(_userContext.CurrentUser, model.CurrentSub.Sub.Id);

                if (!model.IsModerator)
                    // we only show list of mods if the requesting user is not a mod of this sub
                    model.Moderators = _membershipService.GetUsersByIds(_subModerationDao.GetAllModsForSub(model.CurrentSub.Sub.Id).Select(x => x.UserId).ToList());

                // get the number of active users currently viewing this sub.
                // for normal users, this number may be fuzzed (if low enough) for privacy reasons.
                if (_userContext.CurrentUser != null && _userContext.CurrentUser.IsAdmin)
                    model.NumberOfActiveUsers = _subActivityDao.GetActiveNumberOfUsersForSub(model.CurrentSub.Sub.Id);
                else
                {
                    bool wasFuzzed;
                    model.NumberOfActiveUsers = _subActivityDao.GetActiveNumberOfUsersForSubFuzzed(model.CurrentSub.Sub.Id, out wasFuzzed);
                    model.IsNumberOfActiveUsersFuzzed = wasFuzzed;
                }
            }

            if (model.ShowCreateSub)
            {
                if (currentUser != null)
                {
                    var age = Common.CurrentTime() - currentUser.CreatedDate;
                    if (currentUser.IsAdmin || age.TotalDays >= _subSettings.Settings.MinUserAgeCreateSub)
                        model.CanCreateSub = true;
                }
            }

            return PartialView("SideBar", model);
        }