Example #1
0
        private void setUserRect()
        {
            Rectangle userRect = new Rectangle();

            if (_imagePaintingService.ColorAreaSize.LenghtSize / (double)pictureBoxImage.Width > _imagePaintingService.ColorAreaSize.HeightSize / (double)pictureBoxImage.Height)
            {
                // Длина больше высоты. Задаемся макимальной длиной равной длине pictureBox
                userRect.Width  = pictureBoxImage.Width;
                userRect.Height = Convert.ToInt32(pictureBoxImage.Width / _imagePaintingService.ColorAreaSize.ProportionWidthToHeight);
            }
            else
            {
                userRect.Height = pictureBoxImage.Height;
                userRect.Width  = Convert.ToInt32(pictureBoxImage.Height * _imagePaintingService.ColorAreaSize.ProportionWidthToHeight);
            }
            if (_userRect == null)
            {
                _userRect = new UserRect(userRect);
                _userRect.SetPictureBox(pictureBoxImage);
            }
            else
            {
                _userRect.rect = userRect;
            }
        }
 private void setUserRect()
 {
    Rectangle userRect = new Rectangle();
    if (_imagePaintingService.ColorAreaSize.LenghtSize / (double)pictureBoxImage.Width > _imagePaintingService.ColorAreaSize.HeightSize / (double)pictureBoxImage.Height)
    {
       // Длина больше высоты. Задаемся макимальной длиной равной длине pictureBox
       userRect.Width = pictureBoxImage.Width;
       userRect.Height = Convert.ToInt32(pictureBoxImage.Width / _imagePaintingService.ColorAreaSize.ProportionWidthToHeight);
    }
    else
    {
       userRect.Height = pictureBoxImage.Height;
       userRect.Width = Convert.ToInt32(pictureBoxImage.Height * _imagePaintingService.ColorAreaSize.ProportionWidthToHeight);
    }
    if (_userRect == null)
    {
       _userRect = new UserRect(userRect);
       _userRect.SetPictureBox(pictureBoxImage);
    }
    else
    {
       _userRect.rect = userRect;
    }
 }