Exemplo n.º 1
0
        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;
                }
            }
        }
Exemplo n.º 2
0
        void init()
        {
            V_Data.AddTitleImageCheckColumn(15, Titles.check.ToString());
            V_Data.AddTitleTextBoxColumn(100, Titles.name.ToString(), "Name", true);
            V_Data.AddTitleButtonColumn(30, Titles.edit_button.ToString(), "edit", "edit");
            V_Data.AddTitleButtonColumn(30, Titles.send.ToString(), "send", "send");
            V_Data.AddTitleCloseButtonColumn(15, Titles.close.ToString(), "X", "X");
            V_Data.AddTitleTextBoxColumn(-1, Titles.comment.ToString(), "Comment", true);

            V_Data.E_CellClicked        += new FormAdders.EasyGridViewCollections.CellClickEventHandler(V_Data_E_CellClicked);
            V_Data.E_TextChanged        += new FormAdders.CellTextChangedEventHandler(V_Data_E_TextChanged);
            V_Data.E_TextEditFinished   += new FormAdders.CellTextChangedEventHandler(V_Data_E_TextEditFinished);
            V_Data.E_ListRowRemoving    += new CellClickEventHandler(V_Data_E_ListRowRemoving);
            V_Data.E_ListRowRemoved     += new CellClickEventHandler(V_Data_E_ListRowRemoved);
            V_Data.E_ContextMenuClicked += new FormAdders.EasyGridViewCollections.EasyGridMenuClickHandler(V_Data_E_ContextMenuClicked);
            V_Data.ActionOnRightClicked  = FormAdders.EasyGridViewCollections.Actions.ContextMenu;
            V_Data.ActionOnClicked       = Actions.Nothing;

            V_Data.AddContextMenuItem(new String[] { "SetAsStartPoint", "Copy This", "Delete Lines", "Make New Msg" });
            V_Data.E_CheckBoxChanged    += new FormAdders.CellCheckedEventHandler(V_Data_E_CheckBoxChanged);
            V_Data.E_RowPositionChanged += new RowPositionChangedHandler(V_Data_E_RowPositionChanged);
            //_baseDir = Directory.GetCurrentDirectory();

            V_Contents.AddTitleTextBoxColumn(40, contentTitles.name.ToString(), "Name", true);
            V_Contents.AddTitleComboBoxColumn(50, contentTitles.type.ToString(), "Type", _types, 1);
            V_Contents.AddTitleTextBoxColumn(-1, contentTitles.value.ToString(), "Value", true);
            V_Contents.AddTitleComboBoxColumn(40, contentTitles.swap.ToString(), "Swap", _swapYn, 1);

            V_Contents.E_TextChanged     += new CellTextChangedEventHandler(V_Contents_E_TextChanged);
            V_Contents.E_ComboBoxChanged += new CellComboBoxEventHandler(V_Contents_E_ComboBoxChanged);

            B_HideButton.Click += new EventHandler(B_HideButton_Click);
            B_Save.Click       += new EventHandler(B_Save_Click);
            initList();
        }
Exemplo n.º 3
0
        void V_Data_E_TextChanged(object sender, FormAdders.CellTextChangedEventArgs e)
        {
            if (e.ColIndex == (int)Titles.name)//name change
            {
                if (Directory.Exists(_packetDir + "\\" + e.Text))
                {
                    MessageBox.Show("이미 같은 이름을 가진 메시지가 존재합니다. 다른이름으로 해 주세요.");
                    e.IsCancel = true;

                    return;
                }
                try
                {
                    Directory.Move(_packetDir + "\\" + e.BeforeText, _packetDir + "\\" + e.Text);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message + "\r\n" + ex.ToString());
                    e.IsCancel = true;
                    return;
                }
            }
            else if (e.ColIndex == (int)Titles.comment)//comment change
            {
                String commentFile = _packetDir + "\\" + (V_Data.GetCell(e.RowIndex, 1).Value as String) + "\\Comment.txt";
                File.WriteAllText(commentFile, e.Text);
            }
            //saveNameList();
        }
Exemplo n.º 4
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);
            }
        }
