diff --git a/MVPLearning/BaseLibrary/BaseForm.resx b/MVPLearning/BaseLibrary/BaseForm.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/MVPLearning/BaseLibrary/BaseForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/MVPLearning/BaseLibrary/BaseTextBox.cs b/MVPLearning/BaseLibrary/BaseTextBox.cs index 5a7de1f..6137ee8 100644 --- a/MVPLearning/BaseLibrary/BaseTextBox.cs +++ b/MVPLearning/BaseLibrary/BaseTextBox.cs @@ -19,6 +19,7 @@ namespace MVPLearning.BaseLibrary var newBinding = new Binding(nameof(Text), datasource, dataproperty, false); DataBindings.Add(newBinding); + System.Diagnostics.Debug.WriteLine($"Binding count for {Name}.{nameof(Text)} is {DataBindings.Count}"); } protected override void OnGotFocus(EventArgs e) diff --git a/MVPLearning/RecordKeeping/SermonFiler/MaintainSermonFilerView.Designer.cs b/MVPLearning/RecordKeeping/SermonFiler/MaintainSermonFilerView.Designer.cs index acd804e..2fd76e0 100644 --- a/MVPLearning/RecordKeeping/SermonFiler/MaintainSermonFilerView.Designer.cs +++ b/MVPLearning/RecordKeeping/SermonFiler/MaintainSermonFilerView.Designer.cs @@ -62,6 +62,8 @@ namespace MVPLearning.RecordKeeping.SermonFiler ButtonSave = new Button(); ButtonCancel = new Button(); LabelTitleWarning = new Label(); + button1 = new Button(); + button2 = new Button(); ActionPanel.SuspendLayout(); SuspendLayout(); // @@ -363,11 +365,33 @@ namespace MVPLearning.RecordKeeping.SermonFiler LabelTitleWarning.Text = "Title cannont be blank"; LabelTitleWarning.Visible = false; // + // button1 + // + button1.Location = new Point(517, 142); + button1.Name = "button1"; + button1.Size = new Size(75, 23); + button1.TabIndex = 26; + button1.Text = "Rebind"; + button1.UseVisualStyleBackColor = true; + button1.Click += button1_Click; + // + // button2 + // + button2.Location = new Point(517, 177); + button2.Name = "button2"; + button2.Size = new Size(75, 23); + button2.TabIndex = 27; + button2.Text = "button2"; + button2.UseVisualStyleBackColor = true; + button2.Click += button2_Click; + // // MaintainSermonFilerView // AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; ClientSize = new Size(800, 450); + Controls.Add(button2); + Controls.Add(button1); Controls.Add(LabelTitleWarning); Controls.Add(ButtonCancel); Controls.Add(ButtonSave); @@ -435,5 +459,7 @@ namespace MVPLearning.RecordKeeping.SermonFiler private Button ButtonSave; private Button ButtonCancel; private Label LabelTitleWarning; + private Button button1; + private Button button2; } } \ No newline at end of file diff --git a/MVPLearning/RecordKeeping/SermonFiler/MaintainSermonFilerView.cs b/MVPLearning/RecordKeeping/SermonFiler/MaintainSermonFilerView.cs index 845b1fb..c4e4094 100644 --- a/MVPLearning/RecordKeeping/SermonFiler/MaintainSermonFilerView.cs +++ b/MVPLearning/RecordKeeping/SermonFiler/MaintainSermonFilerView.cs @@ -16,7 +16,33 @@ namespace MVPLearning.RecordKeeping.SermonFiler public MaintainSermonFilerView() { InitializeComponent(); + _model = new() { Title = "Constructor value"}; _model.PropertyChanged += ModelChanged; + BindControls(); + TextBoxTitle.DataBindings.Clear(); + TextBoxTitle.DataBindings.Add("Text", _model, "Title"); + //TextBoxFileName.TextChanged += TextBoxFileName_TextChanged ; + //ButtonLaunch.Enabled = !string.IsNullOrEmpty(_model.Filename); + } + public void LoadData(MaintainSermonFilerModel model) + { + if (model == null) { return; } + _loadedModel = model; + _model.Seid = model.Seid; + _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(); + } + public void BindControls() + { TextBoxTitle.Bind(_model, nameof(_model.Title)); TextBoxTitle.GotFocus += TextBoxTitle_GotFocus; TextBoxTitle.LostFocus += TextBoxTitle_LostFocus; @@ -29,24 +55,7 @@ namespace MVPLearning.RecordKeeping.SermonFiler 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) { @@ -62,6 +71,9 @@ namespace MVPLearning.RecordKeeping.SermonFiler { if (e.PropertyName == nameof(_model.Filename)) { EnableButtonLaunch(); } if (e.PropertyName == nameof(_model.Title)) { WarnTitleIsEmpty(); } + bool enableButtons = !_model.Equals(_loadedModel); + ButtonSave.Enabled = enableButtons; + ButtonCancel.Enabled = enableButtons; } private void WarnTitleIsEmpty() { @@ -113,5 +125,14 @@ namespace MVPLearning.RecordKeeping.SermonFiler return true; } + private void button1_Click(object sender, EventArgs e) + { + BindControls(); + } + + private void button2_Click(object sender, EventArgs e) + { + this.Refresh(); + } } } diff --git a/MVPLearning/RecordKeeping/SermonFiler/MaintainSermonFilerView.resx b/MVPLearning/RecordKeeping/SermonFiler/MaintainSermonFilerView.resx index 1af7de1..af32865 100644 --- a/MVPLearning/RecordKeeping/SermonFiler/MaintainSermonFilerView.resx +++ b/MVPLearning/RecordKeeping/SermonFiler/MaintainSermonFilerView.resx @@ -1,17 +1,17 @@  -