sledgemapper/Sledgemapper/UI/NoteWindow.Custom.cs
Michele Scandura 7808363a07
All checks were successful
continuous-integration/drone/push Build is passing
removing dependency on windows all around
2021-09-16 13:07:56 +01:00

44 lines
No EOL
1.4 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 CommunicationManager CommunicationManager;
private readonly Note Note;
public NoteWindow(CommunicationManager communicationManager, Note note)
{
BuildUI();
NoteText.Text = note.Text;
Note = note;
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();
}
}
}