using System;
using System.Collections.Generic;
using System.Web;
using System.Web.Services;

/// <summary>
/// Summary description for webs
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.Web.Script.Services.ScriptService]
public class webs : System.Web.Services.WebService {

    public webs () {

        //Uncomment the following line if using designed components 
        //InitializeComponent(); 
    }

    [WebMethod]
    public string HelloWorld() {
        return "Hello World";
    }
    [WebMethod]

    public AjaxControlToolkit.Slide[] GetSlides1(string contextKey)
    {
        AjaxControlToolkit.Slide[] slides = null;
        int i = -1;
        int index = int.Parse(contextKey);

        System.IO.DirectoryInfo dir1234 = new System.IO.DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory.ToString() + "picGallery/images/");
        System.IO.DirectoryInfo[] tempdir = dir1234.GetDirectories();



        System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory.ToString() + tempdir[index].Parent.Name + "/" + tempdir[index].Name + "/");
        System.IO.FileInfo[] gFiles = dir.GetFiles("*.jpg");

        slides = new AjaxControlToolkit.Slide[gFiles.Length];

        //slides[0] = new AjaxControlToolkit.Slide("images/Blue hills.jpg", "Blue Hills", "Go Blue");
        //slides[1] = new AjaxControlToolkit.Slide("images/Sunset.jpg", "Sunset", "Setting sun");
        //slides[2] = new AjaxControlToolkit.Slide("images/Winter.jpg", "Winter", "Wintery...");
        //slides[3] = new AjaxControlToolkit.Slide("images/Water lilies.jpg", "Water lillies", "Lillies in the water");
        //slides[4] = new AjaxControlToolkit.Slide("images/VerticalPicture.jpg", "Sedona", "Portrait style picture");

        System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory.ToString() + tempdir[index].Parent.Name + "/" + tempdir[index].Name + "/");



        System.IO.FileInfo[] rgFiles = di.GetFiles("*.jpg");
        foreach (System.IO.FileInfo fi in rgFiles)
        {
            i++;
            slides[i] = new AjaxControlToolkit.Slide(tempdir[index].Parent.Name + "/" + tempdir[index].Name + "/" + fi.Name, "", tempdir[index].Name + ": " + fi.ToString().Split('.')[0]);
            //2. parameter does not work because of error in the toolkit
        }


        return (slides);

    }
    
}

