Ejemplo n.º 1
0
        private void buttonX1_Click(object sender, EventArgs e) // 导入
        {
            CD1.Multiselect = true;
            CD1.Filter      = "TGA (*.tga)|*.tga";
            DialogResult dr = CD1.ShowDialog();

            if (dr == DialogResult.OK)
            {
                bool bYesToAll = false;
                bool bNoToAll  = false;
                bool bCancel   = false;

                foreach (string strSelectedFileName in CD1.FileNames)
                {
                    if (bCancel)
                    {
                        break;
                    }

                    bool bNeedDoThisTime = false;

                    if (!File.Exists(strSelectedFileName))
                    {
                        continue;
                    }
                    FileInfo tgafile = new FileInfo(strSelectedFileName);

                    DirectoryInfo dirIcon = new DirectoryInfo(tgaIO.StrIconFolder);
                    if (dirIcon.GetFiles(tgafile.Name).Length > 0)
                    {
                        //包含重复文件

                        if (bNoToAll)
                        {
                            continue;
                        }
                        else if (bYesToAll)
                        {
                            bNeedDoThisTime = true;
                        }
                        else
                        {
                            respond form = new respond("已经包含同名文件[" + tgafile.Name + "],是否覆盖?");
                            if (form == null)
                            {
                                MessageBox.Show("G。", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                return;
                            }
                            form.ShowDialog();
                            switch (form.m_respond)
                            {
                            case "yestoall":
                                bYesToAll       = true;
                                bNeedDoThisTime = true;
                                break;

                            case "yes":
                                bNeedDoThisTime = true;
                                break;

                            case "no":
                                continue;

                            case "notoall":
                                bNoToAll = true;
                                continue;

                            case "cancel":
                                bCancel = true;
                                break;

                            default:
                                break;
                            }
                        }
                    }
                    else
                    {
                        bNeedDoThisTime = true;
                    }

                    if (bNeedDoThisTime)
                    {
                        //生成文件
                        //File.Copy(strSelectedFileName, Path.Combine(tgaIO.StrIconFolder, tgafile.Name));
                        TgaToUitex(strSelectedFileName, tgaIO.StrIconFolder);

                        //导入数据
                        tgaIO.InsertNewRecord(tgafile.Name.Split(new char[] { '.' })[0] + ".UITex", "", "");
                    }
                }

                this.Visible = false;
                this.Refresh();
                this.Close();

                Implement parent = this.Tag as Implement;
                parent.Init(tgaIO.sqlConn, tgaIO.StrIconFolder);
                parent.Show();
            }
        }
Ejemplo n.º 2
0
        private void buttonX1_Click(object sender, EventArgs e) // 导入
        {
            CD1.Multiselect = true;
            CD1.Filter = "TGA (*.tga)|*.tga";
            DialogResult dr =  CD1.ShowDialog();
            if (dr == DialogResult.OK)
            {
                bool bYesToAll = false;
                bool bNoToAll = false;
                bool bCancel = false;

                foreach (string strSelectedFileName in CD1.FileNames)
                {
                    if (bCancel)
                        break;

                    bool bNeedDoThisTime = false;

                    if (!File.Exists(strSelectedFileName)) continue;
                    FileInfo tgafile = new FileInfo(strSelectedFileName);

                    DirectoryInfo dirIcon = new DirectoryInfo(tgaIO.StrIconFolder);
                    if (dirIcon.GetFiles(tgafile.Name).Length > 0)
                    {
                        //包含重复文件

                        if (bNoToAll)
                        {
                            continue;
                        }
                        else if (bYesToAll)
                        {
                            bNeedDoThisTime = true;
                        }
                        else
                        {

                            respond form = new respond("已经包含同名文件[" + tgafile.Name + "],是否覆盖?");
                            if (form == null)
                            {
                                MessageBox.Show("G。", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                return;
                            }
                            form.ShowDialog();
                            switch (form.m_respond)
                            {
                                case "yestoall":
                                    bYesToAll = true;
                                    bNeedDoThisTime = true;
                                    break;
                                case "yes":
                                    bNeedDoThisTime = true;
                                    break;
                                case "no":
                                    continue;
                                case "notoall":
                                    bNoToAll = true;
                                    continue;
                                case "cancel":
                                    bCancel = true;
                                    break;
                                default:
                                    break;
                            }
                        }
                    }
                    else
                    {
                        bNeedDoThisTime = true;
                    }

                    if (bNeedDoThisTime)
                    {
                        //生成文件
                        //File.Copy(strSelectedFileName, Path.Combine(tgaIO.StrIconFolder, tgafile.Name));
                        TgaToUitex(strSelectedFileName, tgaIO.StrIconFolder);

                        //导入数据
                        tgaIO.InsertNewRecord(tgafile.Name.Split(new char[] { '.' })[0] + ".UITex", "", "");
                    }
                }

                this.Visible = false;
                this.Refresh();
                this.Close();

                Implement parent = this.Tag as Implement;
                parent.Init(tgaIO.sqlConn, tgaIO.StrIconFolder);
                parent.Show();
            }
        }