From 23a136e0b4aac7119d5083a42b103ce53f6ea94b Mon Sep 17 00:00:00 2001 From: kotcheshir73 Date: Thu, 8 Apr 2021 14:13:35 +0400 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=B2=D1=8B=D0=BF=D0=B0=D0=B4=D0=B0=D1=8E?= =?UTF-8?q?=D1=89=D0=B5=D0=B3=D0=BE=20=D1=81=D0=BF=D1=81=D0=B8=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BaseControls/AbstractBaseControl.cs | 1 + .../GenericControlEntityElement.cs | 28 +++++++++++++++++-- .../MainControls/GenericControlEntityList.cs | 4 ++- .../MainControlViewEntityElement.Designer.cs | 3 +- .../MainControlViewEntityElement.resx | 10 ------- 5 files changed, 30 insertions(+), 16 deletions(-) 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