mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-01-31 04:40:55 +00:00
more work on the custom fields editor
This commit is contained in:
parent
e640dfbc04
commit
c2b5745803
10 changed files with 562 additions and 12 deletions
|
@ -1,8 +1,3 @@
|
|||
- Finish the custom fields editor
|
||||
- Enums should drop down in list
|
||||
- Remember sort order
|
||||
- Strings should have a mutliline edit window on browse button
|
||||
|
||||
- Complete Things filter with UDMF fields
|
||||
|
||||
- Controls to increase/decrease grid size
|
||||
|
|
|
@ -133,6 +133,7 @@
|
|||
<Compile Include="Types\ColorHandler.cs" />
|
||||
<Compile Include="Types\EnumBitsHandler.cs" />
|
||||
<Compile Include="Types\EnumOptionHandler.cs" />
|
||||
<Compile Include="Types\EnumStringsHandler.cs" />
|
||||
<Compile Include="Types\FlatHandler.cs" />
|
||||
<Compile Include="Types\FloatHandler.cs" />
|
||||
<Compile Include="Types\IntegerHandler.cs" />
|
||||
|
@ -319,6 +320,12 @@
|
|||
<Compile Include="Controls\SectorInfoPanel.Designer.cs">
|
||||
<DependentUpon>SectorInfoPanel.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Windows\TextEditForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Windows\TextEditForm.Designer.cs">
|
||||
<DependentUpon>TextEditForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Windows\TextureBrowserForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
|
@ -605,6 +612,10 @@
|
|||
<SubType>Designer</SubType>
|
||||
<DependentUpon>CustomFieldsForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Windows\TextEditForm.resx">
|
||||
<SubType>Designer</SubType>
|
||||
<DependentUpon>TextEditForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Windows\ThingEditForm.resx">
|
||||
<SubType>Designer</SubType>
|
||||
<DependentUpon>ThingEditForm.cs</DependentUpon>
|
||||
|
|
7
Source/Controls/FieldsEditorControl.Designer.cs
generated
7
Source/Controls/FieldsEditorControl.Designer.cs
generated
|
@ -82,6 +82,8 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
this.fieldslist.UserDeletingRow += new System.Windows.Forms.DataGridViewRowCancelEventHandler(this.fieldslist_UserDeletingRow);
|
||||
this.fieldslist.CellBeginEdit += new System.Windows.Forms.DataGridViewCellCancelEventHandler(this.fieldslist_CellBeginEdit);
|
||||
this.fieldslist.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.fieldslist_CellDoubleClick);
|
||||
this.fieldslist.ColumnHeaderMouseClick += new System.Windows.Forms.DataGridViewCellMouseEventHandler(this.fieldslist_ColumnHeaderMouseClick);
|
||||
this.fieldslist.MouseUp += new System.Windows.Forms.MouseEventHandler(this.fieldslist_MouseUp);
|
||||
this.fieldslist.CellEndEdit += new System.Windows.Forms.DataGridViewCellEventHandler(this.fieldslist_CellEndEdit);
|
||||
this.fieldslist.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.fieldslist_CellClick);
|
||||
this.fieldslist.DataError += new System.Windows.Forms.DataGridViewDataErrorEventHandler(this.fieldslist_DataError);
|
||||
|
@ -98,7 +100,7 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
this.fieldname.Frozen = true;
|
||||
this.fieldname.HeaderText = "Property";
|
||||
this.fieldname.Name = "fieldname";
|
||||
this.fieldname.Width = 180;
|
||||
this.fieldname.Width = 150;
|
||||
//
|
||||
// fieldtype
|
||||
//
|
||||
|
@ -137,12 +139,11 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
this.browsebutton.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.browsebutton.Image = global::CodeImp.DoomBuilder.Properties.Resources.treeview;
|
||||
this.browsebutton.ImageAlign = System.Drawing.ContentAlignment.BottomCenter;
|
||||
this.browsebutton.Location = new System.Drawing.Point(370, 46);
|
||||
this.browsebutton.Location = new System.Drawing.Point(343, 75);
|
||||
this.browsebutton.Name = "browsebutton";
|
||||
this.browsebutton.Size = new System.Drawing.Size(28, 26);
|
||||
this.browsebutton.TabIndex = 2;
|
||||
this.browsebutton.UseVisualStyleBackColor = true;
|
||||
this.browsebutton.Visible = false;
|
||||
this.browsebutton.Click += new System.EventHandler(this.browsebutton_Click);
|
||||
//
|
||||
// enumscombo
|
||||
|
|
|
@ -78,6 +78,19 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
fieldtype.Items.AddRange(General.Types.GetCustomUseAttributes());
|
||||
}
|
||||
|
||||
// This applies last sort order
|
||||
private void Sort()
|
||||
{
|
||||
// Sort
|
||||
int sortcolumn = General.Settings.ReadSetting("customfieldssortcolumn", 0);
|
||||
int sortorder = General.Settings.ReadSetting("customfieldssortorder", (int)ListSortDirection.Ascending);
|
||||
|
||||
if(sortorder == (int)SortOrder.Ascending)
|
||||
fieldslist.Sort(fieldslist.Columns[sortcolumn], ListSortDirection.Ascending);
|
||||
else if(sortorder == (int)SortOrder.Descending)
|
||||
fieldslist.Sort(fieldslist.Columns[sortcolumn], ListSortDirection.Descending);
|
||||
}
|
||||
|
||||
// This adds a list of fixed fields (in undefined state)
|
||||
public void ListFixedFields(List<UniversalFieldInfo> list)
|
||||
{
|
||||
|
@ -85,6 +98,9 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
foreach(UniversalFieldInfo uf in list)
|
||||
fieldslist.Rows.Add(new FieldsEditorRow(fieldslist, uf));
|
||||
|
||||
// Sort fields
|
||||
Sort();
|
||||
|
||||
// Update new row
|
||||
SetupNewRowStyle();
|
||||
}
|
||||
|
@ -159,6 +175,9 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
if(!first) frow.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
// Sort fields
|
||||
Sort();
|
||||
}
|
||||
|
||||
// This applies the current fields to a UniFields object
|
||||
|
@ -228,6 +247,24 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
#endregion
|
||||
|
||||
#region ================== Events
|
||||
|
||||
// Column header clicked
|
||||
private void fieldslist_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
|
||||
{
|
||||
// Save sort order
|
||||
if(fieldslist.SortedColumn != null)
|
||||
{
|
||||
int sortcolumn = fieldslist.SortedColumn.Index;
|
||||
int sortorder = (int)fieldslist.SortOrder;
|
||||
General.Settings.WriteSetting("customfieldssortcolumn", sortcolumn);
|
||||
General.Settings.WriteSetting("customfieldssortorder", sortorder);
|
||||
}
|
||||
|
||||
// Stop any cell editing
|
||||
ApplyEnums(true);
|
||||
fieldslist.EndEdit();
|
||||
HideBrowseButton();
|
||||
}
|
||||
|
||||
// Resized
|
||||
private void FieldsEditorControl_Resize(object sender, EventArgs e)
|
||||
|
@ -235,6 +272,7 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
// Rearrange controls
|
||||
fieldslist.Size = this.ClientSize;
|
||||
fieldvalue.Width = fieldslist.ClientRectangle.Width - fieldname.Width - fieldtype.Width - SystemInformation.VerticalScrollBarWidth - 10;
|
||||
UpdateBrowseButton();
|
||||
}
|
||||
|
||||
// Layout change
|
||||
|
@ -328,7 +366,7 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
enumscombo.Items.Clear();
|
||||
enumscombo.Items.AddRange(frow.TypeHandler.GetEnumList().ToArray());
|
||||
enumscombo.Tag = frow;
|
||||
|
||||
|
||||
// Lock combo to enums?
|
||||
if(frow.TypeHandler.IsLimitedToEnums)
|
||||
enumscombo.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
|
@ -357,10 +395,7 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
enumscombo.Text = frow.TypeHandler.GetStringValue();
|
||||
|
||||
// Show combo
|
||||
// Why does it not select all and focus the combobox?
|
||||
enumscombo.Show();
|
||||
enumscombo.Focus();
|
||||
enumscombo.SelectAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -511,6 +546,7 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
// Selection changes
|
||||
private void fieldslist_SelectionChanged(object sender, EventArgs e)
|
||||
{
|
||||
browsebutton.Visible = false;
|
||||
ApplyEnums(true);
|
||||
|
||||
// Update button
|
||||
|
@ -555,6 +591,17 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
fieldslist.EndEdit();
|
||||
HideBrowseButton();
|
||||
}
|
||||
|
||||
// Mouse up event
|
||||
private void fieldslist_MouseUp(object sender, MouseEventArgs e)
|
||||
{
|
||||
// Focus to enums combobox when visible
|
||||
if(enumscombo.Visible)
|
||||
{
|
||||
enumscombo.Focus();
|
||||
enumscombo.SelectAll();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
|
@ -117,6 +117,9 @@
|
|||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="fieldslist.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="fieldname.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
|
@ -129,4 +132,13 @@
|
|||
<metadata name="deleterowstimer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="browsebutton.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="enumscombo.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="$this.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
</root>
|
176
Source/Types/EnumStringsHandler.cs
Normal file
176
Source/Types/EnumStringsHandler.cs
Normal file
|
@ -0,0 +1,176 @@
|
|||
|
||||
#region ================== Copyright (c) 2007 Pascal vd Heiden
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Pascal vd Heiden, www.codeimp.com
|
||||
* This program is released under GNU General Public License
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Namespaces
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
using CodeImp.DoomBuilder.IO;
|
||||
using CodeImp.DoomBuilder.Data;
|
||||
using System.IO;
|
||||
using System.Diagnostics;
|
||||
using CodeImp.DoomBuilder.Config;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace CodeImp.DoomBuilder.Types
|
||||
{
|
||||
[TypeHandler(16, "Setting", false)]
|
||||
internal class EnumStringsHandler : TypeHandler
|
||||
{
|
||||
#region ================== Constants
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Variables
|
||||
|
||||
private EnumList list;
|
||||
private EnumItem value;
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Properties
|
||||
|
||||
public override bool IsBrowseable { get { return true; } }
|
||||
public override bool IsEnumerable { get { return true; } }
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Constructor
|
||||
|
||||
// When set up for an argument
|
||||
public override void SetupArgument(TypeHandlerAttribute attr, ArgumentInfo arginfo)
|
||||
{
|
||||
base.SetupArgument(attr, arginfo);
|
||||
|
||||
// Keep enum list reference
|
||||
list = arginfo.Enum;
|
||||
}
|
||||
|
||||
// When set up for a universal field
|
||||
public override void SetupField(TypeHandlerAttribute attr, UniversalFieldInfo fieldinfo)
|
||||
{
|
||||
base.SetupField(attr, fieldinfo);
|
||||
|
||||
// Keep enum list reference
|
||||
if(fieldinfo != null) list = fieldinfo.Enum; else list = new EnumList();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Methods
|
||||
|
||||
public override void SetValue(object value)
|
||||
{
|
||||
this.value = null;
|
||||
|
||||
// Input null?
|
||||
if(value == null)
|
||||
{
|
||||
this.value = new EnumItem("", "");
|
||||
}
|
||||
else
|
||||
{
|
||||
// No match found yet?
|
||||
if(this.value == null)
|
||||
{
|
||||
// First try to match the value against the enum values
|
||||
foreach(EnumItem item in list)
|
||||
{
|
||||
// Matching value?
|
||||
if(item.Value == value.ToString())
|
||||
{
|
||||
// Set this value
|
||||
this.value = item;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// No match found yet?
|
||||
if(this.value == null)
|
||||
{
|
||||
// Try to match against the titles
|
||||
foreach(EnumItem item in list)
|
||||
{
|
||||
// Matching value?
|
||||
if(item.Title.ToLowerInvariant() == value.ToString().ToLowerInvariant())
|
||||
{
|
||||
// Set this value
|
||||
this.value = item;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Still no match found?
|
||||
if(this.value == null)
|
||||
{
|
||||
// Make a dummy value
|
||||
this.value = new EnumItem(value.ToString(), value.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override object GetValue()
|
||||
{
|
||||
if(this.value != null) return this.value.Value; else return "";
|
||||
}
|
||||
|
||||
public override int GetIntValue()
|
||||
{
|
||||
if(this.value != null)
|
||||
{
|
||||
// Parse the value to integer
|
||||
int result;
|
||||
if(int.TryParse(this.value.Value, NumberStyles.Integer,
|
||||
CultureInfo.InvariantCulture, out result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public override string GetStringValue()
|
||||
{
|
||||
if(this.value != null) return this.value.Title; else return "NULL";
|
||||
}
|
||||
|
||||
// This returns an enum list
|
||||
public override EnumList GetEnumList()
|
||||
{
|
||||
return list;
|
||||
}
|
||||
|
||||
// This returns the type to display for fixed fields
|
||||
// Must be a custom usable type
|
||||
public override TypeHandlerAttribute GetDisplayType()
|
||||
{
|
||||
return General.Types.GetAttribute((int)UniversalType.String);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -25,6 +25,8 @@ using CodeImp.DoomBuilder.IO;
|
|||
using CodeImp.DoomBuilder.Data;
|
||||
using System.IO;
|
||||
using System.Diagnostics;
|
||||
using CodeImp.DoomBuilder.Windows;
|
||||
using System.Windows.Forms;
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -45,10 +47,17 @@ namespace CodeImp.DoomBuilder.Types
|
|||
|
||||
#region ================== Properties
|
||||
|
||||
public override bool IsBrowseable { get { return true; } }
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Methods
|
||||
|
||||
public override void Browse(IWin32Window parent)
|
||||
{
|
||||
value = TextEditForm.ShowDialog(parent, value);
|
||||
}
|
||||
|
||||
public override void SetValue(object value)
|
||||
{
|
||||
if(value != null)
|
||||
|
|
104
Source/Windows/TextEditForm.Designer.cs
generated
Normal file
104
Source/Windows/TextEditForm.Designer.cs
generated
Normal file
|
@ -0,0 +1,104 @@
|
|||
namespace CodeImp.DoomBuilder.Windows
|
||||
{
|
||||
partial class TextEditForm
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if(disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.cancel = new System.Windows.Forms.Button();
|
||||
this.apply = new System.Windows.Forms.Button();
|
||||
this.textbox = new System.Windows.Forms.TextBox();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// cancel
|
||||
//
|
||||
this.cancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.cancel.Location = new System.Drawing.Point(354, 220);
|
||||
this.cancel.Margin = new System.Windows.Forms.Padding(1);
|
||||
this.cancel.Name = "cancel";
|
||||
this.cancel.Size = new System.Drawing.Size(112, 25);
|
||||
this.cancel.TabIndex = 21;
|
||||
this.cancel.Text = "Cancel";
|
||||
this.cancel.UseVisualStyleBackColor = true;
|
||||
this.cancel.Click += new System.EventHandler(this.cancel_Click);
|
||||
//
|
||||
// apply
|
||||
//
|
||||
this.apply.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.apply.Location = new System.Drawing.Point(235, 220);
|
||||
this.apply.Margin = new System.Windows.Forms.Padding(1);
|
||||
this.apply.Name = "apply";
|
||||
this.apply.Size = new System.Drawing.Size(112, 25);
|
||||
this.apply.TabIndex = 20;
|
||||
this.apply.Text = "OK";
|
||||
this.apply.UseVisualStyleBackColor = true;
|
||||
this.apply.Click += new System.EventHandler(this.apply_Click);
|
||||
//
|
||||
// textbox
|
||||
//
|
||||
this.textbox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.textbox.Location = new System.Drawing.Point(10, 10);
|
||||
this.textbox.Margin = new System.Windows.Forms.Padding(1);
|
||||
this.textbox.Multiline = true;
|
||||
this.textbox.Name = "textbox";
|
||||
this.textbox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
|
||||
this.textbox.Size = new System.Drawing.Size(456, 194);
|
||||
this.textbox.TabIndex = 22;
|
||||
//
|
||||
// TextEditForm
|
||||
//
|
||||
this.AcceptButton = this.apply;
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
|
||||
this.CancelButton = this.cancel;
|
||||
this.ClientSize = new System.Drawing.Size(476, 255);
|
||||
this.Controls.Add(this.textbox);
|
||||
this.Controls.Add(this.cancel);
|
||||
this.Controls.Add(this.apply);
|
||||
this.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "TextEditForm";
|
||||
this.Opacity = 0;
|
||||
this.ShowIcon = false;
|
||||
this.ShowInTaskbar = false;
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "Edit Text";
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Button cancel;
|
||||
private System.Windows.Forms.Button apply;
|
||||
private System.Windows.Forms.TextBox textbox;
|
||||
}
|
||||
}
|
75
Source/Windows/TextEditForm.cs
Normal file
75
Source/Windows/TextEditForm.cs
Normal file
|
@ -0,0 +1,75 @@
|
|||
|
||||
#region ================== Copyright (c) 2007 Pascal vd Heiden
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Pascal vd Heiden, www.codeimp.com
|
||||
* This program is released under GNU General Public License
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Namespaces
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using CodeImp.DoomBuilder.Map;
|
||||
using CodeImp.DoomBuilder.Data;
|
||||
using CodeImp.DoomBuilder.IO;
|
||||
using System.IO;
|
||||
using CodeImp.DoomBuilder.Config;
|
||||
using CodeImp.DoomBuilder.Editing;
|
||||
using CodeImp.DoomBuilder.Controls;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace CodeImp.DoomBuilder.Windows
|
||||
{
|
||||
public partial class TextEditForm : DelayedForm
|
||||
{
|
||||
// Properties
|
||||
public string Value { get { return textbox.Text; } set { textbox.Text = value; } }
|
||||
|
||||
// Constructor
|
||||
public TextEditForm()
|
||||
{
|
||||
// Initialize
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
// This shows the dialog, returns the same value when cancelled
|
||||
public static string ShowDialog(IWin32Window owner, string value)
|
||||
{
|
||||
TextEditForm f = new TextEditForm();
|
||||
f.Value = value;
|
||||
if(f.ShowDialog(owner) == DialogResult.OK) value = f.Value;
|
||||
f.Dispose();
|
||||
return value;
|
||||
}
|
||||
|
||||
// OK clicked
|
||||
private void apply_Click(object sender, EventArgs e)
|
||||
{
|
||||
// Done
|
||||
this.DialogResult = DialogResult.OK;
|
||||
this.Close();
|
||||
}
|
||||
|
||||
// Cancel clciked
|
||||
private void cancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
// Be gone
|
||||
this.DialogResult = DialogResult.Cancel;
|
||||
this.Close();
|
||||
}
|
||||
}
|
||||
}
|
120
Source/Windows/TextEditForm.resx
Normal file
120
Source/Windows/TextEditForm.resx
Normal file
|
@ -0,0 +1,120 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
Loading…
Reference in a new issue