public bool ExternelServerStart() { try { DelegateState.InvokeDispatchStateEvent("正在初始化外围服务..."); string FILEPATH = Application.StartupPath + @"/sysconfig.xml"; Hashtable htServer = XMLClass.GetXMLByParentNode(FILEPATH, XMLConstClass.NODE_SERVER); string port = "2018"; string maxclient = "200"; string rcvtimeout = "100"; string sendtimeout = "100"; string buffersize = "128"; if (htServer.Contains(XMLConstClass.PORT)) { port = htServer[XMLConstClass.PORT].ToString(); } if (htServer.Contains(XMLConstClass.MAXCONNECTCOUNT)) { maxclient = htServer[XMLConstClass.MAXCONNECTCOUNT].ToString(); } if (htServer.Contains(XMLConstClass.RECTIMEOUT)) { rcvtimeout = htServer[XMLConstClass.RECTIMEOUT].ToString(); } if (htServer.Contains(XMLConstClass.SENDTIMEOUT)) { sendtimeout = htServer[XMLConstClass.SENDTIMEOUT].ToString(); } if (htServer.Contains(XMLConstClass.BUFFERSIZE)) { buffersize = htServer[XMLConstClass.BUFFERSIZE].ToString(); } IServerConfig nannyclient_serverconfig = new SocketServer.ServerConfig() { Port = Convert.ToInt16(port), MaxClientCount = Convert.ToInt16(maxclient), RecOutTime = Convert.ToInt16(rcvtimeout), ReceiveBufferSize = Convert.ToInt16(buffersize), SendBufferSize = Convert.ToInt16(buffersize) }; if (_server == null) { _server = new TCPServer(); _server.ReceiveMes += _server_ReceiveMes; } if (!_server.Setup(nannyclient_serverconfig)) { return(false); } else { if (!_server.Start()) { return(false); } } return(true); } catch (Exception ex) { DelegateState.InvokeDispatchStateEvent(ex.Message); return(false); } }
private void InitCanvas(string filename, bool IsNew) { if (!IsNew) { try { AGVDAccess.AGVClientDAccess.GetPlanSet(); string tempFile = AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "\\temSet.agv"; if (File.Exists(tempFile)) { filename = tempFile; } } catch (Exception ex) { MsgBox.ShowError(ex.Message); } } try { m_data = new DataModel(); if (filename.Length > 0 && File.Exists(filename) && m_data.Load(filename, null)) { m_filename = filename; } m_canvas = new CanvasCtrller(this, m_data); m_canvas.Dock = DockStyle.Fill; pclMain.Controls.Clear(); pclMain.Controls.Add(m_canvas); m_canvas.SetCenter(new UnitPoint(0, 0)); m_canvas.IsChooseSpecial = false; string storageColorPath = AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "\\StorageColor.txt"; //加载记忆画布背景颜色 if (File.Exists(storageColorPath)) { Hashtable hs = XMLClass.GetXMLByParentNode(storageColorPath, "StorageColor"); if (hs["BackGroundColor"] != null && !string.IsNullOrEmpty(hs["BackGroundColor"].ToString())) { string[] bgColor = hs["BackGroundColor"].ToString().Split(','); Color BackGroundColor = Color.FromArgb(Convert.ToInt16(bgColor[0]), Convert.ToInt16(bgColor[1]), Convert.ToInt16(bgColor[2])); if (m_canvas != null) { BackgroundLayer layer = m_canvas.Model.BackgroundLayer as BackgroundLayer; layer.Color = BackGroundColor; } } } } catch (Exception ex) { MsgBox.ShowError(ex.Message); } }