Ejemplo n.º 1
0
        private void LoadPreset_Click(object sender, RoutedEventArgs e)
        {
            var screen = new Microsoft.Win32.OpenFileDialog();

            screen.ShowDialog();
            string presetfilename = screen.FileName;

            using (StreamReader reader = new StreamReader(presetfilename))
            {
                string line;
                while ((line = reader.ReadLine()) != null)
                {
                    if (line.Contains("New Case"))
                    {
                        NewCase          action = new NewCase();
                        NewCaseArguments args   = new NewCaseArguments();
                        args.NewCaseName = line.Substring("New Case: New Case with ".Length);
                        action.Args      = args;
                        ActionListBox.Items.Add(action);
                    }
                    if (line.Contains("Move"))
                    {
                        MoveAction    action = new MoveAction();
                        MoveArguments args   = new MoveArguments();
                        args.Position = line.Substring("Move: Move ISBN to ".Length);
                        action.Args   = args;
                        ActionListBox.Items.Add(action);
                    }
                    if (line.Contains("GUID Action"))
                    {
                        GUID          action = new GUID();
                        GUIDArguments args   = new GUIDArguments();
                        action.Args = args;
                        ActionListBox.Items.Add(action);
                    }
                    if (line.Contains("Full Name Normalize"))
                    {
                        FullNameNormalizeAction   action = new FullNameNormalizeAction();
                        FulNameNormalizeArguments args   = new FulNameNormalizeArguments();
                        action.Args = args;
                        ActionListBox.Items.Add(action);
                    }
                    if (line.Contains("Replace action"))
                    {
                        ReplaceAction          action = new ReplaceAction();
                        ReplaceActionArguments args   = new ReplaceActionArguments();
                        args.Needle = line.Substring("Replace action: Replace ".Length, line.IndexOf(" with") - "Replace action: Replace ".Length);
                        args.Hammer = line.Substring(line.IndexOf("with") + "with".Length + 1);
                        action.Args = args;
                        ActionListBox.Items.Add(action);
                    }
                }
            }
        }
 public ReplaceActionDialog(ReplaceActionArguments args)
 {
     InitializeComponent();
     needleTextBox.Text = args.Needle;
     hammerTextBox.Text = args.Hammer;
 }