source: trunk/eraser/Eraser.DefaultPlugins/ErasureTargets/FileErasureTargetConfigurer.cs @ 2070

Revision 2070, 2.7 KB checked in by lowjoel, 5 years ago (diff)

Apply themes for the target configurers.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
Line 
1/*
2 * $Id$
3 * Copyright 2008-2010 The Eraser Project
4 * Original Author: Joel Low <lowjoel@users.sourceforge.net>
5 * Modified By:
6 *
7 * This file is part of Eraser.
8 *
9 * Eraser is free software: you can redistribute it and/or modify it under the
10 * terms of the GNU General Public License as published by the Free Software
11 * Foundation, either version 3 of the License, or (at your option) any later
12 * version.
13 *
14 * Eraser is distributed in the hope that it will be useful, but WITHOUT ANY
15 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
17 *
18 * A copy of the GNU General Public License can be found at
19 * <http://www.gnu.org/licenses/>.
20 */
21
22using System;
23using System.Collections.Generic;
24using System.ComponentModel;
25using System.Drawing;
26using System.Data;
27using System.Linq;
28using System.Text;
29using System.Windows.Forms;
30
31using System.Text.RegularExpressions;
32
33using Eraser.Manager;
34using Eraser.Util;
35
36namespace Eraser.DefaultPlugins
37{
38    public partial class FileErasureTargetConfigurer : UserControl, IErasureTargetConfigurer
39    {
40        public FileErasureTargetConfigurer()
41        {
42            InitializeComponent();
43            Theming.ApplyTheme(this);
44        }
45
46        #region IConfigurer<ErasureTarget> Members
47
48        public void LoadFrom(ErasureTarget target)
49        {
50            FileErasureTarget file = target as FileErasureTarget;
51            if (file == null)
52                throw new ArgumentException("The provided erasure target type is not " +
53                    "supported by this configurer.");
54
55            filePath.Text = file.Path;
56        }
57
58        public bool SaveTo(ErasureTarget target)
59        {
60            FileErasureTarget file = target as FileErasureTarget;
61            if (file == null)
62                throw new ArgumentException("The provided erasure target type is not " +
63                    "supported by this configurer.");
64
65            if (filePath.Text.Length == 0)
66            {
67                errorProvider.SetError(filePath, S._("Invalid file path"));
68                return false;
69            }
70
71            file.Path = filePath.Text;
72            return true;
73        }
74
75        #endregion
76
77        #region ICliConfigurer<ErasureTarget> Members
78
79        public void Help()
80        {
81            throw new NotImplementedException();
82        }
83
84        public bool ProcessArgument(string argument)
85        {
86            Regex regex = new Regex("file=(?<fileName>.*)",
87                RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.RightToLeft);
88            Match match = regex.Match(argument);
89
90            if (match.Groups["fileName"].Success)
91            {
92                filePath.Text = match.Groups["fileName"].Value;
93                return true;
94            }
95
96            return false;
97        }
98
99        #endregion
100
101        private void fileBrowse_Click(object sender, EventArgs e)
102        {
103            fileDialog.FileName = filePath.Text;
104            if (fileDialog.ShowDialog() == DialogResult.OK)
105                filePath.Text = fileDialog.FileName;
106        }
107    }
108}
Note: See TracBrowser for help on using the repository browser.