GTK #Mono - 检索固定容器的大小或水平窗格的宽度

时间:2013-06-03 04:25:28

标签: mono gtk#

我正在开发一种视频播放器,包括在固定容器内运行的mplayer小部件。我希望视频播放器是固定窗格宽度和高度的100%。固定窗格左侧还有一个水平窗格。

我已经弄清楚如何获取窗口的宽度并将视频的初始大小设置为,但我还没弄清楚如何计算它所在的固定窗格的大小或水平的大小旁边的容器。

var width = -1;
var height = -1;

//1048,756 - too big
this.fixed1.ParentWindow.GetSize(out width, out height);

//would rather use this.fixed1.width or something of that sort.

//this.hpaned1 has an initial width that is auto-defined
//this.hpaned1 also contains a vpaned1

Console.WriteLine(width+","+height);
this.socket.WidthRequest = width; 
this.socket.HeightRequest = height; 

1 个答案:

答案 0 :(得分:0)

您可以使用固定容器的“分配”属性获取固定容器的大小。

像这样:

Console.WriteLine(fixed1.Allocation.Width.ToString()+","+fixed1.Allocation.Height.ToString());
this.socket.WidthRequest = fixed1.Allocation.Width; 
this.socket.HeightRequest = fixed1.Allocation.Height;