Exemplo n.º 1
0
        internal bool OpenDesignEditForm(ScriptEditForm scriptForm)
        {
            if (scriptForm == null || scriptForm.IsDisposed)
            {
                return(false);
            }

            DesignEditForm designEditForm = this.GetDesignForm(scriptForm);

            if (designEditForm != null)
            {
                designEditForm.DockHandler.Activate();
                return(true);
            }
            designEditForm          = new DesignEditForm(this.MainForm);
            designEditForm.FlagCode = scriptForm.FlagCode;
            this.MainForm.OpenDesignEditForm(designEditForm);
            return(designEditForm.Open(scriptForm.DocTypeInfo, scriptForm.HndfFile));
        }
Exemplo n.º 2
0
 internal DesignEditForm GetDesignForm(ScriptEditForm scriptForm)
 {
     if (this.MainForm == null || scriptForm == null)
     {
         return(null);
     }
     foreach (IDockContent content in this.MainForm.Documents)
     {
         DesignEditForm designForm = content as DesignEditForm;
         if (designForm == null)
         {
             continue;
         }
         if (designForm.FlagCode == scriptForm.FlagCode)
         {
             return(designForm);
         }
         if (designForm.HndfFile == scriptForm.HndfFile)
         {
             return(designForm);
         }
     }
     return(null);
 }
Exemplo n.º 3
0
        //internal short OpenTemplet(DocTypeInfo docTypeInfo)
        //{
        //    if (docTypeInfo == null)
        //        return SystemData.ReturnValue.FAILED;

        //    DesignEditForm designEditForm = this.GetDesignForm(docTypeInfo);
        //    if (designEditForm != null)
        //    {
        //        designEditForm.Activate();
        //        return SystemData.ReturnValue.OK;
        //    }
        //    designEditForm = new DesignEditForm(this.MainForm);
        //    designEditForm.FlagCode = Guid.NewGuid().ToString();
        //    this.MainForm.OpenDesignEditForm(designEditForm);

        //    string szDocTypeID = docTypeInfo.DocTypeID;
        //    string szHndfFile = string.Format("{0}\\Cache\\{1}.hndt"
        //        , GlobalMethods.Misc.GetWorkingPath(), szDocTypeID);

        //    byte[] byteTempletData = null;
        //    //short shRet = TempletService.Instance.GetFormTemplet(szDocTypeID, ref byteTempletData);
        //    //if (shRet != SystemData.ReturnValue.OK)
        //    //    return shRet;

        //    GlobalMethods.IO.WriteFileBytes(szHndfFile, byteTempletData);
        //    return designEditForm.Open(docTypeInfo, szHndfFile) ?
        //        SystemData.ReturnValue.OK : SystemData.ReturnValue.FAILED;
        //}

        /// <summary>
        /// 保存当前正在编辑的模板文件
        /// </summary>
        /// <returns>bool</returns>
        internal bool SaveTemplet()
        {
            DesignEditForm designForm = this.ActiveTemplet;
            ScriptEditForm scriptForm = this.ActiveScript;

            if (scriptForm == null && designForm == null)
            {
                return(false);
            }

            if (designForm != null)
            {
                scriptForm = this.GetScriptForm(designForm);
            }
            else if (scriptForm != null)
            {
                designForm = this.GetDesignForm(scriptForm);
            }

            FormFileParser parser       = new FormFileParser();
            string         szScriptData = null;

            if (scriptForm != null)
            {
                szScriptData = scriptForm.Save();
            }
            else
            {
                szScriptData = parser.GetScriptData(designForm.HndfFile);
            }

            string szDesignData = null;

            if (designForm != null)
            {
                designForm.Save(ref szDesignData);
            }
            else
            {
                szDesignData = parser.GetDesignData(scriptForm.HndfFile);
            }

            byte[] byteTempletData = null;
            parser.MakeFormData(szDesignData, szScriptData, out byteTempletData);

            DialogResult result = MessageBoxEx.ShowQuestion("是否提交到服务器?"
                                                            + "\r\n提交到服务器,请点击“是”按钮!\r\n仅保存到本地,请点击“否”按钮!");

            if (result == DialogResult.Cancel)
            {
                return(false);
            }
            bool success = true;

            if (result == DialogResult.No)
            {
                success = this.SaveTempletToLocal(byteTempletData);
            }
            else
            {
                success = this.SaveTempletToServer(byteTempletData);
            }
            if (success)
            {
                if (designForm != null)
                {
                    designForm.IsModified = false;
                }
                if (scriptForm != null)
                {
                    scriptForm.IsModified = false;
                }
            }
            return(success);
        }
Exemplo n.º 4
0
        internal void ShowScriptTestForm()
        {
            DesignEditForm designForm = this.ActiveTemplet;
            ScriptEditForm scriptForm = this.ActiveScript;

            if (scriptForm == null && designForm == null)
            {
                return;
            }

            if (designForm != null)
            {
                scriptForm = this.GetScriptForm(designForm);
            }
            else if (scriptForm != null)
            {
                designForm = this.GetDesignForm(scriptForm);
            }

            FormFileParser parser       = new FormFileParser();
            string         szScriptData = null;

            if (scriptForm != null)
            {
                szScriptData = scriptForm.Save();
            }
            else
            {
                szScriptData = parser.GetScriptData(designForm.HndfFile);
            }

            string szDesignData = null;

            if (designForm != null)
            {
                designForm.Save(ref szDesignData);
            }
            else
            {
                szDesignData = parser.GetDesignData(scriptForm.HndfFile);
            }

            //编译脚本
            ScriptProperty scriptProperty = new ScriptProperty();

            scriptProperty.ScriptText = szScriptData;
            CompileResults results = null;

            results = ScriptCompiler.Instance.CompileScript(scriptProperty);
            if (!results.HasErrors)
            {
                this.MainForm.ShowCompileErrorForm(null);
            }
            else
            {
                if (scriptForm == null)
                {
                    this.OpenScriptEditForm(designForm);
                }
                this.MainForm.ShowCompileErrorForm(this.GetCompileErrors(results));
                MessageBoxEx.Show("编译失败,无法启动测试程序!");
                return;
            }

            ScriptTestForm scriptTestForm = new ScriptTestForm();

            scriptTestForm.ScriptData = szScriptData;
            scriptTestForm.DesignData = szDesignData;
            scriptTestForm.ShowDialog();
        }