Example #1
0
        public bool attachDefault(string strExperimentFullName, CPoint pointBoundaryBlock)
        {
            CReadFile   readFile   = new CReadFile();
            CManageFile manageFile = new CManageFile();

            List <string> listString = new List <string>();
            string        strLine    = string.Empty;

            char[]   separators = { ' ', '\t' };
            string[] strArray;

            string strFileName         = Path.GetFileNameWithoutExtension(strExperimentFullName);
            string strTempFileFullName = Path.Combine(Path.GetDirectoryName(strExperimentFullName), strFileName + "_temp.fem");

            if (manageFile.isExistFile(strExperimentFullName) == false)
            {
                CNotice.printTraceID("NFFF");
                return(false);
            }
            else
            {
                File.Move(strExperimentFullName, strTempFileFullName);
            }

            StreamWriter writeFile    = new StreamWriter(strExperimentFullName);
            int          iNumBlock    = 0;
            int          nCountBlock  = 0;
            bool         bBlockLabels = false;

            try
            {
                readFile.getAllLines(strTempFileFullName, ref listString);

                for (int i = 0; i < listString.Count; i++)
                {
                    strLine = listString[i];

                    strArray = strLine.Split(separators, StringSplitOptions.None);

                    if (strArray[0] == "[NumBlockLabels]")
                    {
                        iNumBlock    = Int32.Parse(strArray[2]);
                        nCountBlock  = 0;
                        bBlockLabels = true;

                        writeFile.WriteLine(strLine);

                        /// 구분 Label 행은 건너 뛴다.
                        continue;
                    }

                    if (bBlockLabels == true)
                    {
                        if (pointBoundaryBlock.m_dX == Double.Parse(strArray[0]) && pointBoundaryBlock.m_dY == Double.Parse(strArray[1]))
                        {
                            if (strArray.Length != 9)
                            {
                                CNotice.printTraceID("TWAP2");
                                return(false);
                            }

                            /// dettach block setting
                            strArray[8] = "2";
                            strLine     = string.Empty;

                            foreach (string str in strArray)
                            {
                                strLine += str + '\t';
                            }
                        }

                        nCountBlock++;

                        if (nCountBlock >= iNumBlock)
                        {
                            bBlockLabels = false;
                        }
                    }

                    writeFile.WriteLine(strLine);
                }

                File.Delete(strTempFileFullName);
            }
            catch (Exception ex)
            {
                CNotice.printTrace(ex.Message);
                writeFile.Close();
                return(false);
            }

            writeFile.Close();
            return(true);
        }