Exemplo n.º 1
0
        private void buttonAddImage_Click(object sender, EventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();

            dialog.ValidateNames = true;
            dialog.Multiselect   = true;

            dialog.Filter  = "All Images Files (*.png;*.jpeg;*.gif;*.jpg;*.bmp;*.tiff;*.tif)|*.png;*.jpeg;*.gif;*.jpg;*.bmp;*.tiff;*.tif";
            dialog.Filter += "|PNG Portable Network Graphics (*.png)|" + "*.png";
            dialog.Filter += "|JPEG File Interchange Format (*.jpg *.jpeg *jfif)|" + "*.jpg;*.jpeg;*.jfif";
            dialog.Filter += "|BMP Windows Bitmap (*.bmp)|" + "*.bmp";
            dialog.Filter += "|TIF Tagged Imaged File Format (*.tif *.tiff)|" + "*.tif;*.tiff";
            dialog.Filter += "|GIF Graphics Interchange Format (*.gif)|" + "*.gif";


            var response = dialog.ShowDialog();

            if (response == DialogResult.OK)
            {
                foreach (string fileName in dialog.FileNames)
                {
                    try
                    {
                        FileInfo info = new FileInfo(fileName);
                        File     file = DbService.CreateFile(info.Name, info.FullName);

                        // Data dataSize = this.Datas.FirstOrDefault(d => d.Label == "size");
                        Data dataSize = DbService.GetDatas().ToList().FirstOrDefault(d => d.Label == "size");
                        if (dataSize != null)
                        {
                            DbService.CreateFileData(file, dataSize, info.Length.ToString());
                        }

                        Data dataDimension = DbService.GetDatas().ToList().FirstOrDefault(d => d.Label == "dimension");
                        if (dataDimension != null)
                        {
                            Bitmap placeholder = new Bitmap(fileName);
                            DbService.CreateFileData(file, dataDimension, placeholder.Width + " x " + placeholder.Height);
                        }
                    }
                    catch (Exception exception)
                    {
                        Console.WriteLine(exception);
                        MessageBox.Show(exception.Message, "Error when adding file to our directory.");
                    }
                }

                this.Query = "";
                DisplayService_BindList();
                this.FileActive = null;
                DisplayService_BindPanel();
            }
        }
Exemplo n.º 2
0
 private void DataService_Load()
 {
     this.Datas = DbService.GetDatas().ToList();
 }
Exemplo n.º 3
0
 private void DataService_Load()
 {
     this.File = DbService.GetFileById(this.FileId);
     this.File.FileDatas = DbService.GetFileDatasByFileId(this.FileId);
     this.Datas = DbService.GetDatas().ToList();
 }