コード例 #1
0
        // https://docs.microsoft.com/en-us/dotnet/api/system.drawing.image?view=netframework-4.7.2
        private void buttonAddNewImage_Click(object sender, EventArgs e)
        {
            string   title       = textBoxAddImageTitle.Text;
            string   description = textBoxAddImageDescription.Text;
            DateTime date        = Convert.ToDateTime(dateTimePickerAddImageDate.Text);

            Image currentImage = Image.FromFile(_imageLocation);

            byte[] photo = ImageToByteArray(currentImage);

            if (!FieldsCompleted(title, description))
            {
                labelAddImage.Text = @"Must complete mandatory fields.";
            }
            else
            {
                buttonAddNewImage.Enabled = true;
                Imagine image = new Imagine()
                {
                    Data      = date,
                    Descriere = description,
                    Titlu     = title,
                    Foto      = photo
                };

                _carService.AddImage(image);

                labelAddImage.Text    = @"Image added.";
                labelAddImage.Visible = true;
            }
        }
コード例 #2
0
 public void AddImage(Imagine image)
 {
     _api.AddImage(image);
 }