// ----------------------------------------------------------------------------------
// Microsoft Developer & Platform Evangelism
// 
// Copyright (c) Microsoft Corporation. All rights reserved.
// 
// THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, 
// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES 
// OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// ----------------------------------------------------------------------------------
// The example companies, organizations, products, domain names,
// e-mail addresses, logos, people, places, and events depicted
// herein are fictitious.  No association with any real company,
// organization, product, domain name, email address, logo, person,
// places, or events is intended or should be inferred.
// ----------------------------------------------------------------------------------

namespace Microsoft.Samples.WindowsAzureMmc.SnapIn.Forms
{
    using System;
    using System.ComponentModel;
    using System.Windows.Forms;

  /// <summary>
  /// Form used when downloading a blob
  /// </summary>
  public partial class DownloadBlobForm : Form
  {
    /// <summary>
    /// Construct the form
    /// </summary>
    public DownloadBlobForm()
    {
      InitializeComponent();
    }

    /// <summary>
    /// The selected path to upload
    /// </summary>
    public string Path { get; private set; }

    /// <summary>
    /// OK Button pressed
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    private void OKButton_Click(object sender, EventArgs e)
    {
      if (string.IsNullOrEmpty(PathText.Text))
      {
        epDlg.SetError(PathText, "The Path must be specified");
        return;
      }
      else
      {
        epDlg.SetError(PathText, null);
      }

      Path = PathText.Text;

      //Set dialog result and close the form.
      DialogResult = DialogResult.OK;

      this.Close();
    }

    /// <summary>
    /// Browse for a folder
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    private void BrowseButton_Click(object sender, EventArgs e)
    {
      if (fbDlg.ShowDialog(this) == DialogResult.OK)
      {
        PathText.Text = fbDlg.SelectedPath;
      }
    }
  }
}