예제 #1
0
 public static void LoadDataPacks()
 {
     dataPacks.Clear();
     locDataPacks.Clear();
     System.Collections.Specialized.StringCollection sc = setting.dataPacks;
     dataPacks.AddRange(sc.Cast <string>().Distinct());
     sc = setting.locDataPacks;
     locDataPacks.AddRange(sc.Cast <string>().Distinct());
 }
 public static ConcurrentDictionary <int, T> Parse <T>(
     System.Collections.Specialized.StringCollection collection,
     Func <string, T> valueSelector, bool substituteNull = true)
 {
     return(new ConcurrentDictionary <int, T>(collection.Cast <string>()
                                              .Select(x => ParseMapping(x, valueSelector, substituteNull))));
 }
        /// <summary>DropInfoをファイルパスのリストに変換する</summary>
        /// <param name="dropInfo">変換元ファイル</param>
        /// <param name="filePathList">変換後のファイルパス(絶対パス)リスト</param>
        /// <returns>true:成功, false:失敗/異常</returns>
        private bool ConvertDropInfoToPathList(IDropInfo dropInfo, out List <string> filePathList)
        {
            filePathList = new List <string>();

            if (dropInfo == null)
            {
                Logger.Fatal(CLASS_NAME, "ConvertDropInfoToPathList", "dropInfo is null!");
                return(false);
            }

            System.Windows.DataObject dragOverFiles = (System.Windows.DataObject)dropInfo.Data;
            if (dragOverFiles == null)
            {
                Logger.Fatal(CLASS_NAME, "ConvertDropInfoToPathList", "dragOverFiles are null!");
                return(false);
            }

            System.Collections.Specialized.StringCollection dragOverFileList = dragOverFiles.GetFileDropList();
            if (dragOverFileList == null || dragOverFileList.Count < 1)
            {
                Logger.Fatal(CLASS_NAME, "ConvertDropInfoToPathList", "dragOverFileList is invalid!");
                return(false);
            }

            filePathList = dragOverFileList.Cast <string>().ToList();
            if (filePathList == null || filePathList.Any() == false)
            {
                Logger.Fatal(CLASS_NAME, "ConvertDropInfoToPathList", "filePathList is invalid!");
                return(false);
            }

            return(true);
        }
예제 #4
0
 static void FindSixLetterWords(Document document)
 {
     #region #FindSixLetterWords
     document.LoadDocument("Documents//Grimm.docx", DevExpress.XtraRichEdit.DocumentFormat.OpenXml);
     document.InsertSection(document.Range.Start);
     // Specify a regular expression that will find all six letter words.
     System.Text.RegularExpressions.Regex expr =
         new System.Text.RegularExpressions.Regex("\\b\\w{6}\\b");
     System.Collections.Specialized.StringCollection sixLetterWords =
         new System.Collections.Specialized.StringCollection();
     // Perform the search.
     DocumentRange[] found = document.FindAll(expr);
     foreach (DocumentRange r in found)
     {
         sixLetterWords.Add(document.GetText(r));
     }
     document.BeginUpdate();
     // Insert an ordered list of non-repetitive words in the beginning of the document.
     var distinctWords = sixLetterWords.Cast <string>().Distinct().OrderByDescending(s => s);
     foreach (var s in distinctWords)
     {
         document.InsertText(document.Range.Start, s.ToString() + Environment.NewLine);
     }
     document.EndUpdate();
     #endregion #FindSixLetterWords
 }
예제 #5
0
        internal static List <String> GetFavourCityList()
        {
            System.Collections.Specialized.StringCollection cities = Properties.app.Default.FavourCityList;

            List <String> newCities = cities.Cast <String>().ToList();

            return(newCities);
        }
예제 #6
0
        private void BtnSave_Click(object sender, EventArgs e)
        {
            Properties.Settings.Default.LabwareSetup = this.LabwareSetup;
            System.Collections.Specialized.StringCollection LabwareSetupNew = Properties.Settings.Default.LabwareSetup;
            string sourceDir = Path.Combine(Directory.GetCurrentDirectory(), "Labware\\" + "setup");

            File.WriteAllLines(sourceDir, LabwareSetupNew.Cast <string>());
            uploadSetup();
            this.Close();
        }
