~halega/+junk/sharpdevelop

« back to all changes in this revision

Viewing changes to samples/NAnt/NAnt.AddIn/Src/Gui/NAntAddInOptionPanel.cs

  • Committer: sk
  • Date: 2011-09-10 05:17:57 UTC
  • Revision ID: halega@halega.com-20110910051757-qfouz1llya9m6boy
4.1.0.7915 Release Candidate 1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// SharpDevelop samples
 
2
// Copyright (c) 2007, AlphaSierraPapa
 
3
// All rights reserved.
 
4
//
 
5
// Redistribution and use in source and binary forms, with or without modification, are
 
6
// permitted provided that the following conditions are met:
 
7
//
 
8
// - Redistributions of source code must retain the above copyright notice, this list
 
9
//   of conditions and the following disclaimer.
 
10
//
 
11
// - Redistributions in binary form must reproduce the above copyright notice, this list
 
12
//   of conditions and the following disclaimer in the documentation and/or other materials
 
13
//   provided with the distribution.
 
14
//
 
15
// - Neither the name of the SharpDevelop team nor the names of its contributors may be used to
 
16
//   endorse or promote products derived from this software without specific prior written
 
17
//   permission.
 
18
//
 
19
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS &AS IS& AND ANY EXPRESS
 
20
// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
 
21
// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
 
22
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 
23
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 
24
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
 
25
// IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 
26
// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
27
 
 
28
using System;
 
29
using System.Windows.Forms;
 
30
using ICSharpCode.Core;
 
31
using ICSharpCode.SharpDevelop.Gui;
 
32
using ICSharpCode.SharpDevelop.Gui.OptionPanels;
 
33
 
 
34
namespace ICSharpCode.NAnt.Gui
 
35
{
 
36
        /// <summary>
 
37
        /// Options panel for the NAnt add-in.
 
38
        /// </summary>
 
39
        public class NAntAddInOptionPanel : XmlFormsOptionPanel
 
40
        {
 
41
                static readonly string commandTextBoxName = "nantCommandTextBox";
 
42
                static readonly string argumentsTextBoxName = "argumentsTextBox";
 
43
                static readonly string verboseCheckBoxName = "verboseCheckBox";
 
44
                static readonly string browseButtonName = "browseButton";
 
45
                static readonly string showLogoCheckBoxName = "showLogoCheckBox";
 
46
                static readonly string quietCheckBoxName = "quietCheckBox";
 
47
                static readonly string debugModeCheckBoxName = "debugModeCheckBox";
 
48
                
 
49
                public override void LoadPanelContents()
 
50
                {
 
51
                        SetupFromXmlStream(this.GetType().Assembly.GetManifestResourceStream("ICSharpCode.NAnt.Resources.NAntAddInOptionPanel.xfrm"));
 
52
                                                                
 
53
                        ControlDictionary[commandTextBoxName].Text = AddInOptions.NAntFileName;
 
54
                        ControlDictionary[argumentsTextBoxName].Text = AddInOptions.NAntArguments;
 
55
                        ((CheckBox)ControlDictionary[verboseCheckBoxName]).Checked = AddInOptions.Verbose;
 
56
                        ((CheckBox)ControlDictionary[showLogoCheckBoxName]).Checked = AddInOptions.ShowLogo;
 
57
                        ((CheckBox)ControlDictionary[quietCheckBoxName]).Checked = AddInOptions.Quiet;
 
58
                        ((CheckBox)ControlDictionary[debugModeCheckBoxName]).Checked = AddInOptions.DebugMode;
 
59
                        
 
60
                        ControlDictionary[browseButtonName].Click += new EventHandler(OnBrowse);
 
61
                }
 
62
                
 
63
                public override bool StorePanelContents()
 
64
                {                                       
 
65
                        AddInOptions.NAntFileName = ControlDictionary[commandTextBoxName].Text;
 
66
                        AddInOptions.NAntArguments = ControlDictionary[argumentsTextBoxName].Text;
 
67
                        AddInOptions.Verbose = ((CheckBox)ControlDictionary[verboseCheckBoxName]).Checked;
 
68
                        AddInOptions.ShowLogo = ((CheckBox)ControlDictionary[showLogoCheckBoxName]).Checked;
 
69
                        AddInOptions.Quiet = ((CheckBox)ControlDictionary[quietCheckBoxName]).Checked;
 
70
                        AddInOptions.DebugMode = ((CheckBox)ControlDictionary[debugModeCheckBoxName]).Checked;
 
71
                        
 
72
                        return true;
 
73
                }
 
74
                
 
75
                /// <summary>
 
76
                /// Allows the user to browse for the NAnt executable.
 
77
                /// </summary>
 
78
                void OnBrowse(object sender, EventArgs e)
 
79
                {
 
80
                        using (OpenFileDialog openFileDialog  = new OpenFileDialog()) {
 
81
                                
 
82
                                openFileDialog.CheckFileExists = true;
 
83
                                openFileDialog.Filter = StringParser.Parse("${res:SharpDevelop.FileFilter.ExecutableFiles}|*.exe|${res:SharpDevelop.FileFilter.AllFiles}|*.*");
 
84
                                
 
85
                                if (openFileDialog.ShowDialog() == DialogResult.OK) {
 
86
                                        ControlDictionary[commandTextBoxName].Text = openFileDialog.FileName;
 
87
                                }
 
88
                        }                       
 
89
                }
 
90
        }
 
91
}