Move bindings and add buttons for debugging
This commit is contained in:
120
MVPLearning/BaseLibrary/BaseForm.resx
Normal file
120
MVPLearning/BaseLibrary/BaseForm.resx
Normal file
@@ -0,0 +1,120 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
||||||
@@ -19,6 +19,7 @@ namespace MVPLearning.BaseLibrary
|
|||||||
|
|
||||||
var newBinding = new Binding(nameof(Text), datasource, dataproperty, false);
|
var newBinding = new Binding(nameof(Text), datasource, dataproperty, false);
|
||||||
DataBindings.Add(newBinding);
|
DataBindings.Add(newBinding);
|
||||||
|
System.Diagnostics.Debug.WriteLine($"Binding count for {Name}.{nameof(Text)} is {DataBindings.Count}");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnGotFocus(EventArgs e)
|
protected override void OnGotFocus(EventArgs e)
|
||||||
|
|||||||
@@ -62,6 +62,8 @@ namespace MVPLearning.RecordKeeping.SermonFiler
|
|||||||
ButtonSave = new Button();
|
ButtonSave = new Button();
|
||||||
ButtonCancel = new Button();
|
ButtonCancel = new Button();
|
||||||
LabelTitleWarning = new Label();
|
LabelTitleWarning = new Label();
|
||||||
|
button1 = new Button();
|
||||||
|
button2 = new Button();
|
||||||
ActionPanel.SuspendLayout();
|
ActionPanel.SuspendLayout();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
@@ -363,11 +365,33 @@ namespace MVPLearning.RecordKeeping.SermonFiler
|
|||||||
LabelTitleWarning.Text = "Title cannont be blank";
|
LabelTitleWarning.Text = "Title cannont be blank";
|
||||||
LabelTitleWarning.Visible = false;
|
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
|
// MaintainSermonFilerView
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(800, 450);
|
ClientSize = new Size(800, 450);
|
||||||
|
Controls.Add(button2);
|
||||||
|
Controls.Add(button1);
|
||||||
Controls.Add(LabelTitleWarning);
|
Controls.Add(LabelTitleWarning);
|
||||||
Controls.Add(ButtonCancel);
|
Controls.Add(ButtonCancel);
|
||||||
Controls.Add(ButtonSave);
|
Controls.Add(ButtonSave);
|
||||||
@@ -435,5 +459,7 @@ namespace MVPLearning.RecordKeeping.SermonFiler
|
|||||||
private Button ButtonSave;
|
private Button ButtonSave;
|
||||||
private Button ButtonCancel;
|
private Button ButtonCancel;
|
||||||
private Label LabelTitleWarning;
|
private Label LabelTitleWarning;
|
||||||
|
private Button button1;
|
||||||
|
private Button button2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -16,7 +16,33 @@ namespace MVPLearning.RecordKeeping.SermonFiler
|
|||||||
public MaintainSermonFilerView()
|
public MaintainSermonFilerView()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
_model = new() { Title = "Constructor value"};
|
||||||
_model.PropertyChanged += ModelChanged;
|
_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.Bind(_model, nameof(_model.Title));
|
||||||
TextBoxTitle.GotFocus += TextBoxTitle_GotFocus;
|
TextBoxTitle.GotFocus += TextBoxTitle_GotFocus;
|
||||||
TextBoxTitle.LostFocus += TextBoxTitle_LostFocus;
|
TextBoxTitle.LostFocus += TextBoxTitle_LostFocus;
|
||||||
@@ -29,24 +55,7 @@ namespace MVPLearning.RecordKeeping.SermonFiler
|
|||||||
TextBoxNotes.Bind(_model, nameof(_model.Notes));
|
TextBoxNotes.Bind(_model, nameof(_model.Notes));
|
||||||
TextBoxFileName.Bind(_model, nameof(_model.Filename));
|
TextBoxFileName.Bind(_model, nameof(_model.Filename));
|
||||||
TextBoxWebUrl.Bind(_model, nameof(_model.Web));
|
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)
|
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.Filename)) { EnableButtonLaunch(); }
|
||||||
if (e.PropertyName == nameof(_model.Title)) { WarnTitleIsEmpty(); }
|
if (e.PropertyName == nameof(_model.Title)) { WarnTitleIsEmpty(); }
|
||||||
|
bool enableButtons = !_model.Equals(_loadedModel);
|
||||||
|
ButtonSave.Enabled = enableButtons;
|
||||||
|
ButtonCancel.Enabled = enableButtons;
|
||||||
}
|
}
|
||||||
private void WarnTitleIsEmpty()
|
private void WarnTitleIsEmpty()
|
||||||
{
|
{
|
||||||
@@ -113,5 +125,14 @@ namespace MVPLearning.RecordKeeping.SermonFiler
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void button1_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
BindControls();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void button2_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
this.Refresh();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user