Exemple #1
0
        /// <summary>
        /// Initializes this tab.
        /// </summary>
        /// <param name="propertyControl">The property control that hosts this
        /// tab.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref
        /// name="propertyControl"/> is <c>null</c>.</exception>
        public void Initialize(PropertyControl propertyControl)
        {
            Param.RequireNotNull(propertyControl, "propertyControl");

            // Save the property control.
            this.tabControl = propertyControl;

            // Load the current settings and initialize the controls on the
            // form.
            this.InitializeSettings();

            // Put the form into 'not-dirty' state.
            this.Dirty = false;
        }
Exemple #2
0
 public NormalPropertyBox()
 {
     propertyControl1                = new PropertyControl();
     propertyControl1.Text           = Lang._("Property");
     propertyControl1.HelpVisible    = HelpVisible;
     propertyControl1.ToolbarVisible = ToolbarVisible;
     propertyControl1.BackColor      = ContentBackColor;
     propertyControl1.ShowBorder     = false;
     propertyControl1.Dock           = DockStyle.Fill;
     propertyControl1.Font           = SystemFonts.MessageBoxFont;
     //AddPage(PropertyGrid, Properties.Resources.property);
     Controls.Add(propertyControl1);
     propertyControl1.BringToFront();
 }
Exemple #3
0
 private object GetPropertyText()
 {
     if (GetSForm()?.CurrentControl != null && PropertyControl != null)
     {
         return(PropertyControl?.GetValue(GetSForm()?.CurrentControl));
     }
     if (GetSForm() == null)
     {
         RemoveErrorProvider();
         return(null);
     }
     RemoveErrorProvider();
     return(new SReflection().ConvertProperty(PropertyControl));
 }
Exemple #4
0
        private PropertyControl InstantiateControl(PropertyDefinition def)
        {
            GameObject prefab = SelectControl(def);

            if (prefab)
            {
                GameObject      newObject = Instantiate(prefab, ControlParent);
                PropertyControl control   = newObject.GetComponent <PropertyControl>();
                control.Control(def);

                control.OnValueChanged += OnPropertyValueChanged; // Will doing this result in control dangling if destroyed, or will it be cleaned up by GC?

                return(control);
            }

            throw new InvalidOperationException($"There are no controls that can take care of property def type {def.GetType().Name}'.");
        }
Exemple #5
0
        //属性面板
        public PropertyControl GetActivePropCtl(Document doc)
        {
            string          projectID       = GetDwgId(doc);
            PropertyControl propertyControl = null;

            PropControls.TryGetValue(projectID, out propertyControl);

            if (propertyControl != null)
            {
                return(propertyControl);
            }
            else
            {
                BindPaletteSet.BindPropertyControl(out propertyControl);
                PropControls.Add(projectID, propertyControl);
                return(propertyControl);
            }
        }
        /// <summary>
        /// Initializes the page.
        /// </summary>
        /// <param name="propertyControl">
        /// The tab control object.
        /// </param>
        public void Initialize(PropertyControl propertyControl)
        {
            Param.AssertNotNull(propertyControl, "propertyControl");

            this.tabControl = propertyControl;

            if (this.analyzer != null)
            {
                // Get the list of allowed prefixes from the parent settings.
                this.AddParentPrefixes();

                // Get the list of allowed prefixes from the local settings.
                CollectionProperty localPrefixesProperty =
                    this.tabControl.LocalSettings.GetAddInSetting(this.analyzer, NamingRules.AllowedPrefixesProperty) as CollectionProperty;

                if (localPrefixesProperty != null && localPrefixesProperty.Values.Count > 0)
                {
                    foreach (string value in localPrefixesProperty)
                    {
                        if (!string.IsNullOrEmpty(value))
                        {
                            ListViewItem item = this.prefixList.Items.Add(value);
                            if (item != null)
                            {
                                item.Tag = true;
                                this.SetBoldState(item);
                            }
                        }
                    }
                }
            }

            // Select the first item in the list.
            if (this.prefixList.Items.Count > 0)
            {
                this.prefixList.Items[0].Selected = true;
            }

            this.EnableDisableRemoveButton();

            this.dirty = false;
            this.tabControl.DirtyChanged();
        }
Exemple #7
0
        private void HandleNodeSelection(TreeNode node)
        {
            if (tvProperties.SelectedNode != node)
            {
                tvProperties.SelectedNode = node;
            }
            LoadContextMenuForTreeNode(node);

            UserControl ctrl = null;

            pnlPropertiesContainer.Controls.Clear();
            if (node != null)
            {
                var attributes = (Dictionary <string, string>)node.Tag;

                switch (node.Name.ToLower())
                {
                case "property":
                    ctrl = new PropertyControl(this, attributes, ParentControl.ControlDetails);
                    break;

                case "type-group":
                    ctrl = new TypeGroupControl(this, attributes, ParentControl.ControlDetails);
                    break;

                case "type":
                    ctrl = new TypeControl(this, attributes, ParentControl.ControlDetails);
                    break;

                default:
                    break;
                }
                node.ContextMenuStrip = this.contextMenuNode;
            }
            if (ctrl != null)
            {
                pnlPropertiesContainer.Controls.Add(ctrl);
                InformProjectNeedsBuild();
                ctrl.BringToFront();
            }
        }
