convert FieldDefinitionPropertiesDialog to UWT ContainerLayout-based Glade design
This commit is contained in:
parent
e8228cd78a
commit
fcc613002a
@ -0,0 +1,274 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Generated with glade 3.22.1 -->
|
||||
<interface>
|
||||
<requires lib="gtk+" version="3.20"/>
|
||||
<object class="GtkListStore" id="tmDataType">
|
||||
<columns>
|
||||
<!-- column-name colDataTypeName -->
|
||||
<column type="gchararray"/>
|
||||
<!-- column-name colDataTypeFullyQualifiedTypeName -->
|
||||
<column type="gchararray"/>
|
||||
</columns>
|
||||
<data>
|
||||
<row>
|
||||
<col id="0" translatable="yes">Signed 8-bit integer (SByte)</col>
|
||||
<col id="1" translatable="yes">System.SByte</col>
|
||||
</row>
|
||||
<row>
|
||||
<col id="0" translatable="yes">Unsigned 8-bit integer (Byte)</col>
|
||||
<col id="1" translatable="yes">System.Byte</col>
|
||||
</row>
|
||||
<row>
|
||||
<col id="0" translatable="yes">Signed 16-bit integer (Short)</col>
|
||||
<col id="1" translatable="yes">System.Int16</col>
|
||||
</row>
|
||||
<row>
|
||||
<col id="0" translatable="yes">Unsigned 16-bit integer (UShort)</col>
|
||||
<col id="1" translatable="yes">System.UInt16</col>
|
||||
</row>
|
||||
<row>
|
||||
<col id="0" translatable="yes">Signed 32-bit integer (Int)</col>
|
||||
<col id="1" translatable="yes">System.Int32</col>
|
||||
</row>
|
||||
<row>
|
||||
<col id="0" translatable="yes">Unsigned 32-bit integer (UInt)</col>
|
||||
<col id="1" translatable="yes">System.UInt32</col>
|
||||
</row>
|
||||
<row>
|
||||
<col id="0" translatable="yes">Signed 64-bit integer (Long)</col>
|
||||
<col id="1" translatable="yes">System.Int64</col>
|
||||
</row>
|
||||
<row>
|
||||
<col id="0" translatable="yes">Unsigned 64-bit integer (ULong)</col>
|
||||
<col id="1" translatable="yes">System.UInt64</col>
|
||||
</row>
|
||||
<row>
|
||||
<col id="0" translatable="yes">32-bit floating point (Float/Single)</col>
|
||||
<col id="1" translatable="yes">System.Single</col>
|
||||
</row>
|
||||
<row>
|
||||
<col id="0" translatable="yes">64-bit floating point (Double)</col>
|
||||
<col id="1" translatable="yes">System.Double</col>
|
||||
</row>
|
||||
<row>
|
||||
<col id="0" translatable="yes">Fixed-length string</col>
|
||||
<col id="1" translatable="yes">System.String</col>
|
||||
</row>
|
||||
<row>
|
||||
<col id="0" translatable="yes">Length-prefixed string</col>
|
||||
<col id="1" translatable="yes">System.String</col>
|
||||
</row>
|
||||
<row>
|
||||
<col id="0" translatable="yes">Raw byte array</col>
|
||||
<col id="1" translatable="yes">System.Byte[]</col>
|
||||
</row>
|
||||
</data>
|
||||
</object>
|
||||
<object class="GtkDialog">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="title" translatable="yes">Field Definition Properties</property>
|
||||
<property name="type_hint">dialog</property>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child internal-child="vbox">
|
||||
<object class="GtkBox">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="spacing">2</property>
|
||||
<child internal-child="action_area">
|
||||
<object class="GtkButtonBox">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="layout_style">end</property>
|
||||
<child>
|
||||
<object class="GtkButton" id="cmdOK">
|
||||
<property name="label">gtk-ok</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="use_stock">True</property>
|
||||
<style>
|
||||
<class name="suggested-action"/>
|
||||
</style>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="button1">
|
||||
<property name="label">gtk-cancel</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="use_stock">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkGrid">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="margin_left">16</property>
|
||||
<property name="margin_right">16</property>
|
||||
<property name="margin_top">16</property>
|
||||
<property name="margin_bottom">16</property>
|
||||
<property name="row_spacing">8</property>
|
||||
<property name="column_spacing">8</property>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">_Name</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="xalign">0</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">_Offset</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="xalign">0</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">_Data type</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="xalign">0</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="lblLength">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">_Length</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="xalign">0</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">_Color</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="xalign">0</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">4</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkEntry" id="txtName">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="hexpand">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="top_attach">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSpinButton" id="txtOffset">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="hexpand">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="top_attach">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSpinButton" id="txtLength">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="hexpand">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="top_attach">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkComboBox" id="cboDataType">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="hexpand">True</property>
|
||||
<property name="model">tmDataType</property>
|
||||
<property name="active">0</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText"/>
|
||||
<attributes>
|
||||
<attribute name="text">0</attribute>
|
||||
</attributes>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="top_attach">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="cmdColor">
|
||||
<property name="label" translatable="yes">button</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="hexpand">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="top_attach">4</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<action-widgets>
|
||||
<action-widget response="-6">button1</action-widget>
|
||||
</action-widgets>
|
||||
</object>
|
||||
</interface>
|
||||
@ -726,6 +726,7 @@
|
||||
<Content Include="Editors\RIFF\RIFFEditor.glade" />
|
||||
<Content Include="Editors\RIFF\Commands.uexml" />
|
||||
<Content Include="Editors\RIFF\Dialogs\RIFFChunkPropertiesDialog.glade" />
|
||||
<Content Include="Editors\Binary\Dialogs\FieldDefinitionPropertiesDialog.glade" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Configuration\Application.upl" />
|
||||
@ -780,6 +781,7 @@
|
||||
<Folder Include="Extensions\GameDeveloper\Extensions\Webfoot\Associations\" />
|
||||
<Folder Include="Extensions\GameDeveloper\Extensions\CRI\" />
|
||||
<Folder Include="Editors\RIFF\" />
|
||||
<Folder Include="Editors\Binary\Dialogs\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Extensions\SoftwareDeveloper\Templates\Project\Software Development\Arduino\Images\Blink.xcf" />
|
||||
|
||||
@ -709,7 +709,7 @@ namespace UniversalEditor.Editors.Binary
|
||||
|
||||
private void tsbFieldDefinitionAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
FieldDefinitionPropertiesDialog dlg = new FieldDefinitionPropertiesDialog();
|
||||
FieldDefinitionPropertiesDialog2 dlg = new FieldDefinitionPropertiesDialog2();
|
||||
dlg.FieldDefinition.Offset = hexedit.SelectionStart;
|
||||
if (dlg.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
@ -731,13 +731,25 @@ namespace UniversalEditor.Editors.Binary
|
||||
return;
|
||||
|
||||
FieldDefinition def = lvFieldDefinitions.SelectedRows[0].GetExtraData<FieldDefinition>("def");
|
||||
int highlightAreaIndex = hexedit.HighlightAreas.IndexOf(hexedit.HighlightAreas[def.Name]);
|
||||
|
||||
if (def != null)
|
||||
{
|
||||
FieldDefinitionPropertiesDialog dlg = new FieldDefinitionPropertiesDialog();
|
||||
FieldDefinitionPropertiesDialog2 dlg = new FieldDefinitionPropertiesDialog2();
|
||||
dlg.FieldDefinition = def;
|
||||
if (dlg.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
def = dlg.FieldDefinition;
|
||||
|
||||
hexedit.HighlightAreas[highlightAreaIndex].Name = def.Name;
|
||||
hexedit.HighlightAreas[highlightAreaIndex].BackColor = dlg.FieldDefinition.Color;
|
||||
hexedit.HighlightAreas[highlightAreaIndex].Start = def.Offset;
|
||||
hexedit.HighlightAreas[highlightAreaIndex].Length = def.DataTypeSize;
|
||||
|
||||
lvFieldDefinitions.SelectedRows[0].RowColumns[0].Value = def.Name;
|
||||
lvFieldDefinitions.SelectedRows[0].RowColumns[1].Value = def.Offset;
|
||||
lvFieldDefinitions.SelectedRows[0].RowColumns[2].Value = def.DataType?.Name + " [" + dlg.FieldDefinition.DataTypeSizeString + "]";
|
||||
lvFieldDefinitions.SelectedRows[0].RowColumns[3].Value = GetFieldValue(def);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -28,6 +28,104 @@ using MBS.Framework.UserInterface.Layouts;
|
||||
|
||||
namespace UniversalEditor.Editors.Binary
|
||||
{
|
||||
[ContainerLayout("~/Editors/Binary/Dialogs/FieldDefinitionPropertiesDialog.glade", "GtkDialog")]
|
||||
public class FieldDefinitionPropertiesDialog2 : Dialog
|
||||
{
|
||||
private TextBox txtName;
|
||||
private NumericTextBox txtOffset;
|
||||
private ComboBox cboDataType;
|
||||
private DefaultTreeModel tmDataType;
|
||||
private Label lblLength;
|
||||
private NumericTextBox txtLength;
|
||||
private Button cmdColor;
|
||||
|
||||
public FieldDefinition FieldDefinition { get; set; } = new FieldDefinition();
|
||||
|
||||
protected override void OnCreated(EventArgs e)
|
||||
{
|
||||
base.OnCreated(e);
|
||||
|
||||
DefaultButton = Buttons[0];
|
||||
|
||||
txtName.Text = FieldDefinition.Name;
|
||||
cmdColor.BackgroundBrush = new SolidBrush(FieldDefinition.Color);
|
||||
txtOffset.Value = FieldDefinition.Offset;
|
||||
txtLength.Value = FieldDefinition.Length;
|
||||
|
||||
// TODO: perhaps we should put this in
|
||||
for (int i = 0; i < tmDataType.Rows.Count; i++)
|
||||
{
|
||||
string dataTypeName = tmDataType.Rows[i].RowColumns[1].Value?.ToString();
|
||||
Type type = MBS.Framework.Reflection.FindType(dataTypeName);
|
||||
tmDataType.Rows[i].SetExtraData<Type>("type", type);
|
||||
|
||||
if (type == FieldDefinition.DataType)
|
||||
{
|
||||
cboDataType.SelectedItem = tmDataType.Rows[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[EventHandler("cboDataType", "Changed")]
|
||||
private void cboDataType_Changed(object sender, EventArgs e)
|
||||
{
|
||||
if (cboDataType.SelectedItem == null) return;
|
||||
|
||||
Type type = cboDataType.SelectedItem.GetExtraData<Type>("type");
|
||||
if (type == null) return;
|
||||
|
||||
if (type == typeof(string) || type == typeof(byte[]))
|
||||
{
|
||||
lblLength.Visible = true;
|
||||
txtLength.Visible = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
lblLength.Visible = false;
|
||||
txtLength.Visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
[EventHandler("cmdColor", "Click")]
|
||||
private void cmdColor_Click(object sender, EventArgs e)
|
||||
{
|
||||
ColorDialog dlg = new ColorDialog();
|
||||
dlg.SelectedColor = (cmdColor.BackgroundBrush as SolidBrush).Color;
|
||||
if (dlg.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
cmdColor.BackgroundBrush = new SolidBrush(dlg.SelectedColor);
|
||||
}
|
||||
}
|
||||
|
||||
[EventHandler("cmdOK", "Click")]
|
||||
private void cmdOK_Click(object sender, EventArgs e)
|
||||
{
|
||||
FieldDefinition.Name = txtName.Text;
|
||||
|
||||
if (cboDataType.SelectedItem != null)
|
||||
{
|
||||
FieldDefinition.DataType = cboDataType.SelectedItem.GetExtraData<Type>("type");
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageDialog.ShowDialog("please select a data type");
|
||||
this.DialogResult = DialogResult.None;
|
||||
return;
|
||||
}
|
||||
|
||||
if (FieldDefinition.DataType == typeof(string))
|
||||
{
|
||||
FieldDefinition.Length = (int)txtLength.Value;
|
||||
}
|
||||
FieldDefinition.Color = (cmdColor.BackgroundBrush as SolidBrush).Color;
|
||||
FieldDefinition.Offset = (int)txtOffset.Value;
|
||||
|
||||
this.DialogResult = DialogResult.OK;
|
||||
this.Close();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class FieldDefinitionPropertiesDialog : Dialog
|
||||
{
|
||||
private Label lblName;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user