コード例 #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (this.ValidateChildren())
            {
                LocalEventsSeminarski_API.Models.Event putEvent = new LocalEventsSeminarski_API.Models.Event();

                putEvent.EventID        = eventID;
                putEvent.Naziv          = nazivInput.Text;
                putEvent.Opis           = opisInput.Text;
                putEvent.LokacijaID     = Convert.ToInt32(lokacijaSelect.SelectedValue);
                putEvent.OrganizacijaID = Convert.ToInt32(organizacijaSelect.SelectedValue);
                putEvent.EventTipID     = Convert.ToInt32(eventTypeSelect.SelectedValue);
                putEvent.Status         = statusSelect.SelectedItem.ToString();

                //putEvent.DatumKreiranja = DateTime.Now;

                putEvent.DatumOdrzavanja = datumOdrzavanjaInput.Value;

                putEvent.VrijemePocetka   = DateTime.Parse(vrijemePocetkaInput.Value.ToShortTimeString()).TimeOfDay;
                putEvent.VrijemeZavrsetka = DateTime.Parse(vrijemeKrajaInput.Value.ToShortTimeString()).TimeOfDay;

                HttpResponseMessage eventPutResponse = eventService.PutResponse(putEvent.EventID, putEvent);

                if (eventPutResponse.IsSuccessStatusCode)
                {
                    MessageBox.Show("Saved Changes!");
                    Close();
                }
                else
                {
                    MessageBox.Show("event put error");
                }
            }
        }
コード例 #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            openFileDialog1.ShowDialog();
            slikaInput.Text = openFileDialog1.FileName;

            noviEvent.Slika = File.ReadAllBytes(slikaInput.Text);
            Image orgImage = Image.FromFile(slikaInput.Text);

            int resizedImgWidth  = Convert.ToInt32(ConfigurationManager.AppSettings["resizedImgWidth"]);
            int resizedImgHeight = Convert.ToInt32(ConfigurationManager.AppSettings["resizedImgHeight"]);
            int croppedImgWidth  = Convert.ToInt32(ConfigurationManager.AppSettings["croppedImgWidth"]);
            int croppedImgHeight = Convert.ToInt32(ConfigurationManager.AppSettings["croppedImgHeight"]);

            if (orgImage.Width > resizedImgWidth)
            {
                Image resizedImg = UIHelper.ResizeImage(orgImage, new Size(resizedImgWidth, resizedImgHeight));

                if (resizedImg.Width > croppedImgWidth && resizedImg.Height > croppedImgHeight)
                {
                    int croppedXPosition = (resizedImg.Width - croppedImgWidth) / 2;
                    int croppedYPosition = (resizedImg.Height - croppedImgHeight) / 2;

                    Image croppedImg = UIHelper.CropImage(resizedImg, new Rectangle(croppedXPosition, croppedYPosition, croppedImgWidth, croppedImgHeight));
                    eventPictureBox.Image = croppedImg;

                    using (var ms = new MemoryStream()) {
                        croppedImg.Save(ms, orgImage.RawFormat);
                        noviEvent.SlikaThumb = ms.ToArray();
                    }
                }
                else
                {
                    MessageBox.Show("error");
                    noviEvent = null;
                }
            }
        }