improvements to Palette editor - ability to add/modify/remove entries
This commit is contained in:
parent
4f7f5ae5ff
commit
16ba1aad96
@ -0,0 +1,25 @@
|
||||
<UniversalEditor Version="5.0">
|
||||
<Editors>
|
||||
<Editor ID="{A0389580-FbE6-4512-95F0-BCDD51B8B623}" TypeName="UniversalEditor.Plugins.Multimedia.UserInterface.Editors.Multimedia.Palette.PaletteEditor">
|
||||
<Commands>
|
||||
|
||||
<Command ID="PaletteEditor_ContextMenu_Add" Title="A_dd entry..." />
|
||||
|
||||
<Command ID="PaletteEditor_ContextMenu_Change" Title="C_hange" />
|
||||
<Command ID="PaletteEditor_ContextMenu_Delete" Title="_Delete" />
|
||||
|
||||
<Command ID="PaletteEditor_ContextMenu_Unselected">
|
||||
<Items>
|
||||
<CommandReference CommandID="PaletteEditor_ContextMenu_Add" />
|
||||
</Items>
|
||||
</Command>
|
||||
<Command ID="PaletteEditor_ContextMenu_Selected">
|
||||
<Items>
|
||||
<CommandReference CommandID="PaletteEditor_ContextMenu_Change" />
|
||||
<CommandReference CommandID="PaletteEditor_ContextMenu_Delete" />
|
||||
</Items>
|
||||
</Command>
|
||||
</Commands>
|
||||
</Editor>
|
||||
</Editors>
|
||||
</UniversalEditor>
|
||||
@ -661,6 +661,7 @@
|
||||
<Content Include="Editors\Multimedia3D\Model\Shaders\Default\default_frg.glsl" />
|
||||
<Content Include="Extensions\FileSystem\Associations\InstallShield\PKG.uexml" />
|
||||
<Content Include="Extensions\GameDeveloper\Extensions\Nintendo\Associations\Z64.uexml" />
|
||||
<Content Include="Editors\Multimedia\Palette\PaletteEditor.uexml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Configuration\Application.upl" />
|
||||
@ -688,6 +689,7 @@
|
||||
<Folder Include="Extensions\GameDeveloper\Associations\Database\CRI\" />
|
||||
<Folder Include="Extensions\GameDeveloper\Extensions\Nintendo\" />
|
||||
<Folder Include="Extensions\GameDeveloper\Extensions\Nintendo\Associations\" />
|
||||
<Folder Include="Editors\Multimedia\Palette\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Extensions\SoftwareDeveloper\Templates\Project\Software Development\Arduino\Images\Blink.xcf" />
|
||||
|
||||
@ -45,6 +45,10 @@ namespace UniversalEditor.Plugins.Multimedia.UserInterface.Editors.Multimedia.Pa
|
||||
cInfo.Layout = new BoxLayout(Orientation.Vertical);
|
||||
this.Controls.Add(cInfo, new BoxLayout.Constraints(false, false));
|
||||
|
||||
Context.AttachCommandEventHandler("PaletteEditor_ContextMenu_Add", PaletteEditor_ContextMenu_Add_Click);
|
||||
Context.AttachCommandEventHandler("PaletteEditor_ContextMenu_Change", PaletteEditor_ContextMenu_Change_Click);
|
||||
Context.AttachCommandEventHandler("PaletteEditor_ContextMenu_Delete", PaletteEditor_ContextMenu_Delete_Click);
|
||||
|
||||
txtColorName = new TextBox();
|
||||
txtColorName.KeyDown += txtColorName_KeyDown;
|
||||
cInfo.Controls.Add(txtColorName, new BoxLayout.Constraints(false, true));
|
||||
|
||||
@ -57,6 +57,53 @@ namespace UniversalEditor.Plugins.Multimedia.UserInterface.Editors.Multimedia.Pa
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void PaletteEditor_ContextMenu_Add_Click(object sender, EventArgs e)
|
||||
{
|
||||
PaletteObjectModel palette = (ObjectModel as PaletteObjectModel);
|
||||
if (palette == null) return;
|
||||
|
||||
ColorDialog dlg = new ColorDialog();
|
||||
if (dlg.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
BeginEdit();
|
||||
palette.Entries.Add(new PaletteEntry(dlg.SelectedColor));
|
||||
EndEdit();
|
||||
}
|
||||
}
|
||||
private void PaletteEditor_ContextMenu_Change_Click(object sender, EventArgs e)
|
||||
{
|
||||
PaletteObjectModel palette = (ObjectModel as PaletteObjectModel);
|
||||
if (palette == null || SelectedEntry == null) return;
|
||||
|
||||
ColorDialog dlg = new ColorDialog();
|
||||
dlg.SelectedColor = SelectedEntry.Color;
|
||||
|
||||
if (dlg.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
BeginEdit();
|
||||
SelectedEntry.Color = dlg.SelectedColor;
|
||||
EndEdit();
|
||||
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
private void PaletteEditor_ContextMenu_Delete_Click(object sender, EventArgs e)
|
||||
{
|
||||
PaletteObjectModel palette = (ObjectModel as PaletteObjectModel);
|
||||
if (palette == null || SelectedEntry == null) return;
|
||||
|
||||
if (MessageDialog.ShowDialog("Do you wish to delete the selected color?", "Delete Selected Color", MessageDialogButtons.YesNo, MessageDialogIcon.Warning) == DialogResult.Yes)
|
||||
{
|
||||
BeginEdit();
|
||||
palette.Entries.Remove(SelectedEntry);
|
||||
EndEdit();
|
||||
|
||||
SelectedEntry = null;
|
||||
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
public PaletteEntry HitTest(Vector2D location)
|
||||
{
|
||||
PaletteObjectModel palette = (ObjectModel as PaletteObjectModel);
|
||||
@ -104,19 +151,30 @@ namespace UniversalEditor.Plugins.Multimedia.UserInterface.Editors.Multimedia.Pa
|
||||
{
|
||||
SelectedEntry = HitTest(e.Location);
|
||||
Refresh();
|
||||
|
||||
if (SelectedEntry != null)
|
||||
{
|
||||
ContextMenuCommandID = "PaletteEditor_ContextMenu_Selected";
|
||||
}
|
||||
else
|
||||
{
|
||||
ContextMenuCommandID = "PaletteEditor_ContextMenu_Unselected";
|
||||
}
|
||||
}
|
||||
|
||||
private void cc_MouseDoubleClick(object sender, MBS.Framework.UserInterface.Input.Mouse.MouseEventArgs e)
|
||||
{
|
||||
SelectedEntry = HitTest(e.Location);
|
||||
|
||||
ColorDialog dlg = new ColorDialog();
|
||||
dlg.SelectedColor = SelectedEntry.Color;
|
||||
if (dlg.ShowDialog() == DialogResult.OK)
|
||||
if (SelectedEntry != null)
|
||||
{
|
||||
BeginEdit();
|
||||
SelectedEntry.Color = dlg.SelectedColor;
|
||||
EndEdit();
|
||||
ColorDialog dlg = new ColorDialog();
|
||||
dlg.SelectedColor = SelectedEntry.Color;
|
||||
if (dlg.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
BeginEdit();
|
||||
SelectedEntry.Color = dlg.SelectedColor;
|
||||
EndEdit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -22,7 +22,13 @@ namespace UniversalEditor.ObjectModels.Multimedia.Palette
|
||||
}
|
||||
}
|
||||
|
||||
private string mvarName = String.Empty;
|
||||
public PaletteEntry(Color color = default(Color), string name = "")
|
||||
{
|
||||
Name = name;
|
||||
Color = color;
|
||||
}
|
||||
|
||||
private string mvarName = String.Empty;
|
||||
public string Name { get { return mvarName; } set { mvarName = value; } }
|
||||
|
||||
public Color Color { get; set; } = Color.Empty;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user