Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/327.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 带GTK的C透明背景_C#_Linux_Port_Transparency_Gtk# - Fatal编程技术网

C# 带GTK的C透明背景

C# 带GTK的C透明背景,c#,linux,port,transparency,gtk#,C#,Linux,Port,Transparency,Gtk#,我用.Net制作了这个非常简单的应用程序,大约需要2分钟,但我需要用Gtk移植它,以便在Linux上正常工作 我搜索如何使背景透明,但我没有运气;我还搜索了如何改变背景色,希望找到与透明键等效的颜色,但又没有运气 最重要的是:如何使背景透明 以下是我的应用程序的代码;它是使用Visual Studio 2010和.Net Framework 4客户端配置文件编写的 using System; using System.Collections.Generic; using System.Compo

我用.Net制作了这个非常简单的应用程序,大约需要2分钟,但我需要用Gtk移植它,以便在Linux上正常工作

我搜索如何使背景透明,但我没有运气;我还搜索了如何改变背景色,希望找到与透明键等效的颜色,但又没有运气

最重要的是:如何使背景透明

以下是我的应用程序的代码;它是使用Visual Studio 2010和.Net Framework 4客户端配置文件编写的

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Calendario {
    public partial class Calendar : Form {
        private Timer temporizador;
        private Label lblHora, lblDia, lblFecha;
        public Calendar () {
            InitializeComponent ();

            this.BackColor = System.Drawing.Color.Lime;
            this.ClientSize = new System.Drawing.Size ( 1600, 900 );
            this.DoubleBuffered = true;
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
            this.ShowIcon = false;
            this.ShowInTaskbar = false;
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
            this.TransparencyKey = System.Drawing.Color.Lime;

            temporizador = new Timer();
            temporizador.Tick += new System.EventHandler ( this.temporizador_Tick );
            temporizador.Interval = 1;
            temporizador.Enabled = true;

            lblHora = new Label();
            lblHora.AutoSize = true;
            lblHora.Font = new System.Drawing.Font ( "GE Inspira", 64F, System.Drawing.FontStyle.Regular,
                                                    System.Drawing.GraphicsUnit.Point, ( ( byte ) ( 0 ) ) );
            lblHora.Location = new Point(1240, 12);
            lblHora.TextAlign = ContentAlignment.MiddleRight;
            lblHora.ForeColor = Color.FromArgb(255, 255, 32, 32);
            this.Controls.Add(lblHora);

            lblDia = new Label();
            lblDia.AutoSize = true;
            lblDia.Font = new System.Drawing.Font ( "GE Inspira", 36F, System.Drawing.FontStyle.Regular,
                                                    System.Drawing.GraphicsUnit.Point, ( ( byte ) ( 0 ) ) );
            lblDia.Location = new Point(1430, 117);
            lblDia.TextAlign = ContentAlignment.MiddleRight;
            lblDia.ForeColor = Color.FromArgb(255, 255, 8, 8);
            this.Controls.Add(lblDia);

            lblFecha = new Label();
            lblFecha.AutoSize = true;
            lblFecha.Font = new System.Drawing.Font ( "GE Inspira", 28F, System.Drawing.FontStyle.Regular,
                                                    System.Drawing.GraphicsUnit.Point, ( ( byte ) ( 0 ) ) );
            lblFecha.Location = new Point(1375, 186);
            lblFecha.TextAlign = ContentAlignment.MiddleRight;
            lblFecha.ForeColor = Color.FromArgb(255, 255, 0, 0);
            this.Controls.Add(lblFecha);
        }

        private void temporizador_Tick ( object sender, EventArgs e ) {
            lblHora.Text = DateTime.Now.ToString("HH:mm:ss");
            lblDia.Text = DiaDeLaSemana(DateTime.Now.DayOfWeek.ToString());
            lblFecha.Text = DateTime.Now.Date.ToShortDateString();
        }

        private string DiaDeLaSemana(string DayOfWeek) {
            switch (DayOfWeek) {
                case "Monday":
                    return "lunes";
                case "Tuesday":
                    return "martes";
                case "Wednesday":
                    return "miércoles";
                case "Thursday":
                    return "jueves";
                case "Friday":
                    return "viernes";
                case "Saturday":
                    return "sábado";
                default:
                    return "domingo";
            }
        }
    }
}

提前感谢您的帮助

默认情况下,Compiz没有打开窗口透明度

要在桌面窗口上启用透明度,请执行以下步骤:

1) Install Compiz Config Settings Manager (if you haven’t already)
sudo apt-get install compizconfig-settings-manager compiz-plugins
2) Alt + F2, type ‘ccsm’ and press Enter to launch CCSM.
3) Click on the ‘Opacity Brightness & Saturation’ Plugin / ‘Opacity’ tab.
4) Click ‘New’. Click ‘+’ and a new window will appear. Click ‘Grab’ and then select the desktop window on which you want to enable transparency. The name will then be filled into the Value field. Click ‘add’. Range 0 (transparent) – 100 (opaque).
5) Transparency can the be changed via the Window Values slider .
Some common window classes are ‘Ccsm’,'Nautilus’,'Dialog’,'Normal’,'Empathy’,'Gedit’,'Gnome-Terminal’

我搜索了更多关于GTK的信息,但它与.Net中的TransparenceKey没有100%的等价性,我在半透明背景下做了一些测试。 但这不是我想要的工作方式。 WinForms和GTK的工作方式非常不同,我知道这是显而易见的,所以我将结束这个问题


如果我浪费了你的时间,我很抱歉…

如果我没有很好地解释,我很抱歉。我不想使用Compiz,我想知道是否可以在不使用Composite Manager Compiz、Xcompmgr等的情况下使用GTK设置透明背景,或者是否可以使用alpha设置背景色。如果没有,我将寻找另一种可能性;但现在我想知道这是否可能。@CarlosMartínezMedina-这是可能的