Exemple #8
0
        void InitializeControls()
        {
            // mindMapView1
            mindMapView1      = new MindMapView();
            mindMapView1.Dock = DockStyle.Fill;
            mindMapView1.ShowNavigationMap = true;
            mindMapView1.Text       = Lang._("Preview");
            mindMapView1.Padding    = new Padding(0);
            mindMapView1.ShowBorder = false;

            // myPropertyGrid1
            myPropertyGrid1                = new PropertyControl();
            myPropertyGrid1.Dock           = DockStyle.Fill;
            myPropertyGrid1.ShowBorder     = false;
            myPropertyGrid1.HelpVisible    = false;
            myPropertyGrid1.ToolbarVisible = false;
            myPropertyGrid1.Text           = Lang._("Property");

            // TxbRemark
            TxbRemark              = new TextBox();
            TxbRemark.Dock         = DockStyle.Fill;
            TxbRemark.Multiline    = true;
            TxbRemark.ScrollBars   = ScrollBars.Both;
            TxbRemark.BorderStyle  = BorderStyle.None;
            TxbRemark.BackColor    = SystemColors.Window;
            TxbRemark.ForeColor    = SystemColors.WindowText;
            TxbRemark.TextChanged += new EventHandler(this.TxbRemark_TextChanged);

            // PanelRemark
            PanelRemark      = new Panel();
            PanelRemark.Dock = DockStyle.Fill;
            PanelRemark.Controls.Add(TxbRemark);
            PanelRemark.Text = Lang._("Notes");

            tabControl1.AddPage(mindMapView1);
            tabControl1.AddPage(myPropertyGrid1);
            tabControl1.AddPage(PanelRemark);
            tabControl1.SelectedIndex = 0;
        }
        /// <summary>
        /// Analyzes rules tree directly from UI.
        /// </summary>
        public static void Initialize(PropertyControl tabControl)
        {
            IPropertyControlPage analyzersOptions = tabControl.Pages[0];
            TreeView             tree             = (TreeView)analyzersOptions.GetType().InvokeMember(
                "analyzeTree",
                BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.GetField,
                null,
                analyzersOptions,
                null);

            s_ruleNodes = new Dictionary <string, Dictionary <string, TreeNode> >();

            foreach (TreeNode parserNode in tree.Nodes)
            {
                foreach (TreeNode analyzerNode in parserNode.Nodes)
                {
                    SourceAnalyzer analyzer = (SourceAnalyzer)analyzerNode.Tag;
                    s_ruleNodes[analyzer.Id] = new Dictionary <string, TreeNode>();
                    AnalyzeRuleNodes(s_ruleNodes[analyzer.Id], analyzerNode);
                }
            }
        }
Exemple #10
0
        /// <summary>
        /// 封锁IP
        /// </summary>
        /// <param name="IP">IP地址</param>
        public void LockIP(string IP)
        {
            PropertyControl pc     = con.MainDomainConfigWithoutUserConfig;
            int             max    = 1;
            string          maxStr = pc["IPAccess1"].ToString();

            foreach (DictionaryEntry de in pc)
            {
                Match m = Regex.Match(de.Key.ToString(), @"IPAccess([0-9]+)", RegexOptions.IgnoreCase | RegexOptions.Singleline | RegexOptions.Compiled);
                if (m.Success)
                {
                    int num = Convert.ToInt32(m.Groups[1].Value);
                    if (num > max)
                    {
                        max    = num;
                        maxStr = de.Value.ToString();
                    }
                }
            }
            pc["IPAccess" + (max + 1).ToString()] = maxStr;
            pc["IPAccess" + (max).ToString()]     = "D|" + IP;
            con.SaveIni();
        }
Exemple #11
0
        public PropertyControl GetActivePropCtl(string dwgname)
        {
            string projectID = DwgFilesId.ContainsKey(dwgname) ? DwgFilesId[dwgname] : null;

            if (projectID == null)
            {
                return(null);
            }
            PropertyControl propertyControl = null;

            PropControls.TryGetValue(projectID, out propertyControl);

            if (propertyControl != null)
            {
                return(propertyControl);
            }
            else
            {
                BindPaletteSet.BindPropertyControl(out propertyControl);
                PropControls.Add(projectID, propertyControl);
                return(propertyControl);
            }
        }
