using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using BeWo.Validation;
using BeWo.ViewModel;
using BS.Shared.Core;
using BS.Shared.DataContracts.Compact;

namespace BeWo.View.Controls
{
	/// <summary>
	/// Interaction logic for ServiceRecordPopUp.xaml
	/// </summary>
	public partial class NewsItemEditControl : UserControl
	{
		private NewsItemVM newsItem;

		public event Action CancelButtonClicked;
		public event Action OkButtonClicked;

		public NewsItemEditControl(NewsItemVM newsItem)
		{
			this.InitializeComponent();
			this.CommandBindings.Add(new CommandBinding(ApplicationCommands.Close, (s, e) => BeWoApp.MainControl.CloseCurrentPopUp()));
			this.DataContext = newsItem;
			this.newsItem = newsItem;
			TextBoxTitle.Focus();

			//if (newsItem.Team != null)
			//	popupedit_TeamSearch.Text = newsItem.Team.Name;
		}

		//private void popupedit_TeamSearch_PopUpClick(object sender, RoutedEventArgs e)
		//{
		//	popup_Team.IsOpen = true;
		//}

		//private void TeamSearchView_TeamSelected(object sender, EventArgs<CompactTeamDC> e)
		//{
		//	popup_Team.IsOpen = false;
		//	newsItem.Team = e.Data;
		//}

		private void Popupedit_TeamSearch_OnDeleteClick(object sender, RoutedEventArgs e)
		{
			//popupedit_TeamSearch.Text = "";
			newsItem.Team = null;
		}

		private void button_ok_Click(object sender, RoutedEventArgs e)
		{
			if (ValidationTrigger.Validate(this.RootGrid))
			{
				if (OkButtonClicked != null)
					OkButtonClicked();

			}
		}

		private void button_cancel_Click(object sender, RoutedEventArgs e)
		{
			if (CancelButtonClicked != null)
				CancelButtonClicked();
		}
	}
}