예제 #1
0
        public FormClient(Client c)
        {
            InitializeComponent();
            client = db.Clients.Single(x => x.Id == c.Id);

            labelWelcome.Text            = "Welcome, " + client.FirstName;
            pictureBoxProfilePhoto.Image = ImageManip.ByteArrayToImage(client.ProfilePhoto);
            if (client.Status == Status.Renting)
            {
                RealEstate tmp = db.RealEstate.Single(x => x.Id == client.Id);
                int        realEstateClientId = tmp.Id;
                realEstate           = db.RealEstate.Single(x => x.Id == realEstateClientId);
                labelRentingNow.Text = "Yes";
                labelPrice.Text      = "$" + realEstate.Price.ToString();
                labelStreet.Text     = realEstate.Street;
                labelFloor.Text      = realEstate.Floor.ToString();
            }
            else
            {
                labelRentingNow.Text = "No";
                labelPrice.Text      = "$0";
                labelStreet.Text     = "Unknown";
                labelFloor.Text      = "0";
            }
        }
        private void buttonNext_Click(object sender, EventArgs e)
        {
            if (photoNumber + 1 >= 5)
            {
                return;
            }
            if (photoSlider == null)
            {
                return;
            }

            photoNumber++;
            labelPhotoNumber.Text = $"{photoNumber + 1}/5";

            if (photoSlider[photoNumber] != null)
            {
                pictureBoxSlider.Image = ImageManip.ByteArrayToImage(photoSlider[photoNumber]);
            }
            else
            {
                Image img = Image.FromFile(noImagePath);
                img = ImageManip.ResizeImage(img, new Size(400, 240));
                pictureBoxSlider.Image = img;
            }
        }
        private void listBoxRealEstate_SelectedIndexChanged(object sender, EventArgs e)
        {
            realEstate              = listBoxRealEstate.SelectedItem as RealEstate;
            textBoxStreet.Text      = realEstate.Street;
            textBoxCity.Text        = realEstate.City.ToString();
            textBoxPrice.Text       = realEstate.Price.ToString();
            textBoxRoom.Text        = realEstate.Rooms.ToString();
            textBoxFloor.Text       = realEstate.Floor.ToString();
            textBoxDescription.Text = realEstate.Description;

            photoNumber           = 0;
            labelPhotoNumber.Text = "1/5";
            if (realEstate.Status == Status.Waiting ||
                realEstate.Status == Status.Renting)
            {
                labelAvailable.Text      = "X";
                labelAvailable.ForeColor = Color.Red;
            }
            else
            {
                labelAvailable.Text      = "V";
                labelAvailable.ForeColor = Color.Green;
            }

            photoSlider            = ImageManip.ByteArrToPhotoSlider(realEstate.PhotoSlider);
            pictureBoxSlider.Image = ImageManip.ByteArrayToImage(photoSlider[photoNumber]);
        }
        public FormProfileSetup(Client client)
        {
            InitializeComponent();

            this.client = client;

            textBoxFirstName.Text           = client.FirstName;
            textBoxLastName.Text            = client.LastName;
            textBoxUsername.Text            = client.Username;
            textBoxPassword.Text            = client.Password;
            textBoxEmail.Text               = client.Email;
            dateTimePickerDateOfBirth.Value = client.DateOfBirth;
            profilePhotoByteArr             = client.ProfilePhoto;
            pictureBoxProfilePhoto.Image    = ImageManip.ByteArrayToImage(client.ProfilePhoto);
        }
        private void buttonAddProfilePhoto_Click(object sender, EventArgs e)
        {
            Image          profilePhoto = null;
            OpenFileDialog ofd          = new OpenFileDialog();

            ofd.Title       = "Select profile photo";
            ofd.Filter      = "JPG|*.jpg|PNG|*.png";
            ofd.Multiselect = false;
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                profilePhoto = Image.FromFile(ofd.FileName);
                profilePhoto = ImageManip.ResizeImage(profilePhoto, new Size(200, 220));
            }

            profilePhotoByteArr          = ImageManip.ImageToByteArray(profilePhoto);
            pictureBoxProfilePhoto.Image = profilePhoto;
        }