Exemple #12
0
        /// <summary>
        /// 创建账户
        /// </summary>
        /// <param name="username">用户名</param>
        /// <param name="password">密码</param>
        /// <param name="HomeDir">主目录</param>
        /// <param name="Access">权限</param>
        /// <returns></returns>
        public bool CreateUser(string username, string password, string HomeDir, string Access = "WLP" /*默认为WLP,具体写法请参见serv-u配置文件说明*/)
        {
            if (!con.FtpUserList.ContainsKey(username))
            {
                HomeDir = XMLHelper.getAppSettingValue("FTP_Home") + "\\" + HomeDir;
                if (!Directory.Exists(HomeDir))
                {
                    Directory.CreateDirectory(HomeDir);
                }
                FtpUserInfo userinfo = new FtpUserInfo();
                userinfo.UserName = username;
                userinfo.Password = password;
                PropertyControl pc = userinfo.PropertyList;
                pc.Add("TimeOut", "600");
                pc.Add("RelPaths", "1");
                pc.Add("MaxUsersLoginPerIP", "1");
                pc.Add("HomeDir", HomeDir);
                pc.Add("MaxNrUsers", "1");
                pc.Add("Access1", HomeDir + "|" + Access);
                con.FtpUserList.Add(username, userinfo);
                con.SaveIni();

                if (!File.Exists(HomeDir + "\\上传的光盘文件命名请包含正确的ISBN和光盘条码.txt"))
                {
                    File.Create(@HomeDir + "\\上传的光盘文件命名请包含正确的ISBN和光盘条码!.txt");
                }
                //if (!File.Exists(@HomeDir + "\\请尽量避免光盘文件名包含中文.txt")) { File.Create(@HomeDir + "\\请尽量避免光盘文件名包含中文.txt"); }


                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #13
0
 private void SetValueProperty(object obj)
 {
     try
     {
         if (PropertyControl == null)
         {
             return;
         }
         if (GetSForm()?.CurrentControl == null)
         {
             return;
         }
         if (obj == null)
         {
             obj = new SReflection().ConvertProperty(PropertyControl);
         }
         PropertyControl.SetValue(GetSForm().CurrentControl, obj);
         ShootError(IsValid());
     }
     catch (Exception)
     {
         // Ignote
     }
 }
        /// <summary>
        /// Initializes the page.
        /// </summary>
        /// <param name="propertyControl">The tab control object.</param>
        public void Initialize(PropertyControl propertyControl)
        {
            Param.RequireNotNull(propertyControl, "propertyControl");

            this.tabControl = propertyControl;

            this.InitializeSettings();
            this.DetectBoldState();

            this.dirty = false;
            this.tabControl.DirtyChanged();
        }
Exemple #15
0
        protected override void Start()
        {
            this.AddLabelControl("BlendingOptionsLabel").SetLabelStyle(EditorStyles.boldLabel);
            _blendMode = this.AddEnumControl <BlendMode>("_Mode");
            _colorMode = this.AddEnumControl <ColorMode>("_ColorMode");
            this.AddSpaceControl();

            this.AddLabelControl("MainOptionsLabel").SetLabelStyle(EditorStyles.boldLabel);
            _flipbook = this.AddKeywordToggleControl("_REQUIRE_UV2");
            this.AddToggleControl("_Cull", 0, 2);

            _zWriteOffOptions     = this.AddControlContainer();
            _softParticles        = _zWriteOffOptions.AddToggleListControl("_SoftParticlesEnabled");
            _softParticleNearFade = _softParticles.AddPropertyControl("_SoftParticlesNearFadeDistance");
            _softParticleFarFade  = _softParticles.AddPropertyControl("_SoftParticlesFarFadeDistance");
            _cameraFading         = _zWriteOffOptions.AddToggleListControl("_CameraFadingEnabled");
            _cameraNearFade       = _cameraFading.AddPropertyControl("_CameraNearFadeDistance");
            _cameraFarFade        = _cameraFading.AddPropertyControl("_CameraFarFadeDistance");

            _dissolve = this.AddToggleListControl("_DissolveEnabled");
            _dissolve.AddTextureControl("_DissolveTex");
            _dissolve.AddPropertyControl("_DCutoff");
            _dissolve.AddPropertyControl("_DissolveScale");

            _vertexMod = this.AddToggleListControl("_VertexMod");
            _vertexMod.AddTextureControl("_NoiseTex");
            _vertexMod.AddPropertyControl("_Amplitude");
            _vertexMod.AddVectorControl("_VUVScroll", true, true, false, false).Alias("VertexUVScroll");
            _vertexMod.AddVectorControl("_VUVScroll", false, false, true, true).Alias("VertexUVScale");

            _rim = this.AddToggleListControl("_RimEn");
            _rim.AddPropertyControl("_RimVal");
            _rim.AddColorControl("_RimColor");

            _distorsion = this.AddToggleListControl("_UVDistEnable");
            _distorsion.AddTextureControl("_UVDisTex");
            _distorsion.AddVectorControl("_UVDisSpeed", true, true, false, false).Alias("UVScrollSpeed");
            _distorsion.AddVectorControl("_UVDisSpeed", false, false, true, true).Alias("UVScrollScale");
            this.AddSpaceControl();

            this.AddLabelControl("MapsOptionsLabel").SetLabelStyle(EditorStyles.boldLabel);
            _albedoControl = this.AddTextureControl("_MainTex", "_Color").SetHasHDRColor(true);
            this.AddVectorControl("_UVScroll", true, true, false, false);
            this.AddSpaceControl();

            _albedo2 = this.AddToggleListControl("_MainTex2Enabled");
            _albedo2.AddTextureControl("_MainTex2", "_Color2").SetHasHDRColor(true);
            _albedo2.AddEnumControl <VRLBlend>("_MainTex2Blend");
            _albedo2.AddVectorControl("_UVScroll2", true, true, false, false).Alias("Albedo2ScrollSpeed");
            _albedo2.AddVectorControl("_UVScroll2", false, false, true, true).Alias("Albedo2ScrollScale");
            this.AddSpaceControl();

            _emission        = this.AddKeywordToggleListControl("_EMISSION");
            _emissionControl = _emission.AddTextureControl("_EmissionMap", "_EmissionColor").SetHasHDRColor(true);
            this.AddSpaceControl();

            _mainTileAndOffset = this.AddTilingAndOffsetControl("_MainTex");
            this.AddSpaceControl();

            _streamsControl = this.AddVertexStreamsControl("VertexStreams")
                              .AddVertexStream(ParticleSystemVertexStream.Position)
                              .AddVertexStream(ParticleSystemVertexStream.Color)
                              .AddVertexStream(ParticleSystemVertexStream.UV);
        }
        /// <summary>
        /// Initializes the page.
        /// </summary>
        /// <param name="propertyControl">The tab control object.</param>
        public void Initialize(PropertyControl propertyControl)
        {
            Param.AssertNotNull(propertyControl, "propertyControl");

            this.tabControl = propertyControl;

            // Get the cache setting.
            this.writeCachePropertyDescriptor = this.tabControl.Core.PropertyDescriptors["WriteCache"] as PropertyDescriptor <bool>;

            this.writeCacheParentProperty = this.tabControl.ParentSettings == null
                                                ? null
                                                : this.tabControl.ParentSettings.GlobalSettings.GetProperty(this.writeCachePropertyDescriptor.PropertyName) as
                                            BooleanProperty;

            var mergedWriteCacheProperty = this.tabControl.MergedSettings == null
                                               ? null
                                               : this.tabControl.MergedSettings.GlobalSettings.GetProperty(this.writeCachePropertyDescriptor.PropertyName) as
                                           BooleanProperty;

            this.enableCache.Checked = mergedWriteCacheProperty == null ? this.writeCachePropertyDescriptor.DefaultValue : mergedWriteCacheProperty.Value;

            this.autoUpdateCheckPropertyDescriptor = this.tabControl.Core.PropertyDescriptors["AutoCheckForUpdate"] as PropertyDescriptor <bool>;

            this.autoUpdateParentProperty = this.tabControl.ParentSettings == null
                                                ? null
                                                : this.tabControl.ParentSettings.GlobalSettings.GetProperty(this.autoUpdateCheckPropertyDescriptor.PropertyName) as
                                            BooleanProperty;

            var mergedAutoUpdateProperty = this.tabControl.MergedSettings == null
                                               ? null
                                               : this.tabControl.MergedSettings.GlobalSettings.GetProperty(this.autoUpdateCheckPropertyDescriptor.PropertyName) as
                                           BooleanProperty;

            this.autoUpdateCheckBox.Checked = mergedAutoUpdateProperty == null ? this.autoUpdateCheckPropertyDescriptor.DefaultValue : mergedAutoUpdateProperty.Value;

            this.daysToCheckPropertyDescriptor = this.tabControl.Core.PropertyDescriptors["DaysToCheckForUpdates"] as PropertyDescriptor <int>;

            this.daysToCheckParentProperty = this.tabControl.ParentSettings == null
                                                 ? null
                                                 : this.tabControl.ParentSettings.GlobalSettings.GetProperty(this.daysToCheckPropertyDescriptor.PropertyName) as
                                             IntProperty;

            var mergedDaysToCheckProperty = this.tabControl.MergedSettings == null
                                                ? null
                                                : this.tabControl.MergedSettings.GlobalSettings.GetProperty(this.daysToCheckPropertyDescriptor.PropertyName) as
                                            IntProperty;

            this.daysMaskedTextBox.Text = mergedDaysToCheckProperty == null
                                              ? this.daysToCheckPropertyDescriptor.DefaultValue.ToString(CultureInfo.InvariantCulture)
                                              : mergedDaysToCheckProperty.Value.ToString(CultureInfo.InvariantCulture);

            this.maxViolationCountPropertyDescriptor = this.tabControl.Core.PropertyDescriptors["MaxViolationCount"] as PropertyDescriptor <int>;

            this.maxViolationCountParentProperty = this.tabControl.ParentSettings == null
                                                       ? null
                                                       : this.tabControl.ParentSettings.GlobalSettings.GetProperty(this.maxViolationCountPropertyDescriptor.PropertyName)
                                                   as IntProperty;

            var mergedMaxViolationCountProperty = this.tabControl.MergedSettings == null
                                                      ? null
                                                      : this.tabControl.MergedSettings.GlobalSettings.GetProperty(this.maxViolationCountPropertyDescriptor.PropertyName)
                                                  as IntProperty;

            this.maxViolationCountMaskedTextBox.Text = mergedMaxViolationCountProperty == null
                                                           ? this.maxViolationCountPropertyDescriptor.DefaultValue.ToString(CultureInfo.InvariantCulture)
                                                           : mergedMaxViolationCountProperty.Value.ToString(CultureInfo.InvariantCulture);

            // Culture
            this.culturePropertyDescriptor = this.tabControl.Core.PropertyDescriptors["Culture"] as PropertyDescriptor <string>;

            this.cultureParentProperty = this.tabControl.ParentSettings == null
                                             ? null
                                             : this.tabControl.ParentSettings.GlobalSettings.GetProperty(this.culturePropertyDescriptor.PropertyName) as StringProperty;

            var mergedCultureProperty = this.tabControl.MergedSettings == null
                                            ? null
                                            : this.tabControl.MergedSettings.GlobalSettings.GetProperty(this.culturePropertyDescriptor.PropertyName) as StringProperty;

            this.cultureComboBox.SelectedIndex =
                this.cultureComboBox.FindStringExact(
                    mergedCultureProperty == null
                        ? this.culturePropertyDescriptor.DefaultValue.ToString(CultureInfo.InvariantCulture)
                        : mergedCultureProperty.Value.ToString(CultureInfo.InvariantCulture));

            this.SetBoldState();

            // Reset the dirty flag to false now.
            this.dirty = false;
            this.tabControl.DirtyChanged();
        }
        /// <summary>
        /// Initializes the page.
        /// </summary>
        /// <param name="propertyControl">
        /// The tab control object.
        /// </param>
        public void Initialize(PropertyControl propertyControl)
        {
            Param.AssertNotNull(propertyControl, "propertyControl");

            this.tabControl = propertyControl;

            if (this.analyzer != null)
            {
                // Get the list of allowed prefixes from the parent settings.
                this.AddParentPrefixes();

                // Get the list of allowed prefixes from the local settings.
                CollectionProperty localPrefixesProperty =
                    this.tabControl.LocalSettings.GetAddInSetting(this.analyzer, NamingRules.AllowedPrefixesProperty) as CollectionProperty;

                if (localPrefixesProperty != null && localPrefixesProperty.Values.Count > 0)
                {
                    foreach (string value in localPrefixesProperty)
                    {
                        if (!string.IsNullOrEmpty(value))
                        {
                            ListViewItem item = this.prefixList.Items.Add(value);
                            if (item != null)
                            {
                                item.Tag = true;
                                this.SetBoldState(item);
                            }
                        }
                    }
                }
            }

            // Select the first item in the list.
            if (this.prefixList.Items.Count > 0)
            {
                this.prefixList.Items[0].Selected = true;
            }

            this.EnableDisableRemoveButton();

            this.dirty = false;
            this.tabControl.DirtyChanged();
        }
Exemple #18
0
 private IEnumerable <Attribute> GetAttribute()
 {
     return(PropertyControl?.GetCustomAttributes());
 }
Exemple #19
0
        private Dictionary <string, bool> IsValid()
        {
            if (!(FindForm() is FBase))
            {
                return(new Dictionary <string, bool>());
            }
            if (!(GetSForm().StateForm == StateForm.Inserting || GetSForm().StateForm == StateForm.Editing))
            {
                return(new Dictionary <string, bool>());
            }
            try
            {
                if (Name == string.Empty)
                {
                    return(new Dictionary <string, bool>());
                }
                Validations = new Dictionary <string, bool>();

                if (GetSForm() == null)
                {
                    RemoveErrorProvider();
                    return(new Dictionary <string, bool>());
                }
                if (PropertyControl == null)
                {
                    return(new Dictionary <string, bool>());
                }
                var validationAttributes = GetAttribute();
                var reflection           = new SReflection();
                foreach (var attribute in validationAttributes)
                {
                    try
                    {
                        var validationAttribute = attribute as ValidationAttribute;
                        if (validationAttribute == null)
                        {
                            continue;
                        }
                        bool isValid;

                        var operatorValue = GetAttribute <OperationValue>(PropertyControl);
                        if (operatorValue != null)
                        {
                            decimal result     = 0;
                            var     component1 =
                                GetSForm()
                                .GetListControls()
                                .FirstOrDefault(c => c.Name == operatorValue.PropertyOperationName);
                            var componentTotal =
                                GetSForm()
                                .GetListControls()
                                .FirstOrDefault(c => c.Name == operatorValue.PropertyResultName);
                            if (component1 != null)
                            {
                                if (componentTotal != null)
                                {
                                    switch (operatorValue.TypeOperation)
                                    {
                                    case TypeOperation.Division:
                                        if ((decimal)ValueControl != 0)
                                        {
                                            result = (decimal)component1.ValueControl / (decimal)ValueControl;
                                        }
                                        break;

                                    case TypeOperation.Multiplication:
                                        result = (decimal)ValueControl * (decimal)component1.ValueControl;
                                        break;

                                    case TypeOperation.Sum:
                                        result = (decimal)ValueControl + (decimal)component1.ValueControl;
                                        break;

                                    case TypeOperation.Subtraction:
                                        result = (decimal)component1.ValueControl - (decimal)ValueControl;
                                        break;

                                    case TypeOperation.SubtractionInversion:
                                        result = (decimal)ValueControl - (decimal)component1.ValueControl;
                                        break;

                                    case TypeOperation.SubtractionPorcent:
                                        result = (decimal)component1.ValueControl - (((decimal)component1.ValueControl / 100) * (decimal)ValueControl);
                                        break;

                                    case TypeOperation.AditionalPorcent:
                                        result = (decimal)component1.ValueControl + (((decimal)component1.ValueControl / 100) * (decimal)ValueControl);
                                        break;

                                    case TypeOperation.PorcentValue:
                                        result = (((decimal)component1.ValueControl / 100) * (decimal)ValueControl);
                                        break;

                                    default:
                                        result = 0;
                                        break;
                                    }
                                }
                            }
                            componentTotal.Disable      = false;
                            componentTotal.ValueControl = result;
                        }

                        if (validationAttribute is LockedTrueValue)
                        {
                            var lockedTrueValue = validationAttribute as LockedTrueValue;
                            var valid           = false;
                            if (lockedTrueValue.UniqueValue)
                            {
                                valid = lockedTrueValue.Value[0].ToString() != ValueControl.ToString();
                            }
                            for (var i = 0; i < lockedTrueValue.PropertyName.Count(); i++)
                            {
                                if (!lockedTrueValue.UniqueValue)
                                {
                                    valid = lockedTrueValue.Value[i]?.ToString() != PropertyControl?.GetValue(GetSForm()?.CurrentControl)?.ToString();
                                }

                                var component = GetSForm().GetListControls().FirstOrDefault(c => c.Name == lockedTrueValue.PropertyName[i]);
                                component.Disable = valid;
                                if (!valid)
                                {
                                    component.Clear();
                                }
                            }
                        }

                        if (validationAttribute is CompareAttribute)
                        {
                            var otherName     = validationAttribute.GetType().GetProperty("OtherProperty").GetValue(validationAttribute).ToString();
                            var otherProperty = CurrentControl.GetType().GetProperty(otherName);
                            var otherValue    = otherProperty.GetValue(CurrentControl);
                            isValid = otherValue?.ToString() == ValueControl.ToString();
                        }
                        else
                        {
                            if (this is SComboBox)
                            {
                                isValid = !ValueControl.ToString().Equals("0");
                            }
                            else
                            {
                                isValid = validationAttribute.IsValid(ValueControl);
                            }
                        }
                        var key = validationAttribute.FormatErrorMessage(DisplayName(PropertyControl));
                        if (!isValid && !Validations.ContainsKey(key))
                        {
                            Validations.Add(key, false);
                        }

                        var compoundIndex = GetSForm().GetAttribute <CompoundIndex>();
                        var unique        = attribute as Unique;

                        if ((compoundIndex != null && compoundIndex.Properties.Contains(Name)) || unique != null)
                        {
                            var typeValue = ValueControl as string;
                            if (!(typeValue != null && ReferenceEquals(ValueControl, string.Empty)))
                            {
                                // Pego o tipo do contexto.
                                var typeDataSource = GetSForm().InvokeMethod.TypeModel;

                                // Para garantia de Lista anonima (generica), pesquisa pela propriedade Id,
                                // chave primária do objeto.
                                var property = PropertyControl;

                                // Pego o valor da propriedade do objeto atual.
                                var value = ValueControl;

                                // se o tipo do objeto já foi informado para mesmo contexto, não é passado mais.
                                var parameterType = Expression.Parameter(typeDataSource);

                                // passa o tipo da propriedade
                                var prop = Expression.Property(parameterType, property);
                                // converte o tipo do dado, para garantir a identidade do mesmo.
                                var convertedValue = reflection.ChangeType(value, property.PropertyType);
                                // cria expressao do valor que será passada na expressão.
                                var soap = Expression.Constant(convertedValue);
                                // relaciona a propriedade com o dado. Exemplo: param0 => param0 == 1
                                var equal = Expression.Equal(prop, soap);

                                Expression expressionCompound = null;
                                // Se acaso for index composto adiciona mais uma expressão
                                if (compoundIndex != null && compoundIndex.Properties.Contains(Name))
                                {
                                    // Pesquiso  as outras propriedades que fazem parte da composição.
                                    var properties = compoundIndex.Properties.Where(c => c != Name);

                                    expressionCompound = (from index in properties select typeDataSource.GetProperty(index) into propertyCompoundId let propCompoundId = Expression.Property(parameterType, propertyCompoundId) let convertedValueCompoundId = reflection.ChangeType(propertyCompoundId.GetValue(GetSForm().CurrentControl), propertyCompoundId.PropertyType) let soapCompoundId = Expression.Constant(convertedValueCompoundId) select Expression.Equal(propCompoundId, soapCompoundId)).Aggregate(expressionCompound, (current, equalCompoundId) => current == null ? equalCompoundId : Expression.And(equalCompoundId, current));
                                }

                                if (expressionCompound != null)
                                {
                                    equal = Expression.And(equal, expressionCompound);
                                }

                                var propertyId = typeDataSource.GetProperty("Id");
                                // passa o tipo da propriedade
                                var propId = Expression.Property(parameterType, propertyId);
                                // converte o tipo do dado, para garantir a identidade do mesmo.
                                var convertedValueId = Convert.ChangeType(propertyId.GetValue(GetSForm().CurrentControl), propertyId.PropertyType);
                                // cria expressao do valor que será passada na expressão.
                                var soapId = Expression.Constant(convertedValueId);
                                // relaciona a propriedade com o dado. Exemplo: param0 => param0 == 1
                                var equalId = Expression.NotEqual(propId, soapId);

                                var yourExpression = Expression.And(equal, equalId);

                                var delegateType = typeof(Func <,>).MakeGenericType(typeDataSource, typeof(bool));
                                var expression   = Expression.Lambda(delegateType, yourExpression, true, parameterType);
                                var objetoApp    = GetSForm().InvokeMethod;
                                var method       = objetoApp.Methods.FirstOrDefault(c => c.Key == TypeExecute.Search).Value;
                                if (string.IsNullOrEmpty(method))
                                {
                                    MessageBox.Show("Método Search não configurado\nController: " + objetoApp.TypeController.Name,
                                                    "ESR Softwares", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                                }
                                var result = reflection.GetListContext(objetoApp.TypeController, method, expression);

                                var components = GetSForm().GetListControls().Where(c =>
                                {
                                    if (compoundIndex == null)
                                    {
                                        return(false);
                                    }
                                    foreach (var s in compoundIndex.Properties)
                                    {
                                        if (Equals(s, c.Name))
                                        {
                                            break;
                                        }
                                    }
                                    return(false);
                                });

                                if (result.Any())
                                {
                                    if (compoundIndex != null && compoundIndex.Properties.Contains(Name))
                                    {
                                        var enumerable      = components as IList <IComponent> ?? components.ToList();
                                        var componentValues = enumerable.Aggregate("", (current, component) => current + component.Caption + " = " + component.ValueControl + " ");
                                        foreach (var component in enumerable)
                                        {
                                            component.SetError("Já existem dados com " + componentValues);
                                            component.ComponentBackColor = Color.FromArgb(255, 255, 173, 178);
                                        }
                                        Validations.Add("Já existem dados com " + (componentValues == "" ? " este registro" : componentValues), false);
                                    }
                                    else
                                    {
                                        Validations.Add("Este " + GetTextLabel() + " já existe, considere em informar outro", false);
                                    }
                                }
                                else
                                {
                                    foreach (var component in components)
                                    {
                                        if (!component.Validations.Values.Contains(false))
                                        {
                                            component.RemoveErrorProvider();
                                        }
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception)
                    {
                        continue;
                    }
                    SComponent.BackColor = Validations.Values.Contains(false) ? Color.FromArgb(255, 255, 173, 178) : Color.White;
                }
                return(Validations);
            }
            catch (Exception exception)
            {
                throw new Exception(exception.Message);
            }
        }
Exemple #20
0
        private void HandleNodeMenuClick(string clickedNode, string op, object tag)
        {
            if (op.Equals("add"))
            {
                UserControl ctrl = null;
                pnlPropertiesContainer.Controls.Clear();
                switch (clickedNode)
                {
                case "property":
                    ctrl = new PropertyControl(this, null, ParentControl.ControlDetails);
                    break;

                case "type-group":
                    ctrl = new TypeGroupControl(this, null, ParentControl.ControlDetails);
                    break;

                case "type":
                    ctrl = new TypeControl(this, null, ParentControl.ControlDetails, tag);
                    break;

                default:
                    break;
                }
                if (ctrl != null)
                {
                    pnlPropertiesContainer.Controls.Add(ctrl);
                    InformProjectNeedsBuild();
                    ctrl.BringToFront();
                }
            }
            else if (op.Equals("delete"))
            {
                contextMenuNode.Hide();
                string mboxCaption = "Confirm Delete";
                Dictionary <string, string> details        = (Dictionary <string, string>)tag;
                ControlManifestHelper       manifestHelper = new ControlManifestHelper();
                string mboxMessage = string.Empty;

                switch (clickedNode)
                {
                case "property":
                    if (MessageBox.Show("Are you sure you want to remove this property?", mboxCaption, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                    {
                        manifestHelper.DeleteProperty(ParentControl.ControlDetails, details["Name"]);
                    }
                    break;

                case "type-group":
                    int refCount = manifestHelper.RetrieveTypeGroupReferenceCount(ParentControl.ControlDetails, details["Name"]);
                    mboxMessage = string.Empty;
                    if (refCount > 0)
                    {
                        mboxMessage = $"There {(refCount == 1 ? "is" : "are")} {refCount} reference{(refCount == 1 ? "" : "s")} for this TypeGroup. Do you still want to remove this TypeGroup?\n" +
                                      $"Removing this TypeGroup will cause build errors. Recommendation is to select 'No' and fix the references then remove the TypeGroup.";
                    }
                    else
                    {
                        mboxMessage = "Are you sure you want to remove this type group?";
                    }

                    if (MessageBox.Show(mboxMessage, mboxCaption, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                    {
                        manifestHelper.DeleteTypeGroup(ParentControl.ControlDetails, details["Name"]);
                    }
                    break;

                case "type":
                    int typeCount = manifestHelper.RetrieveTypeInTypeGroupCount(ParentControl.ControlDetails, details["type-groups"]);
                    mboxMessage = string.Empty;
                    if (typeCount == 1)
                    {
                        mboxMessage = $"You are attempting to delete the last type in {details["type-groups"]} TypeGroup. Atleast one type is required in the TypeGroup. " +
                                      $"\nDo you still want to proceed?";
                    }
                    else
                    {
                        mboxMessage = "Are you sure you want to remove this type?";
                    }

                    if (MessageBox.Show(mboxMessage, mboxCaption, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                    {
                        manifestHelper.DeleteTypeInTypeGroup(ParentControl.ControlDetails, details["type-groups"], details["type"]);
                    }
                    break;

                default:
                    break;
                }
                RefreshControlManifestDetails();
            }
        }
        /// <summary>
        /// Initializes the page.
        /// </summary>
        /// <param name="propertyControl">The tab control object.</param>
        public void Initialize(PropertyControl propertyControl)
        {
            Param.AssertNotNull(propertyControl, "propertyControl");

            this.tabControl = propertyControl;

            // Get the cache setting.
            this.writeCachePropertyDescriptor = this.tabControl.Core.PropertyDescriptors["WriteCache"] as PropertyDescriptor<bool>;

            this.writeCacheParentProperty = this.tabControl.ParentSettings == null
                                                ? null
                                                : this.tabControl.ParentSettings.GlobalSettings.GetProperty(this.writeCachePropertyDescriptor.PropertyName) as
                                                  BooleanProperty;

            var mergedWriteCacheProperty = this.tabControl.MergedSettings == null
                                               ? null
                                               : this.tabControl.MergedSettings.GlobalSettings.GetProperty(this.writeCachePropertyDescriptor.PropertyName) as
                                                 BooleanProperty;

            this.enableCache.Checked = mergedWriteCacheProperty == null ? this.writeCachePropertyDescriptor.DefaultValue : mergedWriteCacheProperty.Value;

            this.autoUpdateCheckPropertyDescriptor = this.tabControl.Core.PropertyDescriptors["AutoCheckForUpdate"] as PropertyDescriptor<bool>;

            this.autoUpdateParentProperty = this.tabControl.ParentSettings == null
                                                ? null
                                                : this.tabControl.ParentSettings.GlobalSettings.GetProperty(this.autoUpdateCheckPropertyDescriptor.PropertyName) as
                                                  BooleanProperty;

            var mergedAutoUpdateProperty = this.tabControl.MergedSettings == null
                                               ? null
                                               : this.tabControl.MergedSettings.GlobalSettings.GetProperty(this.autoUpdateCheckPropertyDescriptor.PropertyName) as
                                                 BooleanProperty;

            this.autoUpdateCheckBox.Checked = mergedAutoUpdateProperty == null ? this.autoUpdateCheckPropertyDescriptor.DefaultValue : mergedAutoUpdateProperty.Value;

            this.daysToCheckPropertyDescriptor = this.tabControl.Core.PropertyDescriptors["DaysToCheckForUpdates"] as PropertyDescriptor<int>;

            this.daysToCheckParentProperty = this.tabControl.ParentSettings == null
                                                 ? null
                                                 : this.tabControl.ParentSettings.GlobalSettings.GetProperty(this.daysToCheckPropertyDescriptor.PropertyName) as
                                                   IntProperty;

            var mergedDaysToCheckProperty = this.tabControl.MergedSettings == null
                                                ? null
                                                : this.tabControl.MergedSettings.GlobalSettings.GetProperty(this.daysToCheckPropertyDescriptor.PropertyName) as
                                                  IntProperty;

            this.daysMaskedTextBox.Text = mergedDaysToCheckProperty == null
                                              ? this.daysToCheckPropertyDescriptor.DefaultValue.ToString(CultureInfo.InvariantCulture)
                                              : mergedDaysToCheckProperty.Value.ToString(CultureInfo.InvariantCulture);

            this.maxViolationCountPropertyDescriptor = this.tabControl.Core.PropertyDescriptors["MaxViolationCount"] as PropertyDescriptor<int>;

            this.maxViolationCountParentProperty = this.tabControl.ParentSettings == null
                                                       ? null
                                                       : this.tabControl.ParentSettings.GlobalSettings.GetProperty(this.maxViolationCountPropertyDescriptor.PropertyName)
                                                         as IntProperty;

            var mergedMaxViolationCountProperty = this.tabControl.MergedSettings == null
                                                      ? null
                                                      : this.tabControl.MergedSettings.GlobalSettings.GetProperty(this.maxViolationCountPropertyDescriptor.PropertyName)
                                                        as IntProperty;

            this.maxViolationCountMaskedTextBox.Text = mergedMaxViolationCountProperty == null
                                                           ? this.maxViolationCountPropertyDescriptor.DefaultValue.ToString(CultureInfo.InvariantCulture)
                                                           : mergedMaxViolationCountProperty.Value.ToString(CultureInfo.InvariantCulture);

            // Culture
            this.culturePropertyDescriptor = this.tabControl.Core.PropertyDescriptors["Culture"] as PropertyDescriptor<string>;

            this.cultureParentProperty = this.tabControl.ParentSettings == null
                                             ? null
                                             : this.tabControl.ParentSettings.GlobalSettings.GetProperty(this.culturePropertyDescriptor.PropertyName) as StringProperty;

            var mergedCultureProperty = this.tabControl.MergedSettings == null
                                            ? null
                                            : this.tabControl.MergedSettings.GlobalSettings.GetProperty(this.culturePropertyDescriptor.PropertyName) as StringProperty;

            this.cultureComboBox.SelectedIndex =
                this.cultureComboBox.FindStringExact(
                    mergedCultureProperty == null
                        ? this.culturePropertyDescriptor.DefaultValue.ToString(CultureInfo.InvariantCulture)
                        : mergedCultureProperty.Value.ToString(CultureInfo.InvariantCulture));

            this.SetBoldState();

            // Reset the dirty flag to false now.
            this.dirty = false;
            this.tabControl.DirtyChanged();
        }
Exemple #22
0
        private void AddMainUI(VisualElement mainView)
        {
            var visualTree = EditorGUIUtility.Load("UXML/SpriteEditor/SpriteFrameModuleInspector.uxml") as VisualTreeAsset;

            m_SelectedFrameInspector = visualTree.CloneTree(null).Q("spriteFrameModuleInspector");

            m_NameElement = m_SelectedFrameInspector.Q("name");
            m_NameField   = m_SelectedFrameInspector.Q <PropertyControl <string> >("spriteName");
            m_NameField.OnValueChanged((evt) =>
            {
                if (hasSelected)
                {
                    selectedSpriteName = evt.newValue;
                }
            });

            m_PositionElement = m_SelectedFrameInspector.Q("position");
            m_PositionFieldX  = m_PositionElement.Q <PropertyControl <long> >("positionX");
            m_PositionFieldX.OnValueChanged((evt) =>
            {
                if (hasSelected)
                {
                    var rect               = selectedSpriteRect;
                    rect.x                 = evt.newValue;
                    selectedSpriteRect     = rect;
                    m_PositionFieldX.value = (long)selectedSpriteRect.x;
                }
            });

            m_PositionFieldY = m_PositionElement.Q <PropertyControl <long> >("positionY");
            m_PositionFieldY.OnValueChanged((evt) =>
            {
                if (hasSelected)
                {
                    var rect               = selectedSpriteRect;
                    rect.y                 = evt.newValue;
                    selectedSpriteRect     = rect;
                    m_PositionFieldY.value = (long)selectedSpriteRect.y;
                }
            });

            m_PositionFieldW = m_PositionElement.Q <PropertyControl <long> >("positionW");
            m_PositionFieldW.OnValueChanged((evt) =>
            {
                if (hasSelected)
                {
                    var rect               = selectedSpriteRect;
                    rect.width             = evt.newValue;
                    selectedSpriteRect     = rect;
                    m_PositionFieldW.value = (long)selectedSpriteRect.width;
                }
            });

            m_PositionFieldH = m_PositionElement.Q <PropertyControl <long> >("positionH");
            m_PositionFieldH.OnValueChanged((evt) =>
            {
                if (hasSelected)
                {
                    var rect               = selectedSpriteRect;
                    rect.height            = evt.newValue;
                    selectedSpriteRect     = rect;
                    m_PositionFieldH.value = (long)selectedSpriteRect.height;
                }
            });

            var borderElement = m_SelectedFrameInspector.Q("border");

            m_BorderFieldL = borderElement.Q <PropertyControl <long> >("borderL");
            m_BorderFieldL.OnValueChanged((evt) =>
            {
                if (hasSelected)
                {
                    var border           = selectedSpriteBorder;
                    border.x             = evt.newValue;
                    selectedSpriteBorder = border;
                    m_BorderFieldL.value = (long)selectedSpriteBorder.x;
                }
            });

            m_BorderFieldT = borderElement.Q <PropertyControl <long> >("borderT");
            m_BorderFieldT.OnValueChanged((evt) =>
            {
                if (hasSelected)
                {
                    var border           = selectedSpriteBorder;
                    border.y             = evt.newValue;
                    selectedSpriteBorder = border;
                    m_BorderFieldT.value = (long)selectedSpriteBorder.y;
                }
            });

            m_BorderFieldR = borderElement.Q <PropertyControl <long> >("borderR");
            m_BorderFieldR.OnValueChanged((evt) =>
            {
                if (hasSelected)
                {
                    var border           = selectedSpriteBorder;
                    border.z             = evt.newValue;
                    selectedSpriteBorder = border;
                    m_BorderFieldR.value = (long)selectedSpriteBorder.z;
                }
            });

            m_BorderFieldB = borderElement.Q <PropertyControl <long> >("borderB");
            m_BorderFieldB.OnValueChanged((evt) =>
            {
                if (hasSelected)
                {
                    var border           = selectedSpriteBorder;
                    border.w             = evt.newValue;
                    selectedSpriteBorder = border;
                    m_BorderFieldB.value = (long)selectedSpriteBorder.w;
                }
            });

            m_PivotField = m_SelectedFrameInspector.Q <EnumField>("pivotField");
            m_PivotField.Init(SpriteAlignment.Center);
            m_PivotField.OnValueChanged((evt) =>
            {
                if (hasSelected)
                {
                    SpriteAlignment alignment = (SpriteAlignment)evt.newValue;
                    SetSpritePivotAndAlignment(selectedSpritePivot, alignment);
                    m_CustomPivotElement.SetEnabled(selectedSpriteAlignment == SpriteAlignment.Custom);

                    Vector2 pivot             = selectedSpritePivotInCurUnitMode;
                    m_CustomPivotFieldX.value = pivot.x;
                    m_CustomPivotFieldY.value = pivot.y;
                }
            });


            m_PivotUnitModeField = m_SelectedFrameInspector.Q <EnumField>("pivotUnitModeField");
            m_PivotUnitModeField.Init(PivotUnitMode.Normalized);
            m_PivotUnitModeField.OnValueChanged((evt) =>
            {
                if (hasSelected)
                {
                    m_PivotUnitMode = (PivotUnitMode)evt.newValue;

                    Vector2 pivot             = selectedSpritePivotInCurUnitMode;
                    m_CustomPivotFieldX.value = pivot.x;
                    m_CustomPivotFieldY.value = pivot.y;
                }
            });


            m_CustomPivotElement = m_SelectedFrameInspector.Q("customPivot");
            m_CustomPivotFieldX  = m_CustomPivotElement.Q <PropertyControl <double> >("customPivotX");
            m_CustomPivotFieldX.OnValueChanged((evt) =>
            {
                if (hasSelected)
                {
                    float newValue = (float)evt.newValue;
                    float pivotX   = m_PivotUnitMode == PivotUnitMode.Pixels
                            ? ConvertFromRectToNormalizedSpace(new Vector2(newValue, 0.0f), selectedSpriteRect).x
                            : newValue;

                    var pivot = selectedSpritePivot;
                    pivot.x   = pivotX;
                    SetSpritePivotAndAlignment(pivot, selectedSpriteAlignment);
                }
            });

            m_CustomPivotFieldY = m_CustomPivotElement.Q <PropertyControl <double> >("customPivotY");
            m_CustomPivotFieldY.OnValueChanged((evt) =>
            {
                if (hasSelected)
                {
                    float newValue = (float)evt.newValue;
                    float pivotY   = m_PivotUnitMode == PivotUnitMode.Pixels
                            ? ConvertFromRectToNormalizedSpace(new Vector2(0.0f, newValue), selectedSpriteRect).y
                            : newValue;

                    var pivot = selectedSpritePivot;
                    pivot.y   = pivotY;
                    SetSpritePivotAndAlignment(pivot, selectedSpriteAlignment);
                }
            });

            //// Force an update of all the fields.
            PopulateSpriteFrameInspectorField();

            mainView.RegisterCallback <SpriteSelectionChangeEvent>(SelectionChange);

            // Stop mouse events from reaching the main view.
            m_SelectedFrameInspector.pickingMode = PickingMode.Ignore;
            m_SelectedFrameInspector.RegisterCallback <MouseDownEvent>((e) => { e.StopPropagation(); });
            m_SelectedFrameInspector.RegisterCallback <MouseUpEvent>((e) => { e.StopPropagation(); });
            m_SelectedFrameInspector.AddToClassList("moduleWindow");
            m_SelectedFrameInspector.AddToClassList("bottomRightFloating");
            mainView.Add(m_SelectedFrameInspector);
        }