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

namespace C1_Demo
{
    public partial class DemoWindow 
        : UserControl, IDisposable
    {
        // --------------------------------------------------------------
        #region ** constructor

        public DemoWindow()
        {
            InitializeComponent();
            CenterOnScreen = true;
        }

        #endregion

        // --------------------------------------------------------------
        #region ** properties

        public string DEMO_Content { get; set; }
        public string DEMO_Header { get; set; }
        public int DEMO_Width { get; set; }
        public int DEMO_Height { get; set; }
        public int DEMO_Left { get; set; }
        public int DEMO_Top { get; set; }
        public bool CenterOnScreen { get; set; }

        #endregion

        // --------------------------------------------------------------
        #region ** buttons

        private void CreateWindow_Click(object sender, RoutedEventArgs e)
        {
            C1Window win = new C1Window();
            win.Content = DEMO_Content;
            win.Header = DEMO_Header;
            win.Width = DEMO_Width;
            win.Height = DEMO_Height;
            win.Left = DEMO_Left;
            win.Top = DEMO_Top;
            win.Content = new WindowContent();

            if (CenterOnScreen)
            {
                win.CenterOnScreen();
            }
            win.Show();
            windows.Add(win);
        }


        private void CreateModal_Click(object sender, RoutedEventArgs e)
        {
            C1Window win = new C1Window();
            win.Content = DEMO_Content;
            win.Header = DEMO_Header;
            win.Width = DEMO_Width;
            win.Height = DEMO_Height;
            win.Left = DEMO_Left;
            win.Top = DEMO_Top;
            win.Content = new WindowContent();

            if (CenterOnScreen)
            {
                win.CenterOnScreen();
            }
            win.ShowModal();
        }

        #endregion

        List<C1Window> windows = new List<C1Window>();
        public void Dispose()
        {
            foreach (var w in windows)
            {
                w.Close();
            }
        }
    }
}
