//upload slike
        private void btnOpenFileDialog_Click(object sender, EventArgs e)
        {
            var fileContent = string.Empty;
            var filePath    = string.Empty;

            using (OpenFileDialog openFileDialog = new OpenFileDialog())
            {
                openFileDialog.InitialDirectory = "c:\\";
                openFileDialog.Filter           = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
                openFileDialog.FilterIndex      = 2;
                openFileDialog.RestoreDirectory = true;

                if (openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    //Get the path of specified file
                    filePath = openFileDialog.FileName;

                    //Read the contents of the file into a stream
                    var fileStream = openFileDialog.OpenFile();

                    using (StreamReader reader = new StreamReader(fileStream))
                    {
                        fileContent = reader.ReadToEnd();
                    }
                }
                //ako si odabrao sliku prikazi, ako si zatvorio dialog i nisi odabrao - nemoj prikazivati
                //padne ako se ovako ne stavi
                //prepare for display
                if (!openFileDialog.FileName.Equals(""))
                {
                    Bitmap img = new Bitmap(openFileDialog.FileName);
                    picboxUser.Image = ImageHelperMethods.ResizeImage(img, 120, 120);
                }
            }
        }
        private async void frmUpdateAlbum_Load(object sender, EventArgs e)
        {
            //get object we want to update
            Album obj = await _albumService.GetById <Album>(_albumId, "GetAlbumById");

            //get all performers
            cmbPerformer.DataSource = await _performerService.Get <List <Performer> >(null, "GetPerformers");

            cmbPerformer.DisplayMember = "ArtisticName";
            cmbPerformer.ValueMember   = "Id";
            cmbPerformer.SelectedValue = obj.Performer.Id; //set selected value from db object

            //get all genres
            cmbGenre.DataSource = await _genreService.Get <List <Genre> >(null, "GetGenres");

            cmbGenre.DisplayMember = "Name";
            cmbGenre.ValueMember   = "Id";
            cmbGenre.SelectedValue = obj.Genre.Id; //set selected value from db object


            cmbYear.DataSource = Enumerable.Range(1900, 130).ToList();
            txtTitle.Text      = obj.Name;

            //prepare image for display
            if (obj.Image.Length != 0)
            {
                picboxAlbum.Image = ImageHelperMethods.ResizeImage(ImageHelperMethods.PrepareImgForDisplayFromDB(obj.Image), 120, 140);
            }
        }
Exemple #3
0
        private async void FrmSongDetails_Load(object sender, EventArgs e)
        {
            if (!_id.Equals(null))
            {
                SongGetRequest song = await _songService.GetById <SongGetRequest>(_id, "GetSongById");

                txtboxLyrics.Text = song.Text;
                txtBoxTitle.Text  = song.Title;
                txtboxAlbum.Text  = song.Album.Name;
                txtboxGenre.Text  = song.Album.Genre.Name;
                picboxAlbum.Image = ImageHelperMethods.ResizeImage(ImageHelperMethods.PrepareImgForDisplayFromDB(song.Album.Image), 100, 100);
            }
        }
        private async void FrmUserDetails_Load(object sender, EventArgs e)
        {
            if (_userId.HasValue)
            {
                var user = await _userService.GetById <UserGetRequest>(_userId, null);

                txtboxName.ReadOnly = true;
                txtboxName.Text     = user.Name;

                txtboxSurname.Text     = user.Surname;
                txtboxSurname.ReadOnly = true;

                txtboxEmail.Text     = user.Email;
                txtboxEmail.ReadOnly = true;

                txtBoxPhone.Text     = user.PhoneNumber;
                txtBoxPhone.ReadOnly = true;

                txtboxUsername.Text     = user.Username;
                txtboxUsername.ReadOnly = true;

                txtboxCity.Text     = user.City.Name;
                txtboxCity.ReadOnly = true;

                txtboxUserType.ReadOnly = true;
                txtboxUserType.Text     = user.UserType.Type;

                //prepare image to display from db
                if (user.Image.Length > 0)
                {
                    byte[]       imgData = user.Image;
                    MemoryStream stream  = new MemoryStream(imgData);
                    picboxUser.Image = ImageHelperMethods.ResizeImage(Image.FromStream(stream), 120, 120);
                }
                if (user.Status.Equals(true))
                {
                    blockBtn.Text = "Block";
                }
                else
                {
                    blockBtn.Text = "Unblock";
                }
            }
        }
        private async void frmAlbumDetails_Load(object sender, EventArgs e)
        {
            Album album = await _albumService.GetById <Album>(_id, "GetAlbumById");

            txtTitle.Text       = album.Name;
            txtYearRelease.Text = album.YearRelease.ToString();
            txtGenre.Text       = album.Genre.Name;
            txtPerformer.Text   = album.Performer.Name;

            //prepare image for display
            if (album.Image.Length != 0)
            {
                byte[]       imgData = album.Image;
                MemoryStream stream  = new MemoryStream(imgData);
                picboxAlbum.Image = ImageHelperMethods.ResizeImage(Image.FromStream(stream), 140, 120);
            }
            //end prepare image

            //load songs for album
            dgvAlbumSongs.DataSource = await _songService.GetById <List <SongGetRequest> >(_id, "GetSongsByAlbum");
        }