/// <summary>
 /// Initializes a new instance of the <see cref="PrintLayout"/> class.
 /// </summary>
 /// <param name="printLayout">The print layout.</param>
 public PrintLayout(PrintLayout printLayout)
 {
     if (printLayout != null)
     {
         ID          = printLayout.ID;
         Description = printLayout.Description;
         DisplayName = printLayout.DisplayName;
     }
 }
		/// <summary>
		/// Initializes a new instance of the <see cref="PrintLayout"/> class.
		/// </summary>
		/// <param name="printLayout">The print layout.</param>
		public PrintLayout(PrintLayout printLayout)
		{
			if (printLayout != null)
			{
				ID = printLayout.ID;
				Description = printLayout.Description;
                DisplayName = printLayout.DisplayName;
			}
		}
		/// <summary>
		/// This event is used to display print layout choices as defined in the print configuration file.
		/// </summary>
		private void PrintLayoutsWebClient_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
		{
			(sender as WebClient).DownloadStringCompleted -= PrintLayoutsWebClient_DownloadStringCompleted;
			IsBusy = (sender as WebClient).IsBusy;
			var showPreview = (bool)e.UserState; 
			if (e.Error != null || string.IsNullOrEmpty(e.Result))
			{
				Error = e.Error;
				return;
			}
			if (showPreview) Status = Resources.Strings.GetLayoutTemplatesCompleted;
			using (MemoryStream memoryStream = new MemoryStream(Encoding.UTF8.GetBytes(e.Result)))
			{
				XmlSerializer xmlSerializer = new XmlSerializer(typeof(PrintLayouts));
				memoryStream.Position = 0;
				PrintLayouts = (PrintLayouts)xmlSerializer.Deserialize(memoryStream);
				memoryStream.Close();
			}
			if (PrintLayouts != null)
			{
				if (showPreview)
				{
					PrintLayouts.IsConfig = isConfig;
					var printLayoutPicker = new View.PrintLayoutPicker() { DataContext = PrintLayouts };
					PrintLayouts.PropertyChanged += (a, b) =>
						{
							if (b.PropertyName == "IsApplied")
							{
								PrintLayout = new PrintLayout(PrintLayouts.SelectedLayout);
								MapApplication.Current.HideWindow(printLayoutPicker);
							}
						};
					MapApplication.Current.ShowWindow(Resources.Strings.PrintLayoutPickerTitle, printLayoutPicker, true, null, null,
						isConfig ? WindowType.DesignTimeFloating : WindowType.Floating);
				}
				else if (PrintLayout == null)
					PrintLayout = PrintLayouts.FirstOrDefault();
			}
			IsValid = PrintLayout != null && PrintHeight > 0 && PrintWidth > 0;
		}