/// <summary>
        /// Handles the Loaded event of the Window control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param>
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            bool showWindow = string.IsNullOrEmpty(Client.Default.token);

            if (showWindow)
            {
                Authentication auth = new Authentication {
                    Owner = this
                };
                auth.ShowDialog();
            }

            GalleryServiceSoapClient client = new GalleryServiceSoapClient();

            //retrieve the galleries
            try
            {
                galleries = client.GetAllGalleries(Client.Default.token);
                galleryListBox.DataContext = galleries;
            }
            catch
            {
                //TODO:Logging need to add logging.
                throw;
            }
            finally
            {
                //If the state is not closed, then close it.
                if (client.State != CommunicationState.Closed)
                {
                    client.Close();
                }
            }
        }
        //private void SetUserToken()
        //{
        //    userToken = Cookie.GetCookie("AdminSession");
        //}

        //private void gallerySlider_ValueChanged(object sender, RoutedEventArgs e)
        //{
        //    int galleryIndex = (int)(gallerySlider.Value - 1);
        //    galleryTextBox.Text = galleries[galleryIndex].Namek__BackingField;
        //    currentGalleryTextBox.Text = ((int)gallerySlider.Value).ToString();
        //}

        /// <summary>
        /// Handles the Loaded event of the UserControl control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param>
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            //userToken = "7RnTDIQeIJpM3k92N7Ya0qu+vYwmzHb2q/dE+dupBzEKRwY05xdVRq7pRGwsXlgtBZqXdb30fNkkArISu58udQ==";

            //BasicHttpBinding binding = new BasicHttpBinding {Name = "galleryBinding"};
            //EndpointAddress endpointAddress = new EndpointAddress("http://chuckconway.com/api/GalleryService.svc");

            //Load Galleries

            userToken = CookieHelper.GetCookie("Token");
            //userToken = "Vgqpi/hbzA64H5qFhky/5Fo4yGrxagl6aDRlIaSKaMqX6Bdw5moZz7aMPZbHzOcSOsHOYGt013gN7toVoE3UVw==";



            GalleryServiceSoapClient galleriesClient = new GalleryServiceSoapClient();

            galleriesClient.GetAllGalleriesCompleted += galleries_GetAllGalleriesCompleted;

            galleriesClient.GetAllGalleriesAsync(userToken);
        }
        /// <summary>
        /// Handles the Loaded event of the Window control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param>
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            bool showWindow = string.IsNullOrEmpty(Client.Default.token);

            if(showWindow)
            {
                Authentication auth = new Authentication {Owner = this};
                auth.ShowDialog();
            }

            GalleryServiceSoapClient client = new GalleryServiceSoapClient();

            //retrieve the galleries
            try
            {
                galleries = client.GetAllGalleries(Client.Default.token);
                galleryListBox.DataContext = galleries;
            }
            catch
            {
                //TODO:Logging need to add logging.
                throw;
            }
            finally
            {
                //If the state is not closed, then close it.
                if (client.State != CommunicationState.Closed)
                {
                    client.Close();
                }
            }
        }
        //private void SetUserToken()
        //{
        //    userToken = Cookie.GetCookie("AdminSession");
        //}
        //private void gallerySlider_ValueChanged(object sender, RoutedEventArgs e)
        //{
        //    int galleryIndex = (int)(gallerySlider.Value - 1);
        //    galleryTextBox.Text = galleries[galleryIndex].Namek__BackingField;
        //    currentGalleryTextBox.Text = ((int)gallerySlider.Value).ToString();
        //}
        /// <summary>
        /// Handles the Loaded event of the UserControl control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param>
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            //userToken = "7RnTDIQeIJpM3k92N7Ya0qu+vYwmzHb2q/dE+dupBzEKRwY05xdVRq7pRGwsXlgtBZqXdb30fNkkArISu58udQ==";

            //BasicHttpBinding binding = new BasicHttpBinding {Name = "galleryBinding"};
            //EndpointAddress endpointAddress = new EndpointAddress("http://chuckconway.com/api/GalleryService.svc");

            //Load Galleries

               userToken = CookieHelper.GetCookie("Token");
            //userToken = "Vgqpi/hbzA64H5qFhky/5Fo4yGrxagl6aDRlIaSKaMqX6Bdw5moZz7aMPZbHzOcSOsHOYGt013gN7toVoE3UVw==";

            GalleryServiceSoapClient galleriesClient = new GalleryServiceSoapClient();
            galleriesClient.GetAllGalleriesCompleted += galleries_GetAllGalleriesCompleted;

            galleriesClient.GetAllGalleriesAsync(userToken);
        }