using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using BS.Shared.DataContracts;

namespace BeWo.View.Search
{
    public class AddServGroupOfPeopleSearchView : GenericSearchView<AdditionalServiceGroupOfPeopleDC>
    {
        private Button mButton;

        public event EventHandler EditGroupButtonClicked;

        public AddServGroupOfPeopleSearchView()
        {
            if (!DesignerProperties.GetIsInDesignMode(this))
                ThemeColor = FindResource("SupportConceptContentBrush") as Brush;

            CreateButton();
        }

        protected void CreateButton()
        {
            if (BeWoApp.LoggedOnUser == null || mButton != null) 
                return;

            mButton = new Button
                          {
                              Margin = new Thickness(3, 3, 3, 3),
                              HorizontalAlignment = HorizontalAlignment.Left
                          };

            var sp = new StackPanel {Orientation = Orientation.Horizontal};

            var img = new Image
                          {
                              Source =
                                  new BitmapImage(
								  new Uri("pack://application:,,,/BeWoPlaner;component/Ressources/Icons/UserGroupHome24bw.png"))
                          };

            sp.Children.Add(img);
            var tb = new TextBlock {Margin = new Thickness(3, 4, 3, 0), Text = "Gruppen bearbeiten"};
            sp.Children.Add(tb);

            mButton.Content = sp;
            mButton.ToolTip = "Gruppen bearbeiten";
            mButton.Click += mButton_Click;

            AddCustomContentHeaderElement(mButton);
        }

        void mButton_Click(object sender, RoutedEventArgs e)
        {
            if (EditGroupButtonClicked != null)
                EditGroupButtonClicked(sender, e);
        }

        public List<AdditionalServiceGroupOfPeopleDC> GroupOfPeoples
        {
            get { return _ObjectList; }
            set { base.UpdateObjectList(value); }
        }

        protected override void GetAll(Action<List<AdditionalServiceGroupOfPeopleDC>> pCallBack)
        {
        }
    }
}
