/// <summary> /// 导航数据接收事件发送消息 /// </summary> /// <param name="navigationData"></param> /// <returns></returns> private void OnNavigationDataAcquired(NavigationData navigationData) { if (NavigationDataAcquired != null) { NavigationDataAcquired(navigationData); } }
internal GraphNavigationManager(NavigationData data, IEnumerable <string> entityPhrases, ILinker linker) { _data = data; _linker = linker; _entityPhrases = entityPhrases.ToArray(); _edges = new string[] { "/location/country/form_of_government", "/biology/organism_classification/higher_classification", "/people/person/profession", "/education/field_of_study/students_majoring", "/sports/school_sports_team/school", "/music/genre/albums", "/medicine/disease/causes", "/tv/tv_program/regular_cast", "/people/person/nationality", "/film/film_genre/films_in_this_genre", "/music/artist/genre", "/business/business_operation/industry", "/common/topic/notable_types", "/location/location/contains", }; sampleEdgeRepresentants(20); }
public override void CreateScreenData(NavigationData navigationData) { base.CreateScreenData(navigationData); if (!_presentsBaseView) return; ReloadMediaItems(navigationData.BaseViewSpecification.BuildView(), true); }
public GoToActivity(IActionFactory actionFactory, NavigationData navigationData, INavigator navigator, string name) : base(name) { _actionFactory = actionFactory; _navigationData = navigationData; _destination = navigationData.Destination; _navigator = navigator; }
// Use this for initialization void Start () { Debug.Log("Start"); // initialize data array data = new byte[width*height*3]; // set textures MainRenderer.material.mainTexture = cameraTexture; SecondaryRenderer.material.mainTexture = blackTexture; cameraTexture = new Texture2D (width, height); blackTexture = new Texture2D (1, 1); blackTexture.SetPixel (0, 0, Color.black); blackTexture.Apply (); // Initialize drone videoPacketDecoderWorker = new VideoPacketDecoderWorker(PixelFormat.BGR24, true, OnVideoPacketDecoded); videoPacketDecoderWorker.Start(); droneClient = new DroneClient("192.168.1.1"); droneClient.UnhandledException += HandleUnhandledException; droneClient.VideoPacketAcquired += OnVideoPacketAcquired; droneClient.NavigationDataAcquired += navData => navigationData = navData; videoPacketDecoderWorker.UnhandledException += HandleUnhandledException; droneClient.Start (); // activate main drone camera switchDroneCamera (AR.Drone.Client.Configuration.VideoChannelType.Vertical); // determine connection client = new WlanClient(); }
/// <summary> /// Responds to a <see cref="System.Web.UI.ScriptManager"/> history navigation handler and restores the /// <paramref name="data"/> saved by <see cref="AddHistoryPoint(System.Web.UI.Page, Navigation.NavigationData, string)"/> /// method to the <see cref="Navigation.StateContext"/> /// </summary> /// <param name="data">Saved <see cref="Navigation.StateContext"/> to restore</param> /// <exception cref="System.ArgumentNullException"><paramref name="data"/> is null</exception> /// <exception cref="Navigation.UrlException">There is data that cannot be converted from a <see cref="System.String"/>; /// or the <see cref="Navigation.NavigationShield"/> detects tampering</exception> public static void NavigateHistory(NameValueCollection data) { if (data == null) throw new ArgumentNullException("data"); if (data.Count == 0) { NavigationData derivedData = new NavigationData(StateContext.State.Derived); #if NET40Plus SetStateContext(StateContext.State.Id, new HttpContextWrapper(HttpContext.Current)); #else SetStateContext(StateContext.State.Id, HttpContext.Current.Request.QueryString); #endif StateContext.Data.Add(derivedData); } else { RemoveDefaultsAndDerived(data); data = StateContext.ShieldDecode(data, true, StateContext.State); data.Remove(NavigationSettings.Config.StateIdKey); NavigationData derivedData = new NavigationData(StateContext.State.Derived); StateContext.Data.Clear(); StateContext.Data.Add(derivedData); foreach (string key in data) { StateContext.Data[key] = CrumbTrailManager.ParseURLString(key, data[key], StateContext.State); } } }
public override ActivityStep ResolveStep(GameEntity entity) { if (_navigationData == null) { _navigationData = _navigator.GetNavigationData(entity.position.Position, _destination); if (_navigationData == null) { return(Fail(entity)); } } Position nextStep; NavigationResult navigationResult = _navigator.ResolveNextStep(_navigationData, entity.position.Position, out nextStep); if (navigationResult == NavigationResult.Finished) { return(Succeed(entity)); } IGameAction moveGameAction = CreateMoveAction(nextStep, entity); return(new ActivityStep { State = ActivityState.InProgress, GameAction = moveGameAction }); }
static void HandleNavigationDataAcquired(NavigationData data) { if (data.Velocity.X > 0.4) { Console.WriteLine("Slow down!"); } }
private void PopNavigationUI(NavigationData nd) { if (backSequence.Count > 0) { backSequence.Pop(); } if (nd.beingHidedUI == null) { return; } //显示所有的保存的UI for (int i = 0; i < nd.beingHidedUI.Count; i++) { WindowID backId = nd.beingHidedUI[i]; ShowWindowForNavigation(backId); if (i == nd.beingHidedUI.Count - 1) { UIControllerBase window = GetGameWindowFromCache(backId); if (window.UIConfigData.navigationMode == UIWindowNavigationMode.NormalNavigation) { this.lastNavigationWindow = this.curNavigationWindow; this.curNavigationWindow = window; } } } }
// .j.t // j#.. // j#.. // s... public void GetNavigationData_TargetIsNotReachableByStraightLineButReachableByPathfinding_PathfinderIsUsedAndReturnsCorrectResult() { var start = new Position(0, 0); var target = new Position(3, 3); var pathfinderMock = new Mock <IPathfinder>(); IGrid gridInfoProvider = Mock.Of <IGrid>(gip => gip.IsWalkable(It.IsAny <Position>()) == true && gip.IsWalkable(new Position(1, 1)) == false && gip.IsWalkable(new Position(1, 2)) == false); var jumpPointsFromPathfinder = new List <Position> { new Position(0, 0), new Position(0, 1), new Position(0, 2), new Position(1, 3), new Position(3, 3) }; pathfinderMock.Setup(p => p.FindJumpPointsWithJps(It.IsAny <Position>(), It.IsAny <Position>(), It.IsAny <JpsMode>())) .Returns(new PathfindingResponse(jumpPointsFromPathfinder)); var bresenham = new BresenhamLineCreator(); var navigator = new Navigator(pathfinderMock.Object, gridInfoProvider, new NaturalLineCalculator(bresenham), bresenham, Mock.Of <IUiFacade>()); NavigationData result = navigator.GetNavigationData(start, target); pathfinderMock.Verify(p => p.FindJumpPointsWithJps(It.IsAny <Position>(), It.IsAny <Position>(), It.IsAny <JpsMode>()), Times.Once); result.Destination.Should().Be(target); result.RemainingNodes[0].Should().Be(new Position(0, 2)); IList <Position> expectedNodes // (0,1) is redundant (because of specific of current JPS implementation) and should be pruned. = new List <Position>(new[] { new Position(0, 2), new Position(1, 3), new Position(3, 3) }); result.RemainingNodes.Should().BeEquivalentTo(expectedNodes, options => options.WithStrictOrderingFor(position => position)); result.RemainingStepsInCurrentSegment.Should().BeEmpty(); }
public Task OnNavigatingAsync(NavigationData navigationData, CancellationToken token) { var note = navigationData.GetParameter <NoteViewModel>("Note"); Note = note; return(Task.CompletedTask); }
public void ResolveNextStep_NextStepIsNextNode_ReturnsInProgressWithNextStepAndNavigationDataIsCorrect() { var currentPosition = new Position(2, 2); var nextNode = new Position(3, 2); IPathfinder pathfinder = Mock.Of <IPathfinder>(); IGrid gridInfoProvider = Mock.Of <IGrid>(p => p.IsWalkable(It.IsAny <Position>()) == true); var navigator = new Navigator(pathfinder, gridInfoProvider, Mock.Of <INaturalLineCalculator>(), Mock.Of <IRasterLineCreator>(), Mock.Of <IUiFacade>()); var nodesToVisit = new[] { nextNode, new Position(213, 34254), }; var navigationData = new NavigationData { RemainingNodes = nodesToVisit.ToList(), RemainingStepsInCurrentSegment = new Stack <Position>(new[] { nextNode }), Destination = new Position(4, 2), LastStep = currentPosition }; Position nextStep; NavigationResult result = navigator.ResolveNextStep(navigationData, currentPosition, out nextStep); result.Should().Be(NavigationResult.InProgress); nextStep.Should().Be(nextNode); navigationData.RemainingStepsInCurrentSegment.Should().BeEmpty(); navigationData.RemainingNodes.Should().BeEquivalentTo(nodesToVisit.Skip(1)); }
/// <summary> /// There are two modes for browsing media in its directory structure; ML browsing and local browsing. /// This method switches between those modes. It takes the current media navigation state and tries to navigate to the most sensible sibling state, i.e. /// tries to navigate as close as possible to the current directory navigation in the other mode. /// </summary> public static void NavigateToSiblingState() { IWorkflowManager workflowManager = ServiceRegistration.Get <IWorkflowManager>(); NavigationContext workflowNavigationContext = workflowManager.CurrentNavigationContext; NavigationData nd = MediaNavigationModel.GetNavigationData(workflowNavigationContext, false); if (nd == null) { ServiceRegistration.Get <ILogger>().Warn("AbstractBrowseMediaNavigationScreenData: Cannot navigate to sibling browse media state - there is no active media screen"); return; } AbstractBrowseMediaNavigationScreenData screenData = nd.CurrentScreenData as AbstractBrowseMediaNavigationScreenData; if (screenData == null) { ServiceRegistration.Get <ILogger>().Warn("AbstractBrowseMediaNavigationScreenData: Cannot navigate to sibling browse media state - there is no active media items screen"); return; } ViewSpecification vs = Unwrap(nd.BaseViewSpecification); ResourcePath path; if (BrowseMediaRootProxyViewSpecification.TryGetLocalBrowseViewPath(vs, out path)) { NavigateToLocalBrowsing(path); } else if (LocalMediaRootProxyViewSpecification.TryGetLocalBrowseViewPath(vs, out path)) { NavigateToMLBrowsing(path); } }
void Inititialize() { tmrStatusUpdate = new DispatcherTimer(); tmrStatusUpdate.Interval = TimeSpan.FromMilliseconds(100); tmrStatusUpdate.IsEnabled = true; tmrStatusUpdate.Tick += tmrStatusUpdate_Tick; tmrVideoUpdate = new DispatcherTimer(); tmrVideoUpdate.Interval = TimeSpan.FromMilliseconds(20); tmrVideoUpdate.IsEnabled = true; tmrVideoUpdate.Tick += tmrVideoUpdate_Tick; _videoPacketDecoderWorker = new VideoPacketDecoderWorker(AR.Drone.Video.PixelFormat.BGR24, true, OnVideoPacketDecoded); _videoPacketDecoderWorker.Start(); _droneClient = new DroneClient("192.168.1.1"); _droneClient.NavigationPacketAcquired += OnNavigationPacketAcquired; _droneClient.VideoPacketAcquired += OnVideoPacketAcquired; _droneClient.NavigationDataAcquired += data => _navigationData = data; // commands Command_Connect = new RelayCommand(CommandConnect); Command_Disconnect = new RelayCommand(CommandDisconnect); Command_ShowDrownLayer = new RelayCommand <bool>(CommandShowDrownLayer); Command_UpdateDroneSettings = new RelayCommand(CommandUpdateDroneSettings); }
public void NavigateMvcPersonStartRowIndexLinkTest() { NavigationData data = new NavigationData(); data["startRowIndex"] = 10; string link = StateController.GetNavigationLink("MvcPerson", data); Assert.AreEqual("/MvcList/10", link); }
public override void Execute() { bool isBrowseMode; string screenName; Guid currentWorkflowState; if (!GetRootState(out screenName, out isBrowseMode, out currentWorkflowState)) { return; } string oldScreen = null; if (isBrowseMode) { NavigationData.LoadScreenHierarchy(screenName + "_OLD", out oldScreen); } NavigationData.SaveScreenHierarchy(screenName, isBrowseMode ? oldScreen : Consts.USE_BROWSE_MODE, !isBrowseMode /* backup when switching to browse mode */); IWorkflowManager workflowManager = ServiceRegistration.Get <IWorkflowManager>(); workflowManager.StartBatchUpdate(); workflowManager.NavigatePopToState(currentWorkflowState, true); workflowManager.NavigatePush(currentWorkflowState); workflowManager.EndBatchUpdate(); }
private NavigationData GetEmptyNavigationData(GridUnit _thisGrid, NavigationData _preGrid, int _G, int _H) { //优先从池子里取出 NavigationData nd = null; if (curUsedIdx < navigationDataPool.Count) { nd = navigationDataPool[curUsedIdx]; } else { nd = new NavigationData(); navigationDataPool.Add(nd); } ++curUsedIdx; nd.thisGrid = _thisGrid; nd.preGrid = _preGrid; nd.G = _G; nd.H = _H; nd.F = _G + _H; nd.open = true; nd.thisGrid.tempRef = nd; return(nd); }
private static bool GetRootState(out string screenName, out bool isBrowseMode, out Guid currentWorkflowState) { screenName = null; isBrowseMode = false; currentWorkflowState = Guid.Empty; if (!MediaNavigationModel.IsNavigationDataEnabled) { return(false); } NavigationData current = MediaNavigationModel.GetCurrentInstance().NavigationData; if (current == null) { return(false); } // Find root NavigationData while (current.Parent != null) { current = current.Parent; } screenName = current.BaseViewSpecification.ViewDisplayName; isBrowseMode = current.BaseViewSpecification is BrowseMediaRootProxyViewSpecification; currentWorkflowState = current.CurrentWorkflowStateId; return(true); }
public void ResolveNextStep_ActorWasDisplacedToPositionNeighboringLastStepButNotNextStep_ReturnsInProgressWithMovementToLastStepAndStackIsCorrect() { var currentPosition = new Position(-1, 1); var lastStepPosition = new Position(0, 1); var nextPosition = new Position(1, 1); IPathfinder pathfinder = Mock.Of <IPathfinder>(); IGrid gridInfoProvider = Mock.Of <IGrid>(p => p.IsWalkable(It.IsAny <Position>()) == true); var navigator = new Navigator(pathfinder, gridInfoProvider, Mock.Of <INaturalLineCalculator>(), Mock.Of <IRasterLineCreator>(), Mock.Of <IUiFacade>()); var navigationData = new NavigationData { RemainingStepsInCurrentSegment = new Stack <Position>(new[] { nextPosition, lastStepPosition }), Destination = nextPosition, LastStep = lastStepPosition, RemainingNodes = new [] { nextPosition }.ToList() }; Position nextStep; NavigationResult result = navigator.ResolveNextStep(navigationData, currentPosition, out nextStep); result.Should().Be(NavigationResult.InProgress); nextStep.Should().Be(lastStepPosition); var expectedSteps = new Stack <Position>(new[] { nextPosition }); navigationData.RemainingStepsInCurrentSegment. Should().BeEquivalentTo(expectedSteps, options => options.WithStrictOrderingFor(position => position)); }
public void ResolveNextStep_ActorWasDisplacedToPositionNeighboringLastStepAndNextStep_ReturnsInProgressWithMovementToNextStepAndStackIsEmpty() { var currentPosition = new Position(1, 1); var lastStepPosition = new Position(1, 0); var nextPosition = new Position(2, 0); IPathfinder pathfinder = Mock.Of <IPathfinder>(); IGrid gridInfoProvider = Mock.Of <IGrid>(p => p.IsWalkable(It.IsAny <Position>()) == true); var bresenham = new BresenhamLineCreator(); var navigator = new Navigator(pathfinder, gridInfoProvider, new NaturalLineCalculator(bresenham), bresenham, Mock.Of <IUiFacade>()); var navigationData = new NavigationData { RemainingStepsInCurrentSegment = new Stack <Position>(new[] { nextPosition }), Destination = nextPosition, RemainingNodes = new[] { nextPosition }.ToList(), LastStep = lastStepPosition }; Position nextStep; NavigationResult result = navigator.ResolveNextStep(navigationData, currentPosition, out nextStep); result.Should().Be(NavigationResult.InProgress); nextStep.Should().Be(nextPosition); navigationData.RemainingStepsInCurrentSegment. Should().BeEmpty(); }
public void Add(string key, NavigationData navigationData) { key = key ?? throw new ArgumentNullException(nameof(key)); navigationData = navigationData ?? throw new ArgumentNullException(nameof(navigationData)); _navigationDataByKey[key] = navigationData; }
public void ResolveNextStep_NextStepIsWalkableDestination_ReturnsInProgressWithNextStepAndUpcomingStepsAreCorrect() { var currentPosition = new Position(2, 2); var destination = new Position(3, 2); IPathfinder pathfinder = Mock.Of <IPathfinder>(); IGrid gridInfoProvider = Mock.Of <IGrid>(p => p.IsWalkable(It.IsAny <Position>()) == true); var navigator = new Navigator(pathfinder, gridInfoProvider, Mock.Of <INaturalLineCalculator>(), Mock.Of <IRasterLineCreator>(), Mock.Of <IUiFacade>()); var navigationData = new NavigationData { Destination = destination, RemainingStepsInCurrentSegment = new Stack <Position>(new[] { destination }), RemainingNodes = new List <Position> { destination }, LastStep = currentPosition }; Position nextStep; NavigationResult result = navigator.ResolveNextStep(navigationData, currentPosition, out nextStep); result.Should().Be(NavigationResult.InProgress); nextStep.Should().Be(destination); navigationData.RemainingStepsInCurrentSegment.Should().BeEmpty(); navigationData.LastStep.Should().Be(destination); navigationData.RemainingNodes.Should().BeEmpty(); }
public void NavigatePersonMaximumRowsLinkTest() { NavigationData data = new NavigationData(); data["maximumRows"] = 20; string link = StateController.GetNavigationLink("Person", data); Assert.AreEqual("/List/0/20", link); }
/// <summary> /// Display a page size option on the product list module. /// </summary> /// <param name="datatext"></param> /// <param name="model"></param> /// <param name="attributes"></param> /// <returns></returns> public IEncodedString PageSizeDropDownList(String datatext, NBrightRazor model, String cssclass = "") { if (datatext.StartsWith("ResourceKey:")) { datatext = ResourceKey(datatext.Replace("ResourceKey:", "")).ToString(); } var navigationdata = new NavigationData(PortalSettings.Current.PortalId, model.ModuleRef); if (navigationdata.PageSize == "") { navigationdata.PageSize = model.GetSetting("pagesize"); } var strOut = ""; var datat = datatext.Split(','); strOut = "<select class='pagesizedropdown" + model.ModuleRef + " " + cssclass + " '>"; var c = 0; var s = ""; foreach (var t in datat) { var url = ""; var param = new List <String>(); if (model.GetUrlParam("pagemid") != "") { param.Add("pagemid=" + model.ModuleId.ToString("D")); } if (model.GetUrlParam("catid") != "") { param.Add("catid=" + model.GetUrlParam("catid").Trim()); } param.Add("pagesize=" + t); var paramlist = new string[param.Count]; for (int lp = 0; lp < param.Count; lp++) { paramlist[lp] = param[lp]; } url = Globals.NavigateURL(PortalSettings.Current.ActiveTab.TabID, "", paramlist); s = ""; if (t == navigationdata.PageSize) { s = "selected"; } strOut += " <option value='" + t + "' " + s + " selectedurl='" + url + "' >" + t + "</option>"; c += 1; } strOut += "</select>"; strOut += "<script>"; strOut += "$('.pagesizedropdown" + model.ModuleRef + "').change(function () { window.location.replace($('option:selected', this).attr('selectedurl')); });"; strOut += "</script>"; return(new RawString(strOut)); }
protected void CtrlItemCommand(object source, RepeaterCommandEventArgs e) { var cArg = e.CommandArgument.ToString(); var param = new string[3]; var navigationData = new NavigationData(PortalId, "OrderAdmin"); switch (e.CommandName.ToLower()) { case "entrydetail": param[0] = "eid=" + cArg; Response.Redirect(Globals.NavigateURL(TabId, "", param), true); break; case "reorder": if (Utils.IsNumeric(cArg)) { var orderData = new OrderData(PortalId, Convert.ToInt32(cArg)); orderData.CopyToCart(DebugMode); } Response.Redirect(Globals.NavigateURL(StoreSettings.Current.CartTabId, "", param), true); break; case "return": param[0] = ""; Response.Redirect(Globals.NavigateURL(TabId, "", param), true); break; case "search": var strXml = GenXmlFunctions.GetGenXml(rpSearch, "", ""); navigationData.Build(strXml, _templSearch); navigationData.OrderBy = GenXmlFunctions.GetSqlOrderBy(rpSearch); navigationData.XmlData = GenXmlFunctions.GetGenXml(rpSearch); navigationData.Save(); if (StoreSettings.Current.DebugModeFileOut) { strXml = "<root><sql><![CDATA[" + navigationData.Criteria + "]]></sql>" + strXml + "</root>"; var xmlDoc = new System.Xml.XmlDocument(); xmlDoc.LoadXml(strXml); xmlDoc.Save(PortalSettings.HomeDirectoryMapPath + "debug_search.xml"); } Response.Redirect(Globals.NavigateURL(TabId, "", param), true); break; case "resetsearch": // clear cookie info navigationData.Delete(); Response.Redirect(Globals.NavigateURL(TabId, "", param), true); break; case "downloadinvoice": DownloadInvoice(Convert.ToInt32(cArg)); break; case "orderby": navigationData.OrderBy = GenXmlFunctions.GetSqlOrderBy(rpData); navigationData.Save(); break; } }
public override void EventAfterUpdate(System.Web.UI.WebControls.Repeater rpData, NBrightDNN.NBrightInfo objInfo) { // set page size so we pick it up in the product view. var navigationdata = new NavigationData(PortalId, objInfo.GetXmlProperty("genxml/textbox/modulekey")); navigationdata.PageSize = objInfo.GetXmlProperty("genxml/textbox/pagesize"); navigationdata.Save(); }
public Task PerformNavigationAsync(Page page, NavigationData data, CancellationToken token) { if (page.BindingContext is INavigatedFrom navigationViewModel) { return(navigationViewModel.OnNavigatedFromAsync(data, token)); } return(Task.CompletedTask); }
public virtual void InitMediaNavigation(out string mediaNavigationMode, out NavigationData navigationData) { Prepare(); string nextScreenName; AbstractScreenData nextScreen = null; // Try to load the prefered next screen from settings. if (NavigationData.LoadScreenHierarchy(_viewName, out nextScreenName)) { // Support for browsing mode. if (nextScreenName == Consts.USE_BROWSE_MODE) { SetBrowseMode(); } if (_availableScreens != null) { nextScreen = _availableScreens.FirstOrDefault(s => s.GetType().ToString() == nextScreenName); } } IEnumerable <Guid> optionalMIATypeIDs = MediaNavigationModel.GetMediaSkinOptionalMIATypes(MediaNavigationMode); if (_optionalMias != null) { optionalMIATypeIDs = optionalMIATypeIDs.Union(_optionalMias); optionalMIATypeIDs = optionalMIATypeIDs.Except(_necessaryMias); } // Prefer custom view specification. ViewSpecification rootViewSpecification = _customRootViewSpecification ?? new MediaLibraryQueryViewSpecification(_viewName, _filter, _necessaryMias, optionalMIATypeIDs, true, _necessaryMias) { MaxNumItems = Consts.MAX_NUM_ITEMS_VISIBLE }; if (nextScreen == null) { nextScreen = _defaultScreen; } ScreenConfig nextScreenConfig; NavigationData.LoadLayoutSettings(nextScreen.GetType().ToString(), out nextScreenConfig); Sorting.Sorting nextSortingMode = _availableSortings.FirstOrDefault(sorting => sorting.GetType().ToString() == nextScreenConfig.Sorting) ?? _defaultSorting; Sorting.Sorting nextGroupingMode = _availableGroupings == null || String.IsNullOrEmpty(nextScreenConfig.Grouping) ? null : _availableGroupings.FirstOrDefault(grouping => grouping.GetType().ToString() == nextScreenConfig.Grouping) ?? _defaultGrouping; navigationData = new NavigationData(null, _viewName, MediaNavigationRootState, MediaNavigationRootState, rootViewSpecification, nextScreen, _availableScreens, nextSortingMode, nextGroupingMode) { AvailableSortings = _availableSortings, AvailableGroupings = _availableGroupings, LayoutType = nextScreenConfig.LayoutType, LayoutSize = nextScreenConfig.LayoutSize }; mediaNavigationMode = MediaNavigationMode; }
protected bool PopNavigationWindow() { #region 导航信息为空 if (backSequence.Count == 0) { if (curNavigationWindow == null) { return(false); } //如果当前navigation的栈是空, 就检查当前UI的配置PrewindowID, 打开 WindowID preWindowId = curNavigationWindow.UIConfigData.PreWindowId; if (preWindowId != WindowID.WindowID_Invaild) { Debug.LogWarning(string.Format(string.Format("## Current nav window {0} need show pre window {1}.", curNavigationWindow.ID.ToString(), preWindowId.ToString()))); HideWindow(curNavigationWindow.ID, delegate { //不执行导航 WindowContextDataBase showData = new WindowContextDataBase(); showData.executeNavLogic = false; ShowWindow(preWindowId, showData); }); } else { Debug.LogWarning("## CurrentShownWindow " + curNavigationWindow.ID + " preWindowId is " + WindowID.WindowID_Invaild); } return(false); } #endregion NavigationData backData = backSequence.Peek(); if (backData != null) { // check the current navigation data int curId = this.GetCurrentShownWindow(); if (curId != (int)backData.showingUI.ID) { Debug.Log("<color=red>当前导航Stack里面信息不对 [backData.showingUI.ID != this.curShownWindowId]</color>"); return(false); } //关闭当前的UI, 恢复显示stack里面保存的UI WindowID showingId = backData.showingUI.ID; if (!dicShownWindows.ContainsKey((int)showingId)) { PopNavigationUI(backData); } else { HideWindow(showingId, delegate { PopNavigationUI(backData); }); } } return(true); }
public void BuildNavigation() { List <SAMenuItemDTO> arrangedMenuItems = new List <SAMenuItemDTO>(); //Remove the ff lines to disable caching if (CacheHelper.GetFromCacheWithCheck <List <SAMenuItemDTO> >("arrangedMenuItems") != null && CacheHelper.GetFromCacheWithCheck <List <SAMenuItemDTO> >("arrangedMenuItems").Count > 0) { arrangedMenuItems = CacheHelper.GetFromCacheWithCheck <List <SAMenuItemDTO> >("arrangedMenuItems"); this.view.BindNavigationMenu(arrangedMenuItems); return; } //Remove the ff lines to disable caching NavigationData data = new NavigationData(); MenuFilterSection menu = MenuFilterSection.GetConfig(); List <string> ids = menu.GetItemsToBeRemove(); string filter = string.Join(",", ids.ToArray()); MenuOrderSection menuOrder = MenuOrderSection.GetConfig(); List <SAMenuItemDTO> menuItems = data.GetAllUsedDiagrams(filter); if (menuOrder.MenuOrders.Count > 0) { foreach (MenuOrder item in menuOrder.MenuOrders) { SAMenuItemDTO order = menuItems.FirstOrDefault(c => c.ID == item.Id); if (order != null) { arrangedMenuItems.Insert(item.Order, order); } } if (menuItems.Count > menuOrder.MenuOrders.Count) { foreach (MenuOrder item in menuOrder.MenuOrders) { var order = menuItems.FirstOrDefault(c => c.ID == item.Id); if (order != null) { menuItems.Remove(order); } } arrangedMenuItems.AddRange(menuItems); } } else { arrangedMenuItems = menuItems.OrderBy(diag => diag.Text).ToList(); } //Remove the ff lines to disable caching CacheHelper.AddToCacheWithCheck("arrangedMenuItems", arrangedMenuItems); //Remove the ff lines to disable caching this.view.BindNavigationMenu(arrangedMenuItems); }
public override ActivityStep ResolveStep(GameEntity entity) { if (!_targetEntity.hasPosition) { return(Succeed(entity)); } if (Position.Distance(_targetEntity.position.Position, entity.position.Position) >= _giveUpDistance) { return(Fail(entity)); } Position targetCurrentPosition = _targetEntity.position.Position; bool targetIsOneStepAway = PositionUtilities.IsOneStep(entity.position.Position - targetCurrentPosition); if (targetIsOneStepAway) { return(new ActivityStep { State = ActivityState.InProgress, GameAction = _actionFactory.CreateAttackAction(entity, _targetEntity), }); } if (_rng.Check(0.03f)) { return(Fail(entity, _actionFactory.CreatePassAction(entity, 3f))); } bool targetPositionHasChanged = targetCurrentPosition != _lastTargetPosition; if (targetPositionHasChanged) { _lastTargetPosition = targetCurrentPosition; } if (targetPositionHasChanged || _navigationData == null) { // performance: should in fact be done every couple of turns _navigationData = _navigator.GetNavigationData(entity.position.Position, targetCurrentPosition); } Position nextStep; NavigationResult navigationResult = _navigator.ResolveNextStep(_navigationData, entity.position.Position, out nextStep); if (navigationResult == NavigationResult.Finished) { return(Succeed(entity)); } IGameAction moveGameAction = CreateMoveAction(nextStep, entity); return(new ActivityStep { State = ActivityState.InProgress, GameAction = moveGameAction }); }
public override void CreateScreenData(NavigationData navigationData) { base.CreateScreenData(navigationData); if (!_presentsBaseView) { return; } ReloadMediaItems(navigationData.BaseViewSpecification.BuildView(), true); }
/// <summary> /// 写导航数据文件 /// NavigationData /// </summary> /// <param name="navigationPacket"></param> /// <param name="navigationData"></param> /// <returns></returns> private void Write(NavigationPacket navigationPacket, NavigationData navigationData) { //_navigationDataWriter.WriteLine(navigationPacket.Timestamp + " " + navigationData.Yaw // + " " + navigationData.Pitch + " " + navigationData.Roll + " " + navigationData.Altitude // + " " + navigationData.Velocity.X + " " + navigationData.Velocity.Y + " " + navigationData.Velocity.Z); _navigationDataWriter.WriteLine(navigationData.GPS.latitude + " " + navigationData.GPS.longitude + " " + navigationData.GPS.latFuse + " " + navigationData.GPS.lonFuse); _navigationDataWriter.Flush(); }
public DroneClient(string hostname) { _networkConfiguration = new NetworkConfiguration(hostname); _commandQueue = new ConcurrentQueue <AtCommand>(); _navigationData = new NavigationData(); _commandSender = new CommandSender(NetworkConfiguration, _commandQueue); _navdataAcquisition = new NavdataAcquisition(NetworkConfiguration, OnNavdataPacketAcquired, OnNavdataAcquisitionStarted, OnNavdataAcquisitionStopped); }
//重置导航数据信息 public void Reset() { open = true; G = 0; H = 0; thisGrid = null; preGrid = null; }
public DroneClient(string hostname) { _networkConfiguration = new NetworkConfiguration(hostname); _commandQueue = new ConcurrentQueue<AtCommand>(); _navigationData = new NavigationData(); _commandSender = new CommandSender(NetworkConfiguration, _commandQueue); _navdataAcquisition = new NavdataAcquisition(NetworkConfiguration, OnNavdataPacketAcquired, OnNavdataAcquisitionStarted, OnNavdataAcquisitionStopped); _videoAcquisition = new VideoAcquisition(NetworkConfiguration, OnVideoPacketAcquired); }
private static void UpdateData(NameValueCollection queryString, NavigationData toData) { if (queryString["navigation"] != "history") { var toDataKeys = GetDataKeyEnumerator(queryString["tokeys"]); foreach (var toDataKey in toDataKeys) StateContext.Data[toDataKey] = toData[toDataKey]; } else StateContext.Data.Add(toData); }
public void NavigationDataValueProviderTest() { NavigationData data = new NavigationData() { { "string", "Hello" }, {"int", 1 } }; StateController.Navigate("d0", data); ModelBindingExecutionContext context = new ModelBindingExecutionContext(new MockHttpContext(), new ModelStateDictionary()); NavigationDataValueProvider provider = new NavigationDataValueProvider(context, false, null); Assert.AreEqual("Hello", provider.GetValue("string").RawValue); Assert.AreEqual(1, provider.GetValue("int").RawValue); Assert.AreEqual("1", provider.GetValue("int").AttemptedValue); }
private static MvcHtmlString GenerateSorter(this HtmlHelper htmlHelper, string linkText, string sortBy, string sortExpressionKey, object htmlAttributes) { if (string.IsNullOrEmpty(linkText)) throw new ArgumentException(Resources.NullOrEmpty, "linkText"); if (string.IsNullOrEmpty(sortBy)) throw new ArgumentException(Resources.NullOrEmpty, "sortBy"); string sortExpression = (string)StateContext.Data[sortExpressionKey]; if (sortExpression != sortBy + " DESC") sortExpression = sortBy + " DESC"; else sortExpression = sortBy; NavigationData toData = new NavigationData(); toData[sortExpressionKey] = sortExpression; return htmlHelper.RefreshLink(linkText, toData, true, htmlAttributes); }
/// <summary> /// Wraps the ASP.NET <see cref="System.Web.UI.ScriptManager"/> history point functionality. /// </summary> /// <param name="page">Current <see cref="System.Web.UI.Page"/></param> /// <param name="toData">The <see cref="Navigation.NavigationData"/> used to create the history point</param> /// <param name="title">Title for history point</param> /// <exception cref="System.ArgumentNullException"><paramref name="page"/> is null</exception> /// <exception cref="System.ArgumentException">There is <see cref="Navigation.NavigationData"/> that cannot be converted to a <see cref="System.String"/></exception> public static void AddHistoryPoint(Page page, NavigationData toData, string title) { if (page == null) throw new ArgumentNullException("page"); NameValueCollection coll = new NameValueCollection(); coll[NavigationSettings.Config.StateIdKey] = StateContext.StateId; foreach (NavigationDataItem item in toData) { if (!item.Value.Equals(string.Empty) && !StateContext.State.DefaultOrDerived(item.Key, item.Value)) coll[item.Key] = CrumbTrailManager.FormatURLObject(item.Key, item.Value, StateContext.State); } coll = StateContext.ShieldEncode(coll, true, StateContext.State); ScriptManager.GetCurrent(page).AddHistoryPoint(coll, title); ScriptManager.RegisterClientScriptBlock(page, typeof(StateController), "historyUrl", string.Format(CultureInfo.InvariantCulture, HISTORY_URL_VAR, HISTORY_URL, new JavaScriptSerializer().Serialize(GetRefreshLink(toData))), true); }
public void InitMediaNavigation(out string mediaNavigationMode, out NavigationData navigationData) { IEnumerable<Guid> skinDependentOptionalMIATypeIDs = MediaNavigationModel.GetMediaSkinOptionalMIATypes(MediaNavigationMode); AbstractItemsScreenData.PlayableItemCreatorDelegate picd = mi => new VideoItem(mi) { Command = new MethodDelegateCommand(() => PlayItemsModel.CheckQueryPlayAction(mi)) }; ViewSpecification rootViewSpecification = new MediaLibraryQueryViewSpecification(Consts.RES_VIDEOS_VIEW_NAME, null, Consts.NECESSARY_VIDEO_MIAS, skinDependentOptionalMIATypeIDs, true) { MaxNumItems = Consts.MAX_NUM_ITEMS_VISIBLE }; AbstractScreenData filterByGenre = new VideosFilterByGenreScreenData(); ICollection<AbstractScreenData> availableScreens = new List<AbstractScreenData> { new VideosShowItemsScreenData(picd), new VideosFilterByLanguageScreenData(), new VideosFilterByActorScreenData(), new VideosFilterByDirectorScreenData(), new VideosFilterByWriterScreenData(), filterByGenre, // C# doesn't like it to have an assignment inside a collection initializer new VideosFilterByYearScreenData(), new VideosFilterBySystemScreenData(), new VideosSimpleSearchScreenData(picd), }; Sorting.Sorting sortByTitle = new SortByTitle(); ICollection<Sorting.Sorting> availableSortings = new List<Sorting.Sorting> { sortByTitle, new SortByYear(), new VideoSortByFirstGenre(), new VideoSortByDuration(), new VideoSortByFirstActor(), new VideoSortByFirstDirector(), new VideoSortByFirstWriter(), new VideoSortBySize(), new VideoSortByAspectRatio(), new SortBySystem(), }; navigationData = new NavigationData(null, Consts.RES_VIDEOS_VIEW_NAME, MediaNavigationRootState, MediaNavigationRootState, rootViewSpecification, filterByGenre, availableScreens, sortByTitle) { AvailableSortings = availableSortings }; mediaNavigationMode = MediaNavigationMode; }
/// <summary> /// Updates <see cref="Navigation.StateContext.Data">State Context</see> when the /// <see cref="System.Web.UI.WebControls.HyperLink"/> posts back to the server /// </summary> /// <param name="eventArgument">The argument for the event</param> public void RaisePostBackEvent(string eventArgument) { if (StringComparer.OrdinalIgnoreCase.Compare(eventArgument, REFRESH_POST_BACK) == 0) { Page.ClientScript.ValidateEvent(HyperLink.UniqueID, REFRESH_POST_BACK); NavigationData derivedData = new NavigationData(StateContext.State.Derived); NavigationData toData = StateInfoConfig.ParseNavigationDataExpression(HyperLink.Attributes["__ToData"], StateContext.State, true); StateContext.Data.Clear(); StateContext.Data.Add(toData); StateContext.Data.Add(derivedData); } else { ((IPostBackEventHandler)HyperLink).RaisePostBackEvent(eventArgument); } }
/// <summary> /// Validates the incoming Url and if no <see cref="Navigation.NavigationSettings.StateIdKey"/> /// found will navigate to the <see cref="Navigation.Dialog"/> whose path property matches the Url /// </summary> /// <returns>A <see cref="System.Collections.Specialized.NameValueCollection"/> of the /// postback variables, if any; otherwise null</returns> /// <exception cref="Navigation.UrlException">The <see cref="Navigation.NavigationSettings.StateIdKey"/> /// is not found and the Url does not match the path of any <see cref="Navigation.Dialog"/>; the page of /// the <see cref="Navigation.State"/> does not match the Url path</exception> public override NameValueCollection DeterminePostBackMode() { if (IsLogin() || !HttpContext.Current.Handler.GetType().IsSubclassOf(typeof(Page)) || StateInfoConfig.Dialogs == null || StateInfoConfig.Dialogs.Count == 0) return base.DeterminePostBackMode(); #if NET40Plus StateContext.StateId = Page.Request.QueryString[NavigationSettings.Config.StateIdKey] ?? (string)Page.RouteData.DataTokens[NavigationSettings.Config.StateIdKey]; #else StateContext.StateId = Page.Request.QueryString[NavigationSettings.Config.StateIdKey]; #endif if (StateContext.StateId == null) { if (_DialogPaths.ContainsKey(Page.AppRelativeVirtualPath.ToUpperInvariant())) { NavigationData data = new NavigationData(); foreach (string key in Page.Request.QueryString) data.Add(key, Page.Request.QueryString[key]); StateController.Navigate(_DialogPaths[Page.AppRelativeVirtualPath.ToUpperInvariant()].Key, data); } #if NET40Plus if (Page.RouteData.Route != null) return base.DeterminePostBackMode(); #endif throw new UrlException(Resources.InvalidUrl); } if (StateContext.State == null) { StateContext.StateId = null; throw new UrlException(Resources.InvalidUrl); } #if NET40Plus Route route = Page.RouteData.Route as Route; if (StringComparer.OrdinalIgnoreCase.Compare(StateContext.State.Page, Page.AppRelativeVirtualPath) != 0 && StringComparer.OrdinalIgnoreCase.Compare(StateContext.State.MobilePage, Page.AppRelativeVirtualPath) != 0 && (route == null || StringComparer.OrdinalIgnoreCase.Compare(StateContext.State.Route, route.Url) != 0)) #else if (StringComparer.OrdinalIgnoreCase.Compare(StateContext.State.Page, Page.AppRelativeVirtualPath) != 0 && StringComparer.OrdinalIgnoreCase.Compare(StateContext.State.MobilePage, Page.AppRelativeVirtualPath) != 0) #endif { throw new UrlException(Resources.InvalidUrl); } Page.PreInit += Page_PreInit; return base.DeterminePostBackMode(); }
internal static string GetHref(string nextState, NavigationData navigationData, NavigationData returnData) { string previousState = StateContext.StateId; string crumbTrail = StateContext.CrumbTrailKey; State state = StateContext.GetState(nextState); NameValueCollection coll = new NameValueCollection(); coll[NavigationSettings.Config.StateIdKey] = nextState; if (previousState != null && state.TrackCrumbTrail) { coll[NavigationSettings.Config.PreviousStateIdKey] = previousState; } if (navigationData != null) { foreach (NavigationDataItem item in navigationData) { if (!item.Value.Equals(string.Empty) && !state.DefaultOrDerived(item.Key, item.Value)) coll[item.Key] = FormatURLObject(item.Key, item.Value, state); } } if (returnData != null && state.TrackCrumbTrail && StateContext.State != null) { var returnDataBuilder = FormatReturnData(null, StateContext.State, returnData); if (returnDataBuilder.Length > 0) coll[NavigationSettings.Config.ReturnDataKey] = returnDataBuilder.ToString(); } if (crumbTrail != null && state.TrackCrumbTrail) { coll[NavigationSettings.Config.CrumbTrailKey] = crumbTrail; } #if NET35Plus coll = StateContext.ShieldEncode(coll, false, state); #else coll = StateContext.ShieldEncode(coll, state); #endif #if NET40Plus HttpContextBase context = null; if (HttpContext.Current != null) context = new HttpContextWrapper(HttpContext.Current); else context = new MockNavigationContext(null, state); return state.StateHandler.GetNavigationLink(state, coll, context); #else return state.StateHandler.GetNavigationLink(state, coll); #endif }
/// <summary> /// Returns the object that processes the request /// </summary> /// <param name="requestContext">An object that encapsulates information about the request</param> /// <returns>The object that processes the request</returns> protected override IHttpHandler GetHttpHandler(RequestContext requestContext) { StateController.SetStateContext(State.Id, requestContext.HttpContext); var queryString = requestContext.HttpContext.Request.QueryString; var link = queryString["refreshajax"]; if (link != null) { var toData = new NavigationData(true); StateController.NavigateLink(State, link, NavigationMode.Mock); RefreshAjaxInfo.GetInfo(requestContext.HttpContext).Data = new NavigationData(true); var includeCurrentData = false; bool.TryParse(queryString["includecurrent"], out includeCurrentData); if (!includeCurrentData) { var currentDataKeys = GetDataKeyEnumerator(queryString["currentkeys"]); var currentData = new NavigationData(currentDataKeys); StateContext.Data.Clear(); StateContext.Data.Add(currentData); } UpdateData(queryString, toData); } return base.GetHttpHandler(requestContext); }
public static NavigationData ToNavigationData(NavdataBag navdataBag) { var navigationData = new NavigationData(); var ardroneState = (def_ardrone_state_mask_t)navdataBag.navigationDataHeader.ardrone_state; UpdateStateUsing(ardroneState, ref navigationData.State); navigationData.Masks = ardroneState; var ctrlState = (CTRL_STATES)(navdataBag.demo.ctrl_state >> 0x10); UpdateStateUsing(ctrlState, ref navigationData.State); navigationData.Yaw = DegreeToRadian * (navdataBag.demo.psi / 1000.0f); navigationData.Pitch = DegreeToRadian * (navdataBag.demo.theta / 1000.0f); navigationData.Roll = DegreeToRadian * (navdataBag.demo.phi / 1000.0f); navigationData.Altitude = navdataBag.demo.altitude / 1000.0f; navigationData.Time = navdataBag.time.time; DateTime date = new DateTime(navdataBag.time.time); navigationData.Velocity.X = navdataBag.demo.vx / 1000.0f; navigationData.Velocity.Y = navdataBag.demo.vy / 1000.0f; navigationData.Velocity.Z = navdataBag.demo.vz / 1000.0f; Battery bat = new Battery(); bat.Low = ardroneState.HasFlag(def_ardrone_state_mask_t.ARDRONE_VBAT_LOW); bat.Percentage = navdataBag.demo.vbat_flying_percentage; bat.Voltage = navdataBag.raw_measures.vbat_raw / 1000.0f; navigationData.Battery = bat; navigationData.Wifi.LinkQuality = 1.0f - ConversionHelper.ToSingle(navdataBag.wifi.link_quality); navigationData.Video.FrameNumber = navdataBag.video_stream.frame_number; return navigationData; }
/// <summary> /// Creates <see cref="Navigation.NavigationData"/> that corresponds to the key/value pairs /// specified by the <paramref name="expression"/></summary> /// <param name="expression">The key/value pairs with types optional. Values are optional if /// <paramref name="useCurrentData"/> is true</param> /// <param name="state">Holds the <see cref="Navigation.State.DefaultTypes"/> of the keys</param> /// <param name="useCurrentData">Indicates whether values can be retrieved from the current /// <see cref="Navigation.StateContext.Data"/></param> /// <returns>The <see cref="Navigation.NavigationData"/> that corresponds to the specified /// key/value pairs</returns> /// <exception cref="System.ArgumentNullException"><paramref name="expression"/> is null</exception> /// <exception cref="System.FormatException">Either the <paramref name="expression"/> was not /// in a recognised format or it contained an unrecognised type or a value was not in a format /// recognised by its corresponding type</exception> /// <exception cref="System.InvalidCastException">The <paramref name="expression"/> specifies types /// of guid or timespan</exception> /// <exception cref="System.OverflowException">A value represents a number that is out of the /// range of its corresponding type</exception> public static NavigationData ParseNavigationDataExpression(string expression, State state, bool useCurrentData) { if (expression == null) throw new ArgumentNullException("expression"); string[] keyTypeValue; expression = expression.Trim(); bool includeCurrentData = useCurrentData && expression.StartsWith("&", StringComparison.Ordinal); NavigationData navigationData = new NavigationData(includeCurrentData); if (includeCurrentData) { expression = expression.Substring(1); if (expression.Length == 0) return navigationData; } foreach (string dataItem in expression.Split(new char[] { ',' })) { keyTypeValue = dataItem.Split(new char[] { '=' }); if (keyTypeValue.Length == 2) SetNavigationKeyValue(navigationData, keyTypeValue, state); else SetNavigationKey(navigationData, keyTypeValue, useCurrentData, includeCurrentData); } return navigationData; }
private NavigationData PushToStack(UIViewController controller, string param) { NavigationData data = new NavigationData(controller, param); if (controller.StackPushable) { controllerStacks.Push(data); } return data; }
/// <summary> /// Releases all data which was created in method <see cref="CreateScreenData"/>. This method will be called when the /// screen is no longer needed. After calling this method, <see cref="CreateScreenData"/> might be called again to /// re-create the screen. /// </summary> public virtual void ReleaseScreenData() { _navigationData = null; _numItemsStrProperty = null; _isItemsValidProperty = null; _isItemsEmptyProperty = null; _tooManyItemsProperty = null; _showListProperty = null; _showListHintProperty = null; _listHintProperty = null; if (_items != null) _items.Clear(); _items = null; }
/// <summary> /// Updates all data which is needed by the skin. That is all properties in the region "Lazy initialized properties" /// and all properties from sub classes. After calling this method, the UI screen will be shown. /// </summary> public virtual void CreateScreenData(NavigationData navigationData) { if (IsEnabled) throw new IllegalCallException("Screen data is already initialized"); _navigationData = navigationData; _numItemsStrProperty = new WProperty(typeof(string), string.Empty); _isItemsValidProperty = new WProperty(typeof(bool), true); _isItemsEmptyProperty = new WProperty(typeof(bool), true); _tooManyItemsProperty = new WProperty(typeof(bool), false); _showListProperty = new WProperty(typeof(bool), true); _showListHintProperty = new WProperty(typeof(bool), false); _listHintProperty = new WProperty(typeof(string), string.Empty); }
/// <summary> /// Loads the previously saved view state of the <see cref="Navigation.NavigationHyperLink"/> /// </summary> /// <param name="savedState">The saved view state values for the control</param> protected override void LoadViewState(object savedState) { if (savedState == null) { base.LoadViewState(null); } else { Pair pair = (Pair)savedState; base.LoadViewState(pair.First); if (pair.Second != null) { ToData = new NavigationData(); ((IStateManager)ToData).LoadViewState(pair.Second); } } }
private void UpdateData(NavigationData data) { if (ToData != null) { foreach (NavigationDataItem item in ToData) { data[item.Key] = (!item.Value.Equals(string.Empty) || !ConvertEmptyStringToNull) ? item.Value : null; } } }
/// <summary> /// Updates <see cref="Navigation.StateContext.Data">State Context</see> when the <see cref="Navigation.NavigationHyperLink"/> /// posts back to the server /// </summary> /// <param name="eventArgument">The argument for the event</param> public virtual void RaisePostBackEvent(string eventArgument) { Page.ClientScript.ValidateEvent(UniqueID); OnPreNavigationDataChange(EventArgs.Empty); NavigationData derivedData = new NavigationData(StateContext.State.Derived); if (!IncludeCurrentData) { NavigationData currentData = new NavigationData(CurrentDataKeyEnumerator); StateContext.Data.Clear(); StateContext.Data.Add(currentData); } UpdateData(StateContext.Data); StateContext.Data.Add(derivedData); OnClick(EventArgs.Empty); OnCommand(new CommandEventArgs(CommandName, CommandArgument)); }
private void OnNavigationDataAcquired(NavigationData navigationData) { if (NavigationDataAcquired != null) NavigationDataAcquired(navigationData); }
/// <summary> /// Provides access to the current <see cref="Navigation.StateContext.Data">State Context</see> /// set with any values specified in the <see cref="SelectParameters"/> collection /// </summary> /// <param name="arguments">This parameter is ignored as <see cref="Navigation.NavigationData"/> /// only supports getting values by key</param> /// <returns>A copy of the <see cref="Navigation.StateContext.Data">State Context</see></returns> protected override IEnumerable ExecuteSelect(DataSourceSelectArguments arguments) { NavigationData data = new NavigationData(true); foreach (DictionaryEntry entry in SelectParameters.GetValues(_Context, _Owner)) { data[(string)entry.Key] = entry.Value; } yield return data; }
private void UpdateNavigationData(NavigationPacket packet) { NavigationData navigationData; if (NavigationPacketParser.TryParse(ref packet, out navigationData)) { OnNavigationDataAcquired(navigationData); _navigationData = navigationData; ProcessStateTransitions(navigationData.State); } }
private void SetNavigationLinks(Control parent) { HyperLink link; int startRowIndex; int result; string pageNumber; foreach (Control control in parent.Controls) { link = control as HyperLink; if (link != null) { pageNumber = null; startRowIndex = 0; if (link.NavigateUrl.IndexOf("?", StringComparison.Ordinal) >= 0) pageNumber = HttpUtility.ParseQueryString(link.NavigateUrl.Substring(link.NavigateUrl.IndexOf("?", StringComparison.Ordinal)))[QueryStringField]; if (pageNumber != null) { if (int.TryParse(pageNumber, out result)) startRowIndex = (result - 1) * MaximumRows; NavigationData data = new NavigationData(true); data[StartRowIndexKey] = null; if (startRowIndex != DefaultStartRowIndex) data[StartRowIndexKey] = startRowIndex; data[MaximumRowsKey] = null; if (MaximumRows != DefaultMaximumRows) data[MaximumRowsKey] = MaximumRows; link.NavigateUrl = null; if (link.Enabled && PostBackHyperLink) { link.NavigateUrl = StateController.GetRefreshLink(data); PostBackOptions postBackOptions = new PostBackOptions(this, startRowIndex.ToString(NumberFormatInfo.InvariantInfo)); link.Attributes.Add("onclick", string.Format(CultureInfo.InvariantCulture, "if(!event.ctrlKey&&!event.shiftKey){{{0};return false;}}", Page.ClientScript.GetPostBackEventReference(postBackOptions, true))); } } } SetNavigationLinks(control); } }
private void ResetNavigationData() { _navigationData = new NavigationData(); }
public override void CreateScreenData(NavigationData navigationData) { base.CreateScreenData(navigationData); InitializeSearch(navigationData.BaseViewSpecification); }
private NavigationData GetNavigationData( CampusCache campus ) { using ( var rockContext = new RockContext() ) { var validLocationids = new List<int>(); if ( campus.LocationId.HasValue ) { // Get all the child locations validLocationids.Add( campus.LocationId.Value ); new LocationService( rockContext ) .GetAllDescendents( campus.LocationId.Value ) .Select( l => l.Id ) .ToList() .ForEach( l => validLocationids.Add( l ) ); } var groupTypeTemplateGuid = PageParameter( "Area" ).AsGuidOrNull(); if ( !groupTypeTemplateGuid.HasValue ) { groupTypeTemplateGuid = this.GetAttributeValue( "GroupTypeTemplate" ).AsGuidOrNull(); } if ( !groupTypeTemplateGuid.HasValue ) { // Check to see if a specific group was specified Guid? guid = Rock.SystemGuid.DefinedValue.GROUPTYPE_PURPOSE_CHECKIN_TEMPLATE.AsGuid(); int? groupId = PageParameter( "Group" ).AsIntegerOrNull(); if ( groupId.HasValue && guid.HasValue ) { var group = new GroupService( rockContext ).Get( groupId.Value ); if ( group != null && group.GroupType != null ) { var groupType = GetParentPurposeGroupType( group.GroupType, guid.Value ); if ( groupType != null ) { groupTypeTemplateGuid = groupType.Guid; } } } } if ( groupTypeTemplateGuid.HasValue ) { pnlContent.Visible = true; NavData = new NavigationData(); var chartTimes = GetChartTimes(); // Get the group types var parentGroupType = GroupTypeCache.Read( groupTypeTemplateGuid.Value ); if ( parentGroupType != null ) { foreach ( var childGroupType in parentGroupType.ChildGroupTypes ) { AddGroupType( childGroupType, chartTimes ); } } // Get the groups var groupTypeIds = NavData.GroupTypes.Select( t => t.Id ).ToList(); var groups = new GroupService( rockContext ) .Queryable( "GroupLocations" ).AsNoTracking() .Where( g => groupTypeIds.Contains( g.GroupTypeId ) && g.IsActive ) .ToList(); var groupIds = groups.Select( g => g.Id ).ToList(); foreach( var group in groups ) { var childGroupIds = groups .Where( g => g.ParentGroupId.HasValue && g.ParentGroupId.Value == group.Id ) .Select( g => g.Id ) .ToList(); var childLocationIds = group.GroupLocations .Where( l => validLocationids.Contains( l.LocationId ) ) .Select( l => l.LocationId ) .ToList(); if ( childLocationIds.Any() || childGroupIds.Any() ) { var navGroup = new NavigationGroup( group, chartTimes ); navGroup.ChildLocationIds = childLocationIds; navGroup.ChildGroupIds = childGroupIds; NavData.Groups.Add( navGroup ); if ( !group.ParentGroupId.HasValue || groupIds.Contains( group.ParentGroupId.Value ) ) { NavData.GroupTypes.Where( t => t.Id == group.GroupTypeId ).ToList() .ForEach( t => t.ChildGroupIds.Add( group.Id ) ); } } } // Remove any groups without child locations var emptyGroupIds = NavData.Groups .Where( g => !g.ChildGroupIds.Any() && !g.ChildLocationIds.Any() ) .Select( g => g.Id ) .ToList(); while ( emptyGroupIds.Any() ) { NavData.Groups = NavData.Groups.Where( g => !emptyGroupIds.Contains( g.Id ) ).ToList(); NavData.Groups.ForEach( g => g.ChildGroupIds = g.ChildGroupIds.Where( c => !emptyGroupIds.Contains( c ) ).ToList() ); emptyGroupIds = NavData.Groups .Where( g => !g.ChildGroupIds.Any() && !g.ChildLocationIds.Any() ) .Select( g => g.Id ) .ToList(); } // Remove any grouptype without groups var emptyGroupTypeIds = NavData.GroupTypes .Where( t => !t.ChildGroupIds.Any() && !t.ChildGroupTypeIds.Any() ) .Select( t => t.Id ) .ToList(); while ( emptyGroupTypeIds.Any() ) { NavData.GroupTypes = NavData.GroupTypes.Where( t => !emptyGroupTypeIds.Contains( t.Id ) ).ToList(); NavData.GroupTypes.ForEach( t => t.ChildGroupTypeIds = t.ChildGroupTypeIds.Where( c => !emptyGroupTypeIds.Contains( c ) ).ToList() ); emptyGroupTypeIds = NavData.GroupTypes .Where( t => !t.ChildGroupIds.Any() && !t.ChildGroupTypeIds.Any() ) .Select( t => t.Id ) .ToList(); } // If not group types left, redirect to area select page if ( NavData.GroupTypes.Count == 0 ) { NavigateToLinkedPage( "AreaSelectPage" ); } // Get the locations var locationIds = NavData.Groups.SelectMany( g => g.ChildLocationIds ).Distinct().ToList(); foreach ( var location in new LocationService( rockContext ) .Queryable( "ParentLocation" ).AsNoTracking() .Where( l => locationIds.Contains( l.Id ) ) ) { var navLocation = AddLocation( location, chartTimes ); navLocation.HasGroups = true; } // Get the attendance counts var dayStart = RockDateTime.Today; var now = RockDateTime.Now; groupIds = NavData.Groups.Select( g => g.Id ).ToList(); var attendances = new AttendanceService( rockContext ).Queryable() .Where( a => a.ScheduleId.HasValue && a.GroupId.HasValue && a.LocationId.HasValue && a.StartDateTime > dayStart && a.StartDateTime < now && a.DidAttend.HasValue && a.DidAttend.Value && groupIds.Contains( a.GroupId.Value ) && locationIds.Contains( a.LocationId.Value ) ) .ToList(); var schedules = new ScheduleService( rockContext ).Queryable() .Where( s => s.CheckInStartOffsetMinutes.HasValue ) .ToList(); foreach ( DateTime chartTime in chartTimes ) { // Get the active schedules var activeSchedules = new List<int>(); foreach ( var schedule in schedules ) { if ( schedule.WasScheduleOrCheckInActive( chartTime ) ) { activeSchedules.Add( schedule.Id ); } } bool current = chartTime.Equals( chartTimes.Max() ); foreach ( var groupLocSched in attendances .Where( a => a.StartDateTime < chartTime && a.PersonAlias != null && activeSchedules.Contains( a.ScheduleId.Value ) ) .GroupBy( a => new { ScheduleId = a.ScheduleId.Value, GroupId = a.GroupId.Value, LocationId = a.LocationId.Value } ) .Select( g => new { ScheduleId = g.Key.ScheduleId, GroupId = g.Key.GroupId, LocationId = g.Key.LocationId, PersonIds = g.Select( a => a.PersonAlias.PersonId ).Distinct().ToList() } ) ) { AddGroupCount( chartTime, groupLocSched.GroupId, groupLocSched.PersonIds, current ); AddLocationCount( chartTime, groupLocSched.LocationId, groupLocSched.PersonIds, current ); } } return NavData; } else { if ( string.IsNullOrWhiteSpace( PageParameter( "Area" ) ) ) { // If could not determine area and did not come from are select, redirect to area select page NavigateToLinkedPage( "AreaSelectPage" ); } nbWarning.Text = "Please select a valid Check-in type in the block settings."; nbWarning.Visible = true; pnlContent.Visible = false; } } return null; }