Ejemplo n.º 1
0
        /// <summary>
        /// 初始化数据
        /// </summary>
        private void Init()
        {
            // 初始化数据库管理器
            dataBaseManager = DataBaseManager.GetDataBaseManager();                       

            // 初始化分类管理器
            documentManager = DocumentManager.GetDocumentManager();
            documentManager.TreeMenu = this.bTreeMenu;
            documentManager.UndoButton = this.bUndoCommand;
            documentManager.RedoButton = this.bRedoCommand;
            documentManager.CommandSwitchButton = this.bCommandSwitch;
            documentManager.CurrentTabControl = this.canvasGroupContainer;
            documentManager.TreeTabControl = this.treeContainer;
            documentManager.CurrentAbbreviateCanvas = this.abbreviateCanvas;
            documentManager.CurrentPropertyGrid = this.propertyGrid1;
            documentManager.LogBox = this.LogEditBox;
            documentManager.TreePanel = this.expandablePanel1;
            documentManager.TreeImageList = this.treeNodeImageList;
            documentManager.ScaleComboBox = this.canvasScaleBox;
            documentManager.AddDiagramRecordButton(this.bLatestDiagram1);
            documentManager.AddDiagramRecordButton(this.bLatestDiagram2);
            documentManager.AddDiagramRecordButton(this.bLatestDiagram3);
            documentManager.AddDiagramRecordButton(this.bLatestDiagram4);
            documentManager.AddDiagramRecordButton(this.bLatestDiagram5);
            documentManager.Init();
                       
            // 显示数据库名称
            LDBName.Text = dataBaseManager.Connection.Database;

            #if (!DEBUG) // 自动隐藏日志条
                barLog.AutoHide = true; 
            #endif
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取DataBaseManager的实例
        /// </summary>
        /// <returns>DataBaseManager的实例</returns>
        public static DataBaseManager GetDataBaseManager()
        {
            if (dataBaseManager == null) // 对象未初始化
            {
                dataBaseManager = new DataBaseManager();
                dataBaseManager.Init();

                string fileName = Path.Combine(Application.StartupPath, designerToolsConfigFileName);
                string connectString = GetConnectString(fileName, "General", "ConnString");

                if (!string.IsNullOrEmpty(connectString))
                {
                    dataBaseManager.conn_jx3web = new SqlConnection(connectString);
                }                                
            }

            return dataBaseManager;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 开始转换
        /// </summary>
        /// <param name="sender">事件发送者</param>
        /// <param name="e">事件参数</param>
        private void buttonX1_Click(object sender, EventArgs e)
        {
            scriptFilePath = textBoxX1.Text;
            mapName = textBoxX2.Text;

            if (scriptFilePath != "" && mapName != "")
            {
                string content = GetFileContent(scriptFilePath);
                
                if (content != null)
                {
                    dataBaseManager = DataBaseManager.GetDataBaseManager();

                    StringBuilder newContent = new StringBuilder();
                    string[] lines = content.Split(new string[] { "\r\n" }, StringSplitOptions.None);

                    // 增加加载字符串table的调用
                    string includeLsFile = string.Format("Include('scripts/Map/{0}/include/scenestrings.ls')", mapName);

                    if (lines[0] != includeLsFile)
                    {
                        newContent.AppendLine(includeLsFile);
                    }

                    int insertIndex = -1;

                    for (int i = 0; i < lines.Length; i++)
                    {
                        string s = lines[i];
                        string line = s.Trim(new char[] { '\t', ' ' });
                        string newLine = null;

                        if (lines[i] == "using('Event')")
                        {
                            if (lines[i + 2] != "local stringTable = SCENE_STRING_TABLE")
                            {
                                insertIndex = i + 2;
                            }
                        }

                        // 插入对字符串表的引用
                        if (i == insertIndex)
                        {
                            newContent.AppendLine("local stringTable = SCENE_STRING_TABLE");
                            newContent.AppendLine();
                        }

                        switch (convertState)
                        {
                            case ConvertState.Normal:
                                {
                                    if (line.StartsWith("--[["))
                                    {
                                        convertState = ConvertState.BlockRemark;
                                        newContent.AppendLine(s);
                                    }
                                    else if (line.StartsWith("--"))
                                    {
                                        newContent.AppendLine(s);
                                    }
                                    else
                                    {                                        
                                        newLine = ConvertLine(s);
                                        newContent.AppendLine(newLine);
                                    }

                                    break;
                                }
                            case ConvertState.BlockRemark:
                                {
                                    if (line.StartsWith("--]]"))
                                    {
                                        convertState = ConvertState.Normal;
                                        newContent.AppendLine(s);
                                    }
                                    else
                                    {
                                        newContent.AppendLine(s);
                                    }

                                    break;
                                }
                        }
                    }

                    SaveDataToFile(scriptFilePath, newContent.ToString());

                    string lsFileFolder = Path.GetDirectoryName(scriptFilePath);
                    lsFileFolder = Path.Combine(lsFileFolder, "include");
                    string lsFilePath = Path.Combine(lsFileFolder, "scenestrings.ls");

                    SaveLSFile(lsFilePath);

                    MessageBox.Show(string.Format("文件:\r\n{0}\r\n{1}\r\n\r\n转换成功!", scriptFilePath, lsFilePath), "脚本转换", 
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            else
            {
                MessageBox.Show("参数不能为空!", "脚本转换", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// 初始化数据
 /// </summary>
 /// <param name="canvas">绘图板实例</param>
 /// <param name="propertyGrid">属性面板实例</param>
 public void Init(Canvas canvas)
 {
     graphManager = new GraphManager(this, canvas);
     dataManager = new DataManager(this);
     dataBaseManager = DataBaseManager.GetDataBaseManager();
     int i = path.IndexOf('\\');
     mapName = path.Substring(0, i);
     flowChartInteractor = new FlowChartInteractor();
 }                
Ejemplo n.º 5
0
        /// <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);
        }