示例#1
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();
        }
示例#2
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);
     }
 }
示例#3
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();
        }
示例#4
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);
            }
        }
示例#5
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();
        }
示例#6
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();
        }
示例#7
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();
        }