using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Telerik.WinControls;
using Telerik.WinControls.UI;

namespace MemoryTest
{
    public partial class MDIForm : Telerik.WinControls.UI.RadForm
    {
        public MDIForm()
        {
            InitializeComponent();
        }

        private void RadForm1_Load(object sender, EventArgs e)
        {

        }

        private void addFormToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmSales frm = new frmSales();
            frm.Dock = DockStyle.Fill;
            frm.TopLevel = false;
            frm.TopMost = true;
            frm.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
            var page = new RadPageViewPage();
            page.Controls.Add(frm);
            radPageView1.Pages.Add(page);
            radPageView1.SelectedPage = page;
            frm.Show();


        }

        private void closeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                if (radPageView1.Pages.Count > 0)
                {
                    RadPageViewPage page = radPageView1.Pages[radPageView1.Pages.Count - 1];
                    ////foreach (Control item in page.Controls)
                    RadForm frm = (RadForm)page.Controls[0];
                    frmSales obj = (frmSales)frm;
                    radPageView1.Pages.Remove(page);
                    page.Dispose();
                    page = null;
                    obj.ClearMem2();
                    obj.Close();
                    obj.Dispose();
                    obj = null;
                    GC.Collect();
                    GC.WaitForPendingFinalizers();
                    GC.Collect();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

        }
    }
}
