你好,游客 登录 注册 搜索
背景:
阅读新闻

Linux图形界面开发—MonoDevelop初探

[日期:2012-04-13] 来源:Linux社区  作者:guoyuanwei [字体:大 中 小]

可以看到左边解决方案的下面多了一个项目GtkTest,编译此项目,运行后得到如下界面

上面的界面有点简单,下面加以改进,点击查看-》属性和工具栏,即打开工具栏和熟悉窗口,下面是一部份工具栏窗口,可以适当的修改窗体界面,通过工具栏。

修改后界面如下:

代码如下:

using System;
using Gtk;
  
public partial class MainWindow : Gtk.Window
{
    public MainWindow () : base(Gtk.WindowType.Toplevel)
    {
        Build ();
    }
  
    protected void OnDeleteEvent (object sender, DeleteEventArgs a)
    {
        Application.Quit ();
        a.RetVal = true;
    }
      
    //打开日志进行查看
    protected virtual void OnOpen (object sender, System.EventArgs e)
    {
         // Reset the logTreeView and change the window back to original size
     int width, height;
     this.GetDefaultSize( out width, out height );
     this.Resize( width, height );
       
     LogView.Buffer.Text = "";
       
     // Create and display a fileChooserDialog
     FileChooserDialog chooser = new FileChooserDialog(
        "Please select a logfile to view ...",
        this,
        FileChooserAction.Open,
        "Cancel", ResponseType.Cancel,
        "Open", ResponseType.Accept );
       
     if( chooser.Run() == ( int )ResponseType.Accept )
     {
        // Open the file for reading.
        System.IO.StreamReader file =
        System.IO.File.OpenText( chooser.Filename );
          
        // Copy the contents into the logTextView
        LogView.Buffer.Text = file.ReadToEnd();
          
        // Set the MainWindow Title to the filename.
        this.Title = "Nate's Log Viewer -- " + chooser.Filename.ToString();
          
        // Make the MainWindow bigger to accomodate the text in the logTextView
        this.Resize( 640, 480 );
          
        // Close the file so as to not leave a mess.
        file.Close();
     } // end if
     chooser.Destroy();
    }
    //关闭应用程序
    protected virtual void OnCloseActivated (object sender, System.EventArgs e)
    {
        Application.Quit();
    }
如果要开发出更加复杂的图形界面在linux上,还得继续研究GTK#,不过总体思路和winform开发一致。
linux
相关资讯       Monodevelop 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款