private void packAll_Click(object sender, EventArgs e)
        {
            if (m_selectGame == null)
            {
                return;
            }
            try
            {
                String dir = Application.ExecutablePath.Substring(0, Application.ExecutablePath.LastIndexOf("\\"));
                if (File.Exists(dir + "\\packGame.py"))
                {
                    File.Copy(dir + "\\packGame.py", ProjectConfig.getInstance().getU8Workspace() + "\\scripts\\packGame.py", true);
                }
                else if (File.Exists(dir + "\\..\\..\\packGame.py"))
                {
                    File.Copy(dir + "\\..\\..\\packGame.py", ProjectConfig.getInstance().getU8Workspace() + "\\scripts\\packGame.py", true);
                }

                GameChannel.Channel c = channelList.SelectedItems[0].Tag as GameChannel.Channel;
                String cmd            = "@set PATH=%~dp0\\tool\\win;%PATH% \nPython27\\python.exe scripts\\packGame.py -r -s -t 1 --appID "
                                        + m_selectGame.Params["appID"].value.value
                                        + " --target *"
                                        + " \nif %ERRORLEVEL% == 0 (\n\texit(%ERRORLEVEL%)\n) else ( \n\t@pause \n\texit(%ERRORLEVEL%)\n)";

                StreamWriter sw = new StreamWriter(ProjectConfig.getInstance().getU8Workspace() + "\\runPackageGame.bat");
                sw.Write(cmd);
                sw.Flush();
                sw.Close();

                Process pro = new Process();
                pro.StartInfo.WorkingDirectory = ProjectConfig.getInstance().getU8Workspace();
                pro.StartInfo.FileName         = ProjectConfig.getInstance().getU8Workspace() + "\\runPackageGame.bat";
                pro.StartInfo.CreateNoWindow   = false;
                pro.Start();
                pro.WaitForExit();

                if (pro.ExitCode == 0)
                {
                    MessageBox.Show("打包成功!!!");
                }
                else if (pro.ExitCode == 1)
                {
                    MessageBox.Show("打包失败!!!");
                }
                else if (pro.ExitCode == 2)
                {
                    MessageBox.Show("没有找到母包!!!");
                }
                else if (pro.ExitCode == 3)
                {
                    MessageBox.Show("没有任何可以打包的渠道");
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
        private void viewapkdir_Click(object sender, EventArgs e)
        {
            if (m_selectGame == null)
            {
                return;
            }

            GameChannel gc = m_selectGame.GameChannel;

            if (gc == null)
            {
                return;
            }

            if (channelList.SelectedItems.Count == 0)
            {
                return;
            }

            Process proc = new Process();

            proc.StartInfo.FileName = "explorer";

            GameChannel.Channel c = channelList.SelectedItems[0].Tag as GameChannel.Channel;
            String arg            = "";

            if (Directory.Exists(ProjectConfig.getInstance().getU8Workspace() + "\\output\\" + m_selectGame.AppName))
            {
                if (Directory.Exists(ProjectConfig.getInstance().getU8Workspace() + "\\output\\" + m_selectGame.AppName + "\\" + c.Params["name"].value.value))
                {
                    arg = ProjectConfig.getInstance().getU8Workspace() + "\\output\\" + m_selectGame.AppName + "\\" + c.Params["name"].value.value;
                }
                else
                {
                    arg = ProjectConfig.getInstance().getU8Workspace() + "\\output\\" + m_selectGame.AppName;
                }
            }
            else
            {
                arg = ProjectConfig.getInstance().getU8Workspace() + "\\output\\";
            }
            //proc.StartInfo.Arguments = "E:\\workspace\\program\\WonderKnight\\u8sdk\\U8SDK_20160323130827-old\\U8SDKTool-Win-P34\\output\\game13";
            proc.StartInfo.Arguments = arg.Replace("\\\\", "\\");
            proc.Start();
        }
        private void viewDirctory_Click(object sender, EventArgs e)
        {
            if (m_selectGame == null)
            {
                return;
            }

            Process proc = new Process();

            proc.StartInfo.FileName = "explorer";

            GameChannel.Channel c = channelList.SelectedItems[0].Tag as GameChannel.Channel;
            String arg            = ProjectConfig.getInstance().getU8Workspace() + "\\games\\" + m_selectGame.AppName;;

            //proc.StartInfo.Arguments = "E:\\workspace\\program\\WonderKnight\\u8sdk\\U8SDK_20160323130827-old\\U8SDKTool-Win-P34\\output\\game13";
            proc.StartInfo.Arguments = arg.Replace("\\\\", "\\");
            proc.Start();
        }
        private void channelList_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (channelList.SelectedItems.Count > 0)
            {
                GameChannel.Channel c = channelList.SelectedItems[0].Tag as GameChannel.Channel;
                foreach (ListViewItem lv in channelList.Items)
                {
                    lv.ImageIndex = 3;
                }

                channelList.SelectedItems[0].ImageIndex = 1;
                refreshChannelAttribute(c);
                if (c.sdk == null)
                {
                    label3.Text = c.Params["sdk"].value.value + "渠道属性";
                }
                else
                {
                    label3.Text = c.sdk.ShowName + "渠道属性";
                }
            }
        }
        private void refreshChannelAttribute(GameChannel.Channel c)
        {
            int i = 0;

            channelAttPanel.Controls.Clear();
            int height = 0;

            foreach (KeyValuePair <String, Param> entry in c.Params)
            {
                Param   p       = entry.Value;
                TextBox content = new TextBox();
                content.Anchor   = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top;
                content.Size     = new Size(channelAttPanel.Size.Width - 4, 20);
                content.Name     = "content";
                content.ReadOnly = true;

                Label desc = new Label();
                desc.MaximumSize = new Size(channelAttPanel.Size.Width - 4, 0);
                desc.Name        = "desc";
                desc.AutoSize    = true;
                channelAttPanel.Controls.Add(desc);
                channelAttPanel.Controls.Add(content);
                ++i;


                if (p.require)
                {
                    desc.Text = "*" + p.desc.value;
                }
                else
                {
                    desc.Text = p.desc.value;
                }

                content.Text = p.value.value;

                // location
                desc.Location    = new Point(2, height + 12);
                content.Location = new Point(2, desc.Location.Y + desc.Size.Height + 2);
                height          += desc.Size.Height;
                height          += content.Size.Height;
                height          += 14;
                //EVENT
                content.TextChanged += new EventHandler((object sender, EventArgs e) =>
                {
                    p.value.value = content.Text;
                });
                content.Tag = p;
            }

            Label sdktitle = new Label();

            sdktitle.AutoSize  = true;
            sdktitle.Text      = "------------渠道SDK相关参数-------------";
            sdktitle.ForeColor = Color.Red;
            sdktitle.Location  = new Point(0, height + 16);
            height            += 18;
            channelAttPanel.Controls.Add(sdktitle);

            foreach (KeyValuePair <String, Param> entry in c.SDKParams)
            {
                Param   p       = entry.Value;
                TextBox content = new TextBox();
                content.Anchor   = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top;
                content.Size     = new Size(channelAttPanel.Size.Width - 4, 20);
                content.Name     = "content";
                content.ReadOnly = true;

                Label desc = new Label();
                desc.MaximumSize = new Size(channelAttPanel.Size.Width - 4, 0);
                desc.Name        = "desc";
                desc.AutoSize    = true;
                channelAttPanel.Controls.Add(desc);
                channelAttPanel.Controls.Add(content);
                ++i;


                if (p.require)
                {
                    desc.Text = "*" + p.name.value + ":" + p.desc.value;
                }
                else
                {
                    desc.Text = p.name.value + ":" + p.desc.value;
                }

                content.Text = p.value.value;

                // location
                desc.Location    = new Point(2, height + 12);
                content.Location = new Point(2, desc.Location.Y + desc.Size.Height + 2);
                height          += desc.Size.Height;
                height          += content.Size.Height;
                height          += 14;
                //EVENT
                content.TextChanged += new EventHandler((object sender, EventArgs e) =>
                {
                    p.value.value = content.Text;
                });
                content.Tag = p;
            }
        }