sledgemapper/Sledgemapper/UI/NoteWindow.Custom.cs
Michele 98e5f6bc89
All checks were successful
continuous-integration/drone/push Build is passing
still moving code around
2021-09-15 23:28:30 +01:00

45 lines
No EOL
1.5 KiB
C#

/* Generated by MyraPad at 29/11/2020 23:50:42 */
using System;
using Myra.Graphics2D.UI;
using Sledgemapper.Shared.Entities;
namespace Sledgemapper.UI
{
public partial class NoteWindow
{
private readonly Window Window;
private readonly CommunicationManager CommunicationManager;
private readonly Note Note;
public NoteWindow(CommunicationManager communicationManager, Window window, Note note)
{
BuildUI();
NoteText.Text = note.Text;
Note = note;
Window = window;
CommunicationManager = communicationManager;
BtnOk.Click += OnButtonNoteOkClick;
BtnCancel.Click += OnButtonNoteCancelClick;
}
private void OnButtonNoteOkClick(object sender, EventArgs e)
{
var button = ((TextButton)sender);
var localContent = button.GetParentContentInWindow<NoteWindow>();
var note = new Note
{
X = State.Instance.SelectedNote.X,
Y = State.Instance.SelectedNote.Y,
Text = localContent.Content.NoteText.Text
};
CommunicationManager.SessionData.NewNote(note);
localContent.Window.Close();
}
private void OnButtonNoteCancelClick(object sender, EventArgs e)
{
var button = ((TextButton)sender);
var content = button.GetParentContentInWindow<Widget>();
content.Window.Close();
}
}
}