Exemplo n.º 5
0
        void saveNameList()
        {
            String orderFile = _packetDir + "\\ListOrder.txt";

            File.Delete(orderFile);
            if (Directory.Exists(_packetDir + "\\Backups"))
            {
                if (V_Data.Rows.Count != Directory.GetDirectories(_packetDir).Length - 1)
                {
                    MessageBox.Show("디렉토리 개수와 목록의 개수가 달라서 목록을 다시 만듭니다.");
                    //File.Delete(orderFile);
                    makeNewOrderIfNotExists();
                    initList();
                    return;
                }
            }
            else
            {
                if (V_Data.Rows.Count != Directory.GetDirectories(_packetDir).Length)
                {
                    MessageBox.Show("디렉토리 개수와 목록의 개수가 달라서 목록을 다시 만듭니다.");
                    //File.Delete(orderFile);
                    makeNewOrderIfNotExists();
                    initList();
                    return;
                }
            }
            StreamWriter sw = new StreamWriter(File.OpenWrite(orderFile));

            try
            {
                string root    = Directory.GetCurrentDirectory();
                int    rootLen = root.Length + 1;

                for (int i = 0; i < V_Data.RowCount; i++)
                {
                    String name = V_Data.GetValue(i, (int)Titles.name) as String;
                    String dir  = _packetDir + "\\" + name;

                    if (Directory.Exists(dir) == false)
                    {
                        MessageBox.Show(dir + "라인이 무결성을 통과 못하여 목록을 다시 만듭니다.");
                        sw.Close();
                        File.Delete(orderFile);
                        makeNewOrderIfNotExists();
                        initList();
                        return;
                    }
                    sw.WriteLine(dir.Substring(rootLen));
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
            finally
            {
                sw.Close();
            }
        }
Exemplo n.º 6
0
        private void B_PatternCheck_Click(object sender, EventArgs e)
        {
            L_Log.Items.Clear();
            _selectedCol = C_Title.SelectedIndex;
            if (_selectedCol < 0)
            {
                MessageBox.Show("타이틀을 선택하세요!");
                return;
            }
            bool isTimeStamp = C_TimeStamp.Checked;

            iDiff = 1;

            if (long.TryParse(T_Diff.Text, out iDiff) == false)
            {
                MessageBox.Show("차이는 숫자로 써 주세요(timestamp의경우 시:분:초.ms단위)");
                return;
            }
            V_Data.ClearData();
            if (isTimeStamp)
            {
                _checkThread = new Thread(new ThreadStart(CheckTimeStamp));
            }
            else
            {
                _checkThread = new Thread(new ThreadStart(CheckInteger));
            }
            _checkThread.Start();
        }
Exemplo n.º 7
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);
            }
        }
Exemplo n.º 8
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;
            }
        }
Exemplo n.º 9
0
 public void SetTitles(params String[] titles)
 {
     V_Data.ClearData();
     C_Title.Items.Clear();
     V_Data.AddTitleImageCheckColumn(20, "isCheck");
     V_Data.AddTitleTextBoxColumn(50, "line", "line", false);
     for (int i = 0; i < titles.Length; i++)
     {
         EasyGridTextBoxColumn col = new EasyGridTextBoxColumn(V_Data.ListView as EasyGridViewParent);
         col.ValueType  = typeof(String);
         col.HeaderText = titles[i];
         col.Name       = titles[i];
         columns.Add(col);
         C_Title.Items.Add(titles[i]);
         int wid = 30;// (i == 0 || i == 1) ? 100 : 50;
         V_Data.AddTitleTextBoxColumn(wid, titles[i], titles[i], false);
     }
 }
Exemplo n.º 10
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;
     }
 }
Exemplo n.º 11
0
        private void B_PatternCheck_Click(object sender, EventArgs e)
        {
            L_Log.Items.Clear();
            _selectedCol = C_Title.SelectedIndex;
            if (_selectedCol < 0)
            {
                MessageBox.Show("타이틀을 선택하세요!");
                return;
            }
            iDiff = 1;

            if (long.TryParse(T_Diff.Text, out iDiff) == false)
            {
                MessageBox.Show("차이는 숫자로 써 주세요");
                return;
            }
            V_Data.ClearData();

            _checkThread = new Thread(new ThreadStart(CheckInteger));
            _checkThread.Start();
        }