예제 #7
0
        /*******************************************************************************************************************\
        *                                                                                                                 *
        \*******************************************************************************************************************/

        static public string FindKeyInCollection(System.Collections.Specialized.StringCollection col, string key)
        {
            string a   = string.Join(";", col.Cast <string>().ToArray());
            var    dic = a
                         .Split(';')
                         .Select(part => part.Split(':'))
                         .Where(part => part.Length == 2)
                         .ToDictionary(sp => sp[0], sp => sp[1]);

            if (dic.ContainsKey(key))
            {
                return(dic[key]);
            }
            return("");
        }
예제 #8
0
        public EsfTabPageArmy()
            : base()
        {
            InitializeComponent();
            this.SuspendLayout();
            this.tableLayoutPanel1.SuspendLayout();

            System.Collections.Specialized.StringCollection sc = GameInfo.setting.army_filter;
            comboBoxFilter.Items.AddRange(sc.Cast <string>().ToArray());

            this.tableLayoutPanel1.RowCount = 2;
            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
            this.tableLayoutPanel1.Controls.Add(this.tableLayoutPanel4, 0, 1);
            this.tableLayoutPanel1.ResumeLayout(true);
            this.ResumeLayout(true);
        }
예제 #9
0
        static void Main(string[] args)
        {
            //Get paths to the files
            var sPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\";

            sProdList     = sPath + sProdList;
            sFileList     = sPath + sFileList;
            sProdFiles    = sPath + sProdFiles;
            sFilesReport  = sPath + sFilesReport;
            sFilesMatched = sPath + sFilesMatched;

            //Check destination folder for images
            if (!System.IO.Directory.Exists(sFilesMatched))
            {
                System.IO.Directory.CreateDirectory(sFilesMatched);
            }

            //load the CSV file
            foreach (string sLine in System.IO.File.ReadLines(sProdList))
            {
                if (sLine == null)
                {
                    continue;                  // ignore empty lines
                }
                arCsvLines.Add(sLine + ",\""); //build the list with a separator for an additional col where the file names will go
            }
            ;

            //read the list of file names and try to find matches
            foreach (string sLine in System.IO.File.ReadLines(sFileList))
            {
                if (sLine == null)
                {
                    continue;                                                                               // ignore empty lines
                }
                string sku     = System.IO.Path.GetFileNameWithoutExtension(sLine).Split('_')[0].ToLower(); // get product code part from the first column
                string sku6    = (sku.Length > 6) ? sku.Substring(0, 6) : sku;                              // some codes have suffixes not found in the CSV
                bool   ismatch = false;

                // match line by line
                for (int i = 0; i < arCsvLines.Count; i++)
                {
                    string sCsvLine = arCsvLines[i];
                    if (sCsvLine.ToLower().Contains(sku) || sCsvLine.ToLower().Contains(sku6))
                    {
                        //there is a match - add the file name to the CSV
                        arCsvLines[i] += sLine + "\n";
                        ismatch        = true;
                    }
                }

                //copy the files to the appropriate folder
                foreach (string sSourceFileName in System.IO.Directory.GetFiles(sFilesSource, sLine, System.IO.SearchOption.AllDirectories))
                {
                    if (ismatch)
                    {
                        // move the file to matched folder
                        string fileTarget = sFilesMatched + sLine;
                        if (!System.IO.File.Exists(fileTarget))
                        {
                            System.IO.File.Move(sSourceFileName, fileTarget);
                        }
                        else
                        {
                            System.IO.File.Delete(sSourceFileName); // just in case the same file exists in more than one copy
                        }
                    }
                }

                //add the file name to the report
                arFilesReport.Add(sLine + "," + ((ismatch) ? "1" : "0"));
            }
            ;

            // Close the open lines and remove trailing CR
            for (int i = 0; i < arCsvLines.Count; i++)
            {
                arCsvLines[i] = arCsvLines[i].TrimEnd('\n') + "\"";
            }



            // save the CSV with the file names
            System.IO.File.WriteAllLines(sProdFiles, arCsvLines.Cast <string>());

            // save the CSV with the file report - which files were used and which were not
            System.IO.File.WriteAllLines(sFilesReport, arFilesReport.Cast <string>());
        }