use bindings instead of manual sync
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Data;
|
||||||
|
|
||||||
namespace Lab2
|
namespace Lab2
|
||||||
{
|
{
|
||||||
@@ -67,11 +69,11 @@ namespace Lab2
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void SyncData()
|
private void SyncData()
|
||||||
{
|
{
|
||||||
_lawnmower.Name = _nameTextBox.Text;
|
BindingOperations.GetBindingExpression(_nameTextBox, TextBox.TextProperty)?.UpdateSource();
|
||||||
_lawnmower.Material = (Material)_materialComboBox.SelectedItem;
|
BindingOperations.GetBindingExpression(_materialComboBox, ComboBox.TextProperty)?.UpdateSource();
|
||||||
_lawnmower.Weight = Convert.ToDouble(_weightTextBox.Text, CultureInfo.CurrentCulture);
|
BindingOperations.GetBindingExpression(_weightTextBox, TextBox.TextProperty)?.UpdateSource();
|
||||||
_lawnmower.Power = Convert.ToUInt32(_powerTextBox.Text);
|
BindingOperations.GetBindingExpression(_powerTextBox, TextBox.TextProperty)?.UpdateSource();
|
||||||
_lawnmower.FuelCapacity = (float)Convert.ToDouble(_fuelСapacityTextBox.Text, CultureInfo.CurrentCulture);
|
BindingOperations.GetBindingExpression(_fuelСapacityTextBox, TextBox.TextProperty)?.UpdateSource();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Data;
|
||||||
|
|
||||||
namespace Lab2
|
namespace Lab2
|
||||||
{
|
{
|
||||||
@@ -67,11 +69,11 @@ namespace Lab2
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void SyncData()
|
private void SyncData()
|
||||||
{
|
{
|
||||||
_scissors.Name = _nameTextBox.Text;
|
BindingOperations.GetBindingExpression(_nameTextBox, TextBox.TextProperty)?.UpdateSource();
|
||||||
_scissors.Material = (Material)_materialComboBox.SelectedItem;
|
BindingOperations.GetBindingExpression(_materialComboBox, ComboBox.TextProperty)?.UpdateSource();
|
||||||
_scissors.Weight = Convert.ToDouble(_weightTextBox.Text, CultureInfo.CurrentCulture);
|
BindingOperations.GetBindingExpression(_weightTextBox, TextBox.TextProperty)?.UpdateSource();
|
||||||
_scissors.HandleLength = (float)Convert.ToDouble(_handleLengthTextBox.Text, CultureInfo.CurrentCulture);
|
BindingOperations.GetBindingExpression(_handleLengthTextBox, TextBox.TextProperty)?.UpdateSource();
|
||||||
_scissors.BladeSize = Convert.ToDouble(_bladeSizeTextBox.Text, CultureInfo.CurrentCulture);
|
BindingOperations.GetBindingExpression(_bladeSizeTextBox, TextBox.TextProperty)?.UpdateSource();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Data;
|
||||||
|
|
||||||
namespace Lab2
|
namespace Lab2
|
||||||
{
|
{
|
||||||
@@ -68,11 +70,11 @@ namespace Lab2
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void SyncData()
|
private void SyncData()
|
||||||
{
|
{
|
||||||
_scythe.Name = _nameTextBox.Text;
|
BindingOperations.GetBindingExpression(_nameTextBox, TextBox.TextProperty)?.UpdateSource();
|
||||||
_scythe.Material = (Material)_materialComboBox.SelectedItem;
|
BindingOperations.GetBindingExpression(_materialComboBox, ComboBox.TextProperty)?.UpdateSource();
|
||||||
_scythe.Weight = Convert.ToDouble(_weightTextBox.Text, CultureInfo.CurrentCulture);
|
BindingOperations.GetBindingExpression(_weightTextBox, TextBox.TextProperty)?.UpdateSource();
|
||||||
_scythe.HandleLength = (float)Convert.ToDouble(_handleLengthTextBox.Text, CultureInfo.CurrentCulture);
|
BindingOperations.GetBindingExpression(_handleLengthTextBox, TextBox.TextProperty)?.UpdateSource();
|
||||||
_scythe.BladeType = (BladeType)_bladeTypeComboBox.SelectedItem;
|
BindingOperations.GetBindingExpression(_bladeTypeComboBox, ComboBox.TextProperty)?.UpdateSource();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Data;
|
||||||
|
|
||||||
namespace Lab2
|
namespace Lab2
|
||||||
{
|
{
|
||||||
@@ -68,11 +70,11 @@ namespace Lab2
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void SyncData()
|
private void SyncData()
|
||||||
{
|
{
|
||||||
_trimmer.Name = _nameTextBox.Text;
|
BindingOperations.GetBindingExpression(_nameTextBox, TextBox.TextProperty)?.UpdateSource();
|
||||||
_trimmer.Material = (Material)_materialComboBox.SelectedItem;
|
BindingOperations.GetBindingExpression(_materialComboBox, ComboBox.TextProperty)?.UpdateSource();
|
||||||
_trimmer.Weight = Convert.ToDouble(_weightTextBox.Text, CultureInfo.CurrentCulture);
|
BindingOperations.GetBindingExpression(_weightTextBox, TextBox.TextProperty)?.UpdateSource();
|
||||||
_trimmer.Power = Convert.ToUInt32(_powerTextBox.Text);
|
BindingOperations.GetBindingExpression(_powerTextBox, TextBox.TextProperty)?.UpdateSource();
|
||||||
_trimmer.Mode = (TrimmerMode)_modeComboBox.SelectedItem;
|
BindingOperations.GetBindingExpression(_modeComboBox, ComboBox.TextProperty)?.UpdateSource();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user