Example #1
0
 public ActionResult Edit(int id, Navigation pNewNavigation, string Lang)
 {
     try
     {
         // TODO: Add update logic here
         if (Lang == "Tiếng Việt")
         {
             pNewNavigation.LangId = 0;
         }
         else
         {
             pNewNavigation.LangId = 1;
         }
         pNewNavigation.CreatedBy   = account.Id;
         pNewNavigation.CreatedDate = DateTime.Now;
         pNewNavigation.EditBy      = account.Id;
         pNewNavigation.EditDate    = DateTime.Now;
         var check = new NavigationModel().Edit(id, pNewNavigation);
         if (!check)
         {
             return(View(pNewNavigation));
         }
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View(new NavigationModel().GetNavigationById(id)));
     }
 }
Example #2
0
 public ConferenceViewModel(Conference conference, NavigationModel navigationModel, SurveySnapshotModel surveySnapshot, SurveyNavigationModel surveyNavigationModel)
 {
     _conference            = conference;
     _navigationModel       = navigationModel;
     _surveySnapshot        = surveySnapshot;
     _surveyNavigationModel = surveyNavigationModel;
 }
        private void InitalizeDataCollection()
        {
            var typesSource = new List <NavigationModel>();

            var basicType = new NavigationModel(_eventAggregator, 0, "Основна", null, true)
            {
                Index = 0
            };

            typesSource.Add(basicType);

            var manualType = new NavigationModel(_eventAggregator, 1, "Ручна", basicType)
            {
                Index = 1
            };

            typesSource.Add(manualType);

            var additionalType = new NavigationModel(_eventAggregator, 2, "Допоміжна", basicType)
            {
                Index = 2
            };

            typesSource.Add(additionalType);

            OperationTypesDataSource = new ObservableCollection <NavigationModel>(typesSource);
        }
Example #4
0
        /* ---------------------------------------------------------------------------------------------------------- */

        #region Private Methods

        /// <summary>
        /// Creates a new row in the database.
        /// </summary>
        private SaveResult CreateNavItem(NavigationModel model, ContentManagementDb db)
        {
            try
            {
                DomainNavigationItem navItem = new DomainNavigationItem();
                navItem.Initialise();

                AutoMap.Map(model, navItem);

                int domainId = UserSession.Current.DomainId;
                navItem.DomainId = domainId;

                navItem.Ordinal = db.DomainNavigationItems.Where(s => s.DomainId == domainId && s.IsDeleted == false).Select(s => s.Ordinal).Max() + 1;

                db.DomainNavigationItems.Add(navItem);

                db.SaveChanges();

                return(SaveResult.Success);
            }
            catch
            {
                return(SaveResult.Fail);
            }
        }
 public ButtonControlModel(IElement element, string requiredType = SpecializationType)
 {
     if (!requiredType.Equals(element.SpecializationType, StringComparison.InvariantCultureIgnoreCase))
     {
         throw new Exception($"Cannot create a '{GetType().Name}' from element with specialization type '{element.SpecializationType}'. Must be of type '{SpecializationType}'");
     }
     _element = element;
     if (InternalElement.IsMapped)
     {
         ClickCommandPath = string.Join(".", InternalElement.MappedElement.Path.Select(x => x.Name.ToCamelCase()));
         if (InternalElement.MappedElement.Element.SpecializationTypeId == NavigationTargetEndModel.SpecializationTypeId ||
             InternalElement.MappedElement.Element.SpecializationTypeId == NavigationSourceEndModel.SpecializationTypeId)
         {
             // This is a best-attempt hack.
             var associationEnd     = (IAssociationEnd)InternalElement.MappedElement.Element;
             var navigationModel    = new NavigationModel(associationEnd.Association);
             var navigationEndModel = associationEnd.IsTargetEnd() ? (NavigationEndModel)navigationModel.TargetEnd : navigationModel.SourceEnd;
             var component          = new ComponentModel((IElement)navigationEndModel.Element);
             var sourceComponent    = new ComponentModel((IElement)navigationEndModel.GetOtherEnd().Element);
             ClickCommandPath += $"({string.Join(", ", component.Inputs.Select(x => sourceComponent.Models.Any(m => m.Name == x.Name) || sourceComponent.Inputs.Any(m => m.Name == x.Name) ? x.Name : x.Name.ToDotCase()))})";
         }
         else
         {
             ClickCommandPath += "()";
         }
     }
 }
