using qtcnet_client.Properties;
using System.ComponentModel;

namespace qtcnet_client.Controls
{
    public partial class MessageControl : UserControl
    {
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        public string Username { get; set; } = "Username";
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        public string Message { get; set; } = "Message";
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        public Image ProfileImage { get; set; } = Resources.DefaultPfp;
        public MessageControl()
        {
            InitializeComponent();
        }

        private void MessageControl_Load(object sender, EventArgs e)
        {
            lblUsername.Text = Username;
            rtxtMessage.Text = Message;
            pbProfileImage.Image = ProfileImage;
        }

        private void rtxtMessage_ContentsResized(object sender, ContentsResizedEventArgs e)
        {
            rtxtMessage.Height = e.NewRectangle.Height + 4;

            int bottom =
                rtxtMessage.Bottom +
                Padding.Bottom;

            Height = Math.Max(bottom, pbProfileImage.Bottom + 4);
        }

        public void ReloadProfileImage() => pbProfileImage.Image = ProfileImage;
    }
}
