Exemplo n.º 1
0
 public GUI()
 {
     InitializeComponent();
     Files      = new List <ModelAndAPI.File>();
     Properties = new List <Property>();
     FileToAdd  = null;
 }
Exemplo n.º 2
0
        /// <summary>
        /// Cand butonul de modificare fisier e apasat, se verifica cate fisiere au fost selectate.
        /// Daca este unul singur, atunci fisierul va fi modificat in functie de textul din
        /// path, nume si descriere fisier + propietatile selectate.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void changeButton_Click(object sender, EventArgs e)
        {
            var fileIndices = fileView.CheckedIndices.Cast <int>();

            if (fileIndices.Count() != 1)
            {
                return;
            }

            List <int> propertiesToChange = new List <int>();
            var        propertyIndices    = propertyView.CheckedIndices.Cast <int>();

            foreach (int property in propertyIndices)
            {
                propertiesToChange.Add(Properties[property].Id);
            }

            var file = new ModelAndAPI.File()
            {
                Id          = Files[fileIndices.ElementAt(0)].Id,
                Name        = nameBox.Text,
                Description = fileDescriptionBox.Text,
                Path        = filePathBox.Text
            };

            FileAPI.ModifyFile(file, propertiesToChange);

            nameBox.Text            = "";
            fileDescriptionBox.Text = "";
            filePathBox.Text        = "";
            UpdateFileList();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Cand butonul de selectare fisier e apasat, se va deschide File Explorer-ul.
        /// Exista un filtru ca sa apara numai fisiere de tip imagine si video.
        /// Odata selectat, atributul FileToAdd va avea campurile modificate
        /// in functie de detaliile fisierului.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void chooseFileButton_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter = "Image files (*.jpg, *.jpeg, *.png) | *.jpg; *.jpeg; *.png; *.mp4; *.avi; *.webm; *.mkv";
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                filePathBox.Text = openFileDialog.FileName;
                FileToAdd        = new ModelAndAPI.File()
                {
                    Path         = openFileDialog.FileName,
                    Size         = new FileInfo(openFileDialog.FileName).Length,
                    CreationDate = DateTime.Now
                };

                foreach (ListViewItem property in propertyView.Items)
                {
                    property.Checked = false;
                }
            }
        }