Example #6
0
        /// <summary>
        /// 递归获取子节点
        /// </summary>
        /// <param name="model"></param>
        /// <param name="list"></param>
        /// <param name="parentID"></param>
        /// <returns></returns>
        private NavigationModel GetTree(NavigationModel model, List <CompanyWebsite_ToolBar> list, int?parentID = 0)
        {
            var query = list.Where(m => m.PreID == parentID);

            if (query.Any())
            {
                if (model.children == null)
                {
                    model.children = new List <NavigationModel>();
                }
                foreach (var item in query)
                {
                    NavigationModel child = new NavigationModel()
                    {
                        navigation_id      = item.AutoID,
                        navigation_name    = item.ToolBarName,
                        navigation_link    = item.ToolBarTypeValue,
                        navigation_type    = item.ToolBarType,
                        navigation_ico     = item.ToolBarImage,
                        navigation_img_url = item.ImageUrl
                    };
                    model.children.Add(child);
                    this.GetTree(child, list, item.AutoID);
                }
            }
            return(model);
        }
Example #7
0
        public void NavigationWidget_AllSiblingPagesOfCurrentlyOpenedPage()
        {
            string pageNamePrefix1  = "NavigationPage1";
            string pageTitlePrefix1 = "Navigation Page1";
            string urlNamePrefix1   = "navigation-page1";

            string pageNamePrefix2  = "NavigationPage2";
            string pageTitlePrefix2 = "Navigation Page2";
            string urlNamePrefix2   = "navigation-page2";

            var fluent   = App.WorkWith();
            var page1Key = TestUtils.CreateAndPublishPage(fluent, PageLocation.Frontend, pageNamePrefix1, pageTitlePrefix1, urlNamePrefix1, null, false);

            this.createdPageIDs.Add(page1Key);

            var page2Key = TestUtils.CreateAndPublishPage(fluent, PageLocation.Frontend, pageNamePrefix2, pageTitlePrefix2, urlNamePrefix2, null, false);

            this.createdPageIDs.Add(page2Key);

            var page1Node = SitefinitySiteMap.GetCurrentProvider().FindSiteMapNodeFromKey(page1Key.ToString());

            SystemManager.CurrentHttpContext.Items[SiteMapBase.CurrentNodeKey] = page1Node;

            var navModel = new NavigationModel(PageSelectionMode.CurrentPageSiblings, Guid.Empty, null, -1, true, string.Empty, false);

            var expectedCount = 2;
            var actualCount   = navModel.Nodes.Count;

            Assert.AreEqual(expectedCount, actualCount);
            Assert.AreEqual(pageTitlePrefix1, navModel.Nodes[0].Title);
        }
Example #8
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            ContentWindow contentWindow = new ContentWindow();

            NavigationModel navigationModel = new NavigationModel(contentWindow);

            NavigationManager.Instance.Initialize(navigationModel);
            contentWindow.Show();
            navigationModel.Navigate(ModesEnum.Main);

            Current.MainWindow.Closing += (s, a) =>
            {
                if (MessageBox.Show("Вийти?", "", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes)
                {
                    StationManager.InvokeStopThreads();
                    Environment.Exit(0);
                }
                else
                {
                    a.Cancel = true;
                }
            };
        }
        public async Task <ActionResult <ApiResponse <int> > > CreateNavigation(NavigationModel form)
        {
            try
            {
                var nav = new Navigation_Master
                {
                    Fk_Language_ID = form.Fk_Language_ID,
                    Fk_User_ID     = form.Fk_User_ID,
                    Keys           = form.Keys,
                    Descriptions   = form.Descriptions,
                };
                _context.Add(nav);
                await _context.SaveChangesAsync();

                return(new ApiResponse <int> {
                    code = 1, message = "Success"
                });
            }
            catch (Exception)
            {
                return(new ApiResponse <int> {
                    code = 0, message = "Failed"
                });
            }
        }
        private void InitializeApplication()
        {
            StationManager.Initialize(new SerializedDataStorage());
            var navigationModel = new NavigationModel(this);

            NavigationManager.Instance.Initialize(navigationModel);
        }
