using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.ComponentModel; using CaeGlobals; using DynamicTypeDescriptor; using System.Drawing.Design; using System.Drawing; using CaeModel; namespace CPSO { [Serializable] public class ViewTie : ViewConstraint { // Variables private Tie _tie; // Properties public override string Name { get { return _tie.Name; } set { _tie.Name = value; } } // [Category("Data")] [OrderedDisplayName(1, 10, "Position tolerance")] [Description("Enter the value of largest distance from the master surface for which the slave nodes will be " + "included in the tie constraint. Default value equals 2.5 % of the typical element size.")] [TypeConverter(typeof(EquationLengthDefaultConverter))] [Id(2, 1)] public EquationString PositionTolerance { get { return _tie.PositionTolerance.Equation; } set { _tie.PositionTolerance.Equation = value; } } // [Category("Data")] [OrderedDisplayName(2, 10, "Adjust")] [Description("Set adjust to No to prevent the projection of the slave nodes on the master surface.")] [Id(3, 1)] public bool Adjust { get { return _tie.Adjust; } set { _tie.Adjust = value; } } // MASTER ------------------------------------------------------------------------------------------------------------------ [Category("Master Region")] [OrderedDisplayName(0, 10, "Master region type")] [Description("Select the master region type for the creation of the tie definition.")] [Id(1, 2)] public override string MasterRegionType { get { return base.MasterRegionType; } set { base.MasterRegionType = value; } } // [Category("Master Region")] [OrderedDisplayName(1, 10, "Master surface")] [Description("Select the master surface for the creation of the tie definition.")] [Id(2, 2)] public string MasterSurfaceName { get { return _tie.MasterRegionName; } set { _tie.MasterRegionName = value; } } // SLAVE ------------------------------------------------------------------------------------------------------------------- [Category("Slave Region")] [OrderedDisplayName(0, 10, "Slave region type")] [Description("Select the slave region type for the creation of the tie definition.")] [Id(1, 3)] public override string SlaveRegionType { get { return base.SlaveRegionType; } set { base.SlaveRegionType = value; } } // [Category("Slave Region")] [OrderedDisplayName(1, 10, "Slave surface")] [Description("Select the slave surface for the creation of the tie definition.")] [Id(2, 3)] public string SlaveSurfaceName { get { return _tie.SlaveRegionName; } set { _tie.SlaveRegionName = value; } } // ------------------------------------------------------------------------------------------------------------------------- [Category("Appearance")] [DisplayName("Master surface color")] [Description("Select the master surface color.")] [Editor(typeof(UserControls.ColorEditorEx), typeof(UITypeEditor))] [Id(1, 10)] public Color MasterColor { get { return _tie.MasterColor; } set { _tie.MasterColor = value; } } // [Category("Appearance")] [DisplayName("Slave surface color")] [Description("Select the slave surface color.")] [Editor(typeof(UserControls.ColorEditorEx), typeof(UITypeEditor))] [Id(2, 10)] public Color SlaveColor { get { return _tie.SlaveColor; } set { _tie.SlaveColor = value; } } // Constructors public ViewTie(Tie tie) { _tie = tie; // Master Dictionary masterRegionTypePropertyNamePairs = new Dictionary(); masterRegionTypePropertyNamePairs.Add(RegionTypeEnum.Selection, nameof(MasterSelectionHidden)); masterRegionTypePropertyNamePairs.Add(RegionTypeEnum.SurfaceName, nameof(MasterSurfaceName)); // Slave Dictionary slaveRegionTypePropertyNamePairs = new Dictionary(); slaveRegionTypePropertyNamePairs.Add(RegionTypeEnum.Selection, nameof(SlaveSelectionHidden)); slaveRegionTypePropertyNamePairs.Add(RegionTypeEnum.SurfaceName, nameof(SlaveSurfaceName)); // SetBase(tie, masterRegionTypePropertyNamePairs, slaveRegionTypePropertyNamePairs); DynamicCustomTypeDescriptor = ProviderInstaller.Install(this); // DynamicCustomTypeDescriptor.RenameBooleanPropertyToYesNo(nameof(Adjust)); // StringLengthDefaultConverter.SetInitialValue = Tie.InitialPositionTolerance.ToString(); } // Methods public override Constraint GetBase() { return _tie; } public void PopulateDropDownLists(string[] surfaceNames) { Dictionary masterRegionTypeListItemsPairs = new Dictionary(); masterRegionTypeListItemsPairs.Add(RegionTypeEnum.Selection, new string[] { "Hidden" }); masterRegionTypeListItemsPairs.Add(RegionTypeEnum.SurfaceName, surfaceNames); // Dictionary slaveTypeListItemsPairs = new Dictionary(); slaveTypeListItemsPairs.Add(RegionTypeEnum.Selection, new string[] { "Hidden" }); slaveTypeListItemsPairs.Add(RegionTypeEnum.SurfaceName, surfaceNames); // PopulateDropDownLists(masterRegionTypeListItemsPairs, slaveTypeListItemsPairs); } } }