using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace OsaGateway
{
    public partial class CallDetail : Form
    {
        public delegate void CallDetailHandler();
        static public event CallDetailHandler NewCallChange;

        private string phoneNumber = string.Empty;

        public CallDetail(Guid callGuid)
        {
            InitializeComponent();
            Calls call = Calls.Get(callGuid);
            label2.Text = call.Date.ToString();
            phoneNumber = call.Phone;
            try
            {
                label4.Text = Contact.Get(call.Phone).Name + " (" + call.Phone + ")";
            }
            catch (Exception)
            {
                label4.Text = call.Phone;
            }

            string[] tmp = Program.NewCallGuid.ToArray();
            if (tmp != null && tmp.Count() > 0)
            {
                foreach (string item in tmp)
                {
                    if (item == callGuid.ToString())
                    {
                        Program.NewCallGuid.Remove(item);
                    }
                }
                if (NewCallChange != null)
                    NewCallChange();
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            NewCall call = new NewCall(phoneNumber);
            call.Show();
            this.Hide();
            this.Close();
        }
    }
}
