示例#1
0
        /// <summary>
        /// Updates the user interface to match the content.
        /// </summary>
        private void UpdateUserInterfaceFromContent()
        {
            BackgroundImageView.SetImageBitmap(BackgroundImage);

            MenuBarView.SetButtons(MenuData.Buttons.Select(b => b.Title).ToList());
            MenuBarView.RequestFocus();
        }
        public MenuBarDebugView(
            ILoggerFacade logger,
            IRegionManager regionManager)
        {
#if DEBUG
            Debugger.Break();
#endif

            PreferredPositionRegion.MARK_PREFERRED_POS = true;

            InitializeComponent();

            m_MenuBarView = new MenuBarView(logger, regionManager);
            Content       = m_MenuBarView;
        }
示例#3
0
        /// <summary>
        /// Loads the content asynchronously.
        /// </summary>
        public override async Task LoadContentAsync()
        {
            //
            // Load the menu data.
            //
            var menu = Data.FromJson <Rest.Menu>();

            //
            // If the menu content hasn't actually changed, then ignore.
            //
            if (menu.ToJson().ComputeHash() == MenuData.ToJson().ComputeHash())
            {
                return;
            }
            MenuData = menu;

            //
            // Load the image and get the button titles.
            //
            UIImage image;

            try
            {
                image = await Utility.LoadImageFromUrlAsync(Crex.Application.Current.GetAbsoluteUrl(MenuData.BackgroundImage.BestMatch));
            }
            catch
            {
                image = null;
            }
            var buttons = MenuData.Buttons.Select(b => b.Title).ToList();

            LastLoadedDate = DateTime.Now;

            //
            // Update the UI with the image and buttons.
            //
            InvokeOnMainThread(() =>
            {
                EnsureView();
                BackgroundImageView.Image = image;
                MenuBarView.SetButtons(buttons);
                SetNeedsFocusUpdate();

                ShowNextNotification();
            });
        }