alternetsoft / AlternetUI

MIT License
22 stars 2 forks source link

PictureBox Height and Width not work #77

Closed neoxeo closed 8 months ago

neoxeo commented 8 months ago

@generalloki

Test code :

 private void button1_Click(object? sender, EventArgs e)
 {
     pictureBox1.Image = Image.FromStream(streamFromFile(@"d:\downloads\AlternetSoft.png"));
     pictureBox1.Height = (int)this.Height / 2;
     pictureBox1.Width = (int)this.Width / 2;
 }

  public FileStream streamFromFile(string filename)
  {
      FileStream stream = File.OpenRead(filename);
      return stream;
  }

PictureBox not resize

neoxeo commented 8 months ago

@generalloki

Fix doesn't full work.

Change size of picturebox works only if event "Resize" is present.

This code doesn't works :

 public Form1()
 {
     InitializeComponent();
}

private void loadBtn_Click(object sender, EventArgs e)
{
    pictureBox1.Size= new SizeD(400, 600);
}

This code works with event Resize for pictureBox1 is present :

 public Form1()
 {
     InitializeComponent();
     pictureBox1.Resize += PictureBox1_Resize;
}

private void loadBtn_Click(object sender, EventArgs e)
{
    pictureBox1.Size= new SizeD(1,1);
}

private void PictureBox1_Resize(object sender, EventArgs e)
{
    pictureBox1.Size= new SizeD(400, 600);
}
generalloki commented 8 months ago

It is incorrect to change size in the Resize event. Resize event is fired after size is changed. The problem is in uixml. Please send the full project or at least uixml.

neoxeo commented 8 months ago

@generalloki

Here is the test project : test1.zip

generalloki commented 8 months ago

I have checked the project. It doesn't work that way. You need to add some container control like VerticalStackPanel and insert PictureBox and Buttons there.

neoxeo commented 8 months ago

Ok, thanks.