示例#1
0
        private void UniqueName_Button_Click(object sender, RoutedEventArgs e)
        {
            var prototype = new UniqueNameOperation()
            {
                Args = new UniqueNameArgs()
                {
                }
            };
            var action = prototype;

            if (action.Config())
            {
                _actions.Add(action.Clone());
            }
        }
示例#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();
                }
            }
        }