using System;
using System.Windows.Forms;
namespace Core.Common.Controls.Swf.WizardPages
{
///
/// Use to add select file page to a wizard
///
public partial class SelectFileWizardPage : UserControl, IWizardPage
{
public event EventHandler FileSelected;
private string fileName;
///
///
public SelectFileWizardPage()
{
InitializeComponent();
}
///
/// File used in the openFileDialog
///
public virtual string Filter
{
get
{
return openFileDialog.Filter;
}
set
{
openFileDialog.Filter = value;
}
}
public virtual string FileName
{
get
{
return fileName;
}
set {}
}
///
///
public string FileDescription
{
get
{
return lblDescription.Text;
}
set
{
lblDescription.Text = value;
}
}
public bool CanFinish()
{
return CanDoNext();
}
public virtual bool CanDoNext()
{
return textBox1.Text != string.Empty && labelErrorMessage.Text == string.Empty;
}
public bool CanDoPrevious()
{
return true;
}
protected virtual void OnFileSelected()
{
if (FileSelected != null)
{
FileSelected(this, new EventArgs());
}
}
private void buttonOpenFile_Click(object sender, EventArgs e)
{
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
try
{
fileName = openFileDialog.FileName;
textBox1.Text = openFileDialog.FileName;
labelErrorMessage.Text = "";
}
catch (Exception exception)
{
fileName = "";
textBox1.Text = "";
labelErrorMessage.Text = exception.Message;
}
OnFileSelected();
}
}
}
}