public ReplaceControl(StringArgs args)
 {
     InitializeComponent();
     myArgs = args as ReplaceArgs;
     Replace_From_TextBox.Text = myArgs.From;
     Replace_To_TextBox.Text   = myArgs.To;
 }
 public ReplaceStringDialog(StringArgs Arguments)
 {
     InitializeComponent();
     args             = Arguments as ReplaceArgs;
     FromTextBox.Text = args.From;
     ToTextBox.Text   = args.To;
 }
 public ReplaceOperation()
 {
     Args = new ReplaceArgs()
     {
         From = "<edit>",
         To   = "<edit>"
     };
 }
 public ReplaceConfigDialog(StringArgs args)
 {
     InitializeComponent();
     //Lấy from và to(cũ) từ ReplaceArgs hiện lên dialog
     myArgs           = args as ReplaceArgs;
     fromTextBox.Text = myArgs.From;
     toTextBox.Text   = myArgs.To;
 }
 public ReplaceDialog(ReplaceArgs args)
 {
     InitializeComponent();
     if (args != null)
     {
         fromTextBox.Text = args.From;
         toTextBox.Text   = args.To;
     }
 }
Beispiel #6
0
        private void btnSavePreset_Click(object sender, RoutedEventArgs e)
        {
            var screen = new FillinFileNameDialog();

            if (screen.ShowDialog() == true)
            {
                var filename = screen.FileName + ".txt";
                var writer   = new StreamWriter(filename);

                foreach (StringOperation action in ActionListBox.Items)
                {
                    switch (action.Name)
                    {
                    case "Replace":
                    {
                        ReplaceArgs temp = action.Args as ReplaceArgs;
                        writer.WriteLine($"{action.Name}|{temp.From}|{temp.To}");
                        break;
                    }

                    case "NewCase":
                    {
                        NewCaseArgs temp = action.Args as NewCaseArgs;
                        writer.WriteLine($"{action.Name}|{temp.From}");
                        break;
                    }

                    case "Fullname Normalize":
                    {
                        FullnameNormalizeArgs temp = action.Args as FullnameNormalizeArgs;
                        writer.WriteLine($"{action.Name}|{temp.From}");
                        break;
                    }

                    case "Move":
                    {
                        MoveArgs temp = action.Args as MoveArgs;
                        writer.WriteLine($"{action.Name}|{temp.From}");
                        break;
                    }
                    }
                }
                writer.Close();
                loadPresetFile();
            }
        }
Beispiel #7
0
        private void Save_ListAction_Button_Click(object sender, RoutedEventArgs e)
        {
            // save file dialog
            System.Windows.Forms.SaveFileDialog saveFileDialog = new System.Windows.Forms.SaveFileDialog()
            {
                Title            = "Save text Files",
                CheckPathExists  = true,
                DefaultExt       = "txt",
                Filter           = "Text files (*.txt)|*.txt|All files (*.*)|*.*",
                FilterIndex      = 2,
                RestoreDirectory = true,
            };

            // get filename
            string filename = "";

            if (saveFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                filename = saveFileDialog.FileName;


                var writer = new StreamWriter(filename);
                // Dong dau tien la luot di hien tai

                foreach (var item in _actions)
                {
                    string mySaveArgs = "";
                    string args       = item.Args.ToString();

                    //args.CompareTo(Replace) == 1
                    if (args == Replace)
                    {
                        ReplaceArgs saveargs = item.Args as ReplaceArgs;
                        mySaveArgs = Replace + " From:" + saveargs.From + " To:" + saveargs.To + " " + saveargs.ReplaceName.ToString();
                        writer.WriteLine(mySaveArgs);
                    }
                    if (args == Move)
                    {
                        MoveArgs saveargs = item.Args as MoveArgs;
                        mySaveArgs = Move + " " + saveargs.Start + " " + saveargs.End + " " + saveargs.Before.ToString();
                        writer.WriteLine(mySaveArgs);
                    }
                    if (args == Newcase)
                    {
                        NewCaseArgs saveargs = item.Args as NewCaseArgs;
                        mySaveArgs = Newcase + " " + saveargs.optionNewCase.ToString();
                        writer.WriteLine(mySaveArgs);
                    }
                    if (args == Unique)
                    {
                        UniqueNameArgs saveargs = item.Args as UniqueNameArgs;
                        mySaveArgs = Unique;
                        writer.WriteLine(mySaveArgs);
                    }
                    if (args == Normalize)
                    {
                        FullnameNormalizeArg saveargs = item.Args as FullnameNormalizeArg;
                        mySaveArgs = Normalize;
                        writer.WriteLine(mySaveArgs);
                    }
                }
                writer.Close();
            }
        }