0:   //  ExternalTool.cs
1:   //  Copyright (c) 2001 Mike Krueger
2:   //
3:   //  This program is free software; you can redistribute it and/or modify
4:   //  it under the terms of the GNU General Public License as published by
5:   //  the Free Software Foundation; either version 2 of the License, or
6:   //  (at your option) any later version.
7:   //
8:   //  This program is distributed in the hope that it will be useful,
9:   //  but WITHOUT ANY WARRANTY; without even the implied warranty of
10:   //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11:   //  GNU General Public License for more details.
12:   //
13:   //  You should have received a copy of the GNU General Public License
14:   //  along with this program; if not, write to the Free Software
15:   //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16:  
17:   using System;
18:   using System.Reflection;
19:   using System.Collections;
20:   using System.Drawing;
21:   using System.IO;
22:   using System.ComponentModel;
23:   using System.Windows.Forms;
24:   using System.Xml;
25:   using System.Diagnostics;
26:  
27:   namespace SharpDevelop.Internal.ExternalTool {
28:       
29:       /// <summary>
30:       /// This class describes an external tool, which is a external program
31:       /// that can be launched from the toolmenu inside Sharp Develop.
32:       /// </summary>
33:       public class ExternalTool
34:       {
35:           string menuCommand       "New Tool";
36:           string command           "";
37:           string arguments         "";
38:           string initialDirectory  "";
39:           bool   promptForArguments false;
40:           
41:           public string MenuCommand {
42:               get {
43:                   return menuCommand;
44:               }
45:               set {
46:                   menuCommand value;
47:                   Debug.Assert(menuCommand != null"SharpDevelop.Internal.ExternalTool.ExternalTool : string MenuCommand == null");
48:               }
49:           }
50:           
51:           public string Command {
52:               get {
53:                   return command;
54:               }
55:               set {
56:                   command value;
57:                   Debug.Assert(command != null"SharpDevelop.Internal.ExternalTool.ExternalTool : string Command == null");
58:               }
59:           }
60:           
61:           public string Arguments {
62:               get {
63:                   return arguments;
64:               }
65:               set {
66:                   arguments value;
67:                   Debug.Assert(arguments != null"SharpDevelop.Internal.ExternalTool.ExternalTool : string Arguments == null");
68:               }
69:           }
70:           
71:           public string InitialDirectory {
72:               get {
73:                   return initialDirectory;
74:               }
75:               set {
76:                   initialDirectory value;
77:                   Debug.Assert(initialDirectory != null"SharpDevelop.Internal.ExternalTool.ExternalTool : string InitialDirectory == null");
78:               }
79:           }
80:           
81:           public bool PromptForArguments {
82:               get {
83:                   return promptForArguments;
84:               }
85:               set {
86:                   promptForArguments value;
87:               }
88:           }
89:           
90:           public ExternalTool() 
91:           {
92:           }
93:           
94:           public ExternalTool(XmlElement el)
95:           {
96:               if (el == null) {
97:                   throw new ArgumentNullException("ExternalTool(XmlElement el) : el can't be null");
98:               }
99:               
100:               if (el["INITIALDIRECTORY"] == null ||
101:                   el["ARGUMENTS"] == null ||
102:                   el["COMMAND"] == null ||
103:                   el["MENUCOMMAND"] == null || 
104:                   el["PROMPTFORARGUMENTS"] == null) {
105:                   throw new Exception("ExternalTool(XmlElement el) : INITIALDIRECTORY and ARGUMENTS and COMMAND and MENUCOMMAND and PROMPTFORARGUMENTS attributes must exist.(check the ExternalTool XML)");
106:               }
107:               
108:               InitialDirectory  el["INITIALDIRECTORY"].InnerText;
109:               Arguments         el["ARGUMENTS"].InnerText;
110:               Command           el["COMMAND"].InnerText;
111:               MenuCommand       el["MENUCOMMAND"].InnerText;
112:               
113:               PromptForArguments Boolean.Parse(el["PROMPTFORARGUMENTS"].InnerText);
114:               
115:           }
116:           
117:           public override string ToString()
118:           {
119:               return menuCommand;
120:           }
121:           
122:           public XmlElement ToXmlElement(XmlDocument doc)
123:           {
124:               if (doc == null) {
125:                   throw new ArgumentNullException("ExternalTool.ToXmlElement(XmlDocument doc) : doc can't be null");
126:               }
127:               
128:               XmlElement el doc.CreateElement("TOOL");
129:               
130:               XmlElement x doc.CreateElement("INITIALDIRECTORY");
131:               x.InnerText InitialDirectory;
132:               el.AppendChild(x);
133:               
134:               x doc.CreateElement("ARGUMENTS");
135:               x.InnerText Arguments;
136:               el.AppendChild(x);
137:               
138:               x doc.CreateElement("COMMAND");
139:               x.InnerText command;
140:               el.AppendChild(x);
141:               
142:               x doc.CreateElement("MENUCOMMAND");
143:               x.InnerText MenuCommand;
144:               el.AppendChild(x);
145:               
146:               x doc.CreateElement("PROMPTFORARGUMENTS");
147:               x.InnerText PromptForArguments.ToString();
148:               el.AppendChild(x);
149:               
150:               return el;
151:           }
152:       }
153:   }
154:  

This page was automatically generated by SharpDevelop.