Exemplo n.º 12
0
        void V_Data_E_TextChanged(object sender, FormAdders.CellTextChangedEventArgs e)
        {
            if (e.ColIndex == (int)Titles.name)//name change
            {
                if (Directory.Exists(_packetDir + "\\" + e.Text))
                {
                    MessageBox.Show("이미 같은 이름을 가진 메시지가 존재합니다. 다른이름으로 해 주세요.");
                    e.IsCancel = true;

                    return;
                }
                try
                {
                    Directory.Move(_packetDir + "\\" + e.BeforeText, _packetDir + "\\" + e.Text);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message + "\r\n" + ex.ToString());
                    e.IsCancel = true;
                    return;
                }
                if (_modifiedItems.ContainsKey(e.BeforeText))
                {
                    _modifiedItems.Add(e.Text, _modifiedItems[e.BeforeText]);
                    _modifiedItems.Remove(e.BeforeText);
                }
            }
            else if (e.ColIndex == (int)Titles.comment)//comment change
            {
                String commentFile = _packetDir + "\\" + (V_Data.GetCell(e.RowIndex, 1).Value as String) + "\\Comment.txt";
                File.WriteAllText(commentFile, e.Text);
                int           itemIndex  = (int)V_Contents.Rows[e.RowIndex].RelativeObject[rowInfos.itemIndex.ToString()];
                int           valueIndex = (int)V_Contents.Rows[e.RowIndex].RelativeObject[rowInfos.valueIndex.ToString()];
                CPacketStruct parser     = V_Contents.Rows[e.RowIndex].RelativeObject[rowInfos.parser.ToString()] as CPacketStruct;
                parser.Infos.Comment = e.Text;
                String name = (V_Data.GetCell(e.RowIndex, 1).Value as String);
                _modifiedItems[name] = parser;
            }
            //saveNameList();
        }
Exemplo n.º 13
0
        bool DeleteLine(int rowIndex, bool isConfirm = true)
        {
            String name = V_Data.GetCell(rowIndex, (int)Titles.name).Value as String;

            if (isConfirm)
            {
                DialogResult result = MessageBox.Show("[" + name + "] 을 진짜 지울까요?", "삭제확인", MessageBoxButtons.YesNo);
                if (result == System.Windows.Forms.DialogResult.No)
                {
                    return(false);
                }
            }


            String dir    = _packetDir + "\\" + name;
            String newDir = _packetDir + "\\Backups\\" + name;

            if (Directory.Exists(_packetDir + "\\Backups") == false)
            {
                Directory.CreateDirectory(_packetDir + "\\Backups");
            }

            if (Directory.Exists(newDir))
            {
                newDir += DateTime.Now.ToString("yyyyMMdd_HHmmss");
            }
            try
            {
                Directory.Move(dir, newDir);
            }
            catch (Exception ex)
            {
                MessageBox.Show("문제가 있어서 삭제하지 못했습니다. 다음의 메시지를 확인해주세요." + ex.Message);

                return(false);
            }
            return(true);
        }
Exemplo n.º 14
0
 public SavedList()
 {
     InitializeComponent();
     V_Data.AddTitleImageCheckColumn(15, Titles.check.ToString());
     V_Data.AddTitleTextBoxColumn(100, Titles.name.ToString(), "Name", true);
     V_Data.AddTitleButtonColumn(30, Titles.edit_button.ToString(), "edit", "edit");
     V_Data.AddTitleButtonColumn(30, Titles.send.ToString(), "send", "send");
     V_Data.AddTitleCloseButtonColumn(15, Titles.close.ToString(), "X", "X");
     V_Data.AddTitleTextBoxColumn(-1, Titles.comment.ToString(), "Comment", true);
     V_Data.E_CellClicked        += new FormAdders.EasyGridViewCollections.CellClickEventHandler(V_Data_E_CellClicked);
     V_Data.E_TextChanged        += new FormAdders.CellTextChangedEventHandler(V_Data_E_TextChanged);
     V_Data.E_TextEditFinished   += new FormAdders.CellTextChangedEventHandler(V_Data_E_TextEditFinished);
     V_Data.E_ListRowRemoving    += new CellClickEventHandler(V_Data_E_ListRowRemoving);
     V_Data.E_ListRowRemoved     += new CellClickEventHandler(V_Data_E_ListRowRemoved);
     V_Data.E_ContextMenuClicked += new FormAdders.EasyGridViewCollections.EasyGridMenuClickHandler(V_Data_E_ContextMenuClicked);
     V_Data.ActionOnRightClicked  = FormAdders.EasyGridViewCollections.Actions.ContextMenu;
     V_Data.AddContextMenuItem(new String[] { "SetAsStartPoint", "Copy This", "Delete Lines" });
     V_Data.E_CheckBoxChanged    += new FormAdders.CellCheckedEventHandler(V_Data_E_CheckBoxChanged);
     V_Data.E_RowPositionChanged += new RowPositionChangedHandler(V_Data_E_RowPositionChanged);
     _baseDir = Directory.GetCurrentDirectory();
     initList();
     C_OnTop.CheckedChanged += new EventHandler(C_OnTop_CheckedChanged);
 }
