using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using BankTV.Consts;
using BankTV.Model.Weather;
using BankTV.Helpers;

namespace BankTV.Controls
{
    /// <summary>
    /// Interaction logic for TopBar.xaml
    /// </summary>
    public partial class TopBar : UserControl
    {
        public TopBar()
        {
            InitializeComponent();
        }

        public void Update()
        {
            this.labelDate.Content = DateTime.Now.ToString("dd.MM.yyyy");
            NamedayHelper namedayHelper = new NamedayHelper();
            this.labelNamedays.Content = namedayHelper.getNamesByDate(DateTime.Now.ToString("M.d")).ToUpper();
        }

        public void updateWeather(WeatherCurrent weather, string city)
        {
            if (weather == null)
            {
                return;
            }   //if
            lblCurrentTemperature.Content = String.Format("{0}°C", weather.TempAvg.ToString("0"));
            imgCurrentWeather.SetValue(Image.SourceProperty, new ImageSourceConverter().ConvertFromString(new Uri(weather.GetImagePath(), UriKind.Absolute).ToString()));
            if (String.IsNullOrWhiteSpace(city))
            {
                lblCityName.Content = GlobalConsts.CITY;
            }   //if
            else
            {
                lblCityName.Content = city;
            }   //else
        }

        public void hideUnnecessaryWeatherItems()
        {
            lblCurrentTemperature.Visibility = Visibility.Hidden;
            imgCurrentWeather.Visibility = Visibility.Hidden;
            lblCityName.Visibility = Visibility.Hidden;
        }

    }

}
