/// <summary> /// 生成当前绘图的代码 /// </summary> public void GenerateCode() { string outputDir = helper.OutputDir; // 输出文件目录 if (outputDir != "") // 输入文件目录不为空 { if(flowChartManager != null) // 当前绘图管理器不为空 { GraphManager graphManager = flowChartManager.CurrentGraphManager; DataManager dataManager = flowChartManager.CurrentDataManager; logBox.Text = ""; logBox.Refresh(); // 强制刷新一次 PrintText(string.Format("------ 开始加载绘图 {0} ------", flowChartManager.CurrentPath)); PrintText("初始化绘图成功!"); PrintText("------ 开始检查逻辑有效性 ------"); // 执行逻辑操作 LogicBaseManager logicManager = helper.GetLogicManager(flowChartManager.CurrentChartMode); bool avail = logicManager.DoLogicOperation(flowChartManager, LogicType.CheckLogic, null); bool success = false; if (avail) // 检测绘图有效性 { PrintText("逻辑有效性检查成功!"); // 先保存当前绘图 if (flowChartManager.ContentChanged) { SaveFlowChart(flowChartManager); } // 执行逻辑操作 success = logicManager.DoLogicOperation(flowChartManager, LogicType.CompileCode, null); } else { PrintText("逻辑有效性检查失败!"); } logRecorder.SaveLog("生成代码", string.Format("{0}分类树生成绘图[{1}]的代码", chartMode, flowChartManager.CurrentPath), success); } else { MessageBox.Show("当前没有正在打开的绘图!", "生成代码", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show("输出文件目录不能为空!", "生成代码", MessageBoxButtons.OK, MessageBoxIcon.Information); SettingForm sForm = new SettingForm(); sForm.ShowDialog(); } }
/// <summary> /// 初始化分类管理器 /// </summary> public void Init() { // 检查文件更新 if (helper.CheckRequireUpdate()) { MessageBox.Show("编辑器文件有更新,请运行UpdateProgram.exe获取最新文件!", "检查更新", MessageBoxButtons.OK, MessageBoxIcon.Information); } // 初始化数据库管理器 dataBaseManager = DataBaseManager.GetDataBaseManager(); // 清空当前用户的所有锁 dataBaseManager.ClearRecordLocks(); // 读取地图链表 mapList = dataBaseManager.GetMapList(); // 读取用户配置信息 string ip = helper.GetHostAddress(); object userInfo = dataBaseManager.GetUserConfigInfo(ip); Hashtable info = null; bool infoExist = false; if (userInfo is Hashtable) { info = userInfo as Hashtable; infoExist = true; } else if (userInfo is object[]) // 兼容旧数据 { object[] oldInfo = userInfo as object[]; info = new Hashtable(); info["OutPutDir"] = oldInfo[0]; info["ShowRemark"] = oldInfo[1]; info["AutoAdjustLine"] = oldInfo[2]; info["AutoAdjustGrid"] = oldInfo[3]; infoExist = true; } if (infoExist) { helper.SetArguments(info); // 更新最近打开绘图链表 DataTable diagramTable = dataBaseManager.GetDiagramInformation(null); List<int> latestDiagramList = info["LatestDiagramList"] as List<int>; if (latestDiagramList != null) { for (int i = 0; i < diagramRecordButtonList.Count; i++) { if (i < latestDiagramList.Count) { string diagramID = helper.LatestDiagramList[i].ToString(); string diagramInformation = GetDiagramDescription(diagramID, diagramTable); if (diagramInformation != null) { diagramRecordButtonList[i].Text = diagramInformation; diagramRecordButtonList[i].Tag = diagramID; } else { diagramRecordButtonList[i].Visible = false; } } else { diagramRecordButtonList[i].Visible = false; } } } else { foreach (ButtonItem buttonItem in diagramRecordButtonList) { buttonItem.Visible = false; } } } else { SettingForm sForm = new SettingForm(); DialogResult result = sForm.ShowDialog(); if(result != DialogResult.OK) { MessageBox.Show("客户端目录没有配置,可能有部分功能无法使用,可以在主窗体菜单中打开配置面板进行配置!", "参数配置", MessageBoxButtons.OK, MessageBoxIcon.Information); } } helper.LogBox = logBox; // 初始化逻辑管理器 helper.InitLogicManager(); // 初始化默认绘图分类 chartMode = helper.DiagramNameList[0]; // 刷新交互管理器数值 interactor.RootDir = helper.OutputDir; // 构建分类面板 ConstructClassPanel(); // 写日志 logRecorder.SaveLog("初始化程序", "加载用户配置,绘图分类信息和自定义模板", true); }
/// <summary> /// 设置程序参数 /// </summary> public void SetArgument() { SettingForm sForm = new SettingForm(); sForm.ShowDialog(); }