void L_Log_SelectedIndexChanged(object sender, EventArgs e) { //int index = L_Log.SelectedIndex; //if (index < 0) return; String line = L_Log.SelectedItem as String; if (line == null) { return; } String numStr = line.Split(":(".ToCharArray())[1]; int num; if (int.TryParse(numStr, out num)) { T_From.Text = (num - 1).ToString(); Track_From.Value = num - 1; V_Data.ReleaseSelection(); List <object> list = V_Data.GetAColumnData(1);//get line col int index = list.IndexOf(num.ToString()); if (index > 0) { V_Data.SelectRow(index - 1, true); V_Data.SelectRow(index, true); V_Data.FirstDisplayedScrollingRowIndex = index - 1; } } }
public void AddNewItem(String msgText, String name = null, bool allowSameMsg = false) { if (msgText.Trim().Length == 0) { MessageBox.Show("메시지가 비었습니다."); return; } #region 기존에 같은 이름이 있는지 검사후 있으면 이름 붙여줌. List <object> names = V_Data.GetAColumnData(0); name = (name == null)?"Untitled" : name; String newName = name; int count = 0; while (Directory.Exists(_packetDir + "\\" + (newName)) == true) { newName = name + (count++); } #endregion #region 같은 Text가 있으면 같은 라인을 선택해 줌.. 아니면 추가.. if (allowSameMsg == false) { for (int i = 0; i < V_Data.RowCount; i++) { String msg = V_Data.RowRelativeObject(i)["msg"] as String; if (msg.CompareTo(msgText) == 0) { V_Data.ReleaseSelection(); V_Data.Rows[i].Selected = true; return;///같은 item은 추가하지 않음.. } } } #endregion #region 새 디렉토리 만들고 Msg.txt파일 만들어 내용 넣어줌. String newDir = _packetDir + "\\" + newName; try { Directory.CreateDirectory(newDir); } catch //이미 있는 경우.. 그냥 지나침.. { } if (msgText == null) { msgText = ""; } File.WriteAllText(newDir + "\\Msg.txt", msgText); #endregion #region 표에 줄 삽입 CPacketStruct parser = new CPacketStruct(); Dictionary <String, object> rels = new Dictionary <string, object>(); parser.IsStringWithNullEnd = _isStringWithNullEnd; parser.Endian = _endian; parser.StringEncoding = _strEncoding; String msgName = newName; bool integrity; try { parser.MakePacket(msgText, _endian == Endians.Big); integrity = true; } catch (Exception e) { MessageBox.Show(msgName + ":" + e.Message); integrity = true; } rels["integrity"] = integrity; rels["parser"] = parser; rels["msg"] = msgText; EasyGridRow row = V_Data.AddARow(rels, new object[] { false, msgName, "edit", "send", "X", "", }); if (integrity == false) { (row[(int)Titles.name] as EasyGridTextBoxCell).FontColor = Color.Red; } if (allowSameMsg == true) { row.Selected = true; } #endregion V_Data.RefreshList(); saveNameList(); }
public void AddNewItem(CPacketStruct parserObj = null, String name = null) { #region 기존에 같은 이름이 있는지 검사후 있으면 이름 붙여줌. List <object> names = V_Data.GetAColumnData(0); name = (name == null)?"Untitled" : name; String newName = name; int count = 0; while (Directory.Exists(_packetDir + "\\" + (newName)) == true) { newName = name + (count++); } #endregion #region 새 디렉토리 만들고 Msg.txt파일 만들어 내용 넣어줌. String newDir = _packetDir + "\\" + newName; if (Directory.Exists(newDir) == false) { Directory.CreateDirectory(newDir); } if (parserObj == null) { parserObj = new CPacketStruct(); DlgMsgMaker dlg = new DlgMsgMaker(parserObj, newDir + "\\Msg.txt", _endian == Endians.Big); DialogResult result = dlg.ShowDialog(); if (result == DialogResult.Abort || result == DialogResult.Cancel) { return; } //parserObj.Items = StructXMLParser.CodeToItems(parserObj.NativeText, parserObj); StructXMLParser.ItemsToXml(parserObj.Items, newDir + "\\Msg.xml", parserObj.Infos); } else { parserObj.MakeMsgText(); CPacketStruct oldObj = parserObj; parserObj = new CPacketStruct(); parserObj.NativeText = oldObj.NativeText; //parserObj.Items = StructXMLParser.CodeToItems(oldObj.NativeText, parserObj); StructXMLParser.ItemsToXml(parserObj.Items, newDir + "\\Msg.xml", parserObj.Infos); } #endregion #region 표에 줄 삽입 Dictionary <String, object> rels = new Dictionary <string, object>(); parserObj.IsStringWithNullEnd = _isStringWithNullEnd; parserObj.Endian = _endian; parserObj.StringEncoding = _strEncoding; String msgName = newName; bool integrity; try { parserObj.MakePacket(_endian == Endians.Big); integrity = true; } catch (Exception e) { MessageBox.Show(msgName + ":" + e.Message); integrity = true; } rels["integrity"] = integrity; rels["parser"] = parserObj; rels["msg"] = parserObj.NativeText; EasyGridRow row = V_Data.AddARow(rels, new object[] { false, msgName, "edit", "send", "X", "", }); if (integrity == false) { (row[(int)Titles.name] as EasyGridTextBoxCell).FontColor = Color.Red; } #endregion V_Data.RefreshList(); saveNameList(); }