2013-08-28 31 views
0

我是新來的C#Gtk單聲道。我做了一個窗口有兩個按鈕,此代碼:如何設置背景顏色以固定在c#GTK mono中?

using Gtk; 
using Gdk; 

class FirstScreen : Gtk.Window 
{ 

public FirstScreen() : base("Buttons") 
{ 
    SetDefaultSize(250, 200); 
    SetPosition(WindowPosition.Center); 

    DeleteEvent += delegate { Application.Quit(); }; 

    Fixed fix = new Fixed(); 

    Button btn1 = new Button("Take Photo"); 

    Button btn2 = new Button("Take Video"); 

    Gdk.Color col = new Gdk.Color(); 
    Gdk.Color.Parse("red", ref col); 
    fix.(StateType.Normal, col); 

    fix.Put(btn1,30, 80); 
    fix.Put(btn2, 130, 80); 


    Add(fix); 
    ShowAll(); 
} 


public static void Main() 
{ 
    Application.Init(); 
    new FirstScreen(); 
    Application.Run(); 
} 

}

我希望窗口的背景色或固定的改變。如何能做到這樣,請幫助嗎?

回答

1

默認情況下,Gtk.Fixed沒有自己的Gdk.Window,但在其父窗口上繪製並且不繪製任何背景。把它繪製背景,只要告訴它來創建自己的Gdk.Window

fix.HasWindow = true; 

這就是全部。

+0

Hi @fog我有一個大問題。你有沒有GTK mono的經驗,你可以幫我聊天嗎? – Navdroid

+0

@NavdeepSinghBedi當然。 – fog

+0

我有一個項目在C#Gtk#使用攝像頭你能幫忙嗎? – Navdroid