Esempio n. 1
0
        /// <summary>
        /// 查找操作
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_find_Click(object sender, EventArgs e)
        {
            if (IsOpenedPPT())
            {
                MessageBox.Show("请先关闭PPT!");
                return;
            }
            string directoyPath = this.cob_path.Text;
            var    IsWaring     = directoyPath.Length == 3 && (directoyPath.ToUpper().Contains("C") ||
                                                               directoyPath.ToUpper().Contains("D") || directoyPath.ToUpper().Contains("E"));

            if (IsWaring)
            {
                MessageBox.Show("当前选择的是一个磁盘,太危险!禁止操作,请选择磁盘中的一个文件");
                return;
            }
            string fileText = this.tb_findText.Text;

            FindEnum where = GetWhere();
            if (where.Equals(FindEnum.InContent))
            {
                var    filePaths = GetFlies(directoyPath);
                string message   = "";
                foreach (string fliePath in filePaths)//\n
                {
                    //HTML.XML
                    if (Path.GetExtension(fliePath).ToUpper().Equals(".HTML") || Path.GetExtension(fliePath).ToUpper().Equals(".XML"))
                    {
                        message += FindInHTMLOrXML(fileText, fliePath) + "\n";
                    }
                    if (Path.GetExtension(fliePath).ToUpper().Equals(".TXT"))
                    {
                        message += FindInTXT(fileText, fliePath) + "\n";
                    }
                    if (Path.GetExtension(fliePath).ToUpper().Equals(".XLSX") || Path.GetExtension(fliePath).ToUpper().Equals(".XLS"))
                    {
                        //ExcelHelper2 exceHelper = new ExcelHelper2();
                        //message += exceHelper.FindInExcel(fileText, fliePath) + "\n";
                        // ExcelHelper3 exceHelper = new ExcelHelper3();
                        //message += exceHelper.ReplaceInExcel() + "\n";
                        ExcelHelper3 exceHelper = new ExcelHelper3();
                        message += exceHelper.FindInExcel(fileText, fliePath);
                    }
                    if (Path.GetExtension(fliePath).ToUpper().Equals(".DOCX") || Path.GetExtension(fliePath).ToUpper().Equals(".RTF"))
                    {
                        WordHelper wordHelper = new WordHelper();
                        message += wordHelper.FindInWord(fileText, fliePath) + "\n";;
                    }
                    if (Path.GetExtension(fliePath).ToUpper().Equals(".PPTX") || Path.GetExtension(fliePath).ToUpper().Equals(".PPT"))
                    {
                        OperatePPT ppt = new OperatePPT();
                        ppt.PPTOpen(fliePath);
                        message += ppt.FindInPPT(fileText, fliePath) + "\n";;
                        ppt.PPTClose();
                    }
                }
                MessageBox.Show(message);
            }
        }
        string IAmplifierExport.Line(LibraryAmplifierGroup amplifierGroup, LibraryAmplifierGroupAmplifier amplifier, LibraryAmplifierGroupAmplifierGraphic graphic)
        {
            _notes = "";

            string result   = "";
            string category = "";

            FindEnum find = FindEnum.FindEntities;

            switch (amplifierGroup.AmplifierGroupCode)
            {
            case 1:
            case 2:
                find     = FindEnum.FindEchelons;
                category = "Echelon";
                break;

            case 3:
            case 4:
            case 5:
                find     = FindEnum.FindMobilities;
                category = "Mobility";
                break;

            case 6:
                find     = FindEnum.FindAuxiliaryEquipment;
                category = "Auxiliary Equipment";
                break;
            }

            string graphicPath = _configHelper.GetPath("", find);

            string itemRootedPath   = _configHelper.BuildRootedPath(graphicPath, graphic.Graphic);
            string itemOriginalPath = _configHelper.BuildOriginalPath(graphicPath, graphic.Graphic);

            if (!File.Exists(itemOriginalPath))
            {
                _notes = _notes + "image file does not exist;";
            }

            LibraryStandardIdentityGroup identityGroup = _configHelper.Librarian.StandardIdentityGroup(graphic.StandardIdentityGroup);

            string itemName     = BuildAmplifierItemName(amplifierGroup, amplifier, identityGroup);
            string itemCategory = "Amplifier" + _configHelper.DomainSeparator + category;
            string itemTags     = BuildAmplifierItemTags(amplifierGroup, amplifier, identityGroup, graphicPath + "\\" + graphic.Graphic, _omitSource, _omitLegacy);
            string itemID       = BuildAmplifierCode(amplifierGroup, amplifier, identityGroup);

            result = itemRootedPath + "," +
                     Convert.ToString(_configHelper.PointSize) + "," +
                     itemName + "," +
                     itemCategory + "," +
                     itemTags + "," +
                     itemID + "," +
                     "Point" + "," +
                     _notes;

            return(result);
        }
        public string GetPath(string getWhat, FindEnum ofType, bool sansLeadingSlash = false)
        {
            // The public entry point for retrieving and returning a file path
            // string from the various Dictionarys that hold them.

            string result = "";

            switch (ofType)
            {
            case FindEnum.FindAuxiliaryEquipment:
                result = _getPath("JMSML_AUXILIARY", _basePaths);
                break;

            case FindEnum.FindEchelons:
                result = _getPath("JMSML_ECHELONS", _basePaths);
                break;

            case FindEnum.FindEntities:
                result = _getPath(getWhat, _entityPaths);
                break;

            case FindEnum.FindFrames:
                result = _getPath(getWhat, _framePaths);
                break;

            case FindEnum.FindHQTFFD:
                result = _getPath("JMSML_HQTFDUMMIES", _basePaths);
                break;

            case FindEnum.FindMobilities:
                result = _getPath("JMSML_MOBILITIES", _basePaths);
                break;

            case FindEnum.FindModifierOnes:
                result = _getPath(getWhat, _modifierOnePaths);
                break;

            case FindEnum.FindModifierTwos:
                result = _getPath(getWhat, _modifierTwoPaths);
                break;

            case FindEnum.FindSpecials:
                result = _getPath("JMSML_SPECIALS", _basePaths);
                break;

            case FindEnum.FindOCA:
                result = _getPath("JMSML_OCA", _basePaths);
                break;
            }

            if (result.Length > 1 && sansLeadingSlash)
            {
                result = result.Substring(1);
            }

            return(result);
        }
