diff --git a/DepartmentPortal/Common/DesktopTools/BaseControls/AbstractBaseControl.cs b/DepartmentPortal/Common/DesktopTools/BaseControls/AbstractBaseControl.cs index bb511c1..dda2c1c 100644 --- a/DepartmentPortal/Common/DesktopTools/BaseControls/AbstractBaseControl.cs +++ b/DepartmentPortal/Common/DesktopTools/BaseControls/AbstractBaseControl.cs @@ -56,6 +56,7 @@ namespace DesktopTools.BaseControls public AbstractBaseControl(string propertyName, bool mustFilling, bool readOnly) { InitializeComponent(); + Name = $"Control{propertyName}"; _propertyName = propertyName; _mustFilling = mustFilling; panelControl.Enabled = !readOnly; diff --git a/DepartmentPortal/Common/DesktopTools/MainControls/GenericControlEntityElement.cs b/DepartmentPortal/Common/DesktopTools/MainControls/GenericControlEntityElement.cs index dafd845..feb9cb0 100644 --- a/DepartmentPortal/Common/DesktopTools/MainControls/GenericControlEntityElement.cs +++ b/DepartmentPortal/Common/DesktopTools/MainControls/GenericControlEntityElement.cs @@ -10,6 +10,7 @@ using ModuleTools.Enums; using ModuleTools.Extensions; using ModuleTools.ViewModels; using System; +using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Windows.Forms; @@ -179,7 +180,8 @@ namespace DesktopTools.Controls } } }; - toolStripButtonClose.Click += (object sender, EventArgs e) => { + toolStripButtonClose.Click += (object sender, EventArgs e) => + { if (_haveChages && DialogHelper.MessageQuestion("Имеется несохраненные данные, вы действительно хотите закрыть элемент?", "Закрытие элемента") == DialogResult.Yes) { if (!Save()) @@ -202,7 +204,9 @@ namespace DesktopTools.Controls ToolStripMenuItem item = new() { Text = elem.Value.Title, Name = elem.Key }; item.Click += elem.Value.Event; toolStripSplitButtonActions.DropDownItems.Add(item); - contextMenuStripElement.Items.Add(item); + ToolStripMenuItem itemContext = new() { Text = elem.Value.Title, Name = elem.Key }; + itemContext.Click += elem.Value.Event; + contextMenuStripElement.Items.Add(itemContext); } } // либо скрытие пункта, если не предусмотренно подпунктов @@ -264,7 +268,7 @@ namespace DesktopTools.Controls if (attribute.ControlTypeObject.IsNotEmpty() && Type.GetType(attribute.ControlTypeObject) != null) { control = new BaseControlGuid(property.Name, attribute.MustHaveValue, attribute.ReadOnly, - DependencyManager.Instance.Resolve(Type.GetType(attribute.ControlTypeObject)) as IControlEntitySelectable, + DependencyManager.Instance.Resolve(Type.GetType(attribute.ControlTypeObject)) as IControlEntitySelectable, property.Name == ParentPropertyName ? ParentId : null); } break; @@ -387,5 +391,23 @@ namespace DesktopTools.Controls } private ControlViewEntityElementConfiguration GetConfig() => _genericControlViewEntityElement?.GetConfigControl(); + + protected bool FillModel(S model) + { + if (CheckValues.GetInvocationList().Select(x => (bool)x.DynamicInvoke()).ToList().Any(x => !x)) + { + return false; + } + try + { + GetValues(model); + return true; + } + catch (Exception ex) + { + DialogHelper.MessageException(ex.Message, "Ошибка при получении значений"); + } + return false; + } } } diff --git a/DepartmentPortal/Common/DesktopTools/MainControls/GenericControlEntityList.cs b/DepartmentPortal/Common/DesktopTools/MainControls/GenericControlEntityList.cs index 54661b9..c587b01 100644 --- a/DepartmentPortal/Common/DesktopTools/MainControls/GenericControlEntityList.cs +++ b/DepartmentPortal/Common/DesktopTools/MainControls/GenericControlEntityList.cs @@ -217,7 +217,9 @@ namespace DesktopTools.Controls ToolStripMenuItem item = new() { Text = elem.Value.Title, Name = elem.Key }; item.Click += elem.Value.Event; toolStripSplitButtonActions.DropDownItems.Add(item); - contextMenuStripDataGrid.Items.Add(item); + ToolStripMenuItem itemContext = new() { Text = elem.Value.Title, Name = elem.Key }; + itemContext.Click += elem.Value.Event; + contextMenuStripDataGrid.Items.Add(itemContext); } } // либо скрытие пункта, если не предусмотренно подпунктов diff --git a/DepartmentPortal/Common/DesktopTools/MainControls/MainControlViewEntityElement.Designer.cs b/DepartmentPortal/Common/DesktopTools/MainControls/MainControlViewEntityElement.Designer.cs index 069be42..d9a10bb 100644 --- a/DepartmentPortal/Common/DesktopTools/MainControls/MainControlViewEntityElement.Designer.cs +++ b/DepartmentPortal/Common/DesktopTools/MainControls/MainControlViewEntityElement.Designer.cs @@ -26,7 +26,6 @@ namespace DesktopTools.Controls private void InitializeComponent() { this.components = new System.ComponentModel.Container(); - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainControlViewEntityElement)); this.toolStripActions = new System.Windows.Forms.ToolStrip(); this.toolStripButtonSave = new System.Windows.Forms.ToolStripButton(); this.toolStripButtonReload = new System.Windows.Forms.ToolStripButton(); @@ -91,7 +90,6 @@ namespace DesktopTools.Controls // toolStripSplitButtonActions // this.toolStripSplitButtonActions.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; - this.toolStripSplitButtonActions.Image = ((System.Drawing.Image)(resources.GetObject("toolStripSplitButtonActions.Image"))); this.toolStripSplitButtonActions.ImageTransparentColor = System.Drawing.Color.Magenta; this.toolStripSplitButtonActions.Name = "toolStripSplitButtonActions"; this.toolStripSplitButtonActions.Size = new System.Drawing.Size(74, 22); @@ -130,6 +128,7 @@ namespace DesktopTools.Controls // contextMenuStripElement // this.contextMenuStripElement.Name = "contextMenuStripElement"; + this.contextMenuStripElement.Size = new System.Drawing.Size(61, 4); // // MainControlViewEntityElement // diff --git a/DepartmentPortal/Common/DesktopTools/MainControls/MainControlViewEntityElement.resx b/DepartmentPortal/Common/DesktopTools/MainControls/MainControlViewEntityElement.resx index ee499e1..f298a7b 100644 --- a/DepartmentPortal/Common/DesktopTools/MainControls/MainControlViewEntityElement.resx +++ b/DepartmentPortal/Common/DesktopTools/MainControls/MainControlViewEntityElement.resx @@ -57,14 +57,4 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - - iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAACRSURBVDhPY/j27dt/SjDYACcnJ7IwigEf3n8kCZNswPNb - J/+f6DYF0yA+yQac6Db5f6hWCmwIiE+mC0wIu2DS2Vf/F1x6DefjwlgNyNr34r/0wkdgTMgQDAOQNRNj - CIoBOg0rMTTDMLIhIHbriZeYBmDTiIxBGkEYxge5liQDsGGQqykyAISpZwAlmIEywMAAAAc1/Jwvt6sN - AAAAAElFTkSuQmCC - - \ No newline at end of file