/// <summary> /// Populates the page with content passed during navigation. Any saved state is also /// provided when recreating a page from a prior session. /// </summary> /// <param name="navigationParameter"> /// The parameter value passed to /// <see cref="Frame.Navigate(Type, Object)" /> when this page was initially requested. /// </param> /// <param name="pageState"> /// A dictionary of state preserved by this page during an earlier /// session. This will be null the first time a page is visited. /// </param> protected override async void LoadState(Object navigationParameter, Dictionary<String, Object> pageState) { var r = navigationParameter as SearchResult; if (r != null) { r.ResetAssumptionSelections(); Result = r; //ShowResults(); return; } var query = navigationParameter as string; if (pageState != null && pageState.ContainsKey("result")) { Result = pageState["result"] as SearchResult; Result.ResetAssumptionSelections(); _history = pageState["history"] as Stack<SearchResult>; } else { Result = new SearchResult(query) {NumRows = (int) Math.Floor((Window.Current.Bounds.Height - 186) / 150)}; await Result.RunSearch(); _history.Push(new SearchResult(Result)); } ShowResults(); }
public Pod(XElement source, SearchResult searchResult) { Result = searchResult; _title = source.Attribute("title").Value; Scanner = source.Attribute("scanner").Value; Id = source.Attribute("id").Value; Position = int.Parse(source.Attribute("position").Value); Error = bool.Parse(source.Attribute("error").Value); _numSubpods = int.Parse(source.Attribute("numsubpods").Value); _images = new List<ImageResult>(_numSubpods); int maxHeight = 0, maxWidth = 0; foreach (XElement img in source.Elements("subpod")) { ImageResult i = new ImageResult(img); if (i.Height > maxHeight) { maxHeight = i.Height; } if (i.Width > maxWidth) { maxWidth = i.Width; } i.Owner = this; _images.Add(i); } XElement infos = source.Element("infos"); if (infos != null) { _numInfos = int.Parse(infos.Attribute("count").Value); _infos = new List<Info>(_numInfos); foreach (XElement info in infos.Elements("info")) { Info i = new Info(info); _infos.Add(i); } } else { _infos = new List<Info>(0); _numInfos = 0; } XElement statesNode = source.Element("states"); if (statesNode != null) { _numStates = int.Parse(statesNode.Attribute("count").Value); _states = new List<State>(_numStates); foreach (XElement state in statesNode.Elements("state")) { _states.Add(new State(state)); } } else { _states = new List<State>(); _numStates = 0; } RowSpan = CalcRowSpan(maxHeight + 60); ColSpan = CalcColSpan(maxWidth); //_title += " (" + RowSpan + " x " + ColSpan + ") "; }
private async void c_Checked(object sender, RoutedEventArgs e) { var s = sender as RadioButton; var assumption = s.DataContext as Assumption; _assumptionsFlyout.IsOpen = false; _assumptionsFlyout.Dispose(); _assumptionsFlyout = null; Result.Working = true; assumption.SelectedWord = s.Content as string; var r = new SearchResult(Result); await r.ApplyAssumption(assumption); _history.Push(r); Result = r; Result.Working = false; }
private void CustomGoBack(object sender, RoutedEventArgs e) { if (_history.Count > 1) { _history.Pop(); Result = _history.Peek(); Result.ResetAssumptionSelections(); _firstLoad = true; } else { Frame.GoBack(); } }
private async void AssumptionSet(object sender, SelectionChangedEventArgs e) { var s = sender as ComboBox; // wow. if (Result.Assumptions != null) { var changed = Result.Assumptions.FirstOrDefault( a => s != null && a.Values.SequenceEqual(s.ItemsSource as List<string>)); if (changed != null && !_firstLoad && e.RemovedItems.Count > 0) { var r = new SearchResult(Result); await r.ApplyAssumption(changed); _history.Push(r); Result = r; } _firstLoad = false; } }
protected override void OnNavigatedTo(NavigationEventArgs e) { if (Result == null) { var r = e.Parameter as SearchResult; if (r != null) { Result = r; } Result = new SearchResult(e.Parameter as string); } if (e.NavigationMode == NavigationMode.New || e.NavigationMode == NavigationMode.Refresh) { //Q42.WinRT.Data.WebDataCache.ClearAll(); } base.OnNavigatedTo(e); }