Beispiel #1
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            Tag = e.Parameter;

            if (e.Parameter is FeedItem feed)
            {
                BindingContext.Title = "通知详情";
                PrimaryMenu.Add(new AppBarButton {
                    Icon = new SymbolIcon(Symbol.Flag), Label = "详情", Command = new Command(() => Device.OpenUri(new Uri(feed.Link)))
                });
                Title  = feed.Title;
                Time   = "时间:" + feed.PubDate;
                Sender = "分类:" + feed.Category;
                Body   = feed.Description.Replace(' ', '\n');
            }
            else if (e.Parameter is IMessageItem msg)
            {
                BindingContext.Title = "消息详情";
                PrimaryMenu.Add(new AppBarButton {
                    Icon = new SymbolIcon(Symbol.Delete), Label = "设为未读", Command = msg.SetUnread
                });
                PrimaryMenu.Add(new AppBarButton {
                    Icon = new SymbolIcon(Symbol.Delete), Label = "删除", Command = msg.Delete
                });
                Title  = msg.Title;
                Time   = "时间:" + msg.Time.ToString();
                Sender = "发件人:" + msg.Sender;
                Body   = msg.Body;
            }
        }
Beispiel #2
0
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     if (e.Parameter is AboutViewModel vm)
     {
         BindingContext = AboutViewModel.Instance;
         AboutViewModel.Instance.BindingContext = new ViewResponse(this);
         var sb = new StringBuilder();
         AboutViewModel.Instance.HtmlDocument.ToHtml(sb);
         WebView.Html     = sb.ToString();
         WebView.Register = AboutViewModel.Instance.Response;
     }
     else if (e.Parameter is IInfoEntrance entrance)
     {
         BindingContext = new BaseViewModel {
             Title = entrance.Name
         };
         entrance.Evaluate    = WebView.InvokeScript;
         InfoEntrance         = entrance;
         InfoEntrance.Binding = new ViewResponse(this);
         var sb = new StringBuilder();
         InfoEntrance.HtmlDocument.ToHtml(sb);
         WebView.Html     = sb.ToString();
         WebView.Register = entrance.Receive;
         foreach (var key in InfoEntrance.Menu)
         {
             PrimaryMenu.Add(new AppBarButton {
                 Label = key.Name, Command = key.Command, Icon = new FontIcon {
                     FontFamily = new FontFamily("Segoe MDL2 Assets"), Glyph = key.Icon
                 }
             });
         }
     }
 }
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            Tag = e.Parameter;

            if (e.Parameter is FeedItem feed)
            {
                ViewModel.Title = "通知详情";
                PrimaryMenu.Add(new AppBarButton {
                    Icon = new SymbolIcon(Symbol.Flag), Label = "详情", Command = new Command(() => Device.OpenUri(new Uri(feed.Link)))
                });
                Title  = feed.Title;
                Time   = "时间:" + feed.PubDate;
                Sender = "分类:" + feed.Category;
                var desc = feed.Description.Trim();
                while (desc.Contains("    "))
                {
                    desc = desc.Replace("    ", "  ");
                }
                Body = desc;
            }
            else if (e.Parameter is IMessageItem msg)
            {
                ViewModel.Title = "消息详情";
                PrimaryMenu.Add(new AppBarButton {
                    Icon = new SymbolIcon(Symbol.Delete), Label = "删除", Command = msg.Delete
                });
                Title  = msg.Title;
                Time   = "时间:" + msg.Time.ToString();
                Sender = "发件人:" + msg.Sender;
                Body   = msg.Body;
            }
        }
Beispiel #4
0
        public ShellViewModel(INavigationServiceEx navigationService)
        {
            navigationService.Navigated += (sender, args) =>
            {
                switch (navigationService.CurrentPageKey)
                {
                case PageKeys.HOME:
                case PageKeys.SETTINGS:
                case PageKeys.ABOUT:
                {
                    navigationService.Root.BackStack.Clear();
                }
                break;
                }

                if (navigationService.Root.CanGoBack)
                {
                    SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible;
                }
                else
                {
                    SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Collapsed;
                }

                foreach (var item in PrimaryMenu)
                {
                    (item.NavigateCommand as RelayCommand).RaiseCanExecuteChanged();
                }

                foreach (var item in SecondaryMenu)
                {
                    (item.NavigateCommand as RelayCommand).RaiseCanExecuteChanged();
                }
            };

            // Build the menus
            PrimaryMenu.Add(new MenuItem()
            {
                Glyph           = Icon.GetIcon("HomeIcon"),
                Text            = "Home",
                NavigateCommand = new RelayCommand(() => { navigationService.NavigateTo(PageKeys.HOME); },
                                                   () => { return(!navigationService.CurrentPageKey.Equals(PageKeys.HOME)); })
            });

            SecondaryMenu.Add(new MenuItem()
            {
                Glyph           = Icon.GetIcon("GearIcon"),
                Text            = "Settings",
                NavigateCommand = new RelayCommand(() => { navigationService.NavigateTo(PageKeys.SETTINGS); },
                                                   () => { return(!navigationService.CurrentPageKey.Equals(PageKeys.SETTINGS)); })
            });
            SecondaryMenu.Add(new MenuItem()
            {
                Glyph           = Icon.GetIcon("InfoIcon"),
                Text            = "About",
                NavigateCommand = new RelayCommand(() => { navigationService.NavigateTo(PageKeys.ABOUT); },
                                                   () => { return(!navigationService.CurrentPageKey.Equals(PageKeys.ABOUT)); })
            });
        }
Beispiel #5
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            System.Diagnostics.Debug.Assert(e.Parameter is IWebEntrance, "Error leading");
            InfoEntrance = e.Parameter as BaseController;

            var meta = InfoEntrance.GetType().GetCustomAttribute(typeof(EntAttr)) as EntAttr;

            ViewModel             = e.Parameter as BaseController;
            ViewModel.Title       = meta.Title;
            InfoEntrance.Evaluate = WebView.InvokeScript;
            InfoEntrance.View     = ViewResponse;

            WebView.Register = InfoEntrance.Receive;
            foreach (var key in InfoEntrance.Menu)
            {
                PrimaryMenu.Add(new AppBarButton
                {
                    Label            = key.Name,
                    Command          = key.Command,
                    CommandParameter = (Action <IWebEntrance>)OnEntranceRequested,
                    Icon             = new FontIcon
                    {
                        FontFamily = new FontFamily("Segoe MDL2 Assets"),
                        Glyph      = key.Icon
                    }
                });
            }

            if (InfoEntrance is IInfoEntrance info)
            {
                var sb = new StringBuilder();
                info.HtmlDocument.ToHtml(sb);
                WebView.Html = sb.ToString();
            }
            else if (InfoEntrance is IUrlEntrance urle)
            {
                WebView.Url              = urle.HtmlUrl;
                WebView.SubUrlRequested += OnSubUrlRequested;

                if (WebView.Url.Contains("://"))
                {
                    ViewModel.SetIsBusy(true);
                    WebView.LoadCompleted += () => ViewModel.SetIsBusy(false);
                }
            }
        }