summaryrefslogtreecommitdiff
path: root/C64ConfigForm.cs
blob: dd237e511107c26ac71571356d4ab48b16fce3ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
// Base plugin for GfxEd8
// Copyright (C) 2004  Ian Cowburn
// 
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
// 
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
// 
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
//
// $Id$
//
using System;
using System.Windows.Forms;
using System.IO;
using GfxEdInterface;

namespace GfxEdBasePlugin
{
	/// <summary>
	/// Description of ConfigForm.	
	/// </summary>
	public class C64ConfigForm : System.Windows.Forms.Form, IConfig
	{
		private System.Windows.Forms.RadioButton m_bas;
		private System.Windows.Forms.GroupBox m_typeGroup;
		private System.Windows.Forms.Button m_ok;
		private System.Windows.Forms.RadioButton m_asm;
		private System.Windows.Forms.RadioButton m_C;

		public enum ExportFormat {Assembly, Basic, C};
		
		public C64ConfigForm()
		{
			//
			// The InitializeComponent() call is required for Windows Forms designer support.
			//
			InitializeComponent();
		}
		
		public ExportFormat Format
		{
			get
			{
				if (m_asm.Checked)
				{
					return ExportFormat.Assembly;
				}
				else if (m_bas.Checked)
				{
					return ExportFormat.Basic;
				}

				return ExportFormat.C;
			}
			
			set
			{
				foreach (RadioButton r in m_typeGroup.Controls)
				{
					r.Checked=false;
				}
				
				switch(value)
				{
					case ExportFormat.Assembly:
						m_asm.Checked=true;
						break;
						
					case ExportFormat.Basic:
						m_bas.Checked=true;
						break;
						
					case ExportFormat.C:
						m_C.Checked=true;
						break;
				}
			}
		}
		
		public void Settings(Form parent)
		{
			ShowDialog(parent);
		}
		
		public void Output(TextWriter stream)
		{
			stream.WriteLine(Format.ToString());
		}
		
		public void Input(TextReader stream)
		{
			string s=stream.ReadLine();
			
			Format=(ExportFormat)Enum.Parse(typeof(ExportFormat),s);
		}
		
		#region Windows Forms Designer generated code
		/// <summary>
		/// This method is required for Windows Forms designer support.
		/// Do not change the method contents inside the source code editor. The Forms designer might
		/// not be able to load this method if it was changed manually.
		/// </summary>
		private void InitializeComponent() {
			this.m_C = new System.Windows.Forms.RadioButton();
			this.m_asm = new System.Windows.Forms.RadioButton();
			this.m_ok = new System.Windows.Forms.Button();
			this.m_typeGroup = new System.Windows.Forms.GroupBox();
			this.m_bas = new System.Windows.Forms.RadioButton();
			this.m_typeGroup.SuspendLayout();
			this.SuspendLayout();
			// 
			// m_C
			// 
			this.m_C.Location = new System.Drawing.Point(8, 72);
			this.m_C.Name = "m_C";
			this.m_C.Size = new System.Drawing.Size(120, 16);
			this.m_C.TabIndex = 2;
			this.m_C.Text = "C";
			// 
			// m_asm
			// 
			this.m_asm.Checked = true;
			this.m_asm.Location = new System.Drawing.Point(8, 24);
			this.m_asm.Name = "m_asm";
			this.m_asm.Size = new System.Drawing.Size(72, 16);
			this.m_asm.TabIndex = 0;
			this.m_asm.TabStop = true;
			this.m_asm.Text = "Assembly";
			// 
			// m_ok
			// 
			this.m_ok.Location = new System.Drawing.Point(56, 112);
			this.m_ok.Name = "m_ok";
			this.m_ok.Size = new System.Drawing.Size(96, 24);
			this.m_ok.TabIndex = 0;
			this.m_ok.Text = "OK";
			this.m_ok.Click += new System.EventHandler(this.OnOK);
			// 
			// m_typeGroup
			// 
			this.m_typeGroup.Controls.Add(this.m_C);
			this.m_typeGroup.Controls.Add(this.m_bas);
			this.m_typeGroup.Controls.Add(this.m_asm);
			this.m_typeGroup.Location = new System.Drawing.Point(8, 8);
			this.m_typeGroup.Name = "m_typeGroup";
			this.m_typeGroup.Size = new System.Drawing.Size(144, 96);
			this.m_typeGroup.TabIndex = 1;
			this.m_typeGroup.TabStop = false;
			this.m_typeGroup.Text = "Export Type";
			// 
			// m_bas
			// 
			this.m_bas.Location = new System.Drawing.Point(8, 48);
			this.m_bas.Name = "m_bas";
			this.m_bas.Size = new System.Drawing.Size(128, 16);
			this.m_bas.TabIndex = 1;
			this.m_bas.Text = "Basic (ASCII format)";
			// 
			// C64ConfigForm
			// 
			this.AcceptButton = this.m_ok;
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(162, 143);
			this.ControlBox = false;
			this.Controls.Add(this.m_typeGroup);
			this.Controls.Add(this.m_ok);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
			this.Name = "C64ConfigForm";
			this.ShowInTaskbar = false;
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
			this.Text = "Configuration";
			this.m_typeGroup.ResumeLayout(false);
			this.ResumeLayout(false);
		}
		#endregion
		void OnOK(object sender, System.EventArgs e)
		{
			Close();
		}
		
	}
}