Esempio n. 4
0
        private void _findPath(FindEnum findThis, string forThis, Dictionary<string, string> recordItHere)
        {
            // Look for a given path, in our configuration file, and if
            // found, set it in a path dictionary for later retrieval.

            string whereItIs = "";
            //bool foundIt = false;

            foreach (GraphicFolderType folder in this.GraphicFolders)
            {
                if (_findIt(findThis, forThis, folder, "", ref whereItIs))
                {
                    recordItHere.Add(forThis, whereItIs);
                    //foundIt = true;
                    break;
                }
            }

            //if(!foundIt)
            //    logger.Warn("Can't find the " + findThis + " config data for " + forThis + " graphics.");
        }
        private bool _findIt(FindEnum findThis, string forThis, GraphicFolderType inThis, string whereWeAre, ref string whereItIs)
        {
            // Recursive function that looks for a particular type of attribute (findThis), belonging to
            // a particular JMSML entity (forThis) in the specified graphic folder object (inThis).
            // If it's found we return the path we found it at (whereItIs) all the way up the recursion chain,
            // based on a path string we've been building as we recurse (whereWeAre).
            // If we don't find it, we continue with a depth first search until we do find it or run
            // out of graphic folders to search.

            bool foundIt = false;

            if (inThis != null)
            {
                // First look for what we are searching for in this folder
                // If it is here then append this folder's name to our path
                // and return immediately.

                whereWeAre = whereWeAre + "\\" + inThis.Name;

                // Based on what we are looking for, here is where we check
                // the current folder for the attribute value we want.

                switch (findThis)
                {
                case FindEnum.FindAuxiliaryEquipment:
                    foundIt = inThis.AuxiliaryEquipment;
                    break;

                case FindEnum.FindEchelons:
                    foundIt = inThis.Echelons;
                    break;

                case FindEnum.FindEntities:
                    if (inThis.Entities != null)
                    {
                        foundIt = _splitAndSearch(inThis.Entities, forThis);
                    }
                    break;

                case FindEnum.FindFrames:
                    if (inThis.Frames != null)
                    {
                        foundIt = _splitAndSearch(inThis.Frames, forThis);
                    }
                    break;

                case FindEnum.FindHQTFFD:
                    foundIt = inThis.HQTFFD;
                    break;

                case FindEnum.FindMobilities:
                    foundIt = inThis.Mobilities;
                    break;

                case FindEnum.FindModifierOnes:
                    if (inThis.ModifierOnes != null)
                    {
                        foundIt = _splitAndSearch(inThis.ModifierOnes, forThis);
                    }
                    break;

                case FindEnum.FindModifierTwos:
                    if (inThis.ModifierTwos != null)
                    {
                        foundIt = _splitAndSearch(inThis.ModifierTwos, forThis);
                    }
                    break;

                case FindEnum.FindSpecials:
                    foundIt = inThis.Specials;
                    break;

                case FindEnum.FindOCA:
                    foundIt = inThis.OCA;
                    break;

                case FindEnum.Find2525C:
                    foundIt = inThis.LegacyStandard == "2525C";
                    break;

                case FindEnum.Find2525BC2:
                    foundIt = inThis.LegacyStandard == "2525BC2";
                    break;
                }

                if (foundIt)
                {
                    // We found it here so lets determine where we are so
                    // we can return that information up the recursion chain.

                    whereItIs = whereWeAre;
                }
                else
                {
                    // No luck finding it here, so let's look deeper

                    if (inThis.GraphicFolder != null)
                    {
                        foreach (GraphicFolderType childFolder in inThis.GraphicFolder)
                        {
                            foundIt = _findIt(findThis, forThis, childFolder, whereWeAre, ref whereItIs);

                            if (foundIt)
                            {
                                break;
                            }
                        }
                    }
                }
            }

            return(foundIt);
        }
        private void _findPath(FindEnum findThis, string forThis, Dictionary<string, string> recordItHere)
        {
            // Look for a given path, in our configuration file, and if
            // found, set it in a path dictionary for later retrieval.

            string whereItIs = "";
            //bool foundIt = false;

            foreach (GraphicFolderType folder in this.GraphicFolders)
            {
                if (_findIt(findThis, forThis, folder, "", ref whereItIs))
                {
                    recordItHere.Add(forThis, whereItIs);
                    //foundIt = true;
                    break;
                }
            }

            //if(!foundIt)
            //    logger.Warn("Can't find the " + findThis + " config data for " + forThis + " graphics.");
        }
        private bool _findIt(FindEnum findThis, string forThis, GraphicFolderType inThis, string whereWeAre, ref string whereItIs)
        {
            // Recursive function that looks for a particular type of attribute (findThis), belonging to
            // a particular JMSML entity (forThis) in the specified graphic folder object (inThis).
            // If it's found we return the path we found it at (whereItIs) all the way up the recursion chain,
            // based on a path string we've been building as we recurse (whereWeAre).
            // If we don't find it, we continue with a depth first search until we do find it or run
            // out of graphic folders to search.

            bool foundIt = false;

            if (inThis != null)
            {
                // First look for what we are searching for in this folder
                // If it is here then append this folder's name to our path
                // and return immediately.

                whereWeAre = whereWeAre + "\\" + inThis.Name;

                // Based on what we are looking for, here is where we check
                // the current folder for the attribute value we want.

                switch (findThis)
                {
                    case FindEnum.FindAuxiliaryEquipment:
                        foundIt = inThis.AuxiliaryEquipment;
                        break;

                    case FindEnum.FindEchelons:
                        foundIt = inThis.Echelons;
                        break;

                    case FindEnum.FindEntities:
                        if (inThis.Entities != null)
                        {
                            foundIt = _splitAndSearch(inThis.Entities, forThis);
                        }
                        break;

                    case FindEnum.FindFrames:
                        if (inThis.Frames != null)
                        {
                            foundIt = _splitAndSearch(inThis.Frames, forThis);
                        }
                        break;

                    case FindEnum.FindHQTFFD:
                        foundIt = inThis.HQTFFD;
                        break;

                    case FindEnum.FindMobilities:
                        foundIt = inThis.Mobilities;
                        break;

                    case FindEnum.FindModifierOnes:
                        if (inThis.ModifierOnes != null)
                        {
                            foundIt = _splitAndSearch(inThis.ModifierOnes, forThis);
                        }
                        break;

                    case FindEnum.FindModifierTwos:
                        if (inThis.ModifierTwos != null)
                        {
                            foundIt = _splitAndSearch(inThis.ModifierTwos, forThis);
                        }
                        break;

                    case FindEnum.FindSpecials:
                        foundIt = inThis.Specials;
                        break;

                    case FindEnum.FindOCA:
                        foundIt = inThis.OCA;
                        break;
                }

                if (foundIt)
                {
                    // We found it here so lets determine where we are so
                    // we can return that information up the recursion chain.

                    whereItIs = whereWeAre;
                }
                else
                {
                    // No luck finding it here, so let's look deeper

                    if (inThis.GraphicFolder != null)
                    {
                        foreach (GraphicFolderType childFolder in inThis.GraphicFolder)
                        {
                            foundIt = _findIt(findThis, forThis, childFolder, whereWeAre, ref whereItIs);

                            if (foundIt)
                                break;
                        }
                    }
                }
            }

            return foundIt;
        }
        public string GetPath(string getWhat, FindEnum ofType, bool sansLeadingSlash = false)
        {
            // The public entry point for retrieving and returning a file path
            // string from the various Dictionarys that hold them.

            string result = "";

            switch (ofType)
            {
                case FindEnum.FindAuxiliaryEquipment:
                    result = _getPath("JMSML_AUXILIARY", _basePaths);
                    break;

                case FindEnum.FindEchelons:
                    result = _getPath("JMSML_ECHELONS", _basePaths);
                    break;

                case FindEnum.FindEntities:
                    result = _getPath(getWhat, _entityPaths);
                    break;

                case FindEnum.FindFrames:
                    result = _getPath(getWhat, _framePaths);
                    break;

                case FindEnum.FindHQTFFD:
                    result = _getPath("JMSML_HQTFDUMMIES", _basePaths);
                    break;

                case FindEnum.FindMobilities:
                    result = _getPath("JMSML_MOBILITIES", _basePaths);
                    break;

                case FindEnum.FindModifierOnes:
                    result = _getPath(getWhat, _modifierOnePaths);
                    break;

                case FindEnum.FindModifierTwos:
                    result = _getPath(getWhat, _modifierTwoPaths);
                    break;

                case FindEnum.FindSpecials:
                    result = _getPath("JMSML_SPECIALS", _basePaths);
                    break;

                case FindEnum.FindOCA:
                    result = _getPath("JMSML_OCA", _basePaths);
                    break;
            }

            if (result.Length > 1 && sansLeadingSlash)
                result = result.Substring(1);

            return result;
        }