Пример #1
0
        //打开文件
        public void Open(string file)
        {
            if (string.IsNullOrEmpty(file) || !File.Exists(file))
            {
                return;
            }
            //添加历史
            this.history.AddHistory(file);
            //检查是否已经打开
            if (this.FindEditForm(file, true))
            {
                return;
            }
            //检查可用的
            if (this.FindEditForm(file, false))
            {
                return;
            }

            if (YGOUtil.IsScript(file))
            {
                this.OpenScript(file);
            }
            else if (YGOUtil.IsDataBase(file))
            {
                this.OpenDataBase(file);
            }
        }
Пример #2
0
        //新建文件
        void Menuitem_newClick(object sender, EventArgs e)
        {
            using SaveFileDialog dlg = new();
            dlg.Title = LanguageHelper.GetMsg(LMSG.NewFile);
            if (GetActive() != null)//判断当前窗口是不是DataEditor
            {
                try
                {
                    dlg.Filter = LanguageHelper.GetMsg(LMSG.CdbType);
                }
                catch { }
            }
            else
            {
                try
                {
                    dlg.Filter = LanguageHelper.GetMsg(LMSG.ScriptFilter);
                }
                catch { }
            }

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                string file = dlg.FileName;
                if (File.Exists(file))
                {
                    File.Delete(file);
                }
                //是否是数据库
                if (YGOUtil.IsDataBase(file))
                {
                    if (DataBase.Create(file))                   //是否创建成功
                    {
                        if (MyMsg.Question(LMSG.IfOpenDataBase)) //是否打开新建的数据库
                        {
                            Open(file);
                        }
                    }
                }
                else
                {
                    try
                    {
                        File.Create(file).Dispose();
                    }
                    catch { }
                    Open(file);
                }
            }
        }