示例#1
0
        void ShowPropertyGrid()
        {
            if (localizedTypeDescriptor == null)
            {
                localizedTypeDescriptor = new LocalizedTypeDescriptor();
            }

            if (!Controls.Contains(propertyGrid))
            {
                this.SuspendLayout();
                propertyGrid.Location = new Point(Width - GridMargin, GridMargin);
                propertyGrid.Anchor   = AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom;
                localizedTypeDescriptor.Properties.Clear();
                foreach (TemplateProperty property in SelectedTemplate.Properties)
                {
                    LocalizedProperty localizedProperty;
                    if (property.Type.StartsWith("Types:"))
                    {
                        localizedProperty = new LocalizedProperty(property.Name, "System.Enum", property.Category, property.Description);
                        TemplateType type = null;
                        foreach (TemplateType templateType in SelectedTemplate.CustomTypes)
                        {
                            if (templateType.Name == property.Type.Substring("Types:".Length))
                            {
                                type = templateType;
                                break;
                            }
                        }
                        if (type == null)
                        {
                            throw new Exception("type : " + property.Type + " not found.");
                        }
                        localizedProperty.TypeConverterObject = new CustomTypeConverter(type);
                        StringParserPropertyContainer.LocalizedProperty["Properties." + localizedProperty.Name] = property.DefaultValue;
                        localizedProperty.DefaultValue = property.DefaultValue;                         // localizedProperty.TypeConverterObject.ConvertFrom();
                    }
                    else
                    {
                        localizedProperty = new LocalizedProperty(property.Name, property.Type, property.Category, property.Description);
                        if (property.Type == "System.Boolean")
                        {
                            localizedProperty.TypeConverterObject = new BooleanTypeConverter();
                            string defVal = property.DefaultValue == null ? null : property.DefaultValue.ToString();
                            if (defVal == null || defVal.Length == 0)
                            {
                                defVal = "True";
                            }
                            StringParserPropertyContainer.LocalizedProperty["Properties." + localizedProperty.Name] = defVal;
                            localizedProperty.DefaultValue = Boolean.Parse(defVal);
                        }
                        else
                        {
                            string defVal = property.DefaultValue == null ? String.Empty : property.DefaultValue.ToString();
                            StringParserPropertyContainer.LocalizedProperty["Properties." + localizedProperty.Name] = defVal;
                            localizedProperty.DefaultValue = defVal;
                        }
                    }
                    localizedProperty.LocalizedName = property.LocalizedName;
                    localizedTypeDescriptor.Properties.Add(localizedProperty);
                }
                propertyGrid.ToolbarVisible = false;
                propertyGrid.SelectedObject = localizedTypeDescriptor;
                propertyGrid.Size           = new Size(GridWidth, Height - GridMargin * 4);

                Width = Width + GridWidth;
                Controls.Add(propertyGrid);
                this.ResumeLayout(false);
            }
        }
示例#2
0
		void ShowPropertyGrid()
		{
			if (localizedTypeDescriptor == null) {
				localizedTypeDescriptor = new LocalizedTypeDescriptor();
			}
			
			if (!Controls.Contains(propertyGrid)) {
				this.SuspendLayout();
				propertyGrid.Location = new Point(Width - GridMargin, GridMargin);
				propertyGrid.Anchor = AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom;
				localizedTypeDescriptor.Properties.Clear();
				foreach (TemplateProperty property in SelectedTemplate.Properties) {
					LocalizedProperty localizedProperty;
					if (property.Type.StartsWith("Types:")) {
						localizedProperty = new LocalizedProperty(property.Name, "System.Enum", property.Category, property.Description);
						TemplateType type = null;
						foreach (TemplateType templateType in SelectedTemplate.CustomTypes) {
							if (templateType.Name == property.Type.Substring("Types:".Length)) {
								type = templateType;
								break;
							}
						}
						if (type == null) {
							throw new Exception("type : " + property.Type + " not found.");
						}
						localizedProperty.TypeConverterObject = new CustomTypeConverter(type);
						StringParserPropertyContainer.LocalizedProperty["Properties." + localizedProperty.Name] = property.DefaultValue;
						localizedProperty.DefaultValue = property.DefaultValue; // localizedProperty.TypeConverterObject.ConvertFrom();
					} else {
						localizedProperty = new LocalizedProperty(property.Name, property.Type, property.Category, property.Description);
						if (property.Type == "System.Boolean") {
							localizedProperty.TypeConverterObject = new BooleanTypeConverter();
							string defVal = property.DefaultValue == null ? null : property.DefaultValue.ToString();
							if (defVal == null || defVal.Length == 0) {
								defVal = "True";
							}
							StringParserPropertyContainer.LocalizedProperty["Properties." + localizedProperty.Name] = defVal;
							localizedProperty.DefaultValue = Boolean.Parse(defVal);
						} else {
							string defVal = property.DefaultValue == null ? String.Empty : property.DefaultValue.ToString();
							StringParserPropertyContainer.LocalizedProperty["Properties." + localizedProperty.Name] = defVal;
							localizedProperty.DefaultValue = defVal;
						}
					}
					localizedProperty.LocalizedName = property.LocalizedName;
					localizedTypeDescriptor.Properties.Add(localizedProperty);
				}
				propertyGrid.ToolbarVisible = false;
				propertyGrid.SelectedObject = localizedTypeDescriptor;
				propertyGrid.Size     = new Size(GridWidth, Height - GridMargin * 4);
				
				Width = Width + GridWidth;
				Controls.Add(propertyGrid);
				this.ResumeLayout(false);
			}
		}