Пример #1
0
        private void btnRemoveImage_Click(object sender, EventArgs e)
        {
            if (DgwLessonsImages.SelectedRows.Count == 0)
            {
                MessageBox.Show("Selezionare nella griglia un'immagine da cancellare");
                return;
            }
            picImage.Image = null;

            currentImage = ((List <DbClasses.Image>)DgwLessonsImages.DataSource)[DgwLessonsImages.SelectedRows[0].Index];
            if (MessageBox.Show("Vuole cancellare il file dell'immagine (Sì) o solo il collegamento a questa lezione (No)?",
                                "Cancellazione Immagine", MessageBoxButtons.YesNo, MessageBoxIcon.Question,
                                MessageBoxDefaultButton.Button2)
                == DialogResult.Yes)
            {
                db.RemoveImageFromLesson(currentLesson, currentImage, true);
            }
            else
            {
                db.RemoveImageFromLesson(currentLesson, currentImage, false);
            }
            DgwLessonsImages.DataSource = db.GetLessonsImagesList(currentLesson);
            try
            {
                currentImage = ((List <DbClasses.Image>)DgwLessonsImages.DataSource)[0];
            }catch { }
            LoadImage();
        }
Пример #2
0
 private void DgwLessonsImages_RowEnter(object sender, DataGridViewCellEventArgs e)
 {
     DgwLessonsImages.Rows[e.RowIndex].Selected = true;
     currentImage = ((List <DbClasses.Image>)DgwLessonsImages.DataSource)[e.RowIndex];
     LoadImage();
     txtCaption.Text = currentImage.Caption;
     //indexImages = e.RowIndex;
 }
Пример #3
0
 private void dgwLessonsImages_RowEnter(object sender, DataGridViewCellEventArgs e)
 {
     if (e.RowIndex > -1)
     {
         dgwLessonsImages.Rows[e.RowIndex].Selected = true;
         currentImage         = ((List <DbClasses.Image>)dgwLessonsImages.DataSource)[e.RowIndex];
         currentIndexInImages = e.RowIndex;
         loadCurrentImage();
     }
 }
Пример #4
0
 private void FirstImage()
 {
     if (listImages.Count > 0)
     {
         DgwLessonsImages.Rows[indexImages].Selected = false;
         indexImages  = 0;
         currentImage = (DbClasses.Image)listImages[indexImages];
         LoadImage();
         DgwLessonsImages.Rows[indexImages].Selected = true;
     }
 }
Пример #5
0
 private void firstImage()
 {
     if (listImages.Count > 0)
     {
         dgwLessonsImages.Rows[currentIndexInImages].Selected = false;
         currentIndexInImages = 0;
         currentImage         = (DbClasses.Image)listImages[currentIndexInImages];
         loadCurrentImage();
         dgwLessonsImages.Rows[currentIndexInImages].Selected = true;
     }
 }
Пример #6
0
 private void PreviousImage()
 {
     if (listImages.Count > 0)
     {
         DgwLessonsImages.Rows[indexImages].Selected = false;
         if (indexImages == 0)
         {
             indexImages = listImages.Count;
         }
         indexImages--;
         currentImage = (DbClasses.Image)listImages[indexImages];
         LoadImage();
         DgwLessonsImages.Rows[indexImages].Selected = true;
     }
 }
Пример #7
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            int localIndex = DgwLessonsImages.SelectedRows[0].Index;

            currentImage.Caption = txtCaption.Text;
            db.SaveImage(currentImage);
            // refresh images in grid
            DgwLessonsImages.DataSource = db.GetLessonsImagesList(currentLesson);
            indexImages  = localIndex;
            currentImage = ((List <DbClasses.Image>)DgwLessonsImages.DataSource)[localIndex];
            LoadImage();
            txtCaption.Text = currentImage.Caption;
            DgwLessonsImages.Rows[localIndex].Selected = false;
            DgwLessonsImages.Rows[localIndex].Selected = true;
        }
Пример #8
0
 private void previousImage()
 {
     if (listImages.Count > 0)
     {
         dgwLessonsImages.Rows[currentIndexInImages].Selected = false;
         if (currentIndexInImages == 0)
         {
             currentIndexInImages = listImages.Count;
         }
         currentIndexInImages--;
         currentImage = (DbClasses.Image)listImages[currentIndexInImages];
         loadCurrentImage();
         dgwLessonsImages.Rows[currentIndexInImages].Selected = true;
     }
 }
Пример #9
0
 private void justLinkFileToLesson(string sourcePathAndFileName)
 {
     DbClasses.Image currentImage = Commons.bl.FindImageWithGivenFile(sourcePathAndFileName);
     // if the image that reference to the file isn't anymore in the database
     // create a new image that references to this file
     // (eg. if the lesson has been deleted from the database together with its images, but
     // the file is (somehow) still there)
     if (currentImage == null)
     {
         currentImage         = new DbClasses.Image();
         currentImage.IdImage = 0;
         currentImage.RelativePathAndFilename = sourcePathAndFileName.Remove(0, Commons.PathImages.Length + 1);
     }
     currentImage.Caption = txtCaption.Text;
     Commons.bl.LinkOneImageToLesson(currentImage, currentLesson);
 }
