This project is read-only.

Starting the slide show from Album view

Nov 1, 2008 at 7:18 PM
Hi,

I was wondering if there's a way to start the slide show in album view as opposed to launching right into the first album's slides?  I want to give site visitors a choice of what album they want to see first.

thanks,
-Trish
Nov 5, 2008 at 4:56 PM
Hi Trish

This option is not configurable.

Cheers,
Liam
Nov 5, 2008 at 9:52 PM
Liam,
are you saying the initialAlbumView option was removed from the NavigationTray module? What happened to "All the features of v1 and more" ?

;-)

Marcus.
Nov 8, 2008 at 8:47 AM

There's a pretty simple hack to the source code that will solve the problem.  Its more of a quick and dirty hack than a fix - I'll probably eventually get into it a little deeper and figure out the real fix.  In the mean time, this seems to work to put it in album mode at startup.  It is configured via the data.xml, not in config like Slide.Show v1 was, but...

I have also added the ability to turn off auto-start through the data.xml as well (still a hacky way of doing it):

data.cs
    ..
    public class Data
    {
        ..
        public static int StartAlbumIndex { get; set; }


        /// <summary>
        /// Gets or sets AlbumView startup mode
        /// </summary>
        /// <value><c>true</c> if start in album view, <c>false</c> otherwise.</value>
        public static bool StartInAlbumView { get; set; }

        /// <summary>
        /// Gets or sets whether to auto start slide playback.
        /// </summary>
        /// <value><c>true</c> if auto start, <c>false</c> otherwise.</value>
        public static bool AutoStart { get; set; }
        ..
    }


datahandler.cs
    ..
    public class DataHandler
    {
        ..
        public static bool IsPreloaded { get; set; }


        /// <summary>
        /// Gets or sets AlbumView startup mode
        /// </summary>
        /// <value><c>true</c> if start in album view, <c>false</c> otherwise.</value>
        public static bool StartInAlbumView { get; set; }

        /// <summary>
        /// Gets or sets whether to auto start slide playback.
        /// </summary>
        /// <value><c>true</c> if auto start, <c>false</c> otherwise.</value>
        public static bool AutoStart { get; set; }
        ..
    }
    ..
    public DataHandler()
    {
        CurrentAlbumIndex = Data.StartAlbumIndex;
        IsPreloaded = false;

        StartInAlbumView = Data.StartInAlbumView;
        AutoStart = Data.AutoStart;

        ..
    }

xmldataprovider.cs
    ..
    private void client_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
    {
        XmlReader reader = XmlReader.Create(new StringReader(e.Result));

        while (reader.Read())
        {
            if(reader.IsStartElement() && reader.Name == "data")
            {
                Data.StartAlbumIndex = Convert.ToInt32(reader.GetAttribute("startalbumindex"), CultureInfo.InvariantCulture);

                Data.StartInAlbumView = Convert.ToBoolean(reader.GetAttribute("startinalbumview"), CultureInfo.InvariantCulture);
                Data.AutoStart = Convert.ToBoolean(reader.GetAttribute("autostart"), CultureInfo.InvariantCulture);
                ..
            }
        }
    }

navigation.cs
..
    public static void StartSlideShow()
    {
        SelectAlbum(DataHandler.CurrentAlbumIndex);

        if (DataHandler.StartInAlbumview)
            ToggleAlbumViewOn();
        If (!DataHandler.AutoStart)
            Pause();

    }


To use, edit your data.xml's <data> node to have:
    <data startalbumindex="1" startinalbumview="true" autostart="false" transition="CrossFadeTransition">

Hope this workaround is useful.  Please let me know if any of this doesn't make sense.


Nov 8, 2008 at 8:16 PM
Cool - that does the trick!
Thx mucho, Brian !!

Rgds - Marcus.
Nov 9, 2008 at 4:30 PM
Thanks Brian!
I was looking to enable the album start view in Slide.Show2 as well and your post helped a lot.

Rather than put the bool properties inside the data.xml I added a StartInAlbumView bool property to the Configuration class, and then modified the FinishedLoading method to read it from the initParams element where it also reads what config and data providers to use. That way both the XmlData and Flickr providers can use it.
Nov 9, 2008 at 4:58 PM
Sounds like a much better solution than what I posted - this is actually what I had wanted to do but I hadn't spent the time to understand the full event flow.  Thanks, I'll check that out and probably change my impl as you've stated.
Nov 27, 2008 at 5:03 AM

Brian,

 

Great solution but it might be a little cleaner to add this as a general option rather than something in Data and DataHandler.  By adding what is essentially your solution to the Configuration.Options.General class this can be incorporated into the configuration files.  Doing this involves the following changes – nearly the same as what you did.

 

Configuration.cs

public class GeneralOptions

{

      /// <summary>

      /// Gets or sets the background.

      /// </summary>

      /// <value>The background.</value>

