zoukankan      html  css  js  c++  java
  • Linux图形界面开发—monodevelop初探

    在ubutu10.04下,如果通过源码安装monodevelop有问题,建议用ubuntu自带的软件包管理器安装。

    下面通过几个例子测试下monodevelop

    (1)控制台应用程序

    u

    强大的界面于windows下的vs差不多。输入项目的名称,保存位置,解决方案的名称,保存位置,与windows下一样的哦,其他设置都默认。

    一切都是那么的熟悉,c#代码。编译好后,会生成一个consol.exe的可执行文件,直接F5运行可以得到输出结果

    也可以通过命令guoyuanwei@localhost:~$ mono /home/guoyuanwei/monotest/consol/consol/bin/Debug/consol.exe 得到结果
    Hello World!
    (2)Gtk#图形界面的程序

    在上面创建的解决方案上,点击鼠标右键-》Add-》Add New Project添加一个新的项目,在弹出的窗口中选择GTK#2.0,最后生成的界面如下

    可以看到左边解决方案的下面多了一个项目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开发一致。



  • 相关阅读:
    1)①爬取中国新闻网科技相关部分新闻
    摘记
    KNN算法[分类算法]
    Naive Bayes(朴素贝叶斯算法)[分类算法]
    Oracle 隔离级别
    解决问题没必要过于纠结于原理
    Oracle DBMS_METADATA.GET_DDL
    【听海日志】之ORACLE物化视图 [转]http://www.itpub.net/thread-1614812-1-1.html
    oracle 12c 基础
    Postgres查看数据库中的表及表中字段和类型
  • 原文地址:https://www.cnblogs.com/guoyuanwei/p/2404833.html
Copyright © 2011-2022 走看看