using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ICSharpCode.Core;
using Mesnac.Core;

namespace Mesnac.Gui.Run.Dialog
{
    public partial class FrmMoveChild : Form
    {
        private string caption = StringParser.Parse(ResourceService.GetString("Mesnac_Dialog_Caption")); //提示
        private TreeNode[] _nodeList = null;

        public FrmMoveChild()
        {
            InitializeComponent();
            this.InitUI();
        }

        public FrmMoveChild(TreeNode[] nodeList)
        {
            InitializeComponent();
            this._nodeList = nodeList;
            this.InitUI();
        }

        private void InitUI()
        {
            this.Text = StringParser.Parse(ResourceService.GetString("Dialog_FrmMoveChild_Text"));  //节点变级操作
            this.btnOk.Text = StringParser.Parse(ResourceService.GetString("Dialog_Button_OK"));    //确定
            this.btnCancel.Text = StringParser.Parse(ResourceService.GetString("Dialog_Button_Cancel"));    //取消
            this.label1.Text = StringParser.Parse(ResourceService.GetString("Dialog_FrmMoveChild_label1_Text"));   //移至:
        }

        private void FrmMoveChild_Load(object sender, EventArgs e)
        {
            if (this._nodeList != null)
            {
                foreach (TreeNode tn in this._nodeList)
                {
                    this.cmbNodeList.Items.Add(tn);
                }
            }
        }

        private void btnOk_Click(object sender, EventArgs e)
        {
            if (this.cmbNodeList.SelectedIndex == -1)
            {
                string msg = StringParser.Parse(ResourceService.GetString("Dialog_FrmMoveChild_Msg_btnOk")); //请设定父级节点!
                MessageBox.Show(msg, this.caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            this.DialogResult = System.Windows.Forms.DialogResult.OK;
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
        }

        public TreeNode CurrentNode
        {
            get
            {
                return this.cmbNodeList.SelectedItem as TreeNode;
            }
        }
    }
}