Click here to Skip to main content
15,881,204 members
Articles / Desktop Programming / WPF

Real-Time Multilingual WPF Demo

Rate me:
Please Sign up or sign in to vote.
4.72/5 (22 votes)
29 Jul 2008CPOL7 min read 62.4K   1.1K   64  
Translate a WPF User Interface using the Google AJAX Language API in real-time
#pragma warning disable 1591
//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:2.0.50727.3031
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace Vidyano.TranslationServices.GoogleTranslate
{
	using System.Data.Linq;
	using System.Data.Linq.Mapping;
	using System.Data;
	using System.Collections.Generic;
	using System.Reflection;
	using System.Linq;
	using System.Linq.Expressions;
	using System.ComponentModel;
	using System;
	
	
	public partial class TranslateCache : System.Data.Linq.DataContext
	{
		
		private static System.Data.Linq.Mapping.MappingSource mappingSource = new AttributeMappingSource();
		
    #region Extensibility Method Definitions
    partial void OnCreated();
    partial void InsertSource(Source instance);
    partial void UpdateSource(Source instance);
    partial void DeleteSource(Source instance);
    partial void InsertTranslations(Translations instance);
    partial void UpdateTranslations(Translations instance);
    partial void DeleteTranslations(Translations instance);
    #endregion
		
		public TranslateCache(string connection) : 
				base(connection, mappingSource)
		{
			OnCreated();
		}
		
		public TranslateCache(System.Data.IDbConnection connection) : 
				base(connection, mappingSource)
		{
			OnCreated();
		}
		
		public TranslateCache(string connection, System.Data.Linq.Mapping.MappingSource mappingSource) : 
				base(connection, mappingSource)
		{
			OnCreated();
		}
		
		public TranslateCache(System.Data.IDbConnection connection, System.Data.Linq.Mapping.MappingSource mappingSource) : 
				base(connection, mappingSource)
		{
			OnCreated();
		}
		
		public System.Data.Linq.Table<Source> Source
		{
			get
			{
				return this.GetTable<Source>();
			}
		}
		
		public System.Data.Linq.Table<Translations> Translations
		{
			get
			{
				return this.GetTable<Translations>();
			}
		}
	}
	
	[Table()]
	public partial class Source : INotifyPropertyChanging, INotifyPropertyChanged
	{
		
		private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
		
		private int _ID;
		
		private string _LangCode;
		
		private string _Value;
		
		private EntitySet<Translations> _Translations;
		
    #region Extensibility Method Definitions
    partial void OnLoaded();
    partial void OnValidate(System.Data.Linq.ChangeAction action);
    partial void OnCreated();
    partial void OnIDChanging(int value);
    partial void OnIDChanged();
    partial void OnLangCodeChanging(string value);
    partial void OnLangCodeChanged();
    partial void OnValueChanging(string value);
    partial void OnValueChanged();
    #endregion
		
		public Source()
		{
			this._Translations = new EntitySet<Translations>(new Action<Translations>(this.attach_Translations), new Action<Translations>(this.detach_Translations));
			OnCreated();
		}
		
		[Column(Storage="_ID", AutoSync=AutoSync.OnInsert, DbType="Int NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)]
		public int ID
		{
			get
			{
				return this._ID;
			}
			set
			{
				if ((this._ID != value))
				{
					this.OnIDChanging(value);
					this.SendPropertyChanging();
					this._ID = value;
					this.SendPropertyChanged("ID");
					this.OnIDChanged();
				}
			}
		}
		
		[Column(Storage="_LangCode", DbType="NVarChar(5) NOT NULL", CanBeNull=false)]
		public string LangCode
		{
			get
			{
				return this._LangCode;
			}
			set
			{
				if ((this._LangCode != value))
				{
					this.OnLangCodeChanging(value);
					this.SendPropertyChanging();
					this._LangCode = value;
					this.SendPropertyChanged("LangCode");
					this.OnLangCodeChanged();
				}
			}
		}
		
		[Column(Storage="_Value", DbType="NVarChar(500) NOT NULL", CanBeNull=false)]
		public string Value
		{
			get
			{
				return this._Value;
			}
			set
			{
				if ((this._Value != value))
				{
					this.OnValueChanging(value);
					this.SendPropertyChanging();
					this._Value = value;
					this.SendPropertyChanged("Value");
					this.OnValueChanged();
				}
			}
		}
		
		[Association(Name="Source_Translations", Storage="_Translations", OtherKey="SourceID")]
		public EntitySet<Translations> Translations
		{
			get
			{
				return this._Translations;
			}
			set
			{
				this._Translations.Assign(value);
			}
		}
		
		public event PropertyChangingEventHandler PropertyChanging;
		
		public event PropertyChangedEventHandler PropertyChanged;
		
		protected virtual void SendPropertyChanging()
		{
			if ((this.PropertyChanging != null))
			{
				this.PropertyChanging(this, emptyChangingEventArgs);
			}
		}
		
		protected virtual void SendPropertyChanged(String propertyName)
		{
			if ((this.PropertyChanged != null))
			{
				this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
			}
		}
		
		private void attach_Translations(Translations entity)
		{
			this.SendPropertyChanging();
			entity.Source = this;
		}
		
		private void detach_Translations(Translations entity)
		{
			this.SendPropertyChanging();
			entity.Source = null;
		}
	}
	
	[Table()]
	public partial class Translations : INotifyPropertyChanging, INotifyPropertyChanged
	{
		
		private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);
		
		private int _ID;
		
		private int _SourceID;
		
		private string _LangCode;
		
		private string _Value;
		
		private EntityRef<Source> _Source;
		
    #region Extensibility Method Definitions
    partial void OnLoaded();
    partial void OnValidate(System.Data.Linq.ChangeAction action);
    partial void OnCreated();
    partial void OnIDChanging(int value);
    partial void OnIDChanged();
    partial void OnSourceIDChanging(int value);
    partial void OnSourceIDChanged();
    partial void OnLangCodeChanging(string value);
    partial void OnLangCodeChanged();
    partial void OnValueChanging(string value);
    partial void OnValueChanged();
    #endregion
		
		public Translations()
		{
			this._Source = default(EntityRef<Source>);
			OnCreated();
		}
		
		[Column(Storage="_ID", AutoSync=AutoSync.OnInsert, DbType="Int NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)]
		public int ID
		{
			get
			{
				return this._ID;
			}
			set
			{
				if ((this._ID != value))
				{
					this.OnIDChanging(value);
					this.SendPropertyChanging();
					this._ID = value;
					this.SendPropertyChanged("ID");
					this.OnIDChanged();
				}
			}
		}
		
		[Column(Storage="_SourceID", DbType="Int NOT NULL")]
		public int SourceID
		{
			get
			{
				return this._SourceID;
			}
			set
			{
				if ((this._SourceID != value))
				{
					if (this._Source.HasLoadedOrAssignedValue)
					{
						throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();
					}
					this.OnSourceIDChanging(value);
					this.SendPropertyChanging();
					this._SourceID = value;
					this.SendPropertyChanged("SourceID");
					this.OnSourceIDChanged();
				}
			}
		}
		
		[Column(Storage="_LangCode", DbType="NVarChar(5) NOT NULL", CanBeNull=false)]
		public string LangCode
		{
			get
			{
				return this._LangCode;
			}
			set
			{
				if ((this._LangCode != value))
				{
					this.OnLangCodeChanging(value);
					this.SendPropertyChanging();
					this._LangCode = value;
					this.SendPropertyChanged("LangCode");
					this.OnLangCodeChanged();
				}
			}
		}
		
		[Column(Storage="_Value", DbType="NVarChar(500) NOT NULL", CanBeNull=false)]
		public string Value
		{
			get
			{
				return this._Value;
			}
			set
			{
				if ((this._Value != value))
				{
					this.OnValueChanging(value);
					this.SendPropertyChanging();
					this._Value = value;
					this.SendPropertyChanged("Value");
					this.OnValueChanged();
				}
			}
		}
		
		[Association(Name="Source_Translations", Storage="_Source", ThisKey="SourceID", IsForeignKey=true)]
		public Source Source
		{
			get
			{
				return this._Source.Entity;
			}
			set
			{
				Source previousValue = this._Source.Entity;
				if (((previousValue != value) 
							|| (this._Source.HasLoadedOrAssignedValue == false)))
				{
					this.SendPropertyChanging();
					if ((previousValue != null))
					{
						this._Source.Entity = null;
						previousValue.Translations.Remove(this);
					}
					this._Source.Entity = value;
					if ((value != null))
					{
						value.Translations.Add(this);
						this._SourceID = value.ID;
					}
					else
					{
						this._SourceID = default(int);
					}
					this.SendPropertyChanged("Source");
				}
			}
		}
		
		public event PropertyChangingEventHandler PropertyChanging;
		
		public event PropertyChangedEventHandler PropertyChanged;
		
		protected virtual void SendPropertyChanging()
		{
			if ((this.PropertyChanging != null))
			{
				this.PropertyChanging(this, emptyChangingEventArgs);
			}
		}
		
		protected virtual void SendPropertyChanged(String propertyName)
		{
			if ((this.PropertyChanged != null))
			{
				this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
			}
		}
	}
}
#pragma warning restore 1591

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
2sky
Belgium Belgium
2sky focuses on pushing the development for the Microsoft technology stack using its in-house developed product, Vidyano.
This is a Organisation

3 members

Comments and Discussions