Bound UI Enabled

This commit is contained in:
MaddoScientisto 2024-10-14 23:48:21 +02:00
commit 4e4a59b0b2
3 changed files with 36 additions and 17 deletions

View file

@ -50,9 +50,22 @@ namespace ImageCatalog_2
} }
} }
private bool _uiEnabled = true;
public bool UiEnabled
{
get { return _uiEnabled; }
set
{
_uiEnabled = value;
NotifyPropertyChanged();
}
}
private void Test(object parameter) private void Test(object parameter)
{ {
Debug.WriteLine("Yep"); Debug.WriteLine("Yep");
this.UiEnabled = !this.UiEnabled;
} }
private async Task TestAsync() private async Task TestAsync()

View file

@ -44,9 +44,9 @@ namespace ImageCatalog
TabControl1 = new TabControl(); TabControl1 = new TabControl();
TabPage5 = new TabPage(); TabPage5 = new TabPage();
button1 = new Button(); button1 = new Button();
btnTest = new Button();
bindingSource1 = new BindingSource(components); bindingSource1 = new BindingSource(components);
dataModelBindingSource = new BindingSource(components); dataModelBindingSource = new BindingSource(components);
btnTest = new Button();
GroupBox11 = new GroupBox(); GroupBox11 = new GroupBox();
Panel3 = new Panel(); Panel3 = new Panel();
rdbNuovoMetodo = new RadioButton(); rdbNuovoMetodo = new RadioButton();
@ -246,6 +246,7 @@ namespace ImageCatalog
TabControl1.Controls.Add(TabPage2); TabControl1.Controls.Add(TabPage2);
TabControl1.Controls.Add(TabPage1); TabControl1.Controls.Add(TabPage1);
TabControl1.Controls.Add(TabPage4); TabControl1.Controls.Add(TabPage4);
TabControl1.DataBindings.Add(new Binding("Enabled", bindingSource1, "UiEnabled", true));
TabControl1.Location = new Point(16, 18); TabControl1.Location = new Point(16, 18);
TabControl1.Margin = new Padding(4, 5, 4, 5); TabControl1.Margin = new Padding(4, 5, 4, 5);
TabControl1.Name = "TabControl1"; TabControl1.Name = "TabControl1";
@ -280,6 +281,14 @@ namespace ImageCatalog
button1.Text = "Test Async"; button1.Text = "Test Async";
button1.UseVisualStyleBackColor = true; button1.UseVisualStyleBackColor = true;
// //
// bindingSource1
//
bindingSource1.DataSource = dataModelBindingSource;
//
// dataModelBindingSource
//
dataModelBindingSource.DataSource = typeof(ImageCatalog_2.DataModel);
//
// btnTest // btnTest
// //
btnTest.DataBindings.Add(new Binding("Command", bindingSource1, "TestCommand", true)); btnTest.DataBindings.Add(new Binding("Command", bindingSource1, "TestCommand", true));
@ -290,14 +299,6 @@ namespace ImageCatalog
btnTest.Text = "Test"; btnTest.Text = "Test";
btnTest.UseVisualStyleBackColor = true; btnTest.UseVisualStyleBackColor = true;
// //
// bindingSource1
//
bindingSource1.DataSource = dataModelBindingSource;
//
// dataModelBindingSource
//
dataModelBindingSource.DataSource = typeof(ImageCatalog_2.DataModel);
//
// GroupBox11 // GroupBox11
// //
GroupBox11.Controls.Add(Panel3); GroupBox11.Controls.Add(Panel3);
@ -1703,6 +1704,7 @@ namespace ImageCatalog
// //
// _Button5 // _Button5
// //
_Button5.DataBindings.Add(new Binding("Enabled", bindingSource1, "UiEnabled", true));
_Button5.Font = new Font("Microsoft Sans Serif", 11F, FontStyle.Bold, GraphicsUnit.Point, 0); _Button5.Font = new Font("Microsoft Sans Serif", 11F, FontStyle.Bold, GraphicsUnit.Point, 0);
_Button5.Location = new Point(719, 66); _Button5.Location = new Point(719, 66);
_Button5.Margin = new Padding(4, 5, 4, 5); _Button5.Margin = new Padding(4, 5, 4, 5);
@ -1768,6 +1770,7 @@ namespace ImageCatalog
// //
// _Button6 // _Button6
// //
_Button6.DataBindings.Add(new Binding("Enabled", bindingSource1, "UiEnabled", true));
_Button6.Font = new Font("Microsoft Sans Serif", 11F, FontStyle.Bold, GraphicsUnit.Point, 0); _Button6.Font = new Font("Microsoft Sans Serif", 11F, FontStyle.Bold, GraphicsUnit.Point, 0);
_Button6.Location = new Point(719, 18); _Button6.Location = new Point(719, 18);
_Button6.Margin = new Padding(4, 5, 4, 5); _Button6.Margin = new Padding(4, 5, 4, 5);
@ -1779,6 +1782,7 @@ namespace ImageCatalog
// //
// _btnCreaCatalogoAsync // _btnCreaCatalogoAsync
// //
_btnCreaCatalogoAsync.DataBindings.Add(new Binding("Enabled", bindingSource1, "UiEnabled", true));
_btnCreaCatalogoAsync.Font = new Font("Microsoft Sans Serif", 8.25F, FontStyle.Bold, GraphicsUnit.Point, 0); _btnCreaCatalogoAsync.Font = new Font("Microsoft Sans Serif", 8.25F, FontStyle.Bold, GraphicsUnit.Point, 0);
_btnCreaCatalogoAsync.Location = new Point(719, 120); _btnCreaCatalogoAsync.Location = new Point(719, 120);
_btnCreaCatalogoAsync.Margin = new Padding(4, 5, 4, 5); _btnCreaCatalogoAsync.Margin = new Padding(4, 5, 4, 5);

View file

@ -221,18 +221,20 @@ namespace ImageCatalog
private void lockUI() private void lockUI()
{ {
TabControl1.Enabled = false; Model.UiEnabled = false;
Button5.Enabled = false; //TabControl1.Enabled = false;
Button6.Enabled = false; //Button5.Enabled = false;
btnCreaCatalogoAsync.Enabled = false; //Button6.Enabled = false;
//btnCreaCatalogoAsync.Enabled = false;
} }
private void unlockUI() private void unlockUI()
{ {
TabControl1.Enabled = true; Model.UiEnabled = true;
Button5.Enabled = true; //TabControl1.Enabled = true;
Button6.Enabled = true; //Button5.Enabled = true;
btnCreaCatalogoAsync.Enabled = true; //Button6.Enabled = true;
//btnCreaCatalogoAsync.Enabled = true;
} }
private void btnCreaCatalogo_Click(object sender, EventArgs e) private void btnCreaCatalogo_Click(object sender, EventArgs e)