Click here to Skip to main content
15,881,424 members
Articles / Programming Languages / C#

How we can write on C# in Linux: Implementing PanelApplet to Gnome Desktop

Rate me:
Please Sign up or sign in to vote.
4.86/5 (48 votes)
8 Mar 2010CPOL12 min read 84.8K   382   95  
This article describes how we can use our programming skills on the .NET framework to implement platform-independent code
using System;
using Gtk;


using WeatherApplet.Data;

namespace WeatherApplet.View
{

	public class MyWindow:Window
	{
		//labels, which will show weather params
		private Label lblLocation = new Label();
		private Label lblTime = new Label();
		private Label lblWind = new Label();
		private Label lblVisibility = new Label();
		private Label lblSkyConditions = new Label();
		private Label lblTemperature = new Label();
		private Label lblDewPoint = new Label();
		private Label lblRelativeHumidity = new Label();
		private Label lblPressure = new Label();
		
		
		public MyWindow():base("Center")
		{
			CreateControls();
        	ShowAll();
		}
	
		private void CreateControls()
		{
			SetDefaultSize(400, 200);
			
			Fixed fix = new Fixed();
			
			fix.Put(new Label("Location"), 10, 10 );
			fix.Put(lblLocation, 180, 10 );
			
			fix.Put(new Label("Time"), 10, 30 );
			fix.Put(lblTime, 180, 30 );
			
			fix.Put(new Label("Wind"), 10, 50 );
			fix.Put(lblWind, 180, 50 );
			
			fix.Put(new Label("Visibility"), 10, 70 );
			fix.Put(lblVisibility, 180, 70 );
			
			fix.Put(new Label("Sky conditions"), 10, 90 );
			fix.Put(lblSkyConditions, 180, 90 );
			
			fix.Put(new Label("Temperature"), 10, 110 );
			fix.Put(lblTemperature, 180, 110 );
			
			fix.Put(new Label("Dew point"), 10, 130 );
			fix.Put(lblDewPoint, 180, 130 );
			
			fix.Put(new Label("Relative humidity"), 10, 150 );
			fix.Put(lblRelativeHumidity, 180, 150 );
			
			fix.Put(new Label("Pressure"), 10, 170 );
			fix.Put(lblPressure, 180, 170 );
			
			
			this.Add(fix);
			
       		// SetPosition(WindowPosition.None);
		}
		
		public void ShowWeather(CurrentWeather weather)
		{
			this.lblLocation.Text = weather.Location;
			this.lblTime.Text = weather.Time;
			this.lblWind.Text = weather.Wind;
			this.lblVisibility.Text = weather.Visibility;
			this.lblSkyConditions.Text = weather.SkyConditions;
			this.lblTemperature.Text = weather.Temperature;
			this.lblDewPoint.Text = weather.DewPoint;
			this.lblRelativeHumidity.Text = weather.RelativeHumidity;
			this.lblPressure.Text = weather.Pressure;
		}
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) Nokia
Germany Germany
Interested in design/development of framework functionality using the best patterns and practices.

Comments and Discussions