// <file>
//     <copyright see="prj:///doc/copyright.txt"/>
//     <license see="prj:///doc/license.txt"/>
//     <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
//     <version value="$version"/>
// </file>

using System;
using System.IO;
using System.Windows.Forms;
using System.Drawing;

namespace ICSharpCode.Core.Services
{
	/// <summary>
	///     Add summary description for SaveErrorInformDialog
	/// </summary>
	public class SaveErrorInformDialog : Form 
	{
		Label   descriptionLabel;
		TextBox descriptionTextBox;
		Button  exceptionButton;
		Button  okButton;
		
		string    displayMessage;
		Exception exceptionGot;
		
		public SaveErrorInformDialog(string fileName, string message, string dialogName, Exception exceptionGot) 
		{
			this.Text = dialogName;
			//  Must be called for initialization
			this.InitializeComponents();
			
			StringParserService stringParserService = (StringParserService)ServiceManager.Services.GetService(typeof(StringParserService));
			displayMessage = stringParserService.Parse(message, new string[,] {
				{"FileName", fileName},
				{"Path",     Path.GetDirectoryName(fileName)},
				{"FileNameWithoutPath", Path.GetFileName(fileName)},
				{"Exception", exceptionGot.GetType().FullName},
			});
			descriptionTextBox.Lines = this.displayMessage.Split('\n');
			
			this.exceptionGot = exceptionGot;
		}
		
		void ShowException(object sender, EventArgs e)
		{
			MessageBox.Show(this, exceptionGot.ToString(), "Exception got");
		}
		
		/// <summary>
		///     This method was autogenerated - do not change the contents manually
		/// </summary>
		private void InitializeComponents() 
		{
			ResourceService resourceService = (ResourceService)ServiceManager.Services.GetService(typeof(ResourceService));
			
			//
			//  Set up generated class SaveErrorInformDialog
			// 
			this.SuspendLayout();
			this.MaximizeBox = false;
			this.Name = "SaveErrorInformDialog";
			this.MinimizeBox = false;
			this.Size = new Size(526, 262);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
			this.ShowInTaskbar = false;
			this.StartPosition = FormStartPosition.CenterScreen;
			
			
			// 
			//  Set up member descriptionLabel
			// 
			descriptionLabel = new Label();
			descriptionLabel.Location = new Point(8, 0);
			descriptionLabel.Size = new Size(514, 24);
			descriptionLabel.TabIndex = 3;
			descriptionLabel.Anchor = (System.Windows.Forms.AnchorStyles.Top 
						| (System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right));
			descriptionLabel.TextAlign = System.Drawing.ContentAlignment.BottomLeft;
			descriptionLabel.Text = "Description";
			descriptionLabel.Name = "descriptionLabel";
			this.Controls.Add(descriptionLabel);
			
			// 
			//  Set up member descriptionTextBox
			// 
			descriptionTextBox = new TextBox();
			descriptionTextBox.Name = "descriptionTextBox";
			descriptionTextBox.Multiline = true;
			descriptionTextBox.Size = new Size(506, 176);
			descriptionTextBox.Location = new Point(8, 24);
			descriptionTextBox.TabIndex = 2;
			descriptionTextBox.Anchor = (System.Windows.Forms.AnchorStyles.Top 
						| (System.Windows.Forms.AnchorStyles.Bottom 
						| (System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
			descriptionTextBox.ReadOnly = true;
			this.Controls.Add(descriptionTextBox);
			
			// 
			//  Set up member exceptionButton
			// 
			exceptionButton = new Button();
			exceptionButton.TabIndex = 1;
			exceptionButton.Name = "exceptionButton";
			exceptionButton.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right);
			exceptionButton.Text = "Show Exception";
			exceptionButton.Size = new Size(120, 23);
			exceptionButton.Location = new Point(392, 208);
			exceptionButton.Click += new EventHandler(ShowException);
			this.Controls.Add(exceptionButton);
			
			// 
			//  Set up member chooseLocationButton
			// 
			okButton = new Button();
			okButton.Name = "okButton";
			okButton.TabIndex = 0;
			okButton.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right);
			okButton.Text = resourceService.GetString("Global.OKButtonText");
			okButton.Size = new Size(120, 23);
			okButton.Location = new Point(264, 208);
			okButton.DialogResult = DialogResult.OK;
			this.Controls.Add(okButton);
			this.ResumeLayout(false);
		}
	}
}