Example #11
0
        /// <summary>
        /// 递归获取子节点
        /// </summary>
        /// <param name="model"></param>
        /// <param name="list"></param>
        /// <param name="parentID"></param>
        /// <returns></returns>
        private NavigationModel GetTree(NavigationModel model, IList <BLLJIMP.Model.Navigation> list, int?parentID = 0)
        {
            var query = list.Where(m => m.ParentId == parentID);

            if (query.Any())
            {
                if (model.children == null)
                {
                    model.children = new List <NavigationModel>();
                }
                foreach (var item in query)
                {
                    NavigationModel child = new NavigationModel()
                    {
                        navigation_id      = item.AutoID,
                        navigation_name    = item.NavigationName,
                        navigation_link    = item.NavigationLink,
                        navigation_img_url = bllMall.GetImgUrl(item.NavigationImage)
                    };
                    model.children.Add(child);
                    this.GetTree(child, list, item.AutoID);
                }
            }
            return(model);
        }
Example #12
0
 /// <summary>
 /// Delete
 /// </summary>
 /// <param name="model">Navigation model</param>
 /// <returns>ResponseStatusCodeHelper</returns>
 public ResponseStatusCodeHelper Delete(NavigationModel model)
 {
     try
     {
         using (var _context = new TDHEntities())
         {
             WEB_NAVIGATION _md = _context.WEB_NAVIGATION.FirstOrDefault(m => m.id == model.ID && !m.deleted);
             if (_md == null)
             {
                 throw new DataAccessException(FILE_NAME, "Delete", model.CreateBy);
             }
             _md.deleted     = true;
             _md.delete_by   = model.DeleteBy;
             _md.delete_date = DateTime.Now;
             _context.WEB_NAVIGATION.Attach(_md);
             _context.Entry(_md).State = EntityState.Modified;
             _context.SaveChanges();
         }
     }
     catch (DataAccessException fieldEx)
     {
         throw fieldEx;
     }
     catch (Exception ex)
     {
         throw new ServiceException(FILE_NAME, "Delete", model.CreateBy, ex);
     }
     Notifier.Notification(model.CreateBy, Message.DeleteSuccess, Notifier.TYPE.Success);
     return(ResponseStatusCodeHelper.Success);
 }
Example #13
0
 /// <summary>
 /// Check Delete item
 /// </summary>
 /// <param name="model">Navigation model</param>
 /// <returns>ResponseStatusCodeHelper</returns>
 public ResponseStatusCodeHelper CheckDelete(NavigationModel model)
 {
     try
     {
         using (var _context = new TDHEntities())
         {
             WEB_NAVIGATION _md = _context.WEB_NAVIGATION.FirstOrDefault(m => m.id == model.ID && !m.deleted);
             if (_md == null)
             {
                 throw new DataAccessException(FILE_NAME, "CheckDelete", model.CreateBy);
             }
             var _cate = _context.WEB_CATEGORY.FirstOrDefault(m => m.navigation_id == model.ID && !m.deleted);
             if (_cate != null)
             {
                 Notifier.Notification(model.CreateBy, Message.CheckExists, Notifier.TYPE.Warning);
                 return(ResponseStatusCodeHelper.NG);
             }
         }
     }
     catch (DataAccessException fieldEx)
     {
         throw fieldEx;
     }
     catch (Exception ex)
     {
         throw new ServiceException(FILE_NAME, "CheckDelete", model.CreateBy, ex);
     }
     return(ResponseStatusCodeHelper.OK);
 }
Example #14
0
        public ActionResult Navigation()
        {
            var model = new NavigationModel();

            model.Navigation = publishedContentService.GetNavigation();
            return(PartialView(model));
        }
Example #15
0
        public HttpResponseMessage GetNavigation(int siteId, int navigationId)
        {
            SecurityClientProcessor.UserContext.SiteId = siteId;
            NavigationModel navigation = SecurityClientProcessor.GetNavigation(navigationId);

            return(Request.CreateResponse(HttpStatusCode.OK, navigation));
        }
Example #16
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            ContentWindow   contentWindow   = new ContentWindow();
            NavigationModel navigationModel = new NavigationModel(contentWindow);

            NavigationManager.Instance.Initialize(navigationModel);
            contentWindow.Show();
            if (AUTHORIZATION_STUB != null)
            {
                var authResp = HotelApiClient.GetInstance().Login(AUTHORIZATION_STUB.Login, AUTHORIZATION_STUB.Password);
                if (authResp != null)
                {
                    var userRole = authResp.User.Role;
                    Storage.Instance.ChangeUser(new User(LoginModel.RightsDictionary[userRole]));

                    NavigationManager.Instance.Navigate(ModesEnum.Main);
                }
            }
            else
            {
                navigationModel.Navigate(ModesEnum.Login);
            }
        }
