示例#1
0
        //删除目录
        private void menuItemDeleteDir_Click(object sender, EventArgs e)
        {
            if (MsgBox.ShowQuestionMessage("确定删除该目录吗,这将会删除该目录下所有文件", "提示信息") == DialogResult.Yes)
            {
                TreeNode dirNode = tvCode.SelectedNode;
                tvCode.Nodes.Remove(dirNode);
                DirectoryInfo di      = dirNode.Tag as DirectoryInfo;
                string        dirName = di.FullName;
                di.Delete(true);

                //删除目录时,同时关闭该目录下已打开的文档
                List <IDockContent> deletingDocs = new List <IDockContent>();
                foreach (IDockContent content in this.DockPanel.Documents)
                {
                    if (content is DockDocument)
                    {
                        DockDocument doc = content as DockDocument;
                        //判断文档所属目录是否是该删除目录,若是则将其关闭
                        if (Path.GetDirectoryName(doc.FileName) == dirName)
                        {
                            deletingDocs.Add(doc);
                        }
                    }
                }
                foreach (IDockContent content in deletingDocs)
                {
                    content.DockHandler.Close();
                }
            }
        }
示例#2
0
        //删除文件
        private void menuItemDeleteFile_Click(object sender, EventArgs e)
        {
            if (MsgBox.ShowQuestionMessage("确定删除该文件吗", "提示信息") == DialogResult.Yes)
            {
                TreeNode fileNode = tvCode.SelectedNode;
                tvCode.Nodes.Remove(fileNode);

                FileInfo fi          = fileNode.Tag as FileInfo;
                string   oldFileName = fi.FullName;
                File.Delete(fi.FullName);

                //若删除的文档已经打开,则将其关闭
                IDockContent deletingDoc = null;
                foreach (IDockContent content in this.DockPanel.Documents)
                {
                    if (content is DockDocument)
                    {
                        DockDocument doc = content as DockDocument;
                        if (doc.FileName == oldFileName)
                        {
                            deletingDoc = doc;
                            break;
                        }
                    }
                }
                if (deletingDoc != null)
                {
                    deletingDoc.DockHandler.Close();
                }
            }
        }
示例#3
0
        private void menuItemBuildPdf_Click(object sender, EventArgs e)
        {
            IList <PDTable> tableList = new List <PDTable>();
            string          title     = string.Empty;
            TreeNode        node      = tv.SelectedNode;

            if (node.Tag is PDModel)
            {
                PDModel m = node.Tag as PDModel;
                tableList = m.AllTableList;
                title     = m.Name;
            }
            if (node.Tag is PDPackage)
            {
                PDPackage p = node.Tag as PDPackage;
                tableList = p.TableList;
                title     = p.Name;
            }

            saveFileDialog1.FileName = title;
            saveFileDialog1.Filter   = "pdf文件(*.pdf)|*.pdf|所有文件(*.*)|*.*";

            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                string fileName = saveFileDialog1.FileName;

                iTextExporter exporter = new iTextExporter(fileName);
                exporter.PDModel2Pdf(tableList, title);

                if (MsgBox.ShowQuestionMessage("数据库文档生成成功,是否打开文档", "提示信息") == DialogResult.Yes)
                {
                    CmdHelper.Execute(fileName);
                }
            }
        }
示例#4
0
 private void toolItemExit_Click(object sender, EventArgs e)
 {
     if (MsgBox.ShowQuestionMessage("是否退出Kalman Studio", "信息提示") == DialogResult.Yes)
     {
         this.Close();
         Application.Exit();
     }
 }
示例#5
0
        private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            DialogResult result = MsgBox.ShowQuestionMessage("代码生成成功,是否打开输出目录", "代码生成消息提示");

            if (result == DialogResult.Yes)
            {
                string cmd = "explorer.exe " + outputPath;
                Kalman.Command.CmdHelper.Execute(cmd);
            }
            btnBuildCode.Enabled = true;
        }
