Beispiel #1
0
        void V_Data_E_CellClicked(object sender, FormAdders.EasyGridViewCollections.CellClickEventArgs e)
        {
            if (e.RowIndex < 0 || e.ColIndex < 0)
            {
                return;
            }
            String packetName = (V_Data.GetCell(e.RowIndex, 1).Value as String);

            if (e.ColIndex == (int)Titles.edit_button) //edit msg
            {
                CPacketStruct cp = V_Data.RowRelativeObject(e.RowIndex)["parser"] as CPacketStruct;
                cp.MakeMsgText();
                //cp.MakeMsg();
                String      msgFile  = _packetDir + "\\" + packetName + "\\Msg.txt";
                DlgMsgMaker msgMaker = new DlgMsgMaker(cp, msgFile, _endian == Endians.Big);
                msgMaker.Location = this.Location;
                msgMaker.ShowDialog();
                cp.MakePacket(_endian == Endians.Big);
                //cp.MakeMsg();//다시 메시지를 만들어준다.
            }
            else if (e.ColIndex == (int)Titles.send) //send msg
            {
                CPacketStruct cp = V_Data.RowRelativeObject(e.RowIndex)["parser"] as CPacketStruct;
                cp.MakePacket(_endian == Endians.Big);
                _sendFunc(cp.PacketBuffer, 0, cp.PacketDataSize, cp);
                ReleaseSelections();
                V_Data.Rows[e.RowIndex].RowBackMode = FormAdders.EasyGridViewCollections.RowBackModes.Red;
            }
            else//내용보기
            {
                V_Contents.RelativeObject["name"] = packetName;
                CPacketStruct cp = V_Data.RowRelativeObject(e.RowIndex)["parser"] as CPacketStruct;
                viewContent(cp);
            }
        }
Beispiel #2
0
        public CPacketStruct GetStructParser(int row)
        {
            bool integrity = (bool)V_Data.RowRelativeObject(row)["integrity"];

            if (row > V_Data.RowCount - 1 || integrity == false)
            {
                return(null);
            }
            else
            {
                return(V_Data.RowRelativeObject(row)["parser"] as CPacketStruct);
            }
        }
Beispiel #3
0
        void V_Data_E_ContextMenuClicked(object sender, FormAdders.EasyGridViewCollections.EasyGridMenuClickArgs args)
        {
            switch (args.Text)
            {
            case "SetAsStartPoint":
                if (SetAsStartPoint(args.RowIndex) == false)
                {
                    MessageBox.Show("비활성된 라인입니다. 체크를 풀어주세요.");
                }
                break;

            case "Copy This":
            {
                String        name   = V_Data.GetValue(args.RowIndex, (int)Titles.name) as String;
                String        msg    = V_Data.RowRelativeObject(args.RowIndex)["msg"] as String;
                CPacketStruct parser = V_Data.Rows[args.RowIndex].RelativeObject["parser"] as CPacketStruct;
                AddNewItem(parser, name);
                //initList();
            }
            break;

            case "Delete Lines":
                if (V_Data.SelectedRows.Count > 0)
                {
                    List <EasyGridRow> rows = new List <EasyGridRow>(V_Data.SelectedRows);
                    foreach (EasyGridRow row in rows)
                    {
                        DeleteLine(row.Index);
                    }
                    foreach (EasyGridRow row in rows)
                    {
                        V_Data.RemoveARow(row, false);
                    }
                    V_Data.RefreshList();
                    saveNameList();
                }
                break;

            case "Make New Msg":
            {
                InputForm    input  = new InputForm();
                DialogResult result = input.ShowDialog("새 메시지 이름");
                if (result == DialogResult.Cancel || result == DialogResult.Abort)
                {
                    return;
                }
                AddNewItem(null, input.InputText);
            }
            break;
            }
        }
Beispiel #4
0
 void V_Data_E_CellClicked(object sender, FormAdders.EasyGridViewCollections.CellClickEventArgs e)
 {
     if (e.ColIndex == (int)Titles.edit_button) //edit msg
     {
         CPacketStruct cp = V_Data.RowRelativeObject(e.RowIndex)["parser"] as CPacketStruct;
         cp.MakeMsgText();
         String      msgFile  = _packetDir + "\\" + (V_Data.GetCell(e.RowIndex, 1).Value as String) + "\\Msg.txt";
         DlgMsgMaker msgMaker = new DlgMsgMaker(cp, msgFile, _endian == Endians.Big);
         msgMaker.Location = this.Location;
         msgMaker.ShowDialog();
     }
     else if (e.ColIndex == (int)Titles.send) //send msg
     {
         CPacketStruct cp = V_Data.RowRelativeObject(e.RowIndex)["parser"] as CPacketStruct;
         cp.MakePacket(_endian == Endians.Big);
         _sendFunc(cp.PacketBuffer, 0, cp.PacketDataSize, cp.SimpleText);
         ReleaseSelections();
         V_Data.Rows[e.RowIndex].RowBackMode = FormAdders.EasyGridViewCollections.RowBackModes.Red;
     }
 }
Beispiel #5
0
        void V_Data_E_ContextMenuClicked(object sender, FormAdders.EasyGridViewCollections.EasyGridMenuClickArgs args)
        {
            switch (args.Text)
            {
            case "SetAsStartPoint":
                if (SetAsStartPoint(args.RowIndex) == false)
                {
                    MessageBox.Show("비활성된 라인입니다. 체크를 풀어주세요.");
                }
                break;

            case "Copy This":
                String name = V_Data.GetValue(args.RowIndex, (int)Titles.name) as String;
                String msg  = V_Data.RowRelativeObject(args.RowIndex)["msg"] as String;
                AddNewItem(msg, name, true);
                //initList();
                break;

            case "Delete Lines":
                if (V_Data.SelectedRows.Count > 0)
                {
                    List <EasyGridRow> rows = new List <EasyGridRow>(V_Data.SelectedRows);
                    foreach (EasyGridRow row in rows)
                    {
                        DeleteLine(row.Index);
                    }
                    foreach (EasyGridRow row in rows)
                    {
                        V_Data.RemoveARow(row, false);
                    }
                    V_Data.RefreshList();
                    saveNameList();
                }
                break;
            }
        }
Beispiel #6
0
        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();
        }