// ----------------------------------------------------------------------------------
// 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 creating a new container
  /// </summary>
  public partial class BlobContainerForm : Form
  {
    /// <summary>
    /// Construct the form
    /// </summary>
    public BlobContainerForm()
    {
      InitializeComponent();
    }

    /// <summary>
    /// Expose the name of the new container
    /// </summary>
    public string ContainerName { get; private set; }
    /// <summary>
    /// Create a private container?  Public if not
    /// </summary>
    public bool CreatePrivate { 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(NameText.Text))
      {
        epDlg.SetError(NameText, "The Name must be specified");
        return;
      }
      else
      {
        epDlg.SetError(NameText, null);
      }

      ContainerName = NameText.Text;
      CreatePrivate = rbPrivate.Checked;

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

      this.Close();
    }

    /// <summary>
    /// Force the new container name to lower case
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    private void NameText_KeyPress(object sender, KeyPressEventArgs e)
    {
      e.KeyChar = char.ToLower(e.KeyChar);
    }


  }
}