示例#6
0
        protected override void OnClosing(CancelEventArgs e)
        {
            if (this.Text.EndsWith("*"))
            {
                if (MsgBox.ShowQuestionMessage("是否保存文件" + this.Text.TrimEnd('*'), "信息提示") == DialogResult.Yes)
                {
                    Save();
                }
            }

            base.OnClosing(e);
        }
示例#7
0
        private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            DialogResult result = MsgBox.ShowQuestionMessage("代码生成成功,是否打开输出目录", "代码生成消息提示");

            if (result == DialogResult.Yes)
            {
                Process p = new Process();
                p.StartInfo = new ProcessStartInfo(outputPath);
                p.Start();
            }
            btnBuildCode.Enabled = true;
        }
        private void OpenDirectory(string message = "代码生成成功,是否打开输出目录")
        {
            DialogResult result = MsgBox.ShowQuestionMessage(message, "提示");

            if (result == DialogResult.Yes)
            {
                if (Directory.Exists(codePath))
                {
                    Process p = new Process();
                    p.StartInfo = new ProcessStartInfo(codePath);
                    p.Start();
                }
            }
        }
示例#9
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            List <SOTable> list = new List <SOTable>();

            foreach (object item in listBox2.Items)
            {
                list.Add(item as SOTable);
            }
            if (list.Count == 0)
            {
                return;
            }

            if (rbtnPdf.Checked)
            {
                saveFileDialog1.Filter   = "pdf文件(*.pdf)|*.pdf|所有文件(*.*)|*.*";
                saveFileDialog1.FileName = CurrentDatabase.Name;
                if (saveFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    string fileName = saveFileDialog1.FileName;

                    iTextExporter exporter = new iTextExporter(fileName);
                    exporter.DbSchema2Pdf(currentSchema, CurrentDatabase, list);

                    if (MsgBox.ShowQuestionMessage("数据库文档生成成功,是否打开文档", "提示信息") == DialogResult.Yes)
                    {
                        CmdHelper.Execute(fileName);
                    }
                }
            }

            if (rbtnWord.Checked)
            {
                saveFileDialog1.Filter   = "rtf文件(*.rtf)|*.rtf|所有文件(*.*)|*.*";
                saveFileDialog1.FileName = CurrentDatabase.Name;
                if (saveFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    string fileName = saveFileDialog1.FileName;

                    iTextExporter exporter = new iTextExporter(fileName);
                    exporter.DbSchema2Rtf(currentSchema, CurrentDatabase, list);

                    if (MsgBox.ShowQuestionMessage("数据库文档生成成功,是否打开文档", "提示信息") == DialogResult.Yes)
                    {
                        CmdHelper.Execute(fileName);
                    }
                }
            }
        }
示例#10
0
 private void BeegoProjectCodeBuilder_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (backgroundWorkerGenerate.IsBusy)
     {
         DialogResult result = MsgBox.ShowQuestionMessage("正在生成代码,强制关闭可能会导致错误,是否关闭?");
         if (result == DialogResult.Yes)
         {
             backgroundWorkerGenerate.CancelAsync();
         }
         else
         {
             e.Cancel = false;
         }
     }
 }
示例#11
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            if (txtUrl.Text.Trim() == string.Empty)
            {
                MsgBox.Show("请求地址不能为空");
                return;
            }

            DialogResult result = MsgBox.ShowQuestionMessage("是否提交当前请求", "确认提交请求");

            if (result != DialogResult.Yes)
            {
                return;
            }

            DoSubmit();
        }