Exemplo n.º 15
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;
            }
        }
Exemplo n.º 16
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();
        }
Exemplo n.º 17
0
        void addLines(long startIndex, long numLines)
        {
            String line;
            long   lineIndex = 0;

            try
            {
                _checking = true;
                //long backPoint = 0;
                int backLine = 0;

                while ((line = _fileReader.ReadLine()) != null && _checking)
                {
                    /*
                     * if (_totalLines == 0)
                     * {
                     *  if (_seekPoint[_seekPoint.Count - 1] == _fileReader.BaseStream.Position)
                     *  {
                     *      _seekPoint.Add(_seekPoint[_seekPoint.Count - 1] + Buffer.ByteLength(line.ToCharArray()));
                     *  }
                     *  else
                     *  {
                     *      _seekPoint.Add(_fileReader.BaseStream.Position);
                     *  }
                     * }
                     */

                    if (lineIndex >= startIndex && numLines > 0)
                    {
                        addALine(false, lineIndex, line);


                        if ((--numLines) == 0 && _isInit)  //최초 1회, 끝까지 간다.
                        {
                            //backPoint = _fileReader.BaseStream.Position;
                            backLine = (int)lineIndex;
                        }
                        else if (numLines == 0)
                        {
                            break;
                        }
                    }
                    lineIndex++;
                }

                if (_isInit)//포인터를 되돌려놓기 위함..
                {
                    _isInit     = false;
                    _totalLines = lineIndex - 1;

                    _fileReader.Close();
                    _fileReader = File.OpenText(_fileName);

                    line     = _fileReader.ReadLine();
                    _nowLine = backLine;
                    int lines = _nowLine;
                    while ((line = _fileReader.ReadLine()) != null && --lines > 0)
                    {
                    }

                    L_Total.Text = _totalLines.ToString();

                    Track_From.Maximum     = (int)_totalLines;
                    Track_From.LargeChange = (int)lineIndex / 10;
                    //MessageBox.Show("파일의 일부를 표시합니다.. from:" + T_From.Text + "  to:" + (_nowLine - startIndex).ToString());
                    try
                    {
                        long time0 = getTime(V_Data.GetValue(0, 2).ToString());
                        long time1 = getTime(V_Data.GetValue(1, 2).ToString());
                        T_Diff.Text = (time1 - time0).ToString();
                    }
                    catch { }
                }
                else
                {
                    _nowLine = (int)lineIndex;
                }
                //T_From.Text = _nowLine.ToString();
            }
            catch { }
        }
Exemplo n.º 18
0
 void addTitles()
 {
     V_Data.AddTitleTextBoxColumn(-1, Titles.name.ToString(), "Name", false);
     V_Data.AddTitleTextBoxColumn(200, Titles.value.ToString(), "value", true);
 }
