using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using C1.Silverlight;
using System.Windows.Controls;
using System.Windows.Data;

namespace C1_Demo
{
    public partial class DemoNewTab
    {
        DateTime lastMonth = DateTime.Today;
        public DemoNewTab()
        {
            InitializeComponent();
            AddTab();
            AddTab();
        }

        private void C1TabItem_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            AddTab();
        }
        
        void AddTab()
        {
            lastMonth = lastMonth.AddMonths(1);
            var cal = new Calendar();
            cal.Style = (Style)Resources["MonthCalendarStyle"];
            cal.SelectedDate = cal.DisplayDate = lastMonth;            
            var item = new C1TabItem();
            item.Header = lastMonth.ToString("MMMM");
            item.Content = cal;
            this.Items.Insert(this.Items.Count - 1, item);
            this.SelectedItem = item;
        }
    }
}
