12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- using System;
- using System.Collections.Specialized;
- using System.ComponentModel;
- using System.Threading.Tasks;
- using System.Web;
- using System.Windows;
- using System.Windows.Controls;
- namespace MediaBrowser.UI.Pages
- {
- public abstract class BasePage : Page, INotifyPropertyChanged
- {
- public event PropertyChangedEventHandler PropertyChanged;
- public void OnPropertyChanged(String info)
- {
- if (PropertyChanged != null)
- {
- PropertyChanged(this, new PropertyChangedEventArgs(info));
- }
- }
- protected Uri Uri
- {
- get
- {
- return NavigationService.CurrentSource;
- }
- }
- protected MainWindow MainWindow
- {
- get
- {
- return App.Instance.MainWindow as MainWindow;
- }
- }
- private NameValueCollection _queryString;
- protected NameValueCollection QueryString
- {
- get
- {
- if (_queryString == null)
- {
- string url = Uri.ToString();
- int index = url.IndexOf('?');
- if (index == -1)
- {
- _queryString = new NameValueCollection();
- }
- else
- {
- _queryString = HttpUtility.ParseQueryString(url.Substring(index + 1));
- }
- }
- return _queryString;
- }
- }
- protected BasePage()
- : base()
- {
- Loaded += BasePageLoaded;
- }
- async void BasePageLoaded(object sender, RoutedEventArgs e)
- {
- await LoadData();
- DataContext = this;
- }
- protected abstract Task LoadData();
- }
- }
|