      public Brush Background { get; set; }

 

    /// <summary>

    /// Gets or sets AlbumView startup mode

    /// </summary>

    /// <value><c>true</c> if start in album view, <c>false</c> otherwise.</value>

    public bool StartInAlbumView { get; set; }

 

    /// <summary>

    /// Gets or sets whether to auto start slide playback.

    /// </summary>

    /// <value><c>true</c> if auto start, <c>false</c> otherwise.</value>

    public bool AutoStart { get; set; }

}

 

Navigation.cs

public static void StartSlideShow()

{

    SelectAlbum(DataHandler.CurrentAlbumIndex);

    if (Configuration.Options.General.StartInAlbumView)

        ToggleAlbumViewOn();

    if (!Configuration.Options.General.AutoStart)

        Pause();

}

 

 

XMLConfigurationProvider.cs

#region [ General ]

Dictionary<string, string> generalOptions = xmlOptions[string.Empty];

Options.General = new Options.GeneralOptions()

{

    Background =

        generalOptions.ContainsKey("background") ?

        ParseBrush(generalOptions["background"]) :

        Options.General.Background,

    StartInAlbumView = ParseBool(generalOptions, "StartInAlbumView") ?? Options.General.StartInAlbumView,

    AutoStart = ParseBool(generalOptions, "AutoStart") ?? Options.General.AutoStart

};

#endregion

 

XMLConfigurationProvider.cs

private Dictionary<string, string> ParseRoot(XmlReader reader)

{

      Dictionary<string, string> options = new Dictionary<string, string>();

    options.Add("background", reader.GetAttribute("background"));

    options.Add("autoStart", reader.GetAttribute("autoStart")??"true");

    options.Add("startInAlbumView", reader.GetAttribute("startInAlbumView")??"false");

    return options;

}

 

 

For good measure we should also set the default value for these two new configuration options in each of the supplied themes.  Since these are Booleans, they do default to false, but that would change the original behavior of the application.  Since the default theme is LightTheme these options also need to be added to this theme.  Just for good measure, I went ahead and added defaults to all the supplied themes.

 

LightTheme.cs

Options.General = new Options.GeneralOptions()

{

      Background = ParseBrush("White"),

    AutoStart = true,

    StartInAlbumView = false

};

 

And now we can add these as options in the configuration.xml file

<configuration background="Silver" autoStart="true" startInAlbumView="false">

This isn't necessarly easier than what you did, but it does make this part of the configuration provider rather than the data provider which seems a little cleaner to me.

Thanks for providing the groundwork for this approach.

Nov 30, 2008 at 8:36 AM

That works out much cleaner, thanks for posting the mods Andrew.

Mar 31, 2009 at 10:32 PM
Edited Apr 1, 2009 at 12:20 AM
Incase anyone gets confused on implementing this (like i did) you should take a look at the "slide.show 2 configuration guide" and check out the information on using a configuration.xml file to customize slide.show 2.  thanks for the mod guys...i like it! :-)
Jun 25, 2009 at 3:49 PM
Edited Jun 25, 2009 at 6:23 PM

I downloaded the latest version which has these changes in it and created a Configuration.xml file that has startInAlbumView set to true.  But when I browse that page, the control still starts in player view.  Is there something else I need to change?

Jun 27, 2009 at 2:27 AM

The latest version doesn't include these changes.  You have to implement them manually.  I'm planning to add it to the source code (along with some other enhancements and bug fixes) this weekend, but don't know when a new version including these fixes will be available for download.

Jun 29, 2009 at 3:24 PM

That is bizarre.  I went to make the changes outlined by Andrew and in all the specified files, they are already there.  I just looked again at LightTheme.cs, XMLConfigurationProvider.cs and Configuration.cs again and I see them.  And the one Configuration.xml that comes with the video sample has the new attributes in it.  IAC, I am going to set up some test albums of my own so that I can step through the code and get a handle on how the configuration works.  I am hunting for a good starting breakpoint as I type.

Jun 30, 2009 at 8:57 PM

Andrew,

Your changes are great but there is one thing that needs to be done differently.  When you are parsing generalOptions to create Options.General...

ParseBool(generalOptions, "StartInAlbumView") should be ParseBool(generalOptions, "startInAlbumView")and

ParseBool(generalOptions, "AutoStart") should be ParseBool(generalOptions, "autoStart")

Thanks for the solution

Jul 6, 2009 at 5:53 AM

Fixed in change set 25804. Note that the change set includes additional enhancements and bug fixes as well.

http://slideshow2.codeplex.com/SourceControl/changeset/view/25804

Jul 7, 2009 at 9:21 PM

Bugs in the previous change set related to this issue have been fixed in change set 25849:
http://slideshow2.codeplex.com/SourceControl/changeset/view/25849

The XML Configuration sample included in the change set demos setting the AutoStart and StartInAlbumView options via an XML file.