Esempio n. 1
0
        //right button
        public void pictureBox1_Click(object sender, EventArgs e)
        {
            bool found = false;

                List<Exhibit> exhibitList = dao.displayfromCategory(category);
                //if we are at the last position of the list do nothing
                if(exhibitList.Last().id!= mainExhibit.id)
                {
                    foreach (Exhibit ex in exhibitList)
                    {
                        if (found == true)
                        {
                            var nextForm = new SingleExhibitForm(ex.id,ex.category,sender,e);
                            nextForm.singlePictureBox.BackgroundImage = Image.FromFile("..\\..\\Resources\\" + ex.image);
                            nextForm.singlePictureBox.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
                            nextForm.singleLabeltype.Text = ex.type;
                            nextForm.singleLabelDimensions.Text = ex.dimensions;
                            nextForm.singleLabelDescription.Text = ex.description;
                            nextForm.singleLabelTiming.Text = ex.timing;
                            nextForm.singleLabelArea.Text = ex.area;
                            nextForm.singleLabelDescription.MaximumSize = new Size(296, 0);
                            nextForm.singleLabelDescription.AutoSize = true;
                            nextForm.Show();
                            //closes the current form
                            this.Close();
                            /*the form is closed but not destroyed so we keep on*/
                            break;
                        }
                        /*if you find the id change the flag and show the next exhibit on the following iteration. if we are at the last exhibit then nothing happens, which is something expected*/
                        if (ex.id == mainExhibit.id )
                        {

                            found = true;
                        }
                    }
            }
        }
Esempio n. 2
0
        private void singleFormAppear(object sender)
        {
            if(sender is PictureBox)
            {
                /*get the id from the name*/
                string pictureBoxId = ((PictureBox)sender).Name.Split('-').Last();
                /*get the category from the name*/
                string[] categoryIdString = ((PictureBox)sender).Name.Split('-');
                string categoryId = categoryIdString[categoryIdString.Length - 2];

                Form singleExhibitDisplayForm = new SingleExhibitForm(Int32.Parse(pictureBoxId), Int32.Parse(categoryId),null,null);
                singleExhibitDisplayForm.Show();
            }
            else if (sender is LinkLabel)
            {
                /*get the id from the name*/
                string linkLabelId = ((LinkLabel)sender).Name.Split('-').Last();
                /*get the category from the name*/
                string[] categoryIdString = ((LinkLabel)sender).Name.Split('-');
                string categoryId = categoryIdString[categoryIdString.Length - 2];

                Form singleExhibitDisplayForm = new SingleExhibitForm(Int32.Parse(linkLabelId), Int32.Parse(categoryId),null,null);
                singleExhibitDisplayForm.Show();

            }
        }
Esempio n. 3
0
        //left button
        /*the click events need to be declared public in order to be accessed by the MainForm class*/
        public void pictureBox2_Click(object sender, EventArgs e)
        {
            bool found = false;

            List<Exhibit> exhibitList = dao.displayfromCategory(category);
            //if we are at the first position of the list do nothing
            if (exhibitList.First().id != mainExhibit.id)
            {
                /*using a for loop instead of a foreach loop in order to iterate the list in reverse order*/
                for (int i = exhibitList.Count() - 1; i >= 0; i--)
                {

                    if (found == true)
                    {
                        var nextForm = new SingleExhibitForm(exhibitList[i].id, exhibitList[i].category,sender,e);
                        nextForm.singlePictureBox.BackgroundImage = Image.FromFile("..\\..\\Resources\\" + exhibitList[i].image);
                        nextForm.singlePictureBox.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
                        nextForm.singleLabelPlace.Text = exhibitList[i].place;
                        nextForm.singleLabeltype.Text = exhibitList[i].type;
                        nextForm.singleLabelDimensions.Text = exhibitList[i].dimensions;
                        nextForm.singleLabelDescription.Text = exhibitList[i].description;
                        nextForm.singleLabelTiming.Text = exhibitList[i].timing;
                        nextForm.singleLabelArea.Text = exhibitList[i].area;
                        nextForm.singleLabelDescription.MaximumSize = new Size(296, 0);
                        nextForm.singleLabelDescription.AutoSize = true;
                        nextForm.Show();

                        //closes the current form
                        this.Close();
                        /*the form is closed but not destroyed so we keep on*/
                        break;
                    }
                    /*if you find the id change the flag and show the next exhibit on the following iteration. if we are at the last exhibit then nothing happens, which is something expected*/
                    if (exhibitList[i].id == mainExhibit.id)
                    {
                        //we add the historyObject ONLY IF the exhibit is found and displayed
                        //Globals.addHistoryObject(sender, e);
                        found = true;
                    }
                }
            }
        }