public PeopleTopicView() { InitializeComponent(); var click = Observable .FromEventPattern <ItemClickEventArgs>(PeopleTopicsList, nameof(PeopleTopicsList.ItemClick)) .Select(x => x.EventArgs.ClickedItem as TopicModel) .ObserveOnCoreDispatcher() .Subscribe(x => PageStack.Next("Right", "Right", typeof(RepliesAndTopicView), x.Id)); NotifyData.LoadDataTask = async count => { var html = await ApiClient.GetFavoriteTopics(NotifyData.CurrentPage); var dom = new HtmlParser().ParseDocument(html); return(new PagesBaseModel <TopicModel> { Pages = DomParse.ParseMaxPage(dom), Entity = DomParse.ParseTopics(dom) ?? new List <TopicModel>() }); }; _events = new List <IDisposable> { click }; }
public IActionResult Preview(String file) { //This can be optimized like index, but will only be hit //for one page if requested, so whatever targetFileInfo = fileInfoProvider.GetFileInfo(file, HttpContext.Request.PathBase); templateEnvironment = new TemplateEnvironment(targetFileInfo.FileNoExtension, fileFinder, overrideVars: overrideValuesProvider.OverrideVars); PageStack pageStack = new PageStack(templateEnvironment, fileFinder); pageStack.ContentFile = targetFileInfo.HtmlFile; var pageSettings = fileFinder.GetProjectPageDefinition(targetFileInfo); switch (targetFileInfo.Extension) { case ".html": if (targetFileInfo.IsProjectFile) { return(new FileStreamResult(fileFinder.ReadFile(targetFileInfo.HtmlFile), "text/html")); } return(Redirect(targetFileInfo.NoHtmlRedirect)); case "": return(buildAsPage(pageStack, pageSettings.Layout)); default: var cleanExtension = targetFileInfo.Extension.TrimStart('.') + ".html"; if (fileFinder.DoesLayoutExist(cleanExtension)) { return(buildAsPage(pageStack, cleanExtension)); } return(returnFile(file)); } }
public async Task <IActionResult> OnGet(long id, int primary) { PageStack.PushPage(HttpContext.Session, $"/Admin/ShowPerson/{id}", ""); var prim = await this.treeService.GetIndividualById(id).ConfigureAwait(false); if (prim == null) { return(RedirectToPage("Back")); } Primary = new IndividualVm(prim); foreach (var spouseFam in await this.treeService.GetSpouseFamiliesByIndividualId(id, false).ConfigureAwait(false)) { Marriages.Add(new FamilyVm(spouseFam)); } var childFams = await this.treeService.GetChildFamiliesByIndividualId(id, false).ConfigureAwait(false); if (childFams.Any()) { ParentFamily = new FamilyVm(childFams.First()); SetSiblings(); // skip grandparents SortData(); } return(Page()); }
public void PushPopTest() { var stack = new PageStack(); Assert.That(stack.Count, Is.EqualTo(0)); stack.Push(new Page { Name = "Page1", Data = null }); Assert.That(stack.Count, Is.EqualTo(1)); Assert.That(stack.Peek().Name, Is.EqualTo("Page1")); stack.Push(new Page { Name = "Page2", Data = null }); Assert.That(stack.Count, Is.EqualTo(2)); Assert.That(stack.Peek().Name, Is.EqualTo("Page2")); var page2 = stack.Pop(); Assert.That(page2.Name, Is.EqualTo("Page2")); Assert.That(stack.Count, Is.EqualTo(1)); Assert.That(stack.Peek().Name, Is.EqualTo("Page1")); var page1 = stack.Pop(); Assert.That(page1.Name, Is.EqualTo("Page1")); Assert.That(stack.Count, Is.EqualTo(0)); }
private void DeleteSelectedBlob() { Dialog.ConfirmYesOrNo("Are you sure you want ot delete blob " + (Grid.SelectedItem as CloudBlob).Name + "?", () => { var operation = new ProgressOperation() { Message = "Deleting blob ".ToConsoleString() + (Grid.SelectedItem as CloudBlob).Name.ToConsoleString(ConsoleColor.Yellow), State = OperationState.InProgress }; Application.MessagePump.QueueAsyncAction((Grid.SelectedItem as CloudBlob).DeleteAsync(), (tp) => { if (tp.Exception != null) { operation.State = OperationState.Failed; operation.Details = tp.Exception.ToString().ToConsoleString(); operation.Message = "Failed to delete blob ".ToConsoleString() + (Grid.SelectedItem as CloudBlob).Name.ToConsoleString(ConsoleColor.Yellow); } else { operation.State = OperationState.Completed; operation.Message = "Finished deleting blob ".ToConsoleString() + (Grid.SelectedItem as CloudBlob).Name.ToConsoleString(ConsoleColor.Yellow); } if (Application != null && PageStack.CurrentPage == this) { PageStack.TryRefresh(); } }); }); }
public void GoBack() { var lastPage = CurrentPage; PageStack.Pop(); CallOnNavigatedFrom(lastPage, CurrentPage); }
public static Page Replace(string pageName, string param = null, Admission admision = null) { if (AdmissionManager.busing) { return(null); } Debug.Log("Replace to: " + pageName); var oldPage = PageStack.Find(pageName); if (oldPage != null) { throw new Exception("page: " + pageName + " already in stack, can't replace, try use Backto"); } var fromPage = PageStack.Peek(); var page = TakeOrCreatePage(pageName); page.param = param; PageStack.RelpaceTop(page); RepositionMask(); if (admision != null) { AdmissionManager.Play(admision, fromPage, page); } return(page); }
public static void Back(object result = null, Admission admision = null) { if (AdmissionManager.busing) { return; } var page = PageStack.Pop(); if (page != null) { pagePool.Put(page.name, page); } if (PageStack.Count > 0) { var top = PageStack.Peek(); Debug.Log("Back to: " + top.name); top.OnResult(result); } else { Debug.Log("All pages poped!"); } if (admision != null) { AdmissionManager.Play(admision, page, PageStack.Peek()); } RepositionMask(); }
public static Page Forward(string pageName, object param = null, Admission admision = null) { if (AdmissionManager.busing) { return(null); } Debug.Log("Navigate to: " + pageName); var oldPage = PageStack.Find(pageName); if (oldPage != null) { throw new Exception("page: " + pageName + " already in stack, can't navigate, try use BackTo"); } var fromPage = PageStack.Peek(); var page = TakeOrCreatePage(pageName); page.param = param; page.OnParamChanged(); PageStack.Push(page); RepositionMask(); if (admision != null) { AdmissionManager.Play(admision, fromPage, page); } return(page); }
public static void BackTo <T>() where T : Page { if (AdmissionManager.busing) { return; } var name = typeof(T).Name; var targetPage = PageStack.Find(name); if (targetPage == null) { // page not in stack, can't pop to return; } var popedList = PageStack.PopUtil(targetPage); // var top = Top; // while(typeof(T) != top.GetType()) // { // UIEngine.Back(); // top = Top; // if(top == null) // { // break; // } // } foreach (var p in popedList) { pagePool.Put(p.name, p); } }
public IActionResult OnGet() { PageStack.PushPage(HttpContext.Session, "/Admin/AddFamily", ""); // TODO return(RedirectToPage("Back")); }
private IActionResult build(PageStack pageStack, HtmlDocumentRenderer dr) { try { return(getConvertedDocument(pageStack, dr)); } catch (DirectoryNotFoundException) { //If the source file cannot be read offer to create the new file instead. if (targetFileInfo.PathCanCreateFile) { return(showNewPage(pageStack, dr)); } else { throw; } } catch (FileNotFoundException ex) { //If the source file cannot be read offer to create the new file instead. if (targetFileInfo.PathCanCreateFile) { var sb = new StringBuilder($"Could not find file '{ex.FileName}' Message: '{ex.Message}' building page '{pageStack.ContentFile}'. Showing new page."); WriteSearchLocations(sb, ex as PageStackFileNotFoundException); logger.LogInformation(sb.ToString()); return(showNewPage(pageStack, dr)); } else { throw; } } }
public void GoBack() { if (!CanGoBack) { return; } var page = PageStack[PageIndex]; var args = new HBNavigatingCancelEventArgs(); page.OnNavigatingFrom(args); page.Visibility = Windows.UI.Xaml.Visibility.Collapsed; PageStack.Remove(page); FrameGrid.Children.Remove(page); page.OnNavigatedFrom(new HBNavigationEventArgs()); GC.SuppressFinalize(page); GC.Collect(); page.Content = null; page = null; PageIndex--; if (PageIndex >= 0) { page = PageStack[PageIndex]; //page.OnNavigatedTo(new HBNavigationEventArgs() { NavigationMode = NavigationMode.Back }); } else { this.Visibility = Visibility.Collapsed; } }
private static void HidePage(Page page, Direction direction) { page.Closing(direction); var previous = PageStack.Peek(); // Previous page. ShowPage(previous, direction); // Show previous page. }
public static T FindInStack <T>() where T : Page { var name = typeof(T).Name; var page = PageStack.Find(name); return(page as T); }
public State Reduce(State state, StateAction action) { if (!(action.Reducer is PageInitReducer)) { return(state); } var definitionKey = PageConst.StateDefinitionKey; var stackKey = PageConst.StateStackKey; var definition = action.GetValue <PageDefinition>(); if (state.Get(stackKey).IsNull() || state.Get(definitionKey).IsNull()) { var pageStack = new PageStack(); pageStack.Push(new Page { Name = definition.RootPageName, Data = null }); state.Set(definitionKey, new Any(definition)); state.Set(stackKey, new Any(pageStack)); // load permanent scenes PageReducerUtility.ChangeScenes(state, definition.PermanentScenes, true); state.NotifyValue(SceneConst.StateKey); } return(state); }
/// <summary> /// Called when a GET request occurs. /// </summary> public async Task <IActionResult> OnGet() { PageStack.PushPage(HttpContext.Session, "/Admin/EditFamily", $"id={Id}"); if (this.Id <= 0) { // create new family // todo: who are the spouses? this.MarriageDate = new MutableGeneaDate(); } else { FamilyDto fam = await this.treeService.GetFamilyById(this.Id).ConfigureAwait(false); if (fam is null) { // explicit ID not found return(RedirectToPage("Index")); } this.MarriageDate = new MutableGeneaDate(fam.MarriageDate); this.MarriagePlace = fam.MarriagePlace; this.DivorceDate = new MutableGeneaDate(fam.DivorceDate); this.DivorcePlace = fam.DivorcePlace; this.FamilyName = string.Join(" and ", fam.Spouses.Select(sp => $"{sp.Firstnames}")); } return(Page()); }
private PageStack CreatePageStack() { templateEnvironment = new TemplateEnvironment(targetFileInfo.FileNoExtension, fileFinder, overrideVars: overrideValuesProvider.OverrideVars); PageStack pageStack = new PageStack(templateEnvironment, fileFinder); pageStack.ContentFile = targetFileInfo.HtmlFile; return(pageStack); }
private IActionResult buildAsPage(PageStack pageStack, String layout) { HtmlDocumentRenderer dr = new HtmlDocumentRenderer(templateEnvironment); dr.addTransform(new HashTreeMenus(fileFinder)); dr.addTransform(new ExpandRootedPaths(this.HttpContext.Request.PathBase)); pageStack.pushLayout(layout); return(build(pageStack, dr)); }
private void Navigate() { var route = $"accounts/{RouteVariables["account"]}/{(Grid.SelectedItem as Service).Name}"; if (PageStack.TryNavigate(route) == false) { Dialog.ShowMessage("Not implemented"); } }
public void PageStackDefault() { PageStack stack = new PageStack(); stack.RegisterDefaultRoute("home", () => new Page()); Assert.IsNull(stack.CurrentPage); stack.Navigate(""); Assert.IsNotNull(stack.CurrentPage); }
public AzureTableBrowserApp() { PageStack.RegisterDefaultRoute("accounts", () => new StorageAccountsPage()); PageStack.RegisterRoute("accounts/{account}", () => new ServicesPage()); PageStack.RegisterRoute("accounts/{account}/tables", () => new TablesPage()); PageStack.RegisterRoute("accounts/{account}/containers", () => new ContainersPage()); PageStack.RegisterRoute("accounts/{account}/tables/{table}", () => new TablePage()); PageStack.RegisterRoute("accounts/{account}/containers/{container}", () => new ContainerPage()); PageStack.Navigate("accounts"); }
private static void BackButton_Callback(Direction parameter) { if (PageStack.Count == 0) { return; } var page = PageStack.Pop(); // Remove current page. HidePage(page, parameter); // Hide current page. }
public IActionResult OnGet() { var back = PageStack.GoBack(HttpContext.Session); if (back is null) { return(RedirectToPage("Index")); } return(Redirect(back.Url)); }
private void ExpectBadRoute(string badRoute) { PageStack stack = new PageStack(); try { stack.RegisterRoute(badRoute, () => new Page()); Assert.Fail("An exception should have been thrown for bad route: " + badRoute); } catch (FormatException) { } }
private void ForgetSelectedStorageAccount() { var selectedAccount = Grid.SelectedItem as StorageAccountInfo; Dialog.ConfirmYesOrNo("Are you sure you want to forget storage account " + selectedAccount.AccountName, () => { (Grid.DataSource as MemoryDataSource).Items.Remove(selectedAccount); StorageAccountInfo.Save((Grid.DataSource as MemoryDataSource).Items); PageStack.TryRefresh(); }); }
public CollectedTopicsFragment() { InitializeComponent(); LabelPanel.ItemsSource = _tabs; async Task <IEnumerable <TopicModel> > loadData() { var model = LabelPanel.SelectedItem as CollectedListModel; var html = await ApiClient.GetTopicsWithTab(model.Name); var dom = new HtmlParser().ParseDocument(html); return(DomParse.ParseTopics(dom)); } var selectionChanged = Observable .FromEventPattern <SelectionChangedEventArgs>(LabelPanel, nameof(LabelPanel.SelectionChanged)) .SelectMany(x => loadData()) .Retry(10) .ObserveOnCoreDispatcher() .Subscribe(x => { News.Clear(); foreach (var item in x) { News.Add(item); } }); var click = Observable.FromEventPattern <ItemClickEventArgs>(NewsList, nameof(NewsList.ItemClick)) .Select(x => x.EventArgs.ClickedItem as TopicModel) .ObserveOnCoreDispatcher() .Subscribe(x => PageStack.Next("Left", "Right", typeof(RepliesAndTopicView), x.Id)); var refresh = Observable.FromEventPattern <TappedRoutedEventArgs>(Refresh, nameof(Refresh.Tapped)) .SelectMany(x => loadData()) .Retry(10) .ObserveOnCoreDispatcher() .Subscribe(x => { News.Clear(); foreach (var item in x) { News.Add(item); } }); LabelPanel.SelectedIndex = 0; this.Unloaded += (s, e) => { selectionChanged.Dispose(); click.Dispose(); refresh.Dispose(); }; }
public async Task OnGet(string firstname, string lastname) { PageStack.PushPage(HttpContext.Session, "/Admin/Search", $"firstname={Uri.EscapeDataString(firstname??"")}&lastname={Uri.EscapeDataString(lastname??"")}"); this.Firstname = firstname; this.Lastname = lastname; if (!string.IsNullOrWhiteSpace(Firstname) || !string.IsNullOrWhiteSpace(Lastname)) { var qry = await this.treeService.SearchByName(Firstname, Lastname).ConfigureAwait(false); this.List.AddRange(qry.Select(i => new IndividualVm(i))); } }
private async void CheckServerSettingFile() { (bool res, string ip, string port) = await CustomIO.GetIpAndPort(); if (res == false) { await CustomDialog.ServerSettingLoadError(); PageStack.Push(page.GetType()); page.Frame.Navigate(typeof(ServerSettingPage), PageStack); return; } }
private void UploadBlob() { Dialog.ShowTextInput("Choose file".ToConsoleString(), (f) => { var operation = new ProgressOperation() { Message = "Uploading file ".ToConsoleString() + f.ToConsoleString(), State = OperationState.Scheduled }; ProgressOperationManager.Operations.Add(operation); if (File.Exists(f.ToString()) == false) { operation.State = OperationState.Failed; operation.Message = "File not found - ".ToConsoleString() + f; } else { Dialog.ShowTextInput("Enter blob prefix".ToConsoleString(), (pre) => { var blobPath = System.IO.Path.Combine(pre.ToString(), System.IO.Path.GetFileName(f.ToString())); var blob = container.GetBlockBlobReference(blobPath); Application.MessagePump.QueueAsyncAction(blob.UploadFromFileAsync(f.ToString(), FileMode.Open), (t) => { if (t.Exception != null) { operation.State = OperationState.Failed; operation.Message = operation.Message = "Failed to upload file ".ToConsoleString() + f.ToConsoleString(); operation.Details = t.Exception.ToString().ToConsoleString(); } else { operation.State = OperationState.Completed; operation.Message = operation.Message = "Finished uploading file ".ToConsoleString() + f.ToConsoleString(); if (Application != null && PageStack.CurrentPage == this) { PageStack.TryRefresh(); } } }); }, () => { operation.State = OperationState.CompletedWithWarnings; operation.Message = "Cancelled uploading file ".ToConsoleString() + f.ToConsoleString(); }); } }); }