public object GetPage(int pageId)
        {
            try {
                // Look for the page with the specified ID
                IDashboardPage page = DashboardContext.Current.GetPageById(pageId);
                if (page == null || page.Content == null)
                {
                    throw new DashboardException("Den pågældende side ser ikke til at være publiceret");
                }

                // Throw an exception if the site wasn't found
                if (page.Site == null)
                {
                    throw new DashboardException(HttpStatusCode.NotFound, "Det efterspurgte site blev ikke fundet.");
                }

                return(new {
                    page,
                    site = page.Site,
                    blocks = page.GetBlocks()
                });
            } catch (DashboardException ex) {
                return(Request.CreateResponse(JsonMetaResponse.GetError(HttpStatusCode.InternalServerError, ex.Message)));
            } catch (Exception ex) {
                return(Request.CreateResponse(JsonMetaResponse.GetError(
                                                  HttpStatusCode.InternalServerError,
                                                  "Unknown server error. Check the log for further information."
                                                  )));
            }
        }
Exemple #2
0
        /// <summary>
        /// Gets the page with the specified <code>pageId</code>, or <code>null</code> if the page couldn't be found.
        /// </summary>
        /// <param name="pageId">The ID of the page.</param>
        public IDashboardPage GetPageById(int pageId)
        {
            foreach (IDashboardPlugin plugin in Plugins)
            {
                try {
                    IDashboardPage page = plugin.GetPageById(pageId);

                    if (page != null)
                    {
                        return(page);
                    }
                } catch (Exception ex) {
                    LogHelper.Error <DashboardContext>("Plugin of type " + plugin.GetType() + " has failed for GetPageById()", ex);
                }
            }

            return(null);
        }
        // Navigator changed event
        private void DashboardPageChanged(object sender, DashboardPageEventArgs e)
        {
            selectedDashboardPage = e.SelectedPage;

            // Change background color
            if (selectedDashboardPage.ShouldUseLightBackground)
                LayoutRoot.Background = new SolidColorBrush(Colors.White);
            else
                LayoutRoot.Background = new SolidColorBrush(Colors.Black);

            // Fade out the old image
            Storyboard animation = new Storyboard();
            animation.Duration = new Duration(TimeSpan.FromSeconds(0.3));

            DoubleAnimation fadeOutAnimation = new DoubleAnimation();
            animation.Children.Add(fadeOutAnimation);
            fadeOutAnimation.Duration = animation.Duration;
            fadeOutAnimation.To = 0;
            Storyboard.SetTarget(fadeOutAnimation, BackgroundImage);
            Storyboard.SetTargetProperty(fadeOutAnimation, new PropertyPath("Opacity"));

            animation.Completed += FadeOutAnimationCompleted;
            animation.Begin();
        }
        private void OnDashboardPageChanged(object sender, DashboardPageEventArgs e)
        {
            selectedDashboardPage = e.SelectedPage;

            if (selectedDashboardPage.ShouldUseLightBackground && BackgroundImage.Source == lightBackgroundImage)
                return;

            if (!selectedDashboardPage.ShouldUseLightBackground && BackgroundImage.Source == darkBackgroundImage)
                return;

            // Fade out the old image
            Storyboard animation = new Storyboard();
            animation.Duration = new Duration(TimeSpan.FromSeconds(0.3));

            DoubleAnimation fadeOutAnimation = new DoubleAnimation();
            animation.Children.Add(fadeOutAnimation);
            fadeOutAnimation.Duration = animation.Duration;
            fadeOutAnimation.To = 0;
            Storyboard.SetTarget(fadeOutAnimation, BackgroundImage);
            Storyboard.SetTargetProperty(fadeOutAnimation, new PropertyPath("Opacity"));

            animation.Completed += FadeOutAnimationCompleted;
            animation.Begin();
        }
Exemple #5
0
 public GadgetsLoaded(IDashboardPage page)
 {
     Page = page;
 }
 /// <summary>
 /// The add gadget to execute.
 /// </summary>
 /// <param name="page">
 /// The page.
 /// </param>
 /// <param name="parameter">
 /// The parameter.
 /// </param>
 public void AddGadgetToExecute(IDashboardPage page, object parameter)
 {
     page.AddGadgetToExecute(parameter);
     SelectedPage = page;
     SelectedPage.ArrangeNewGadget = true;
 }