예제 #1
0
        private void loadPresetFile()
        {
            presetComboBox.Items.Clear();
            string path = $"{AppDomain.CurrentDomain.BaseDirectory}";

            string[] filePreset = Directory.GetFiles(path, "*.txt");

            foreach (string preset in filePreset)
            {
                string[] tokens     = preset.Split(new string[] { "\\" }, StringSplitOptions.None);
                string[] tokendots  = tokens[tokens.Length - 1].Split(new string[] { "." }, StringSplitOptions.None);
                string   extensions = tokendots[tokendots.Length - 1];

                InfoFile temp = new InfoFile();
                for (int i = 0; i < tokens.Length - 1; i++)
                {
                    temp.Path += tokens[i] + "\\";
                }
                temp.Name = tokendots[0];
                presetComboBox.Items.Add(temp);
            }
        }
예제 #2
0
        private void presetChange(object sender, SelectionChangedEventArgs e)
        {
            InfoFile selected = presetComboBox.SelectedItem as InfoFile;

            if (selected != null)
            {
                List <StringOperation> result = new List <StringOperation>();
                var filename = selected.Name + ".txt";
                var lines    = File.ReadAllLines(filename);
                foreach (var line in lines)
                {
                    var tokens = line.Split(new string[]
                                            { "|" }, StringSplitOptions.RemoveEmptyEntries);

                    switch (tokens[0].ToString())
                    {
                    case "Replace":
                    {
                        ReplaceOperation replace = new ReplaceOperation()
                        {
                            Args = new ReplaceArgs()
                            {
                                From = tokens[1], To = tokens[2]
                            }
                        };
                        result.Add(replace);
                        break;
                    }

                    case "NewCase":
                    {
                        NewCaseOperation newcase = new NewCaseOperation()
                        {
                            Args = new NewCaseArgs()
                            {
                                From = tokens[1],
                            }
                        };
                        result.Add(newcase);
                        break;
                    }

                    case "Fullname Normalize":
                    {
                        FullnameNormalizeOperation newcase = new FullnameNormalizeOperation()
                        {
                            Args = new FullnameNormalizeArgs()
                            {
                                From = tokens[1],
                            }
                        };
                        result.Add(newcase);
                        break;
                    }

                    case "Move":
                    {
                        MoveOperation newcase = new MoveOperation()
                        {
                            Args = new MoveArgs()
                            {
                                From = tokens[1],
                            }
                        };
                        result.Add(newcase);
                        break;
                    }
                    }
                }
                foreach (StringOperation item in result)
                {
                    ActionListBox.Items.Add(item);
                }
            }
        }