public MainViewModel() { _windowState = (WindowState)Enum.Parse(typeof(WindowState), Services.UiConfig.WindowState); _windowWidth = Services.UiConfig.WindowWidth ?? 1280; _windowHeight = Services.UiConfig.WindowHeight ?? 960; var(x, y) = (Services.UiConfig.WindowX, Services.UiConfig.WindowY); if (x != null && y != null) { _windowPosition = new PixelPoint(x.Value, y.Value); } _dialogScreen = new DialogScreenViewModel(); _fullScreen = new DialogScreenViewModel(NavigationTarget.FullScreen); _compactDialogScreen = new DialogScreenViewModel(NavigationTarget.CompactDialogScreen); MainScreen = new TargettedNavigationStack(NavigationTarget.HomeScreen); NavigationState.Register(MainScreen, DialogScreen, FullScreen, CompactDialogScreen); _isMainContentEnabled = true; _isDialogScreenEnabled = true; _isFullScreenEnabled = true; _statusBar = new StatusBarViewModel(); UiServices.Initialize(); _addWalletPage = new AddWalletPageViewModel(); _settingsPage = new SettingsPageViewModel(); _privacyMode = new PrivacyModeViewModel(); _navBar = new NavBarViewModel(MainScreen); MusicControls = new MusicControlsViewModel(); NavigationManager.RegisterType(_navBar); RegisterViewModels(); RxApp.MainThreadScheduler.Schedule(async() => await _navBar.InitialiseAsync()); this.WhenAnyValue(x => x.WindowState, x => x.WindowPosition, x => x.WindowWidth, x => x.WindowHeight) .Where(x => x.Item1 != WindowState.Minimized) .Where(x => x.Item2 != new PixelPoint(-32000, -32000)) // value when minimized .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(t => { var(state, position, width, height) = t; Services.UiConfig.WindowState = state.ToString(); if (position is { }) { Services.UiConfig.WindowX = position.Value.X; Services.UiConfig.WindowY = position.Value.Y; } Services.UiConfig.WindowWidth = width; Services.UiConfig.WindowHeight = height; });
private void BindingNavBar() { var navBarViewModel = new NavBarViewModel(); var categories = _feedManager.GetCategories(); categories.ForEach(c => { navBarViewModel.FirstBrothers.Add(new Brother() { Id = c.Id.ToString(), Name = c.Name, ImageUri = c.ImageUri.ToString().StartsWith("/") ? c.ImageUri : new Uri("/" + c.ImageUri.ToString(), UriKind.Relative), Stats = CategoryHelper.GetStatsString(c.Id), Selected = c.Id.Equals(_viewModel.Id), PostAction = ViewModels.PostAction.Binding, BindingData = new BindingData() { CategoryId = c.Id, PublisherId = default(Guid), FeedId = default(Guid) } }); }); NavBar.BindingNavBar(navBarViewModel); NavBar.SelectedEvent -= NavBar_SelectedEvent; NavBar.SelectedEvent += NavBar_SelectedEvent; NavBar.NavigateHome = (() => this.BackToMainPage()); }
public IViewComponentResult Invoke() { var viewModel = new NavBarViewModel(); viewModel.Years = this.yearsSercive.GetLastYears(5); return(this.View()); }
private void BindingNavBarForPrevCatPage() { var navBarViewModel = new NavBarViewModel(); var categories = _feedManager.GetCategories(); categories.ForEach(c => { navBarViewModel.FirstBrothers.Add(new Brother() { Id = c.Id.ToString(), Name = c.Name, ImageUri = c.ImageUri.ToString().StartsWith("/") ? c.ImageUri : new Uri("/" + c.ImageUri.ToString(), UriKind.Relative), Stats = CategoryHelper.GetStatsString(c.Id), Selected = c.Id.Equals(_itemContainer.Id), PostAction = ViewModels.PostAction.Navigation, NavigateUri = new Uri(string.Format("/CategoryPage.xaml?categoryId={0}", c.Id), UriKind.Relative) }); }); NavBar.BindingNavBar(navBarViewModel); NavBar.Navigation = ((uri, id) => { DisposeAll(); if (!id.Equals(_itemContainer.Id)) { UserBehaviorManager.Instance.Log(UserAction.CatEnter, id); } NavigationService.Navigate(uri); }); NavBar.NavigateHome = (() => this.BackToMainPage()); }
public IViewComponentResult Invoke(int count) { var viewModel = new NavBarViewModel(); viewModel.Years = this.yearsService.GetLastYears(count); return(View(viewModel)); }
/// <summary> /// Invokes the Default Component /// </summary> /// <returns>A <see cref="T:System.Threading.Tasks.Task"/> task with the ViewComponent.</returns> public async Task <IViewComponentResult> InvokeAsync(string activeLink) { NavBarViewModel vm = new NavBarViewModel { ActiveLink = activeLink }; return(View(vm)); }
public void MessagePropertyValueUpdated() { var vm = new NavBarViewModel(_regionManagerMock.Object, _messageServiceMock.Object); _messageServiceMock.Verify(x => x.GetMessage(), Times.Once); Assert.Equal(MessageServiceDefaultMessage, vm.Message); }
public Task <IViewComponentResult> InvokeAsync() { NavBarViewModel navBarViewModel = new NavBarViewModel() { applicationUser = user, currentRoute = "/" }; return(Task.FromResult <IViewComponentResult>(View(navBarViewModel))); }
public IViewComponentResult Invoke() { var viewModel = new NavBarViewModel() { Categories = this.categoriesService.GetAll <CategoryIdNameViewModel>(), Galleries = this.galleryService.GetAll <GalleryIdNameViewModel>(), }; return(this.View(viewModel)); }
public ActionResult Mobile() { NavBarViewModel VM = new NavBarViewModel() { Product = db.Product.Where(p => p.DeletedDate == null).ToList(), SubCategory = db.Subcategory.Where(p => p.DeletedDate == null).ToList(), Category = db.Category.Where(p => p.DeletedDate == null).ToList() }; return(View(VM)); }
public IViewComponentResult Invoke() { var categories = this.service.AllCategoryNames(); var navBarItems = new NavBarViewModel { Privacy = "Privacy", AddProduct = "Add a Product", Category = "Categories", Categories = categories, }; return(this.View(navBarItems)); }
public async Task <IViewComponentResult> InvokeAsync() { var navBarItems = new List <NavBarItemViewModel>(); await Task.Run(() => { navBarItems.Add(new NavBarItemViewModel("Action 1", "#")); navBarItems.Add(new NavBarItemViewModel("Action 2", "#")); navBarItems.Add(new NavBarItemViewModel("Action 3", "#")); }); var viewModel = new NavBarViewModel(navBarItems); return(View(viewModel)); }
public IViewComponentResult Invoke() { var navBarViewModel = new NavBarViewModel(); UserDto user = HttpContext.Session.Get <UserDto>("User"); if (user != null) { navBarViewModel.IsLoggedIn = true; navBarViewModel.UserName = user.FirstName; navBarViewModel.IsChef = user.IsChef(); } return(View("NavBarViewComponent", navBarViewModel)); }
public ActionResult Navbar() { var model = new NavBarViewModel() { User = User.IsInRole("User"), Manager = User.IsInRole("Manager"), Dispatcher = User.IsInRole("Dispatcher"), Solver = User.IsInRole("Solver"), Administrator = User.IsInRole("Administrator") } ; return(PartialView("_Navbar", model)); }
public IViewComponentResult Invoke() { var model = new NavBarViewModel { SiteName = _configuration["Site:SiteName"] }; // Numero de mensajes de contacto. if (User.Identity.IsAuthenticated && User.IsInRole("Admins")) { model.ContactUnreadMessages = _contactRepository.GetUnreadMessages().Count(); } return(View(model)); }
// GET: api/PublicitNavBars public List <NavBarViewModel> GetPublicitNavBars() { List <NavBarViewModel> ListNav = new List <NavBarViewModel>(); var nv = db.PublicitNavBars.ToList(); foreach (var n in nv) { NavBarViewModel nvb = new NavBarViewModel(); nvb.ID = n.ID; nvb.Pub_image = n.Pub_image; nvb.Pub_title = n.Pub_title; ListNav.Add(nvb); } return(ListNav); }
private void BindingNavBarForPrevStoredItemsPage() { var navBarViewModel = new NavBarViewModel(); navBarViewModel.SecondBrothers.Add(new Brother() { Id = null, Name = "tin đã lưu", ImageUri = null, Stats = "lưu các tin hay trên điện thoại", Selected = true, NavigateUri = null }); navBarViewModel.SecondBrothers.Add(new Brother() { Id = null, Name = "xem theo báo", ImageUri = null, Stats = "xem theo các đầu báo đã cài", Selected = true, PostAction = ViewModels.PostAction.Navigation, NavigateUri = new Uri("/HubTilePage.xaml", UriKind.Relative) }); navBarViewModel.SecondBrothers.Add(new Brother() { Id = null, Name = "xem theo mục", ImageUri = null, Stats = "xem nhóm các báo theo chuyên mục", Selected = true, PostAction = ViewModels.PostAction.Navigation, NavigateUri = new Uri("/CustomViewPage.xaml", UriKind.Relative) }); NavBar.BindingNavBar(navBarViewModel); NavBar.Navigation = ((uri, id) => { DisposeAll(); NavigationService.Navigate(uri); }); NavBar.NavigateHome = (() => this.BackToMainPage()); }
public void BindingNavBar(NavBarViewModel viewModel) { if (viewModel == null) { throw new ApplicationException("ViewModel is null"); } LayoutRoot.Visibility = System.Windows.Visibility.Collapsed; var showBoth = viewModel.FirstBrothers != null && viewModel.FirstBrothers.Count > 1 && viewModel.SecondBrothers != null && viewModel.SecondBrothers.Count > 1; BindBrothers(lpkFirstBrothers, txtFirstBrother, viewModel.FirstBrothers, showBoth); BindBrothers(lpkSecondBrothers, txtSecondBrother, viewModel.SecondBrothers, showBoth); imgSeparator2.Visibility = showBoth ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed; txtHome.Tap += txtHome_Tap; LayoutRoot.Visibility = System.Windows.Visibility.Visible; }
public IViewComponentResult Invoke(string color = null, string size = null, string brandName = null, string searchString = null) { var navBarItems = new List <NavBarItemViewModel>(); var parentCategories = this.categoryService.GetAllParentCategories <CategoryViewModel>(); if (parentCategories != null) { foreach (var parenCategory in parentCategories) { var subCategories = this.categoryService.GetAllSubCategoriesByParentId <CategoryViewModel>(parenCategory.Id); var navBarItem = new NavBarItemViewModel(); navBarItem.ParentCategory = parenCategory; if (subCategories != null) { navBarItem.SubCategories = subCategories; } else { navBarItem.SubCategories = new List <CategoryViewModel>(); } navBarItems.Add(navBarItem); } } var viewModel = new NavBarViewModel() { NavBarItems = navBarItems, }; viewModel.Color = color; viewModel.Size = size; viewModel.BrandName = brandName; viewModel.SearchString = searchString; return(this.View(viewModel)); }
private void BindingNavBar() { var navBarViewModel = new NavBarViewModel(); var subscribedPublisher = _feedManager.GetSubscribedPublishers(); subscribedPublisher.Target.ForEach(p => { navBarViewModel.FirstBrothers.Add(new Brother() { Id = p.Id.ToString(), Name = p.Name, ImageUri = p.ImageUri.ToString().StartsWith("/") ? p.ImageUri : new Uri("/" + p.ImageUri.ToString(), UriKind.Relative), Stats = PublisherHelper.GetStatsString(p.Id), Selected = p.Id.Equals(_viewModel.Publisher.Id), PostAction = ViewModels.PostAction.Binding, BindingData = new BindingData() { PublisherId = p.Id, FeedId = p.FeedIds[0], CategoryId = default(Guid) } }); }); navBarViewModel.FirstBrothers.Add(new Brother() { Id = string.Empty, Name = string.Empty, ImageUri = new Uri("/Images/publishers/install.png", UriKind.Relative), Stats = "cài thêm hoặc gỡ bớt báo", Selected = false, PostAction = PostAction.Navigation, NavigateUri = new Uri("/PublisherPickupPage.xaml", UriKind.Relative) }); _currentPublisher.FeedIds.ForEach(f => { var feedResult = _feedManager.GetSubscribedFeed(f); if (feedResult.HasError) { return; } navBarViewModel.SecondBrothers.Add(new Brother() { Id = f.ToString(), Name = feedResult.Target.Name, ImageUri = null, Stats = FeedHelper.GetStatsString(f), Selected = f.Equals(_viewModel.Id), PostAction = ViewModels.PostAction.Binding, BindingData = new BindingData() { PublisherId = feedResult.Target.Publisher.Id, FeedId = f, CategoryId = default(Guid) } }); }); if (_currentPublisher.FeedIds.Count > 1) { navBarViewModel.SecondBrothers.Add(new Brother() { Id = string.Empty, Name = "Cài thêm chuyên mục", ImageUri = null, Stats = "hoặc gỡ bớt chuyên mục không thích", Selected = false, PostAction = PostAction.Navigation, NavigateUri = new Uri("/FeedPickupPage.xaml?publisherId=" + _currentPublisher.Id.ToString(), UriKind.Relative) }); } NavBar.BindingNavBar(navBarViewModel); NavBar.SelectedEvent -= NavBar_Selected; NavBar.SelectedEvent += NavBar_Selected; NavBar.Navigation = ((uri, id) => NavigationService.Navigate(uri)); NavBar.NavigateHome = (() => this.BackToMainPage()); }
private void BindingNavBarForPrevFeedPage() { var navBarViewModel = new NavBarViewModel(); var item = _itemContainer.AllItemViewModels[_currentIndex]; var subscribedPublisher = _feedManager.GetSubscribedPublishers(); subscribedPublisher.Target.ForEach(p => { navBarViewModel.FirstBrothers.Add(new Brother() { Id = p.Id.ToString(), Name = p.Name, ImageUri = p.ImageUri.ToString().StartsWith("/") ? p.ImageUri : new Uri("/" + p.ImageUri.ToString(), UriKind.Relative), Stats = PublisherHelper.GetStatsString(p.Id), Selected = p.Id.Equals(_itemContainer.Publisher.Id), PostAction = ViewModels.PostAction.Navigation, NavigateUri = new Uri(string.Format("/FeedPage.xaml?publisherId={0}&feedId={1}", p.Id, p.FeedIds[0]), UriKind.Relative) }); }); navBarViewModel.FirstBrothers.Add(new Brother() { Id = string.Empty, Name = string.Empty, ImageUri = new Uri("/Images/publishers/install.png", UriKind.Relative), Stats = "cài thêm hoặc gỡ bớt báo", Selected = false, PostAction = PostAction.Navigation, NavigateUri = new Uri("/PublisherPickupPage.xaml", UriKind.Relative) }); _itemContainer.Publisher.FeedIds.ForEach(f => { var feedResult = _feedManager.GetSubscribedFeed(f); if (feedResult.HasError) { return; } navBarViewModel.SecondBrothers.Add(new Brother() { Id = f.ToString(), Name = feedResult.Target.Name, ImageUri = null, Stats = FeedHelper.GetStatsString(f), Selected = f.Equals(_itemContainer.Id), PostAction = ViewModels.PostAction.Navigation, NavigateUri = new Uri(string.Format("/FeedPage.xaml?publisherId={0}&feedId={1}", _itemContainer.Publisher.Id, f), UriKind.Relative) }); }); if (_itemContainer.Publisher.FeedIds.Count > 1) { navBarViewModel.SecondBrothers.Add(new Brother() { Id = string.Empty, Name = "Cài thêm chuyên mục", ImageUri = null, Stats = "hoặc gỡ bớt chuyên mục không thích", Selected = false, PostAction = PostAction.Navigation, NavigateUri = new Uri("/FeedPickupPage.xaml?publisherId=" + _itemContainer.Publisher.Id.ToString(), UriKind.Relative) }); } NavBar.BindingNavBar(navBarViewModel); NavBar.Navigation = ((uri, id) => { DisposeAll(); if (!id.Equals(_itemContainer.Publisher.Id)) { UserBehaviorManager.Instance.Log(UserAction.PubEnter, _itemContainer.Publisher.Id.ToString()); } if (!id.Equals(_itemContainer.Id)) { UserBehaviorManager.Instance.Log(UserAction.FeedEnter, _itemContainer.Id.ToString()); } NavigationService.Navigate(uri); }); NavBar.NavigateHome = (() => this.BackToMainPage()); }
public MainViewModel() { _windowState = (WindowState)Enum.Parse(typeof(WindowState), Services.UiConfig.WindowState); _dialogScreen = new DialogScreenViewModel(); _fullScreen = new DialogScreenViewModel(NavigationTarget.FullScreen); _compactDialogScreen = new DialogScreenViewModel(NavigationTarget.CompactDialogScreen); MainScreen = new TargettedNavigationStack(NavigationTarget.HomeScreen); NavigationState.Register(MainScreen, DialogScreen, FullScreen, CompactDialogScreen); _isMainContentEnabled = true; _isDialogScreenEnabled = true; _isFullScreenEnabled = true; _statusBar = new StatusBarViewModel(); UiServices.Initialize(); _addWalletPage = new AddWalletPageViewModel(); _settingsPage = new SettingsPageViewModel(); _privacyMode = new PrivacyModeViewModel(); _searchPage = new SearchPageViewModel(); _navBar = new NavBarViewModel(MainScreen); NavigationManager.RegisterType(_navBar); RegisterCategories(_searchPage); RegisterViewModels(); RxApp.MainThreadScheduler.Schedule(async() => await _navBar.InitialiseAsync()); _searchPage.Initialise(); this.WhenAnyValue(x => x.WindowState) .Where(x => x != WindowState.Minimized) .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(windowState => Services.UiConfig.WindowState = windowState.ToString()); this.WhenAnyValue( x => x.DialogScreen !.IsDialogOpen, x => x.FullScreen !.IsDialogOpen, x => x.CompactDialogScreen !.IsDialogOpen) .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(tup => { var(dialogScreenIsOpen, fullScreenIsOpen, compactDialogScreenIsOpen) = tup; IsMainContentEnabled = !(dialogScreenIsOpen || fullScreenIsOpen || compactDialogScreenIsOpen); }); this.WhenAnyValue( x => x.DialogScreen.CurrentPage, x => x.CompactDialogScreen.CurrentPage, x => x.FullScreen.CurrentPage, x => x.MainScreen.CurrentPage) .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(tup => { var(dialog, compactDialog, fullscreenDialog, mainsScreen) = tup; /* * Order is important. * Always the topmost content will be the active one. */ if (compactDialog is { }) { compactDialog.SetActive(); return; } if (dialog is { })
public async Task <IViewComponentResult> InvokeAsync() { var user = _aspNetUser.GetCurrentUser(); //var userTenant = "Banco de Sangue"; var navBarGroups = new List <NavBarGroup>(); var navBarItems = new List <NavBarItemViewModel>(); var permissao = _aspNetUser.GetClaim(); await Task.Run(() => { if (user == null) { navBarGroups.Add(new NavBarGroup("Visitante", new List <NavBarItemViewModel> { new NavBarItemViewModel("Cadastrar", Url.Content("~/account/register/")), new NavBarItemViewModel("Resetar Senha", Url.Content("~/account/SendPasswordToken/")), new NavBarItemViewModel("Login", Url.Content("~/account/Login/")), })); } else if (user.Id == null) { navBarGroups.Add(new NavBarGroup("Administração", new List <NavBarItemViewModel> { new NavBarItemViewModel("Planos", Url.Content("~/admin/plano/")), new NavBarItemViewModel("Itens dos Planos", Url.Content("~/admin/planoitem/")), new NavBarItemViewModel("Clientes", Url.Content("~/admin/tenant/")), new NavBarItemViewModel("Usuários", Url.Content("~/admin/usuario/")), })); } else if (user.Id != null && permissao.Equals("Administrador")) { navBarGroups.Add(new NavBarGroup("Administrador", new List <NavBarItemViewModel> { new NavBarItemViewModel("Clientes", Url.Content("~/admin/clientes/")), new NavBarItemViewModel("Doador", Url.Content("~/admin/doador/")), })); } else if (user.Id != null && permissao.Equals("Doador")) { navBarGroups.Add(new NavBarGroup("Doador", new List <NavBarItemViewModel> { new NavBarItemViewModel("Fazer Agendamento", Url.Content("~/admin/agendamento/")), new NavBarItemViewModel("Consultar Hospitais", Url.Content("~/admin/clientes/mostrarclientes")), new NavBarItemViewModel("Alterar Dados", Url.Content("~/admin/doador/edit")), })); } else if (user.Id != null && permissao.Equals("Cliente")) { navBarGroups.Add(new NavBarGroup("Hospital", new List <NavBarItemViewModel> { new NavBarItemViewModel("Banco de Sangue", Url.Content("~/admin/bancosangue/")), new NavBarItemViewModel("Banco de Sangue Saídas", Url.Content("~/admin/bancosanguesaida/")), new NavBarItemViewModel("Doações", Url.Content("~/admin/doacoes/")), new NavBarItemViewModel("Alterar Dados", Url.Content("~/admin/clientes/edit")), new NavBarItemViewModel("Campanhas", Url.Content("~/admin/campanha/")), })); } //else //{ // navBarGroups.Add(new NavBarGroup("Administração", new List<NavBarItemViewModel> // { // new NavBarItemViewModel("Configurações", Url.Content("~/admin/configuracaotenant/edit/" + user.IdTenant.Value.ToString())), // new NavBarItemViewModel("Usuários", Url.Content("~/admin/usuario/")), // })); //} //if (!user.IdTenant.HasValue || (vmPlanoTenant != null && (vmPlanoTenant.IdTipoPlano == 1 || vmPlanoTenant.IdTipoPlano == 3))) //{ // navBarGroups.Add(new NavBarGroup("Imóveis", new List<NavBarItemViewModel> // { // new NavBarItemViewModel("Serviços", Url.Content("~/admin/servico/")), // new NavBarItemViewModel("Tipos de Imóveis", Url.Content("~/admin/tipoimovel/")), // new NavBarItemViewModel("Cidades", Url.Content("~/admin/categoria/cidade")), // new NavBarItemViewModel("Bairros", Url.Content("~/admin/categoria/bairro")), // new NavBarItemViewModel("Imóveis", Url.Content("~/admin/imovel/")), // })); //} //if (!user.IdTenant.HasValue || (vmPlanoTenant != null && (vmPlanoTenant.IdTipoPlano == 2 || vmPlanoTenant.IdTipoPlano == 3))) //{ // navBarGroups.Add(new NavBarGroup("Veículos", new List<NavBarItemViewModel> // { // new NavBarItemViewModel("Marcas(Fipe) ", Url.Content("~/admin/marca/")), // new NavBarItemViewModel("Modelos(Fipe)", Url.Content("~/admin/modelo/")), // new NavBarItemViewModel("Veículos", Url.Content("~/admin/anuncioveiculo/")) // })); //} }); if (user == null) { var nav = new NavBarViewModel("visitante", "visitante@visitante", navBarGroups); return(View(nav)); } var viewModel = new NavBarViewModel(user.FullName, _aspNetUser.GetCurrentUser().Email, navBarGroups); return(View(viewModel)); }
public NavBar() { InitializeComponent(); BindingContext = new NavBarViewModel(Navigation); }
public void MessageINotifyPropertyChangedCalled() { var vm = new NavBarViewModel(_regionManagerMock.Object, _messageServiceMock.Object); Assert.PropertyChanged(vm, nameof(vm.Message), () => vm.Message = "Changed"); }
public NavBarView(IUnityContainer container, NavBarViewModel viewModel) { InitializeComponent(); this.container = container; this.DataContext = viewModel; }