Exemplo n.º 19
0
        void initList()
        {
            V_Data.ClearData();
            String listDir   = _packetDir = _baseDir + "\\PacketList";
            String orderFile = _packetDir + "\\ListOrder.txt";

            makeNewOrderIfNotExists();

            List <String> listOrder = new List <string>();

            #region 순서를 가져옴
            StreamReader sr = new StreamReader(File.OpenRead(orderFile));
            String       line;
            String       rootDir = Directory.GetCurrentDirectory() + "\\";
            while ((line = sr.ReadLine()) != null)
            {
                if (line.Trim().Length > 0)
                {
                    if (line.IndexOf(rootDir) == 0)
                    {
                        listOrder.Add(line);
                    }
                    else
                    {
                        listOrder.Add(rootDir + line);
                    }
                }
            }
            sr.Close();

            #endregion

            //if (Directory.Exists(listDir) == false) Directory.CreateDirectory(listDir);
            //else
            {
                CPacketStruct parser;// = new CStructParser();

                //foreach (String dir in Directory.GetDirectories(listDir))
                foreach (String dir in listOrder)
                {
                    if (dir.Substring(dir.LastIndexOf("\\") + 1).Equals("Backups"))
                    {
                        continue;                                                            //백업디렉토리는 제외..
                    }
                    String Msg = "";
                    Dictionary <String, object> rels = new Dictionary <string, object>();
                    try
                    {
                        if (File.Exists(dir + "\\Msg.txt") == false)
                        {
                            MessageBox.Show(dir + "\\Msg.txt 가 없습니다.메시지를 다시 작성하십시오.");//필수파일
                            File.WriteAllText(dir + "\\Msg.txt", "");
                        }
                        else
                        {
                            Msg = File.ReadAllText(dir + "\\Msg.txt");
                        }
                    }
                    catch
                    {
                        continue;
                    }
                    String comment = "";
                    if (File.Exists(dir + "\\Comment.txt"))
                    {
                        comment = File.ReadAllText(dir + "\\Comment.txt");
                    }
                    Dictionary <String, String> states = new Dictionary <string, string>();
                    if (File.Exists(dir + "\\States.txt"))
                    {
                        String[] lines = File.ReadAllLines(dir + "\\States.txt");
                        for (int i = 0; i < lines.Length; i++)
                        {
                            String[] tokens = lines[i].Split("=;".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                            if (tokens.Length > 1)
                            {
                                states[tokens[0].ToLower().Trim()] = tokens[1].ToLower().Trim();
                            }
                        }
                    }
                    bool isChecked = (states.ContainsKey("check")) ? (states["check"].Equals("y") || states["check"].Equals("true")) : false;

                    parser = new CPacketStruct();
                    parser.IsStringWithNullEnd = _isStringWithNullEnd;
                    parser.Endian         = _endian;
                    parser.StringEncoding = _strEncoding;

                    String msgName = dir.Substring(dir.LastIndexOf("\\") + 1);
                    bool   integrity;
                    try
                    {
                        parser.MakePacket(Msg, _endian == Endians.Big);
                        integrity = true;
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show(msgName + ":" + e.Message);
                        integrity = true;
                    }
                    rels["integrity"] = integrity;
                    rels["parser"]    = parser;
                    rels["msg"]       = Msg;

                    EasyGridRow row = V_Data.AddARow(rels, new object[] {
                        isChecked,
                        msgName,
                        "edit",
                        "send",
                        "X",
                        comment
                    });
                    if (integrity == false)
                    {
                        (row[(int)Titles.name] as EasyGridTextBoxCell).FontColor = Color.Red;
                    }
                    if (isChecked)
                    {
                        row.RowBackMode = RowBackModes.Gray;
                    }
                }
            }
            if (V_Data.Rows.Count > 0)
            {
                V_Data.Rows[0].RowBackMode = FormAdders.EasyGridViewCollections.RowBackModes.Red;
                //V_Data.Rows[0].RowBackCustomColor = Color.FromArgb(255, 222, 222);
            }
        }
Exemplo n.º 20
0
        public void initList()
        {
            V_Data.ClearData();
            //if (packetDir != null) _packetDir = packetDir;
            if (_packetDir == null)
            {
                return;
            }
            String listDir   = _packetDir;// = _baseDir+"\\PacketList";
            String orderFile = _packetDir + "\\ListOrder.txt";

            makeNewOrderIfNotExists();

            List <String> listOrder = new List <string>();

            #region 순서를 가져옴
            StreamReader sr = new StreamReader(File.OpenRead(orderFile));
            String       line;
            //String rootDir = Directory.GetCurrentDirectory() + "\\";
            while ((line = sr.ReadLine()) != null)
            {
                if (line.Trim().Length > 0)
                {
                    listOrder.Add(line);
                    //if (line.IndexOf(rootDir) == 0) listOrder.Add(line);
                    //else listOrder.Add(rootDir + line);
                }
            }
            sr.Close();

            #endregion
            String[] dirs = Directory.GetDirectories(_packetDir);

            for (int i = 0; i < dirs.Length; i++)
            {
                String name = dirs[i].Substring(dirs[i].LastIndexOf("\\") + 1);
                if (name.Equals("Backups"))
                {
                    continue;                          //백업디렉토리는 제외..
                }
                if (listOrder.Contains(name) == false) //만일 리스트에 없으면..
                {
                    File.Delete(orderFile);
                    makeNewOrderIfNotExists();
                    listOrder.Clear();
                    for (int d = 0; d < dirs.Length; d++)//새로만듬..
                    {
                        name = dirs[i].Substring(dirs[i].LastIndexOf("\\") + 1);
                        if (name.Equals("Backups"))
                        {
                            continue;                        //백업디렉토리는 제외..
                        }
                        listOrder.Add(name);
                    }

                    break;
                }
            }
            //if (Directory.Exists(listDir) == false) Directory.CreateDirectory(listDir);
            //else
            {
                //CStructParser parser;// = new CStructParser();

                //foreach (String dir in Directory.GetDirectories(listDir))
                foreach (String name in listOrder)
                {
                    String        Msg       = "";
                    bool          integrity = false;
                    String        path      = _packetDir + "\\" + name;
                    String        msgXml    = path + "\\Msg.xml";
                    String        msgTxt    = path + "\\Msg.txt";
                    CPacketStruct parser    = new CPacketStruct();

                    IList <CPacketItem>         itemsList = null;
                    Dictionary <String, object> rels      = new Dictionary <string, object>();
                    //try
                    {
                        if (File.Exists(msgXml))
                        {
                            //try
                            {
                                itemsList = StructXMLParser.XmlToItems(msgXml, parser);
                                Msg       = StructXMLParser.ItemsToCode(itemsList);
                                integrity = true;
                            }
                            //catch {

                            /*
                             *  integrity = false;
                             *  if (File.Exists(msgTxt))
                             *  {
                             *      Msg = File.ReadAllText(msgTxt);
                             *  }
                             *  else
                             *  {
                             *
                             *      MessageBox.Show(msgXml + "이나 "+ msgTxt+" 가 없습니다.메시지를 다시 작성하십시오.");//필수파일
                             *      File.WriteAllText(msgTxt, "");
                             *
                             *  }
                             */
                            //}
                        }
                        else if (File.Exists(msgTxt))
                        {
                            Msg = File.ReadAllText(msgTxt);
                        }
                        else
                        {
                            //MessageBox.Show(msgXml + "이나 " + msgTxt + " 가 없습니다.메시지를 다시 작성하십시오.");//필수파일
                            if (Directory.Exists(path))
                            {
                                Directory.Delete(path, true);
                            }
                            //File.WriteAllText(msgTxt,"");
                        }
                    }
                    //catch
                    {
                        //    continue;
                    }
                    String comment = "";
                    if (File.Exists(path + "\\Comment.txt"))
                    {
                        comment = File.ReadAllText(path + "\\Comment.txt");
                    }
                    Dictionary <String, String> states = new Dictionary <string, string>();
                    if (File.Exists(path + "\\States.txt"))
                    {
                        String[] lines = File.ReadAllLines(path + "\\States.txt");
                        for (int i = 0; i < lines.Length; i++)
                        {
                            String[] tokens = lines[i].Split("=;".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                            if (tokens.Length > 1)
                            {
                                states[tokens[0].ToLower().Trim()] = tokens[1].ToLower().Trim();
                            }
                        }
                    }
                    bool isChecked = (states.ContainsKey("check")) ? (states["check"].Equals("y") || states["check"].Equals("true")) : false;

                    parser.IsStringWithNullEnd = _isStringWithNullEnd;
                    parser.Endian         = _endian;
                    parser.StringEncoding = _strEncoding;

                    String msgName = name;
                    //try
                    {
                        if (itemsList == null)
                        {
                            parser.MakePacket(Msg, _endian == Endians.Big);
                            integrity = true;
                        }
                        else
                        {
                            //parser.Items.Clear();
                            parser.Items.CopyFrom(itemsList);
                            //parser.Items = itemsList as List<CPacketItem>;

                            parser.MakePacket(_endian == Endians.Big);
                        }
                    }
                    //catch(Exception e)
                    {
                        //    MessageBox.Show(msgName+":"+e.Message);
                        integrity = true;
                    }
                    rels["integrity"] = integrity;
                    rels["parser"]    = parser;
                    rels["msg"]       = Msg;

                    EasyGridRow row = V_Data.AddARow(rels, new object[] {
                        isChecked,
                        msgName,
                        "edit",
                        "send",
                        "X",
                        comment
                    });
                    if (integrity == false)
                    {
                        (row[(int)Titles.name] as EasyGridTextBoxCell).FontColor = Color.Red;
                    }
                    if (isChecked)
                    {
                        row.RowBackMode = RowBackModes.Gray;
                    }
                }
            }
            if (V_Data.Rows.Count > 0)
            {
                if (_startIndex < V_Data.Rows.Count)
                {
                    V_Data.Rows[_startIndex].RowBackMode = FormAdders.EasyGridViewCollections.RowBackModes.Red;
                }
                //V_Data.Rows[0].RowBackCustomColor = Color.FromArgb(255, 222, 222);
            }
            V_Data.RefreshList();
        }
Exemplo n.º 21
0
        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();
        }
Exemplo n.º 22
0
        //List<long> _seekPoint = new List<long>();
        public void LoadFile(String fileName, bool isInit, int columns = -1)
        {
            if (columns > 0)
            {
                _cols          = columns;
                T_Columns.Text = _cols.ToString();
            }
            _isInit = isInit;

            _fileName = fileName;
            this.Text = fileName.Substring(fileName.LastIndexOf('\\') + 1) + "[" + fileName.Substring(0, (fileName.LastIndexOf('\\')) + 1) + "]";
            if (File.Exists(fileName) == false)
            {
                if (fileName.Length > 0)
                {
                    MessageBox.Show(fileName + " 그런 파일이 없습니다.");
                }
                return;
            }

            _nowLine = 0;
            //_seekPoint.Clear();
            if (isInit)
            {
                _totalLines = 0;
            }
            if (_fileStream != null)
            {
                try
                {
                    _fileStream.Close();
                }
                catch { }
            }
            _fileStream = File.OpenRead(fileName);

            if (_isInit)
            {
                V_Data.ClearData();
                V_Data.ClearTitles();

                List <String> titles = new List <string>();
                _cols = Convert.ToInt32(T_Columns.Text);
                if (_cols <= 0)
                {
                    _cols = 16;          //default 16
                }
                for (int i = 0; i < _cols; i++)
                {
                    titles.Add(string.Format("{0:X2}", i));
                }

                SetTitles(titles.ToArray());
            }
            else
            {
                V_Data.ClearData();
            }
            //_seekPoint.Add(_fileReader.BaseStream.Position); //제목을 제외한 제일 첫 줄.
            if (V_Data.ColumnCount > 0)
            {
                C_Title.SelectedIndex = 0;
            }

            _loadFileThread = new Thread(new ThreadStart(loadFile));
            _loadFileThread.Start();
        }
Exemplo n.º 23
0
        //List<long> _seekPoint = new List<long>();
        public void LoadFile(String fileName, bool isInit)
        {
            _isInit = isInit;

            _fileName = fileName;
            this.Text = fileName.Substring(fileName.LastIndexOf('\\') + 1) + "[" + fileName.Substring(0, (fileName.LastIndexOf('\\')) + 1) + "]";
            if (File.Exists(fileName) == false)
            {
                if (fileName.Length > 0)
                {
                    MessageBox.Show(fileName + " 그런 파일이 없습니다.");
                }
                return;
            }

            _nowLine = 0;
            //_seekPoint.Clear();
            if (isInit)
            {
                _totalLines = 0;
            }
            if (_fileReader != null)
            {
                try
                {
                    _fileReader.Close();
                }
                catch { }
            }
            _fileReader = File.OpenText(fileName);

            if (_isInit)
            {
                V_Data.ClearData();
                V_Data.ClearTitles();



                String line;

                line = _fileReader.ReadLine();
                if (line == null)
                {
                    _fileReader.Close();
                    this.ResumeLayout();
                    return;
                }
                addTitle(line);
            }
            else
            {
                V_Data.ClearData();
            }
            //_seekPoint.Add(_fileReader.BaseStream.Position); //제목을 제외한 제일 첫 줄.
            if (V_Data.ColumnCount > 0)
            {
                C_Title.SelectedIndex = 0;
            }

            _loadFileThread = new Thread(new ThreadStart(loadFile));
            _loadFileThread.Start();
        }
Exemplo n.º 24
0
 public void SuspendRefresh()
 {
     this.SuspendLayout();
     V_Data.SuspendLayout();
 }