Пример #10
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (dgwLessonsImages.SelectedRows != null)
     {
         int localIndex = dgwLessonsImages.SelectedRows[0].Index;
         currentImage.Caption = txtCaption.Text;
         Commons.bl.SaveImage(currentImage);
         currentIndexInImages = localIndex;
         refreshUi(currentIndexInImages);
         currentImage = ((List <DbClasses.Image>)dgwLessonsImages.DataSource)[localIndex];
         loadCurrentImage();
         //txtCaption.Text = currentImage.Caption;
         //DgwLessonsImages.Rows[localIndex].Selected = false;
         //DgwLessonsImages.Rows[localIndex].Selected = true;
     }
 }
Пример #11
0
        private void btnRemoveImage_Click(object sender, EventArgs e)
        {
            // values before
            int oldIndex = currentIndexInImages;

            if (dgwLessonsImages.SelectedRows.Count == 0)
            {
                MessageBox.Show("Selezionare nella griglia un'immagine da cancellare");
                return;
            }
            picImage.Image = null;
            // read from grid the data of the image to delete
            currentImage = ((List <DbClasses.Image>)dgwLessonsImages.DataSource)[dgwLessonsImages.SelectedRows[0].Index];
            DialogResult r = MessageBox.Show(" (Sì) Cancella anche il FILE dell'immagine '" + currentImage.Caption + "';" +
                                             "\n (No) Cancella il solo collegamento a questa lezione; " +
                                             "\n (Annulla) Non cancella nulla.",
                                             "Cancellazione Immagine", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question,
                                             MessageBoxDefaultButton.Button2);

            if (r == DialogResult.Yes)
            {
                Commons.bl.RemoveImageFromLesson(currentLesson, currentImage, true);
            }
            else if (r == DialogResult.No)
            {
                Commons.bl.RemoveImageFromLesson(currentLesson, currentImage, false);
            }
            else
            {
                return;
            }

            if (currentIndexInImages > 0)
            {
                currentIndexInImages = oldIndex - 1;
            }
            try
            {
                currentImage = ((List <DbClasses.Image>)dgwLessonsImages.DataSource)[currentIndexInImages];
            }
            catch { }
            loadCurrentImage();
            refreshUi(currentIndexInImages);
        }
Пример #12
0
        private void frmImages_Load(object sender, EventArgs e)
        {
            txtLessonDate.Text = currentLesson.Date.ToString();
            txtSchoolYear.Text = currentClass.SchoolYear;
            txtClass.Text      = currentClass.Abbreviation;

            txtSchoolSubject.Text = currentLesson.IdSchoolSubject;
            txtLessonCode.Text    = currentLesson.IdLesson.ToString();;
            txtLessonDesc.Text    = currentLesson.Note;

            DgwLessonsImages.DataSource = listImages;

            if (type == ImagesFormType.ShowImage)
            {
                picImage.Location = new System.Drawing.Point(0, 0);
                picImage.Size     = this.Size;
                currentImage      = listImages[0];
                LoadImage();
                //picImage.Load(Commons.PathImages + "\\"+ listImages[0].RelativePathAndFilename);
            }
            else if (type == ImagesFormType.NormalManagement)
            {
                DgwLessonsImages.DataSource = listImages;
            }
            if (listImages.Count > 0)
            {
                currentImage = listImages[0];
                LoadImage();
            }
            else
            {
                currentImage = new DbClasses.Image();
            }

            if (currentSubject != null)
            {
                int col = (int)currentSubject.Color;
                this.BackColor = Commons.ColorFromNumber(currentSubject);
                rdbAutoRename_CheckedChanged(null, null);
            }
        }
Пример #13
0
 private void btnAddImage_Click(object sender, EventArgs e)
 {
     if (txtFileImportImage.Text != "")
     {
         string sourcePathAndFileName = txtPathImportImage.Text + "\\" +
                                        txtFileImportImage.Text;
         // if the chosen file is already in the image path, the program
         // will avoid copying it under the image path and will link to the
         // existing file instead
         if (txtPathImportImage.Text.Contains(Commons.PathImages))
         {
             // chosen file is inside the images path
             // does not copy and rename the file
             // this spares HDD space on teachers' machine
             justLinkFileToLesson(sourcePathAndFileName);
         }
         else
         {
             // chosen file is outside the images path
             copyFileToImagesAndLinkToLessons(sourcePathAndFileName);
         }
         try
         {
             picImage.Load(sourcePathAndFileName);
         }
         catch
         {
             Console.Beep();
         };
         // goto the last in the grid (the one just added)
         currentIndexInImages = dgwLessonsImages.Rows.Count;
         if (currentIndexInImages < 0)
         {
             currentIndexInImages = 0;
         }
         refreshUi(currentIndexInImages);
         // load data from the last
         currentImage = ((List <DbClasses.Image>)dgwLessonsImages.DataSource)[dgwLessonsImages.Rows.Count - 1];
         loadCurrentImage();
     }
 }