private void buttonNext_Click(object sender, EventArgs e)
        {
            if (checkBox1.Checked == true)
            {
                //save data to folder
                Controller.SaveMetadataToFolder(this.Metadata);
            }
            if (checkBoxDatabase.Checked == true)
            {
                //var infoPage = new WritingToDbInfo();
                var infoPage = new InfoForm();
                infoPage.Show();
                infoPage.Update();

                if (Controller.SaveMetadataToDatabase(this.Metadata))
                {
                    infoPage.label1.Text += " SUCCESS!";
                }
                else
                {
                    infoPage.label1.Text += " FAIL";
                }

                infoPage.Update();
                Thread.Sleep(2000);

                infoPage.Close();
                //ScannerDatabase.ScannerDatabase database = new ScannerDatabase.ScannerDatabase();
                //database.AddScan(basicScanObject);
            }

            this.Close();
        }
        private void disableVideoStreamToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var infoPage = new InfoForm();

            infoPage.Text        = "Pleas Wait...";
            infoPage.label1.Text = "Stoping Video Stream...";
            infoPage.Show();
            infoPage.Update();

            this.enableVideoStreamToolStripMenuItem.Enabled  = false;
            this.disableVideoStreamToolStripMenuItem.Enabled = false;

            if (Controller.StopVideoStream())
            {
                this.enableVideoStreamToolStripMenuItem.Enabled  = true;
                this.disableVideoStreamToolStripMenuItem.Enabled = false;
                infoPage.label1.Text += " SUCCESS!";
            }
            else
            {
                this.enableVideoStreamToolStripMenuItem.Enabled  = false;
                this.disableVideoStreamToolStripMenuItem.Enabled = true;
                infoPage.label1.Text += " FAIL!";
            }

            infoPage.Update();
            Thread.Sleep(2000);
            infoPage.Close();
        }
        //[Show All] button
        private void buttonShowAll_Click(object sender, EventArgs e)
        {
            //var infoPage = new WritingToDbInfo();
            var infoPage = new InfoForm();

            infoPage.label1.Text = "Searching from DB, Please wait...";
            infoPage.Show();
            infoPage.Update();

            try
            {
                //listView1.Clear();
                //UpdateListView();
                //listView1.Refresh();
                //listView1.Invalidate();
                //listView1.Update();
                //listView1.ResetText();
                //listView1.Items.Clear();

                Metadata metadata = new Metadata();

                results = new List <Metadata>();

                var metadatas = Controller.GetAllScansFromDatabase();

                //{
                Metadata tmp = new Metadata();
                for (int i = 0; i < metadatas.Count; i++)
                {
                    //tmp = CopyAndNormalize(metadatas[i]);
                    results.Add(metadatas[i]);
                }

                UpdateListView();
                //}
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.ExitThread();
            }
            finally
            {
                infoPage.Close();
            }
        }
        //[Search] button
        private void button1_Click(object sender, EventArgs e)
        {
            //var infoPage = new WritingToDbInfo();
            var infoPage = new InfoForm();

            infoPage.label1.Text = "Searching from DB, Please wait...";
            infoPage.Show();
            infoPage.Update();

            try
            {
                //listView1.ResetText();

                var metadata = new Metadata();

                results = new List <Metadata>();

                if (checkBoxScanID.Checked == true)
                {
                    results = Controller.GetScanFromDatabaseBasedOnQuery(textBoxScanID.Text);
                }

                if (checkBoxPatientIDNP.Checked == true)
                {
                    results = Controller.GetScanFromDatabaseBasedOnQuery(null, textBoxPatientIDNP.Text);
                }

                if (checkBoxDoctorName.Checked == true)
                {
                    results = Controller.GetScanFromDatabaseBasedOnQuery(null, null, textBoxDoctorName.Text);
                }

                if (checkBoxDoctorSurname.Checked == true)
                {
                    results = Controller.GetScanFromDatabaseBasedOnQuery(null, null, null, textBoxDoctorSurname.Text);
                }

                if (checkBoxPatientName.Checked == true)
                {
                    results = Controller.GetScanFromDatabaseBasedOnQuery(null, null, null, null, textBoxPatientName.Text);
                }

                if (checkBoxPatientSurname.Checked == true)
                {
                    results = Controller.GetScanFromDatabaseBasedOnQuery(null, null, null, null, null, textBoxPatientSurname.Text);
                }

                //var metadataContext = new Model1();
                //results = new List<Metadata>();

                ////results.Add(metadataContext.Scans.First(s => s.TissueType.Contains("test tissue")));

                //foreach (var scan in metadataContext.Scans)
                //    if (scan.TissueType.Contains("test tissue"))
                //        results.Add(scan);

                UpdateListView();
                this.Refresh();

                //OpenScan openScanObj = new OpenScan(basicScanObject);
                //openScanObj.Show();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.ExitThread();
            }
            finally
            {
                infoPage.Close();
            }

            #region controller
            //try
            //{
            //    //listView1.ResetText();

            //    BasicScanObject basicScanObject = new BasicScanObject();

            //    ScannerDatabase.ScannerDatabase database = new ScannerDatabase.ScannerDatabase();

            //    results = new List<BasicScanObject>();

            //    if (checkBoxScanID.Checked == true)
            //        results = database.GetScan(textBoxScanID.Text);

            //    if (checkBoxPatientIDNP.Checked == true)
            //        results = database.GetScan(null, textBoxPatientIDNP.Text);

            //    if (checkBoxDoctorName.Checked == true)
            //        results = database.GetScan(null, null, textBoxDoctorName.Text);

            //    if (checkBoxDoctorSurname.Checked == true)
            //        results = database.GetScan(null, null, null, textBoxDoctorSurname.Text);

            //    if (checkBoxPatientName.Checked == true)
            //        results = database.GetScan(null, null, null, null, textBoxPatientName.Text);

            //    if (checkBoxPatientSurname.Checked == true)
            //        results = database.GetScan(null, null, null, null, null, textBoxPatientSurname.Text);

            //    UpdateListView();
            //    this.Refresh();

            //    //OpenScan openScanObj = new OpenScan(basicScanObject);
            //    //openScanObj.Show();
            //}
            //catch (Exception ex)
            //{
            //    MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            //    Application.ExitThread();
            //}
            #endregion
        }