示例#12
0
        private void btn_Ok_Click(object sender, EventArgs e)
        {
            if (listView1.SelectedItems.Count < 1)
            {
                MsgBox.Show("请选择模板目录!");
                return;
            }

            if (string.IsNullOrEmpty(txtProName.Text.Trim()))
            {
                MsgBox.Show("请填写项目名称!");
                return;
            }

            if (string.IsNullOrEmpty(txtProPath.Text.Trim()))
            {
                MsgBox.Show("请选择项目输出目录!");
                return;
            }

            TemplatePath = this.listView1.SelectedItems[0].Tag.ToString();
            OutputPath   = txtProPath.Text.Trim();
            ProjctName   = txtProName.Text.Trim();

            var outputCount = IOUtil.GetFilesCount(new DirectoryInfo(OutputPath));

            if (outputCount > 0)
            {
                if (MsgBox.ShowQuestionMessage("输出目录不为空,是否立即查看?") == DialogResult.Yes)
                {
                    DialogResult = DialogResult.Cancel;
                    Process p = new Process();
                    p.StartInfo = new ProcessStartInfo(OutputPath);
                    p.Start();
                    Close();
                }
                return;
            }


            DialogResult = DialogResult.OK;
            this.Close();
        }
示例#13
0
 private void BeegoProjectCodeBuilder_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (backgroundWorkerGenerate.IsBusy)
     {
         DialogResult result = MsgBox.ShowQuestionMessage("正在生成代码,强制关闭可能会导致错误,是否关闭?");
         if (result == DialogResult.Yes)
         {
             var processes = Process.GetProcesses();
             foreach (var pro in processes)
             {
                 if (pro.ProcessName == "cmd" || pro.ProcessName == "cnnhost" || pro.ProcessName == "bee")
                 {
                     pro.Kill();
                 }
             }
         }
         else
         {
             e.Cancel = false;
         }
     }
 }
示例#14
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (!CheckGoEnvironment())
            {
                if (MsgBox.ShowQuestionMessage("检测到未安装GO环境!是否查看帮助?") == DialogResult.Yes)
                {
                    Help.ShowHelp(this, "https://jingyan.baidu.com/article/d2b1d102cbac775c7f37d477.html");
                }
                return;
            }

            if (!CheckBeeEnvironment())
            {
                if (MsgBox.ShowQuestionMessage("检测到未安装Bee工具!是否查看帮助?") == DialogResult.Yes)
                {
                    CmdHelper.CreateBat(Config.TEMP_BAT_FILENAME, "go get -u github.com/astaxie/beego \r\ngo get -u github.com/beego/bee");
                    //CmdHelper.RunApp(Config.TEMP_BAT_FILENAME, ProcessWindowStyle.Normal, GOPATH);
                    Config.MainForm.RunApp(Config.TEMP_BAT_FILENAME, GOPATH);
                    Help.ShowHelp(this, "https://beego.me/quickstart");
                }
                ;
                return;
            }

            if (string.IsNullOrEmpty(cmbDatabase.Text))
            {
                MsgBox.Show("请选择数据库!");
                return;
            }

            if (string.IsNullOrEmpty(txtProjectName.Text.Trim()))
            {
                MsgBox.Show("请输入项目名称!");
                return;
            }

            if (string.IsNullOrEmpty(GOROOT))
            {
                MsgBox.Show("请先在选项中设置GOROOT环境变量!");
                return;
            }

            if (string.IsNullOrEmpty(GOPATH))
            {
                MsgBox.Show("请先在选项中设置GOPATH环境变量!");
                return;
            }

            if (currentDatabase.Parent.DbProvider.DatabaseType != DatabaseType.MySql)
            {
                MsgBox.Show("该数据库不是MySql,不支持该操作!");
                this.Close();
                return;
            }

            if (rbWebProject.Checked)
            {
                if (listBox2.Items.Count == 0)
                {
                    MsgBox.Show("请选择要生成的表!");
                    return;
                }
            }

            codePath = GOPATH + (GOPATH.EndsWith(@"\") ? "src" : @"\src") + @"\" + txtProjectName.Text.Trim();
            if (Directory.Exists(codePath))
            {
                OpenDirectory(string.Format("文件夹“{0}”已经存在,是否立即打开?", codePath));
                this.Close();
                return;
            }

            SetBtnDisable();
            backgroundWorkerGenerate.RunWorkerAsync();
        }