Example #1
0
        private void FullNameNormalize_Button_Click(object sender, RoutedEventArgs e)
        {
            var prototype = new FullnameNormalizeOperation()
            {
                Args = new FullnameNormalizeArg()
                {
                }
            };
            var action = prototype;

            if (action.Config())
            {
                _actions.Add(action.Clone());
            }
        }
Example #2
0
        private void LoadFromFile_Button_Click(object sender, RoutedEventArgs e)
        {
            string         line     = "";
            OpenFileDialog openFile = new OpenFileDialog();

            if (openFile.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                _actions.Clear();
                var reader = new StreamReader(openFile.FileName);
                line = reader.ReadLine();
                while (line != null)
                {
                    var tokens = line.Split(new string[] { " " }, StringSplitOptions.None);
                    {
                        if (tokens[0] == Replace)
                        {
                            string firstString  = tokens[1].Substring(0, 5).Trim();
                            string secondString = tokens[1].Substring(5).Trim();
                            tokens[1] = secondString;

                            string firstString1  = tokens[2].Substring(0, 3).Trim();
                            string secondString1 = tokens[2].Substring(3).Trim();
                            tokens[2] = secondString1;


                            bool temp = false;
                            if (tokens[3] == "True")
                            {
                                temp = true;
                            }

                            var prototype = new ReplaceOperation()
                            {
                                Args = new ReplaceArgs
                                {
                                    From        = tokens[1],
                                    To          = tokens[2],
                                    ReplaceName = temp
                                }
                            };
                            var action = prototype;
                            _actions.Add(action.Clone());
                        }
                        else
                        {
                            if (tokens[0] == Move)
                            {
                                bool temp;

                                if (tokens[3] == "True")
                                {
                                    temp = true;
                                }
                                else
                                {
                                    temp = false;
                                }
                                var prototype = new MoveOperation()
                                {
                                    Args = new MoveArgs
                                    {
                                        Start  = int.Parse(tokens[1]),
                                        End    = int.Parse(tokens[2]),
                                        Before = temp
                                    }
                                };
                                var action = prototype;
                                _actions.Add(action.Clone());
                            }
                            else
                            {
                                if (tokens[0] == Newcase)
                                {
                                    var prototype = new NewCaseOperation()
                                    {
                                        Args = new NewCaseArgs
                                        {
                                            optionNewCase = int.Parse(tokens[1])
                                        }
                                    };
                                    var action = prototype;
                                    _actions.Add(action.Clone());
                                }
                                else
                                {
                                    if (tokens[0] == Unique)
                                    {
                                        var prototype = new UniqueNameOperation()
                                        {
                                            Args = new UniqueNameArgs
                                            {
                                            }
                                        };
                                        var action = prototype;
                                        _actions.Add(action.Clone());
                                    }
                                    else
                                    {
                                        if (tokens[0] == Normalize)
                                        {
                                            var prototype = new FullnameNormalizeOperation()
                                            {
                                                Args = new FullnameNormalizeArg
                                                {
                                                }
                                            };
                                            var action = prototype;
                                            _actions.Add(action.Clone());
                                        }
                                        else
                                        {
                                            System.Windows.Forms.MessageBox.Show("Khong hop le!!!");
                                        }
                                    }
                                }
                            }
                        }
                    }
                    line = reader.ReadLine();
                }
            }
        }
Example #3
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);
                }
            }
        }
Example #4
0
        private void btnOpenPreset_Click(object sender, RoutedEventArgs e)
        {
            List <StringOperation> result = new List <StringOperation>();

            var screen = new OpenFileDialog();

            if (screen.ShowDialog() == true)
            {
                var filename = screen.FileName;
                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);
            }
        }