First MVP View - binding is working, but not updating
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
using MVPLearning.RecordKeeping.SermonFiler;
|
||||
|
||||
namespace MVPLearning
|
||||
{
|
||||
public partial class MainView : Form
|
||||
@@ -9,7 +11,7 @@ namespace MVPLearning
|
||||
|
||||
private void MaintainSermonFilerToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
_ = new MaintainSermonFilerPresenter(new MaintainSermonFilerView() { MdiParent = this });
|
||||
}
|
||||
|
||||
private void ExitToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
|
||||
@@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace MVPLearning.RecordKeeping.SermonFiler
|
||||
{
|
||||
internal class MaintainSermonFilerModel : ObservableObject
|
||||
public class MaintainSermonFilerModel : ObservableObject
|
||||
{
|
||||
public int Seid { get; set; }
|
||||
public string Title { get => _title; set => SetProperty(ref _title, value); }
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
namespace MVPLearning.RecordKeeping.SermonFiler
|
||||
using MVPLearning.BaseLibrary;
|
||||
|
||||
namespace MVPLearning.RecordKeeping.SermonFiler
|
||||
{
|
||||
partial class MaintainSermonFilerView
|
||||
{
|
||||
@@ -28,12 +30,410 @@
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Text = "MaintainSermonFilerView";
|
||||
ActionPanel = new Panel();
|
||||
ButtonClose = new Button();
|
||||
ButtonPrevious = new Button();
|
||||
ButtonNext = new Button();
|
||||
ButtonLocate = new Button();
|
||||
ButtonDelete = new Button();
|
||||
ButtonAdd = new Button();
|
||||
TitleLabel = new Label();
|
||||
TextBoxTitle = new BaseTextBox();
|
||||
ScriptureReferenceLabel = new Label();
|
||||
TextBoxScriptureReference = new BaseTextBox();
|
||||
WhenDeliveredLabel = new Label();
|
||||
DatePickerWhenDelivered = new BaseDateTimePicker();
|
||||
WhereDeliveredLabel = new Label();
|
||||
TextBoxWhereDelivered = new BaseTextBox();
|
||||
ReferenceNumberLabel = new Label();
|
||||
TextBoxReferenceNumber = new BaseTextBox();
|
||||
SubjectLabel = new Label();
|
||||
TextBoxSubject = new BaseTextBox();
|
||||
NotesLabel = new Label();
|
||||
TextBoxNotes = new BaseTextBox();
|
||||
WebUrlLabel = new Label();
|
||||
TextBoxWebUrl = new BaseTextBox();
|
||||
FileNameLabel = new Label();
|
||||
TextBoxFileName = new BaseTextBox();
|
||||
ButtonBrowse = new Button();
|
||||
ButtonLaunch = new Button();
|
||||
TextBoxWhoDelivered = new BaseTextBox();
|
||||
WhoDeliveredLabel = new Label();
|
||||
ButtonSave = new Button();
|
||||
ButtonCancel = new Button();
|
||||
LabelTitleWarning = new Label();
|
||||
ActionPanel.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// ActionPanel
|
||||
//
|
||||
ActionPanel.BorderStyle = BorderStyle.FixedSingle;
|
||||
ActionPanel.Controls.Add(ButtonClose);
|
||||
ActionPanel.Controls.Add(ButtonPrevious);
|
||||
ActionPanel.Controls.Add(ButtonNext);
|
||||
ActionPanel.Controls.Add(ButtonLocate);
|
||||
ActionPanel.Controls.Add(ButtonDelete);
|
||||
ActionPanel.Controls.Add(ButtonAdd);
|
||||
ActionPanel.Location = new Point(70, 12);
|
||||
ActionPanel.Name = "ActionPanel";
|
||||
ActionPanel.Size = new Size(486, 30);
|
||||
ActionPanel.TabIndex = 0;
|
||||
//
|
||||
// ButtonClose
|
||||
//
|
||||
ButtonClose.Location = new Point(408, 3);
|
||||
ButtonClose.Name = "ButtonClose";
|
||||
ButtonClose.Size = new Size(75, 23);
|
||||
ButtonClose.TabIndex = 5;
|
||||
ButtonClose.Text = "Close";
|
||||
ButtonClose.UseVisualStyleBackColor = true;
|
||||
ButtonClose.Click += CloseButton_Click;
|
||||
//
|
||||
// ButtonPrevious
|
||||
//
|
||||
ButtonPrevious.Location = new Point(327, 3);
|
||||
ButtonPrevious.Name = "ButtonPrevious";
|
||||
ButtonPrevious.Size = new Size(75, 23);
|
||||
ButtonPrevious.TabIndex = 4;
|
||||
ButtonPrevious.Text = "Previous";
|
||||
ButtonPrevious.UseVisualStyleBackColor = true;
|
||||
ButtonPrevious.Click += PreviousButton_Click;
|
||||
//
|
||||
// ButtonNext
|
||||
//
|
||||
ButtonNext.Location = new Point(246, 3);
|
||||
ButtonNext.Name = "ButtonNext";
|
||||
ButtonNext.Size = new Size(75, 23);
|
||||
ButtonNext.TabIndex = 3;
|
||||
ButtonNext.Text = "Next";
|
||||
ButtonNext.UseVisualStyleBackColor = true;
|
||||
ButtonNext.Click += NextButton_Click;
|
||||
//
|
||||
// ButtonLocate
|
||||
//
|
||||
ButtonLocate.Location = new Point(165, 3);
|
||||
ButtonLocate.Name = "ButtonLocate";
|
||||
ButtonLocate.Size = new Size(75, 23);
|
||||
ButtonLocate.TabIndex = 2;
|
||||
ButtonLocate.Text = "Locate";
|
||||
ButtonLocate.UseVisualStyleBackColor = true;
|
||||
ButtonLocate.Click += LocateButton_Click;
|
||||
//
|
||||
// ButtonDelete
|
||||
//
|
||||
ButtonDelete.Location = new Point(84, 3);
|
||||
ButtonDelete.Name = "ButtonDelete";
|
||||
ButtonDelete.Size = new Size(75, 23);
|
||||
ButtonDelete.TabIndex = 1;
|
||||
ButtonDelete.Text = "Delete";
|
||||
ButtonDelete.UseVisualStyleBackColor = true;
|
||||
ButtonDelete.Click += DeleteButton_Click;
|
||||
//
|
||||
// ButtonAdd
|
||||
//
|
||||
ButtonAdd.Location = new Point(3, 3);
|
||||
ButtonAdd.Name = "ButtonAdd";
|
||||
ButtonAdd.Size = new Size(75, 23);
|
||||
ButtonAdd.TabIndex = 0;
|
||||
ButtonAdd.Text = "Add";
|
||||
ButtonAdd.UseVisualStyleBackColor = true;
|
||||
ButtonAdd.Click += AddButton_Click;
|
||||
//
|
||||
// TitleLabel
|
||||
//
|
||||
TitleLabel.AutoSize = true;
|
||||
TitleLabel.Location = new Point(92, 58);
|
||||
TitleLabel.Name = "TitleLabel";
|
||||
TitleLabel.Size = new Size(29, 15);
|
||||
TitleLabel.TabIndex = 1;
|
||||
TitleLabel.Text = "Title";
|
||||
//
|
||||
// TextBoxTitle
|
||||
//
|
||||
TextBoxTitle.BorderStyle = BorderStyle.FixedSingle;
|
||||
TextBoxTitle.Location = new Point(127, 56);
|
||||
TextBoxTitle.Name = "TextBoxTitle";
|
||||
TextBoxTitle.Size = new Size(451, 23);
|
||||
TextBoxTitle.TabIndex = 2;
|
||||
//
|
||||
// ScriptureReferenceLabel
|
||||
//
|
||||
ScriptureReferenceLabel.AutoSize = true;
|
||||
ScriptureReferenceLabel.Location = new Point(12, 87);
|
||||
ScriptureReferenceLabel.Name = "ScriptureReferenceLabel";
|
||||
ScriptureReferenceLabel.Size = new Size(109, 15);
|
||||
ScriptureReferenceLabel.TabIndex = 3;
|
||||
ScriptureReferenceLabel.Text = "Scripture Reference";
|
||||
//
|
||||
// TextBoxScriptureReference
|
||||
//
|
||||
TextBoxScriptureReference.BorderStyle = BorderStyle.FixedSingle;
|
||||
TextBoxScriptureReference.Location = new Point(127, 85);
|
||||
TextBoxScriptureReference.Name = "TextBoxScriptureReference";
|
||||
TextBoxScriptureReference.Size = new Size(399, 23);
|
||||
TextBoxScriptureReference.TabIndex = 4;
|
||||
//
|
||||
// WhenDeliveredLabel
|
||||
//
|
||||
WhenDeliveredLabel.AutoSize = true;
|
||||
WhenDeliveredLabel.Location = new Point(31, 119);
|
||||
WhenDeliveredLabel.Name = "WhenDeliveredLabel";
|
||||
WhenDeliveredLabel.Size = new Size(90, 15);
|
||||
WhenDeliveredLabel.TabIndex = 5;
|
||||
WhenDeliveredLabel.Text = "When Delivered";
|
||||
//
|
||||
// DatePickerWhenDelivered
|
||||
//
|
||||
DatePickerWhenDelivered.BoundValue = null;
|
||||
DatePickerWhenDelivered.Format = DateTimePickerFormat.Short;
|
||||
DatePickerWhenDelivered.Location = new Point(127, 113);
|
||||
DatePickerWhenDelivered.Name = "DatePickerWhenDelivered";
|
||||
DatePickerWhenDelivered.ShowCheckBox = true;
|
||||
DatePickerWhenDelivered.Size = new Size(117, 23);
|
||||
DatePickerWhenDelivered.TabIndex = 6;
|
||||
//
|
||||
// WhereDeliveredLabel
|
||||
//
|
||||
WhereDeliveredLabel.AutoSize = true;
|
||||
WhereDeliveredLabel.Location = new Point(28, 203);
|
||||
WhereDeliveredLabel.Name = "WhereDeliveredLabel";
|
||||
WhereDeliveredLabel.Size = new Size(93, 15);
|
||||
WhereDeliveredLabel.TabIndex = 11;
|
||||
WhereDeliveredLabel.Text = "Where Delivered";
|
||||
//
|
||||
// TextBoxWhereDelivered
|
||||
//
|
||||
TextBoxWhereDelivered.BorderStyle = BorderStyle.FixedSingle;
|
||||
TextBoxWhereDelivered.Location = new Point(127, 201);
|
||||
TextBoxWhereDelivered.Name = "TextBoxWhereDelivered";
|
||||
TextBoxWhereDelivered.Size = new Size(237, 23);
|
||||
TextBoxWhereDelivered.TabIndex = 12;
|
||||
//
|
||||
// ReferenceNumberLabel
|
||||
//
|
||||
ReferenceNumberLabel.AutoSize = true;
|
||||
ReferenceNumberLabel.Location = new Point(15, 232);
|
||||
ReferenceNumberLabel.Name = "ReferenceNumberLabel";
|
||||
ReferenceNumberLabel.Size = new Size(106, 15);
|
||||
ReferenceNumberLabel.TabIndex = 13;
|
||||
ReferenceNumberLabel.Text = "Reference Number";
|
||||
//
|
||||
// TextBoxReferenceNumber
|
||||
//
|
||||
TextBoxReferenceNumber.BorderStyle = BorderStyle.FixedSingle;
|
||||
TextBoxReferenceNumber.Location = new Point(127, 230);
|
||||
TextBoxReferenceNumber.Name = "TextBoxReferenceNumber";
|
||||
TextBoxReferenceNumber.Size = new Size(100, 23);
|
||||
TextBoxReferenceNumber.TabIndex = 14;
|
||||
//
|
||||
// SubjectLabel
|
||||
//
|
||||
SubjectLabel.AutoSize = true;
|
||||
SubjectLabel.Location = new Point(75, 146);
|
||||
SubjectLabel.Name = "SubjectLabel";
|
||||
SubjectLabel.Size = new Size(46, 15);
|
||||
SubjectLabel.TabIndex = 7;
|
||||
SubjectLabel.Text = "Subject";
|
||||
//
|
||||
// TextBoxSubject
|
||||
//
|
||||
TextBoxSubject.BorderStyle = BorderStyle.FixedSingle;
|
||||
TextBoxSubject.Location = new Point(127, 144);
|
||||
TextBoxSubject.Name = "TextBoxSubject";
|
||||
TextBoxSubject.Size = new Size(100, 23);
|
||||
TextBoxSubject.TabIndex = 8;
|
||||
//
|
||||
// NotesLabel
|
||||
//
|
||||
NotesLabel.AutoSize = true;
|
||||
NotesLabel.Location = new Point(83, 261);
|
||||
NotesLabel.Name = "NotesLabel";
|
||||
NotesLabel.Size = new Size(38, 15);
|
||||
NotesLabel.TabIndex = 15;
|
||||
NotesLabel.Text = "Notes";
|
||||
//
|
||||
// TextBoxNotes
|
||||
//
|
||||
TextBoxNotes.BorderStyle = BorderStyle.FixedSingle;
|
||||
TextBoxNotes.Location = new Point(127, 259);
|
||||
TextBoxNotes.Name = "TextBoxNotes";
|
||||
TextBoxNotes.Size = new Size(451, 23);
|
||||
TextBoxNotes.TabIndex = 16;
|
||||
//
|
||||
// WebUrlLabel
|
||||
//
|
||||
WebUrlLabel.AutoSize = true;
|
||||
WebUrlLabel.Location = new Point(70, 290);
|
||||
WebUrlLabel.Name = "WebUrlLabel";
|
||||
WebUrlLabel.Size = new Size(51, 15);
|
||||
WebUrlLabel.TabIndex = 17;
|
||||
WebUrlLabel.Text = "Web/Url";
|
||||
//
|
||||
// TextBoxWebUrl
|
||||
//
|
||||
TextBoxWebUrl.BorderStyle = BorderStyle.FixedSingle;
|
||||
TextBoxWebUrl.Location = new Point(127, 288);
|
||||
TextBoxWebUrl.Name = "TextBoxWebUrl";
|
||||
TextBoxWebUrl.Size = new Size(452, 23);
|
||||
TextBoxWebUrl.TabIndex = 18;
|
||||
//
|
||||
// FileNameLabel
|
||||
//
|
||||
FileNameLabel.AutoSize = true;
|
||||
FileNameLabel.Location = new Point(61, 319);
|
||||
FileNameLabel.Name = "FileNameLabel";
|
||||
FileNameLabel.Size = new Size(60, 15);
|
||||
FileNameLabel.TabIndex = 19;
|
||||
FileNameLabel.Text = "File Name";
|
||||
//
|
||||
// TextBoxFileName
|
||||
//
|
||||
TextBoxFileName.BorderStyle = BorderStyle.FixedSingle;
|
||||
TextBoxFileName.Location = new Point(127, 317);
|
||||
TextBoxFileName.Name = "TextBoxFileName";
|
||||
TextBoxFileName.Size = new Size(452, 23);
|
||||
TextBoxFileName.TabIndex = 20;
|
||||
//
|
||||
// ButtonBrowse
|
||||
//
|
||||
ButtonBrowse.Location = new Point(127, 346);
|
||||
ButtonBrowse.Name = "ButtonBrowse";
|
||||
ButtonBrowse.Size = new Size(75, 23);
|
||||
ButtonBrowse.TabIndex = 21;
|
||||
ButtonBrowse.Text = "Browse";
|
||||
ButtonBrowse.UseVisualStyleBackColor = true;
|
||||
ButtonBrowse.Click += BrowseButton_Click;
|
||||
//
|
||||
// ButtonLaunch
|
||||
//
|
||||
ButtonLaunch.Location = new Point(208, 346);
|
||||
ButtonLaunch.Name = "ButtonLaunch";
|
||||
ButtonLaunch.Size = new Size(75, 23);
|
||||
ButtonLaunch.TabIndex = 22;
|
||||
ButtonLaunch.Text = "Launch";
|
||||
ButtonLaunch.UseVisualStyleBackColor = true;
|
||||
ButtonLaunch.Click += LaunchButton_Click;
|
||||
//
|
||||
// TextBoxWhoDelivered
|
||||
//
|
||||
TextBoxWhoDelivered.BorderStyle = BorderStyle.FixedSingle;
|
||||
TextBoxWhoDelivered.Location = new Point(127, 173);
|
||||
TextBoxWhoDelivered.Name = "TextBoxWhoDelivered";
|
||||
TextBoxWhoDelivered.Size = new Size(237, 23);
|
||||
TextBoxWhoDelivered.TabIndex = 10;
|
||||
//
|
||||
// WhoDeliveredLabel
|
||||
//
|
||||
WhoDeliveredLabel.AutoSize = true;
|
||||
WhoDeliveredLabel.Location = new Point(37, 175);
|
||||
WhoDeliveredLabel.Name = "WhoDeliveredLabel";
|
||||
WhoDeliveredLabel.Size = new Size(84, 15);
|
||||
WhoDeliveredLabel.TabIndex = 9;
|
||||
WhoDeliveredLabel.Text = "Who Delivered";
|
||||
//
|
||||
// ButtonSave
|
||||
//
|
||||
ButtonSave.Location = new Point(423, 398);
|
||||
ButtonSave.Name = "ButtonSave";
|
||||
ButtonSave.Size = new Size(75, 23);
|
||||
ButtonSave.TabIndex = 23;
|
||||
ButtonSave.Text = "Save";
|
||||
ButtonSave.UseVisualStyleBackColor = true;
|
||||
ButtonSave.Click += SaveButton_Click;
|
||||
//
|
||||
// ButtonCancel
|
||||
//
|
||||
ButtonCancel.Location = new Point(504, 398);
|
||||
ButtonCancel.Name = "ButtonCancel";
|
||||
ButtonCancel.Size = new Size(75, 23);
|
||||
ButtonCancel.TabIndex = 24;
|
||||
ButtonCancel.Text = "Cancel";
|
||||
ButtonCancel.UseVisualStyleBackColor = true;
|
||||
ButtonCancel.Click += CancelButton_Click;
|
||||
//
|
||||
// LabelTitleWarning
|
||||
//
|
||||
LabelTitleWarning.AutoSize = true;
|
||||
LabelTitleWarning.BackColor = SystemColors.Window;
|
||||
LabelTitleWarning.ForeColor = Color.IndianRed;
|
||||
LabelTitleWarning.Location = new Point(136, 58);
|
||||
LabelTitleWarning.Name = "LabelTitleWarning";
|
||||
LabelTitleWarning.Size = new Size(124, 15);
|
||||
LabelTitleWarning.TabIndex = 25;
|
||||
LabelTitleWarning.Text = "Title cannont be blank";
|
||||
LabelTitleWarning.Visible = false;
|
||||
//
|
||||
// MaintainSermonFilerView
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(800, 450);
|
||||
Controls.Add(LabelTitleWarning);
|
||||
Controls.Add(ButtonCancel);
|
||||
Controls.Add(ButtonSave);
|
||||
Controls.Add(TextBoxWhoDelivered);
|
||||
Controls.Add(WhoDeliveredLabel);
|
||||
Controls.Add(ButtonLaunch);
|
||||
Controls.Add(ButtonBrowse);
|
||||
Controls.Add(TextBoxFileName);
|
||||
Controls.Add(FileNameLabel);
|
||||
Controls.Add(TextBoxWebUrl);
|
||||
Controls.Add(WebUrlLabel);
|
||||
Controls.Add(TextBoxNotes);
|
||||
Controls.Add(NotesLabel);
|
||||
Controls.Add(TextBoxSubject);
|
||||
Controls.Add(SubjectLabel);
|
||||
Controls.Add(TextBoxReferenceNumber);
|
||||
Controls.Add(ReferenceNumberLabel);
|
||||
Controls.Add(TextBoxWhereDelivered);
|
||||
Controls.Add(WhereDeliveredLabel);
|
||||
Controls.Add(DatePickerWhenDelivered);
|
||||
Controls.Add(WhenDeliveredLabel);
|
||||
Controls.Add(TextBoxScriptureReference);
|
||||
Controls.Add(ScriptureReferenceLabel);
|
||||
Controls.Add(TextBoxTitle);
|
||||
Controls.Add(TitleLabel);
|
||||
Controls.Add(ActionPanel);
|
||||
Name = "MaintainSermonFilerView";
|
||||
Text = "Maintain Sermon Filer";
|
||||
ActionPanel.ResumeLayout(false);
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Panel ActionPanel;
|
||||
private Button ButtonPrevious;
|
||||
private Button ButtonNext;
|
||||
private Button ButtonLocate;
|
||||
private Button ButtonDelete;
|
||||
private Button ButtonClose;
|
||||
private Label TitleLabel;
|
||||
private Label ScriptureReferenceLabel;
|
||||
private BaseTextBox TextBoxScriptureReference;
|
||||
private Label WhenDeliveredLabel;
|
||||
private BaseDateTimePicker DatePickerWhenDelivered;
|
||||
private Label WhereDeliveredLabel;
|
||||
private BaseTextBox TextBoxWhereDelivered;
|
||||
private Label ReferenceNumberLabel;
|
||||
private BaseTextBox TextBoxReferenceNumber;
|
||||
private Label SubjectLabel;
|
||||
private BaseTextBox TextBoxSubject;
|
||||
private Label NotesLabel;
|
||||
private BaseTextBox TextBoxNotes;
|
||||
private Label WebUrlLabel;
|
||||
private BaseTextBox TextBoxWebUrl;
|
||||
private Label FileNameLabel;
|
||||
private BaseTextBox TextBoxFileName;
|
||||
private Button ButtonBrowse;
|
||||
private Button ButtonLaunch;
|
||||
private BaseTextBox TextBoxWhoDelivered;
|
||||
private Label WhoDeliveredLabel;
|
||||
private BaseTextBox TextBoxTitle;
|
||||
private Button ButtonAdd;
|
||||
private Button ButtonSave;
|
||||
private Button ButtonCancel;
|
||||
private Label LabelTitleWarning;
|
||||
}
|
||||
}
|
||||
@@ -11,11 +11,107 @@ using System.Windows.Forms;
|
||||
|
||||
namespace MVPLearning.RecordKeeping.SermonFiler
|
||||
{
|
||||
public partial class MaintainSermonFilerView : BaseForm
|
||||
public partial class MaintainSermonFilerView : BaseForm, IMaintainSermonFilerView
|
||||
{
|
||||
public MaintainSermonFilerView()
|
||||
{
|
||||
InitializeComponent();
|
||||
_model.PropertyChanged += ModelChanged;
|
||||
TextBoxTitle.Bind(_model, nameof(_model.Title));
|
||||
TextBoxTitle.GotFocus += TextBoxTitle_GotFocus;
|
||||
TextBoxTitle.LostFocus += TextBoxTitle_LostFocus;
|
||||
TextBoxScriptureReference.Bind(_model, nameof(_model.Scripture));
|
||||
DatePickerWhenDelivered.Bind(_model, nameof(_model.When));
|
||||
TextBoxSubject.Bind(_model, nameof(_model.Subject));
|
||||
TextBoxWhoDelivered.Bind(_model, nameof(_model.Minister));
|
||||
TextBoxWhereDelivered.Bind(_model, nameof(_model.Where));
|
||||
TextBoxReferenceNumber.Bind(_model, nameof(_model.Ref_No));
|
||||
TextBoxNotes.Bind(_model, nameof(_model.Notes));
|
||||
TextBoxFileName.Bind(_model, nameof(_model.Filename));
|
||||
TextBoxWebUrl.Bind(_model, nameof(_model.Web));
|
||||
//TextBoxFileName.TextChanged += TextBoxFileName_TextChanged ;
|
||||
//ButtonLaunch.Enabled = !string.IsNullOrEmpty(_model.Filename);
|
||||
}
|
||||
public void LoadData(MaintainSermonFilerModel model)
|
||||
{
|
||||
if (model == null) { return; }
|
||||
_loadedModel = model;
|
||||
_model.Title = model.Title;
|
||||
_model.Scripture = model.Scripture;
|
||||
_model.When = model.When;
|
||||
_model.Subject = model.Subject;
|
||||
_model.Minister = model.Minister;
|
||||
_model.Where = model.Where;
|
||||
_model.Ref_No = model.Ref_No;
|
||||
_model.Notes = model.Notes;
|
||||
_model.Filename = model.Filename;
|
||||
_model.Web = model.Web;
|
||||
//EnableButtonLaunch();
|
||||
}
|
||||
private void TextBoxTitle_LostFocus(object? sender, EventArgs e)
|
||||
{
|
||||
WarnTitleIsEmpty();
|
||||
}
|
||||
|
||||
private void TextBoxTitle_GotFocus(object? sender, EventArgs e)
|
||||
{
|
||||
LabelTitleWarning.Visible = false;
|
||||
}
|
||||
|
||||
private void ModelChanged(object? sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
if (e.PropertyName == nameof(_model.Filename)) { EnableButtonLaunch(); }
|
||||
if (e.PropertyName == nameof(_model.Title)) { WarnTitleIsEmpty(); }
|
||||
}
|
||||
private void WarnTitleIsEmpty()
|
||||
{
|
||||
// This is business logic, should these only happen when the user clicks Save?
|
||||
if (string.IsNullOrEmpty(_model.Title)) { LabelTitleWarning.Visible = true; }
|
||||
}
|
||||
private void EnableButtonLaunch()
|
||||
{
|
||||
//_view.LaunchButtonWrapper.Enabled = !string.IsNullOrEmpty(_view.FileNameTextWrapper.Text);
|
||||
ButtonLaunch.Enabled = !string.IsNullOrEmpty(_model.Filename);
|
||||
}
|
||||
|
||||
private readonly MaintainSermonFilerModel _model = new();
|
||||
private MaintainSermonFilerModel? _loadedModel;
|
||||
public event EventHandler? AddButtonClicked;
|
||||
public event EventHandler<int>? DeleteButtonClicked;
|
||||
public event EventHandler<int>? LocateButtonClicked;
|
||||
public event EventHandler<int>? NextButtonClicked;
|
||||
public event EventHandler<int>? PreviousButtonClicked;
|
||||
public event EventHandler? CloseButtonClicked;
|
||||
public event EventHandler? BrowseButtonClicked;
|
||||
public event EventHandler<string>? LaunchButtonClicked;
|
||||
public event EventHandler<MaintainSermonFilerModel>? SaveButtonClicked;
|
||||
public event EventHandler? CancelButtonClicked;
|
||||
|
||||
private void AddButton_Click(object sender, EventArgs _) { if (CheckForChangedData()) { AddButtonClicked?.Invoke(sender, EventArgs.Empty); } }
|
||||
private void DeleteButton_Click(object sender, EventArgs _) { DeleteButtonClicked?.Invoke(sender, _model.Seid); }
|
||||
private void LocateButton_Click(object sender, EventArgs _) { if (CheckForChangedData()) { LocateButtonClicked?.Invoke(sender, _model.Seid); } }
|
||||
private void NextButton_Click(object sender, EventArgs _) { if (CheckForChangedData()) { NextButtonClicked?.Invoke(sender, _model.Seid); } }
|
||||
private void PreviousButton_Click(object sender, EventArgs _) { if (CheckForChangedData()) { PreviousButtonClicked?.Invoke(sender, _model.Seid); } }
|
||||
private void CloseButton_Click(object sender, EventArgs _) { if (CheckForChangedData()) { CloseButtonClicked?.Invoke(sender, EventArgs.Empty); } }
|
||||
private void BrowseButton_Click(object sender, EventArgs _) { if (CheckForChangedData()) { BrowseButtonClicked?.Invoke(sender, EventArgs.Empty); } }
|
||||
private void LaunchButton_Click(object sender, EventArgs _) { LaunchButtonClicked?.Invoke(sender, _model.Filename); }
|
||||
private void SaveButton_Click(object sender, EventArgs _) { SaveButtonClicked?.Invoke(sender, _model); }
|
||||
private void CancelButton_Click(object sender, EventArgs _) { if (_loadedModel != null) { LoadData(_loadedModel); } }
|
||||
|
||||
|
||||
|
||||
|
||||
private bool CheckForChangedData()
|
||||
{
|
||||
if (_loadedModel == null) { return true; }
|
||||
if (!_loadedModel.Equals(_model))
|
||||
{
|
||||
DialogResult saveChanges = MessageBox.Show("Do you want to save the changes made?", this.Text, MessageBoxButtons.YesNoCancel);
|
||||
if (saveChanges == DialogResult.Cancel) { return false; }
|
||||
if (saveChanges == DialogResult.Yes) { SaveButtonClicked?.Invoke(this, _model); }
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace MVPLearning.Structure
|
||||
{
|
||||
internal class ObservableObject : INotifyPropertyChanged
|
||||
public class ObservableObject : INotifyPropertyChanged
|
||||
{
|
||||
public event PropertyChangedEventHandler? PropertyChanged;
|
||||
protected virtual void RaisePropertyChanged([CallerMemberName] string propertyName = "")
|
||||
|
||||
Reference in New Issue
Block a user