Exemplo n.º 1
0
        private void buttonRemoveImage_Click(object sender, EventArgs e)
        {
            if (this.FileActive != null)
            {
                DbService.RemoveFileById(this.FileActive.FileId);
                MessageBox.Show(this.FileActive.Name, "File removed from directory listing.");

                this.FileActive = null;
                DisplayService_BindList();
                DisplayService_BindPanel();
            }
        }
Exemplo n.º 2
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);
                        MyPhotos.Model.File file     = DbService.CreateFile(info.Name, info.FullName);
                        MyPhotos.Model.Data dataSize = this.Datas.Single(d => d.Label == "size");
                        if (dataSize != null)
                        {
                            DbService.CreateFileData(file, dataSize, info.Length.ToString());
                        }

                        MyPhotos.Model.Data dataDimension = this.Datas.Single(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.º 3
0
 private void list_MouseClick(object sender, MouseEventArgs e)
 {
     if (this.list.Items != null)
     {
         for (int i = 0; i < this.list.Items.Count; i++)
         {
             ListViewItem item = this.list.Items[i];
             if (item.Bounds.Contains(e.Location))
             {
                 this.FileActive = Files[i];
                 DisplayService_BindPanel();
             }
         }
     }
 }
Exemplo n.º 4
0
 private void DataService_Load()
 {
     this.File           = DbService.GetFileById(this.FileId);
     this.File.FileDatas = DbService.GetFileDatasByFileId(this.FileId);
     this.Datas          = DbService.GetDatas();
 }