Example #17
0
        public MainWindow()
        {
            InitializeComponent();
            var navigationModel = new NavigationModel(this);

            NavigationManager.Instance.Initialize(navigationModel);

            try
            {
                String guid = SerializationManager.Deserialize <String>(FileFolderHelper.StorageFilePath);
                StationManager.CurrentUser = ConnectionManager.GetUserByGuid(guid);
                if (StationManager.CurrentUser != null)
                {
                    StationManager.CurrentUser.LastSingInDate = DateTime.Now;
                    ConnectionManager.SaveUser(StationManager.CurrentUser);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            MainWindowViewModel mainWindowViewModel = new MainWindowViewModel();

            DataContext = mainWindowViewModel;
            mainWindowViewModel.StartApplication();
        }
Example #18
0
        public async Task <NavigationModel <UserModel> > GetUsersAsync(UserFiltrPaginSortModel model)
        {
            var users = await _userManager.Users.
                        Where(n => EF.Functions.Like(n.Id.ToString(), $"%{model.Id}%") &&
                              EF.Functions.Like(n.LastName, $"%{model.LastName}%") &&
                              EF.Functions.Like(n.LastName, $"%{model.LastName}%") &&
                              (n.IsBlocked == model.IsBlocked || model.IsBlocked == null))
                        .OrderBy(model.PropertyForSort, model.IsAscending).Skip((model.CurrentPage - 1) * model.PageSize).Take(model.PageSize).ToListAsync();

            if (!users.Any())
            {
                throw new CustomExeption(Constants.Error.NO_USER_THIS_CONDITIONS,
                                         StatusCodes.Status400BadRequest);
            }

            int usersCount = await _userManager.Users.
                             Where(n => EF.Functions.Like(n.Id.ToString(), $"%{model.Id}%") &&
                                   EF.Functions.Like(n.LastName, $"%{model.LastName}%") &&
                                   EF.Functions.Like(n.LastName, $"%{model.LastName}%") &&
                                   (n.IsBlocked == model.IsBlocked || model.IsBlocked == null)).CountAsync();

            var userModels = _mapper.Map <IEnumerable <UserModel> >(users).ToList();

            PaginatedPageModel          paginatedPage = new PaginatedPageModel(usersCount, model.CurrentPage, model.PageSize);
            NavigationModel <UserModel> navigation    = new NavigationModel <UserModel>
            {
                PageModel    = paginatedPage,
                EntityModels = userModels
            };

            return(navigation);
        }
        public ActionResult Create()
        {
            try
            {
                #region " [ Declaration ] "

                NavigationModel model = new NavigationModel()
                {
                    ID       = Guid.NewGuid(),
                    CreateBy = UserID,
                    Insert   = true
                };

                #endregion

                return(View(model));
            }
            catch (ServiceException serviceEx)
            {
                throw serviceEx;
            }
            catch (DataAccessException accessEx)
            {
                throw accessEx;
            }
            catch (Exception ex)
            {
                throw new ControllerException(FILE_NAME, "Create", UserID, ex);
            }
        }
        public JsonResult CheckDelete(NavigationModel model)
        {
            try
            {
                #region " [ Declaration ] "

                NavigationService _service = new NavigationService();

                #endregion

                #region " [ Main process ] "

                model.CreateBy = UserID;

                #endregion

                //Call to service
                return(this.Json(_service.CheckDelete(model), JsonRequestBehavior.AllowGet));
            }
            catch (ServiceException serviceEx)
            {
                throw serviceEx;
            }
            catch (DataAccessException accessEx)
            {
                throw accessEx;
            }
            catch (Exception ex)
            {
                throw new ControllerException(FILE_NAME, "CheckDelete", UserID, ex);
            }
        }
Example #21
0
        // GET: View
        public async Task <ActionResult> Navigate(Guid accountId, string path = "")
        {
            var bookmarkedService = new BookmarkedService(accountId, GetIocForGuid(accountId), Server);
            var item = await bookmarkedService.GetContent(path);


            var model = new NavigationModel {
                Path = path, AccountId = accountId
            };

            if (item == null)
            {
                model.IsNotFoundView = true;
            }
            else if (item is FolderModel folderModel)
            {
                model.FolderModel  = folderModel;
                model.IsFolderView = true;
            }
            else
            {
                model.EntryModel = (EntryModel)item;
            }

            return(View("Navigate", model));
        }
        public ActionResult Edit(string id)
        {
            ViewBag.id = id;
            try
            {
                #region " [ Declaration ] "

                NavigationService _service = new NavigationService();

                ViewBag.id = id;

                #endregion

                //Call to service
                NavigationModel model = _service.GetItemByID(new NavigationModel()
                {
                    ID = new Guid(id), CreateBy = UserID, Insert = false
                });

                return(View(model));
            }
            catch (ServiceException serviceEx)
            {
                throw serviceEx;
            }
            catch (DataAccessException accessEx)
            {
                throw accessEx;
            }
            catch (Exception ex)
            {
                throw new ControllerException(FILE_NAME, "Edit", UserID, ex);
            }
        }
Example #23
0
        /// <summary>
        /// Updates an existing row in the database.
        /// </summary>
        private SaveResult UpdateNavItem(DomainNavigationItem navItem, NavigationModel model, ContentManagementDb db)
        {
            if (UserSession.Current.IsAdministrator == false)
            {
                return(SaveResult.AccessDenied);
            }

            if (UserSession.Current.CurrentDomain().CanAccess(navItem) == false)
            {
                return(SaveResult.IncorrectDomain);
            }

            try
            {
                AutoMap.Map(model, navItem);
                navItem.UpdateTimeStamp();

                db.SaveChanges();

                return(SaveResult.Success);
            }
            catch
            {
                return(SaveResult.Fail);
            }
        }
Example #24
0
        internal void SettingNewPage()
        {
            if (_previousPage != null)
            {
                // if _previousNavModel has been set than _navModel has already been reinitialized
                if (_previousNavModel != null)
                {
                    _previousNavModel = null;
                    if (_navModel == null)
                    {
                        _navModel = new NavigationModel();
                    }
                }
                else
                {
                    _navModel = new NavigationModel();
                }
            }

            if (_window.Page == null)
            {
                _previousPage = null;

                return;
            }

            _navModel.Push(_window.Page, null);
            _previousPage = _window.Page;
        }
Example #25
0
        internal void SetPage(Page newRoot)
        {
            var layout = false;

            if (Page != null)
            {
                _renderer.RemoveAllViews();

                foreach (IVisualElementRenderer rootRenderer in _navModel.Roots.Select(Android.Platform.GetRenderer))
                {
                    rootRenderer.Dispose();
                }
                _navModel = new NavigationModel();

                layout = true;
            }

            if (newRoot == null)
            {
                return;
            }

            _navModel.Push(newRoot, null);

            Page          = newRoot;
            Page.Platform = this;
            AddChild(Page, layout);

            ((Application)Page.RealParent).NavigationProxy.Inner = this;
        }
Example #26
0
 public ActionResult Create(Navigation pNewNavigation, string Lang)
 {
     try
     {
         // TODO: Add insert logic here
         if (Lang == "Tiếng Việt")
         {
             pNewNavigation.LangId = 0;
         }
         else
         {
             pNewNavigation.LangId = 1;
         }
         pNewNavigation.CreatedBy   = account.Id;
         pNewNavigation.CreatedDate = DateTime.Now;
         pNewNavigation.EditBy      = account.Id;
         pNewNavigation.EditDate    = DateTime.Now;
         pNewNavigation.IsActive    = true;
         var check = new NavigationModel().Create(pNewNavigation);
         if (!check)
         {
             return(View(pNewNavigation));
         }
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View(pNewNavigation));
     }
 }
Example #27
0
 private NavigationModel GetNavigationModel(long id)
 {
     try
     {
         NavigationModel navigationModel = new NavigationModel();
         Navigation      navigation      = db.Navigations.Where(x => x.id == id).SingleOrDefault();
         if (navigation != null)
         {
             navigationModel.barColor = navigation.barColor;
             navigationModel.logo     = navigation.logo;
             List <NavigationItem> navigationItems = db.NavigationItems.Where(x => x.navID == id).ToList();
             if (navigationItems != null)
             {
                 List <NavigationItemModel> navigationItemModels = new List <NavigationItemModel>();
                 foreach (NavigationItem navigationItem in navigationItems)
                 {
                     NavigationItemModel navigationItemModel = new NavigationItemModel();
                     navigationItemModel.content     = navigationItem.content;
                     navigationItemModel.sectionName = navigationItem.sectionName;
                     navigationItemModels.Add(navigationItemModel);
                 }
                 navigationModel.navigationItems = navigationItemModels;
             }
         }
         return(navigationModel);
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         return(null);
     }
 }
Example #28
0
        internal void SetPage(Page newRoot)
        {
            var layout = false;

            if (Page != null)
            {
                _renderer.RemoveAllViews();

                foreach (IVisualElementRenderer rootRenderer in _navModel.Roots.Select(GetRenderer))
                {
                    rootRenderer.Dispose();
                }
                _navModel = new NavigationModel();

                layout = true;
            }

            if (newRoot == null)
            {
                return;
            }

            _navModel.Push(newRoot, null);

            Page          = newRoot;
            Page.Platform = this;
            AddChild(Page, layout);

            Application.Current.NavigationProxy.Inner = this;

            _toolbarTracker.Target = newRoot;

            UpdateActionBar();
        }
Example #29
0
        public void NavigationWidget_AllChildPagesOfSpecifiedPage()
        {
            string pageName1  = "NavigationPage1";
            string pageTitle1 = "Navigation Page1";
            string urlName1   = "navigation-page1";

            string pageName2  = "NavigationPage2";
            string pageTitle2 = "Navigation Page2";
            string urlName2   = "navigation-page2";

            var fluent   = App.WorkWith();
            var page1Key = TestUtils.CreateAndPublishPage(fluent, PageLocation.Frontend, pageName1, pageTitle1, urlName1, null, false);

            this.createdPageIDs.Add(page1Key);

            var page1Node = fluent.Page(page1Key).Get();
            var page2Key  = TestUtils.CreateAndPublishPage(fluent, PageLocation.Frontend, pageName2, pageTitle2, urlName2, page1Node, false);

            this.createdPageIDs.Add(page2Key);

            var navModel = new NavigationModel(PageSelectionMode.SelectedPageChildren, page1Key, null, -1, false, string.Empty, false);

            var expectedCount = 1;
            var actualCount   = navModel.Nodes.Count;

            Assert.AreEqual(expectedCount, actualCount);
            Assert.AreEqual(pageTitle2, navModel.Nodes[0].Title);
        }
Example #30
0
        void SetPageInternal(Page newRoot)
        {
            var layout = false;

            if (Page != null)
            {
                _navModel = new NavigationModel();

                layout = true;
            }

            if (newRoot == null)
            {
                Page = null;

                return;
            }

            _navModel.Push(newRoot, null);

            Page = newRoot;

            AddChild(Page, layout);

            Application.Current.NavigationProxy.Inner = this;
        }
Example #31
0
        public LoggedInModel(User aPanelForUser, User aLoggedInUser, SiteSection aSection)
        {
            theIsMyProfile = aPanelForUser.Id == aLoggedInUser.Id;

            NavigationModel = new NavigationModel(aPanelForUser, aSection, theIsMyProfile);

            if(PrivacyHelper.IsAllowed(aPanelForUser, PrivacyAction.DisplayProfile)) {
                BuildMenu(aPanelForUser, aLoggedInUser);
            }
        }
		public void PushFirstItem ()
		{
			var navModel = new NavigationModel ();

			var page1 = new ContentPage ();
			navModel.Push (page1, null);

			Assert.AreEqual (page1, navModel.CurrentPage);
			Assert.AreEqual (page1, navModel.Roots.First ());
		}
        public void LaunchNavigationAsync(NavigationModel navigationModel)
        {
            var mapsDirectionsTask = new MapsDirectionsTask();

            var destinationGeolocation = new GeoCoordinate(navigationModel.Latitude, navigationModel.Longitude);
            var destinationMapLocation = new LabeledMapLocation(navigationModel.DestinationName, destinationGeolocation);
            
            mapsDirectionsTask.End = destinationMapLocation;

            mapsDirectionsTask.Show();
        }
		public void CurrentGivesLastViewWithoutModal ()
		{
			var navModel = new NavigationModel ();

			var page1 = new ContentPage ();
			var page2 = new ContentPage ();

			navModel.Push (page1, null);
			navModel.Push (page2, page1);

			Assert.AreEqual (page2, navModel.CurrentPage);
		}
        public void Closing_screen_calls_event()
        {
            var model = new NavigationModel();

            var createdScreen = MockScreen.CreateOrSelectInNavigation(model, 1);

            ScreenViewModel removedScreen = null;
            model.ScreenRemoved += (ss, arg) => removedScreen = arg.Screen;
            model.CloseScreen(createdScreen);

            Assert.AreSame(createdScreen, removedScreen);
        }
    /// <summary>
    /// Starts the Native Map Navigation
    /// Implementation from https://github.com/jamesmontemagno/Xamarin.Plugins/tree/master/ExternalMaps
    /// </summary>
    /// <param name="navigationModel"></param>
    public void LaunchNavigationAsync(NavigationModel navigationModel)
    {
      var mapItem =
        new MKMapItem(new MKPlacemark(new CLLocationCoordinate2D(navigationModel.Latitude, navigationModel.Longitude),
          new MKPlacemarkAddress{Street = navigationModel.DestinationAddress})) {Name = navigationModel.DestinationName};

      var launchOptions =
         new MKLaunchOptions
        {
          DirectionsMode =  MKDirectionsMode.Driving
        };

      var mapItems = new[] { mapItem };

      MKMapItem.OpenMaps(mapItems, launchOptions);
    }
		public void Roots ()
		{
			var navModel = new NavigationModel ();

			var page1 = new ContentPage ();
			var page2 = new ContentPage ();

			var modal1 = new ContentPage ();
			var modal2 = new ContentPage ();

			navModel.Push (page1, null);
			navModel.Push (page2, page1);

			navModel.PushModal (modal1);
			navModel.Push (modal2, modal1);

			Assert.True (navModel.Roots.SequenceEqual (new[] {page1, modal1}));
		}
        public void Closing_screen_removes_it()
        {
            var model = new NavigationModel();

            var createdScreen = MockScreen.CreateOrSelectInNavigation(model, 1);

            model.CloseScreen(createdScreen);

            Assert.IsFalse(model.Items.Contains(createdScreen));
        }
		public void PopTopPageWithSinglePage ()
		{
			var navModel = new NavigationModel ();

			var page1 = new ContentPage ();

			navModel.Push (page1, null);

			Assert.Null (navModel.PopTopPage ());
		}
		public void PopTopPageWithModal ()
		{
			var navModel = new NavigationModel ();

			var page1 = new ContentPage ();
			var modal1 = new ContentPage ();

			navModel.Push (page1, null);
			navModel.PushModal (modal1);

			Assert.AreEqual (modal1, navModel.PopTopPage ());
		}
Example #41
0
		internal void SetPage(Page newRoot)
		{
			var layout = false;
			if (Page != null)
			{
				_renderer.RemoveAllViews();

				foreach (IVisualElementRenderer rootRenderer in _navModel.Roots.Select(Android.Platform.GetRenderer))
					rootRenderer.Dispose();
				_navModel = new NavigationModel();

				layout = true;
			}

			if (newRoot == null)
				return;

			_navModel.Push(newRoot, null);

			Page = newRoot;
			Page.Platform = this;
			AddChild(Page, layout);

			((Application)Page.RealParent).NavigationProxy.Inner = this;
		}
		public void PopTopPageWithoutModals ()
		{
			var navModel = new NavigationModel ();

			var page1 = new ContentPage ();
			var page2 = new ContentPage ();

			navModel.Push (page1, null);
			navModel.Push (page2, page1);

			Assert.AreEqual (page2, navModel.PopTopPage ());
		}
		public void ThrowsWhenPopToRootWithInvalidAncestor()
		{
			var navModel = new NavigationModel ();

			var page1 = new ContentPage ();
			var page2 = new ContentPage ();

			navModel.Push (page1, null);
			navModel.Push (page2, page1);

			Assert.Throws<InvalidNavigationException> (() => navModel.PopToRoot (new ContentPage ()));
		}
 internal static MockScreen CreateOrSelectInNavigation(NavigationModel model, int id)
 {
     return model.AddOrSelectScreen(scr => scr.Id == id, () => new MockScreen(id));
 }
        public void Closing_screen_that_is_current_selects_one_under_it()
        {
            var model = new NavigationModel();

            var createdScreen1 = MockScreen.CreateOrSelectInNavigation(model, 1);
            var createdScreen2 = MockScreen.CreateOrSelectInNavigation(model, 2);
            var createdScreen3 = MockScreen.CreateOrSelectInNavigation(model, 3);

            MockScreen.CreateOrSelectInNavigation(model, 2);
            model.CloseScreen(createdScreen2);

            Assert.AreSame(createdScreen1, model.CurrentScreen);
        }
		public void ThrowsWhenPopToRootOnRoot ()
		{
			var navModel = new NavigationModel ();

			var page1 = new ContentPage ();

			navModel.Push (page1, null);
			Assert.Throws<InvalidNavigationException> (() => navModel.PopToRoot (page1));
		}
		public void ThrowsPoppingRootOfModal ()
		{
			var navModel = new NavigationModel ();

			var page1 = new ContentPage ();
			var page2 = new ContentPage ();

			var modal1 = new ContentPage ();

			navModel.Push (page1, null);
			navModel.Push (page2, page1);

			navModel.PushModal (modal1);
			Assert.Throws<InvalidNavigationException> (() => navModel.Pop (modal1));
		}
		public void CurrentNullWhenEmpty ()
		{
			var navModel = new NavigationModel ();
			Assert.Null (navModel.CurrentPage);
		}
        public void Closing_screen_when_only_one_selects_null()
        {
            var model = new NavigationModel();

            var createdScreen = MockScreen.CreateOrSelectInNavigation(model, 1);

            model.CloseScreen(createdScreen);

            Assert.IsNull(model.CurrentScreen);
        }
		public void ThrowsWhenPushingWithoutAncestor ()
		{
			var navModel = new NavigationModel ();

			var page1 = new ContentPage ();
			var page2 = new ContentPage ();

			navModel.Push (page1, null);
			Assert.Throws<InvalidNavigationException> (() => navModel.Push (page2, null));
		}
		public void PopModal ()
		{
			var navModel = new NavigationModel ();

			var child1 = new ContentPage ();
			var modal1 = new ContentPage ();

			navModel.Push (child1, null);
			navModel.PushModal (modal1);

			navModel.PopModal ();

			Assert.AreEqual (child1, navModel.CurrentPage);
			Assert.AreEqual (1, navModel.Roots.Count ());
		}
		public void PushFromNonRootAncestor ()
		{
			var navModel = new NavigationModel ();

			var page1 = new ContentPage ();
			var page2 = new ContentPage ();
			var page3 = new ContentPage ();

			page2.Parent = page1;
			page3.Parent = page2;

			navModel.Push (page1, null);
			navModel.Push (page2, page1);
			navModel.Push (page3, page2);

			Assert.AreEqual (page3, navModel.CurrentPage);
		}
		public void ReturnsCorrectModal ()
		{
			var navModel = new NavigationModel ();

			var child1 = new ContentPage ();
			var modal1 = new ContentPage ();
			var modal2 = new ContentPage ();

			navModel.Push (child1, null);
			navModel.PushModal (modal1);
			navModel.PushModal (modal2);

			Assert.AreEqual (modal2, navModel.PopModal ());
		}
		public void ThrowsWhenPushFromInvalidAncestor ()
		{
			var navModel = new NavigationModel ();

			var page1 = new ContentPage ();
			var page2 = new ContentPage ();

			Assert.Throws<InvalidNavigationException> (() => navModel.Push (page2, page1));
		}
Example #55
0
		public async Task LaunchNavigationAsync (NavigationModel navigationModel)
		{
			var uri = Uri.Parse ("google.navigation:q=" + navigationModel.DestinationAddress);

			StartActivity (uri);		
		}
		public void Pop ()
		{
			var navModel = new NavigationModel ();

			var page1 = new ContentPage ();
			var page2 = new ContentPage ();

			navModel.Push (page1, null);
			navModel.Push (page2, page1);

			navModel.Pop (page1);

			Assert.AreEqual (page1, navModel.CurrentPage);
		}
        public void Closing_screen_that_is_not_current_does_nothing_to_current()
        {
            var model = new NavigationModel();

            var createdScreen1 = MockScreen.CreateOrSelectInNavigation(model, 1);
            var createdScreen2 = MockScreen.CreateOrSelectInNavigation(model, 2);

            model.CloseScreen(createdScreen1);

            Assert.AreSame(createdScreen2, model.CurrentScreen);
        }
 public NavigationService()
 {
     NavigationModel = new NavigationModel();
     _current = this;
 }
Example #59
0
 public SessionModel()
 {
     Navigation = new NavigationModel();
     CurrentWorkspace = new WorkspaceModel();
     Results = new ResultsModel();
 }