Compare commits

...

3 Commits

Author SHA1 Message Date
6a3a564d77 code cleanup 2024-03-31 01:09:31 -04:00
95163afa67 Move bindings and add buttons for debugging 2024-03-30 23:41:40 -04:00
f0426c35d6 Increase the MDI window size 2024-03-30 23:40:15 -04:00
7 changed files with 216 additions and 60 deletions

View File

@@ -18,7 +18,7 @@ namespace MVPLearning.BaseLibrary
}
public void Bind(object datasource, string dataproperty)
{
var oldBinding = this.DataBindings[nameof(BoundValue)];
var oldBinding = DataBindings[nameof(BoundValue)];
if (oldBinding != null) { DataBindings.Remove(oldBinding); }
var newBinding = new Binding(nameof(BoundValue), datasource, dataproperty, true);
@@ -50,23 +50,11 @@ namespace MVPLearning.BaseLibrary
}
protected override void OnValueChanged(EventArgs eventargs)
{
System.Diagnostics.Debug.WriteLine("OnValueChanged");
base.OnValueChanged(eventargs);
BoundValue = Value;
Format = DateTimePickerFormat.Custom;
CustomFormat = Checked ? "MM/dd/yyyy" : " ";
}
protected override void OnValidated(EventArgs e)
{
base.OnValidated(e);
}
protected override void OnValidating(CancelEventArgs e)
{
base.OnValidating(e);
System.Diagnostics.Debug.WriteLine("OnValidating");
System.Diagnostics.Debug.WriteLine($"Value: {Value}");
System.Diagnostics.Debug.WriteLine($"BoundValue: {BoundValue}");
}
}
}

View 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>

View File

@@ -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)

View File

@@ -42,7 +42,7 @@
menuStrip1.Items.AddRange(new ToolStripItem[] { fileToolStripMenuItem, recordKeepingToolStripMenuItem });
menuStrip1.Location = new Point(0, 0);
menuStrip1.Name = "menuStrip1";
menuStrip1.Size = new Size(800, 24);
menuStrip1.Size = new Size(1101, 24);
menuStrip1.TabIndex = 1;
menuStrip1.Text = "menuStrip1";
//
@@ -56,7 +56,7 @@
// exitToolStripMenuItem
//
exitToolStripMenuItem.Name = "exitToolStripMenuItem";
exitToolStripMenuItem.Size = new Size(180, 22);
exitToolStripMenuItem.Size = new Size(93, 22);
exitToolStripMenuItem.Text = "E&xit";
exitToolStripMenuItem.Click += ExitToolStripMenuItem_Click;
//
@@ -71,7 +71,7 @@
//
sermonFilerToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { maintainSermonFilerToolStripMenuItem });
sermonFilerToolStripMenuItem.Name = "sermonFilerToolStripMenuItem";
sermonFilerToolStripMenuItem.Size = new Size(180, 22);
sermonFilerToolStripMenuItem.Size = new Size(140, 22);
sermonFilerToolStripMenuItem.Text = "Sermon Filer";
//
// maintainSermonFilerToolStripMenuItem
@@ -85,7 +85,7 @@
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450);
ClientSize = new Size(1101, 636);
Controls.Add(menuStrip1);
IsMdiContainer = true;
MainMenuStrip = menuStrip1;

View File

@@ -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;
}
}

View File

@@ -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();
}
}
}

View File

@@ -1,17 +1,17 @@
<?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
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>
@@ -26,36 +26,36 @@
<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
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
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
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
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
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
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
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->