/// <summary> /// 获取指定标记内容在字节数组中的位置 /// </summary> /// <param name="totalArray" type="byte[]"> /// <para> /// 字节数组 /// </para> /// </param> /// <param name="Flag" type="byte[]"> /// <para> /// 标记内容 : byte[] /// </para> /// </param> /// <param name="flag" type="KJFramework.Helper.ByteArrayHelper.FLAG"> /// <para> /// 判断条件 : 开始 / 结尾 /// </para> /// </param> /// <returns> /// 返回根据判断条件的位置结果 /// * 如果是从判断第一次相同的情况,则返回第一次开始出现处索引,不存在则返回 -1 /// * 如果是从判断最后一次相同的情况,则返回最后一次开始出现处索引,不存在则返回 -1 /// </returns> public static int IndexOfFlagForArray(byte[] totalArray, byte[] Flag, FLAG flag) { ArrayList list = new ArrayList(); for (int i = 0; i < totalArray.Length; i++) { byte[] destinationArray = new byte[Flag.Length]; Array.ConstrainedCopy(totalArray, i, destinationArray, 0, destinationArray.Length); int num2 = 0; for (int j = 0; j < destinationArray.Length; j++) { if (destinationArray[j] != Flag[j]) { num2++; break; } } if (num2 == 0) { if (flag == FLAG.Begin) { return(i); } list.Add(i); if ((totalArray.Length - i) < Flag.Length) { return((int)list[list.Count - 1]); } } } return((list.Count > 0) ? ((int)list[list.Count - 1]) : -1); }
public void StartListener() { try { running = true; serverIP = "10.202.20.32"; serverPORT = 65452; serverIP = "10.202.0.6"; // serverIP = "127.0.0.1"; clientSocket = new System.Net.Sockets.TcpClient(); clientSocket.Connect(serverIP, serverPORT); serverStream = clientSocket.GetStream(); serverStream.BeginRead(dataStream, 0, dataStream.Length, new AsyncCallback(myReadCallBack), serverStream); messageHandler = new MessageHandler(this); computerDetails.SetComputerDetails(); FLAG ID = FLAG.SYN_FLAG; if (computerDetails.computerDetailsData.inWinpe) { ID = FLAG.SYN_FLAG_WINPE; } Packet packet = new Packet(ID, computerDetails.computerDetailsData); packet.computerDetailsData = computerDetails.computerDetailsData; SendMessage(packet); Console.WriteLine("Connected on IP: " + serverIP + " PORT: " + serverPORT); } catch (Exception e) { Console.WriteLine("Server Offline repeat: " + e.ToString()); //Console.WriteLine("Server Offline repeat"); running = false; } }
/// <summary> /// Tab 页 [改变] /// </summary> private void tabIndexChange(object sender, EventArgs e) { if (tabControlMain.SelectedTab == null) { return; } if (tabControlMain.SelectedTab == tabPageWorkers) { flag = FLAG.STAFF; currentLView = lvWorker; } else if (tabControlMain.SelectedTab == tabPageProjects) { flag = FLAG.PROJECT; currentLView = lvProjects; } else if (tabControlMain.SelectedTab == tabPageCompany) { flag = FLAG.CORP; currentLView = lvCompanys; } else { flag = FLAG.MAINTANCE; currentLView = null; return; } RefreshListview(currentLView); }
public Packet(FLAG _ID, ComputerDetailsData _computerDetailsData, string _message) { this.dataIdentifier = _ID; this.computerDetailsData = _computerDetailsData; this.clonningMessage = _message; this.IDTime = DateTime.Now; }
/// <summary>アニメーション周りの各パラメータを初期化</summary> public void Initialize() { this.playerAnimator.SetTrigger(TRIGGER_FORCE_STAY); this.choice = FLAG.NONE; this.isFixedChoice = false; this.animationPlaying = false; }
private void CheckFlags(FLAG _stepDataIdentifier1, Packet packet, FLAG _stepDataIdentifier2 = FLAG.CLOSE, int WaitingTime = 5000) { try { stepDataIdentifier1 = _stepDataIdentifier1; stepDataIdentifier2 = _stepDataIdentifier2; receivePacket.ID = FLAG.Null; ChangeProgressData(stepDataIdentifier1.ToString()); try { if (connection != null) { SendMessage(packet, connection); } } catch { connection = null; } Thread.Sleep(1000); while (receivePacket.ID != stepDataIdentifier1 && receivePacket.ID != stepDataIdentifier2 && !stopped) { if (stopped || failed) { return; } try { if (connection != null) { SendMessage(packet, connection); } } catch { connection = null; } if ((receivePacket.ID == FLAG.SYN_FLAG || receivePacket.ID == FLAG.SYN_FLAG_WINPE) && (receivePacket.ID != stepDataIdentifier1 || receivePacket.ID != stepDataIdentifier2)) { cloneFaildMessage = "CLIENT NEED RESTART"; restart = true; return; } Thread.Sleep(WaitingTime); } if (!failed && !stopped) { progressComputerData = new ProgressComputerData("Images/Done.ico", computer.Name, receivePacket.ID.ToString(), executedTaskData.GetFileName(), "", computer.MacAddress); } SaveProgress(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
/// <summary>左右どちらかの旗をあげ、アニメーション完了時にコールバックする</summary> public void SetFlagAnimation(FLAG choice, System.Action callback = null) { this.choice = choice; this.isFixedChoice = true; this.callback = callback; this.animationPlaying = true; // この判定は良いか悪いか要検証 if (this.timeUpFlg) { this.FinishAnimation(); return; } if (this.choice == FLAG.NONE) { return; } this.playerAnimator.SetTrigger((this.choice == FLAG.LEFT) ? TRIGGER_RAISE_FLAG_LEFT : TRIGGER_RAISE_FLAG_RIGHT); }
public Packet(FLAG _ID, ComputerDetailsData _computerDetailsData, string _message) { this.ID = _ID; this.computerDetailsData = _computerDetailsData; this.clonningMessage = _message; }
public Packet(FLAG _ID, ComputerDetailsData _computerDetailsData) { this.ID = _ID; this.computerDetailsData = _computerDetailsData; }
public Packet(FLAG _ID) { this.ID = _ID; }
/// <summary> /// 从一个字节数组中根据开始字节以及结束字节按照指定的分割长度来获取第一次或者最后一次出现的位置 /// * 分割长度是指: 开始字节与结尾字节之间的字节长度(距离) /// 如: start --中间距离3个位置-- end /// [注] 必须指定一个大于0的分割长度。 /// </summary> /// <param name="totalArray">字节数组</param> /// <param name="startFlag">开始字节</param> /// <param name="endFlag">结尾字节</param> /// <param name="startIndex">开始查找的位置</param> /// <param name="splitSize">分割(距离)长度</param> /// <param name="flag">判断位置标示</param> /// <returns>返回根据判断标示判断到的位置,如果不存在则返回 -1</returns> public static int IndexOfFlagForArray(byte[] totalArray, byte startFlag, byte endFlag, int startIndex, int splitSize, FLAG flag) { if (totalArray == null || totalArray.Length < splitSize + 2) { return(-1); } if (splitSize <= 0) { return(-1); } if (startIndex >= totalArray.Length || startIndex + splitSize + 2 > totalArray.Length) { return(-1); } //计算要查找对象的总长度 int totalsize = splitSize + 2; //设置查找偏移 int offset = startIndex; //计算查找次数 int searchCount = (totalArray.Length - startIndex) / totalsize; if (searchCount <= 0) { return(-1); } //用来记录最后的记过 int result = -1; //用来保存当前截取到的数据 byte[] current; while (offset != -1) { try { //截取数据 current = GetNextData(totalArray, offset, totalsize); } catch { break; } //如果截取的数据为空或者小于指定长度,则直接退出 if (current == null || current.Length < totalsize) { break; } //如果截取到数据,但是不符合标准 if (current[0] != startFlag || current[current.Length - 1] != endFlag) { offset++; continue; } //找到标记 result = offset; if (flag == FLAG.Begin) { break; } offset++; } return(result); }
public void OnGUI() { GUILayout.BeginVertical(); { EditorGUILayout.HelpBox("探测当前打开的场景中的资源", MessageType.Info, true); GUILayout.BeginHorizontal(); { if (GUILayout.Button("Refresh")) { SearchAssetsItems(); } bool isShader = GUILayout.Toggle(flag == FLAG.SHADER, "Shader", EditorStyles.radioButton); if (isShader && flag != FLAG.SHADER) { flag = FLAG.SHADER; SearchAssetsItems(); } bool isTexture = GUILayout.Toggle(flag == FLAG.TEXTURE, "Texture", EditorStyles.radioButton); if (isTexture && flag != FLAG.TEXTURE) { flag = FLAG.TEXTURE; SearchAssetsItems(); } bool isMesh = GUILayout.Toggle(flag == FLAG.MESH, "Mesh", EditorStyles.radioButton); if (isMesh && flag != FLAG.MESH) { flag = FLAG.MESH; SearchAssetsItems(); } } GUILayout.EndHorizontal(); GUILayout.Button( flag == FLAG.SHADER ? "Shader" : flag == FLAG.TEXTURE ? "Texture" : "Mesh", EditorStyles.toolbarPopup ); scroll = EditorGUILayout.BeginScrollView(scroll); { foreach (var kv in items) { if (expandedItem == kv.Value) { GUI.contentColor = Color.green; } else { GUI.contentColor = Color.white; } if (GUILayout.Button((kv.Value.tips == null ? kv.Value.obj.name : kv.Value.obj.name + kv.Value.tips) + " " + "(" + kv.Value.objects.Count + ")", EditorStyles.toolbarDropDown)) { if (expandedItem == kv.Value) { expandedItem = null; } else { expandedItem = kv.Value; } } GUI.contentColor = Color.white; if (expandedItem == kv.Value) { foreach (var obj in kv.Value.objects) { if (GUILayout.Button(obj.ToString(), EditorStyles.miniButton)) { Selection.activeGameObject = obj as GameObject; } } } } } EditorGUILayout.EndScrollView(); } GUILayout.EndVertical(); }
public Packet(FLAG _ID, ComputerDetailsData _computerDetailsData) { this.dataIdentifier = _ID; this.computerDetailsData = _computerDetailsData; this.IDTime = DateTime.Now; }
public Packet(FLAG _ID) { this.dataIdentifier = _ID; this.IDTime = DateTime.Now; }
public void StartListener() { messageHandler = new MessageHandler(this); Start: serverIP = null; WriteToLogs("Getting IP"); GetServerIP(); WriteToLogs("Server IP: " + serverIP); computerDetails.SetComputerDetails(); WriteToLogs("Getting computer details"); try { if (File.Exists(@"X:\TaskData.my")) { File.Delete(@"X:\TaskData.my"); Thread.Sleep(1000); } } catch { } SetLectorDisplayDuplicate(); bool created = false; int counter = 0; int MAX_COUNT_REFRESH = 5; while (!created) { created = true; ConnectionInfo serverConnectionInfo = null; try { serverConnectionInfo = new ConnectionInfo(serverIP.Trim(), serverPort); try { connection = TCPConnection.GetConnection(serverConnectionInfo); } catch (Exception ex) { Console.WriteLine("Failed with Creating connection"); //Console.WriteLine(ex.ToString()); Thread.Sleep(10000); created = false; if (counter == MAX_COUNT_REFRESH) { goto Start; } counter++; } } catch (Exception) { Console.WriteLine("Failed to parse the server IP and port. Please ensure it is correct and try again"); Thread.Sleep(10000); created = false; } } FLAG ID = FLAG.SYN_FLAG; if (computerDetails.computerDetailsData.inWinpe) { ID = FLAG.SYN_FLAG_WINPE; } Packet packet = new Packet(ID, computerDetails.computerDetailsData) { computerDetailsData = computerDetails.computerDetailsData }; connection.AppendIncomingPacketHandler <byte[]>("Packet", IncommingMessage); connection.AppendShutdownHandler(HandleConnectionClosed); WriteToLogs("Connected to: " + serverIP); SendMessage(packet); WriteToLogs("Sending SYN FLAG"); running = true; }