using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Input;
using Haestad.Framework.UI.Integration;
using Telerik.Windows.Controls;

namespace Haestad.WPFRibbonPrototype.WPF
{
    public class RibbonUISignInCommand : RibbonUICommand
    {
        public RibbonUISignInCommand(ICommand command, string name, string text, string toolTipTitle, string toolTipDescription, string graphicResourceName) 
            : base(command, name, text, toolTipTitle, toolTipDescription, graphicResourceName)
        {
        }

        protected override void AfterComplete()
        {
            IList<FrameworkElement> elements = GetLinkedElements(RibbonUICommandLinkedElementTypes.RegularButtons);
            foreach (RadRibbonButton button in elements)
            {
                if (button.Name == StandardButtonNames.ImageSignInButton)
                {
                    if (SignInCommand.SignedIn)
                        button.Visibility = Visibility.Visible;
                    else
                        button.Visibility = Visibility.Collapsed;
                }
                else
                {
                    if (SignInCommand.SignedIn)
                        button.Visibility = Visibility.Collapsed;
                    else
                        button.Visibility = Visibility.Visible;
                }
            }
        }

        private SignInCommand SignInCommand
        {
            get { return Command as SignInCommand;  }
        }
    }
}
