protected PropertyBase(PropertyEditor owner) { Owner = owner; isEnabled = true; isVisible = Visibility.Visible; }
protected virtual void FilterEditor(PropertyEditor propertyEditor, IEnumerable<object> markers) { var comboBoxItemCollection = GetEditorItems(propertyEditor); for (int index = comboBoxItemCollection.Count - 1; index >= 0; index--) { var item = comboBoxItemCollection[index]; var enumerable = markers as object[] ?? markers.ToArray(); if (!enumerable.Contains(item.GetPropertyValue("Value"))) comboBoxItemCollection.RemoveAt(index); } }
public NumericEditorTemplate(PropertyEditor parent) : base(parent) { this.stringEditor = new StringEditorTemplate(parent); this.stringEditor.Invalidate += this.ForwardInvalidate; this.stringEditor.Edited += this.stringEditor_Edited; this.stringEditor.EditingFinished += this.stringEditor_EditingFinished; this.ResetProperties(); this.Value = 0; }
public override void ClearContent() { base.ClearContent(); if (this.addKeyEditor != null) { this.addKeyEditor.ButtonPressed -= this.AddKeyButtonPressed; this.addKeyEditor.EditingFinished -= this.AddKeyEditingFinished; this.addKeyEditor = null; } this.offset = 0; }
/// <summary> /// Constructor /// </summary> /// <param name="instance"></param> /// <param name="descriptor"></param> /// <param name="owner"></param> public Property(object instance, PropertyDescriptor descriptor, PropertyEditor owner) : base(owner) { Instance = instance; Descriptor = descriptor; Name = descriptor.Name; Header = descriptor.DisplayName; ToolTip = descriptor.Description; // todo: is this ok? could it be a weak event? Descriptor.AddValueChanged(Instance, InstancePropertyChanged); }
IList GetEditorItems(PropertyEditor propertyEditor) { if (!XpandModuleBase.IsHosted) { var value = EditorProperties(propertyEditor); var type = Application.TypesInfo.FindTypeInfo("DevExpress.XtraEditors.Repository.RepositoryItemComboBox").Type; return ((IList)type.GetProperty("Items").GetValue(value, null)); } else { var type = Application.TypesInfo.FindTypeInfo("DevExpress.ExpressApp.Web.Editors.WebPropertyEditor").Type; var propertyInfo = type.Property("Editor"); var delegateForGetPropertyValue = propertyInfo.DelegateForGetPropertyValue(); var value = delegateForGetPropertyValue(propertyEditor); return (IList) value.GetPropertyValue("Items"); } }
public override void InitContent() { base.InitContent(); if (this.EditedType != null) { Type keyType = this.GetKeyType(); this.addKeyEditor = this.ParentGrid.CreateEditor(keyType, this); this.addKeyEditor.Hints |= HintFlags.HasButton | HintFlags.ButtonEnabled; this.addKeyEditor.ButtonIcon = EmbeddedResources.Resources.ImageAdd; this.addKeyEditor.EditedType = keyType; this.addKeyEditor.PropertyName = "Add Entry"; this.addKeyEditor.Getter = this.AddKeyValueGetter; this.addKeyEditor.Setter = this.AddKeyValueSetter; this.addKeyEditor.ButtonPressed += this.AddKeyButtonPressed; this.addKeyEditor.EditingFinished += this.AddKeyEditingFinished; this.PerformGetValue(); } else this.ClearContent(); }
public SlidableProperty(object instance, PropertyDescriptor descriptor, PropertyEditor owner) : base(instance, descriptor, owner) { }
public ComboBoxItemsBuilder WithPropertyEditor(PropertyEditor propertyEditor) { if (!(propertyEditor is IObjectSpaceHolder)) throw new NotImplementedException(propertyEditor.GetType() + " must implement " + typeof(IObjectSpaceHolder)); _propertyEditor = propertyEditor; return this; }
protected void UpdateElementEditors(IList[] values, bool getValueOnNewEditors) { PropertyInfo indexer = typeof(IList).GetProperty("Item"); IEnumerable <IList> valuesNotNull = values.Where(v => v != null); int visibleElementCount = valuesNotNull.Min(o => (int)o.Count); bool showOffset = false; if (visibleElementCount > 10) { this.offset = Math.Min(this.offset, visibleElementCount - 10); this.offsetEditor.Maximum = visibleElementCount - 10; this.offsetEditor.ValueBarMaximum = this.offsetEditor.Maximum; visibleElementCount = 10; showOffset = true; } else { this.offset = 0; } if (this.sizeEditor.ParentEditor == null) { this.AddPropertyEditor(this.sizeEditor, 0); } if (showOffset && this.offsetEditor.ParentEditor == null) { this.AddPropertyEditor(this.offsetEditor, 1); } else if (!showOffset && this.offsetEditor.ParentEditor != null) { this.RemovePropertyEditor(this.offsetEditor); } this.internalEditors = showOffset ? 2 : 1; this.BeginUpdate(); // Add missing editors Type elementType = GetIListElementType(this.EditedType); Type reflectedArrayType = PropertyEditor.ReflectDynamicType(elementType, valuesNotNull.Select(a => GetIListElementType(a.GetType()))); for (int i = this.internalEditors; i < visibleElementCount + this.internalEditors; i++) { int elementIndex = i - this.internalEditors + this.offset; Type reflectedElementType = PropertyEditor.ReflectDynamicType( reflectedArrayType, valuesNotNull.Select(v => indexer.GetValue(v, new object[] { elementIndex }))); bool elementEditorIsNew = false; PropertyEditor elementEditor; // Retrieve and Update existing editor if (i < this.ChildEditors.Count()) { elementEditor = this.ChildEditors.ElementAt(i); if (elementEditor.EditedType != reflectedElementType) { // If the editor has the wrong type, we'll need to create a new one PropertyEditor oldEditor = elementEditor; elementEditor = this.ParentGrid.CreateEditor(reflectedElementType, this); elementEditorIsNew = true; this.AddPropertyEditor(elementEditor, oldEditor); this.RemovePropertyEditor(oldEditor); this.ParentGrid.ConfigureEditor(elementEditor); } } // Create a new editor else { elementEditor = this.ParentGrid.CreateEditor(reflectedElementType, this); elementEditorIsNew = true; this.AddPropertyEditor(elementEditor); this.ParentGrid.ConfigureEditor(elementEditor); } elementEditor.Getter = this.CreateElementValueGetter(indexer, elementIndex); elementEditor.Setter = this.CreateElementValueSetter(indexer, elementIndex); elementEditor.PropertyName = "[" + elementIndex + "]"; // Immediately retrieve a valid value for the newly created editor when requested if (elementEditorIsNew && getValueOnNewEditors) { elementEditor.PerformGetValue(); } } // Remove overflowing editors for (int i = this.ChildEditors.Count() - (this.internalEditors + 1); i >= visibleElementCount; i--) { PropertyEditor child = this.ChildEditors.Last(); this.RemovePropertyEditor(child); } this.EndUpdate(); }
protected virtual object GetPropertyEditorControl(PropertyEditor item) { return(XpandModuleBase.IsHosted ? ((Control)item.Control).FindNestedControls(GetControlType()).FirstOrDefault() : item.Control); }
public IEnumerable <ValidationResult> Validate(object rawValue, PreValueCollection preValues, PropertyEditor editor) { var value = JsonConvert.DeserializeObject <List <object> >(rawValue.ToString()); if (value == null) { yield break; } var contentType = NestedContentHelper.GetContentTypeFromPreValue(preValues); if (contentType == null) { yield break; } for (var i = 0; i < value.Count; i++) { var o = value[i]; var propValues = ((JObject)o); var propValueKeys = propValues.Properties().Select(x => x.Name).ToArray(); foreach (var propKey in propValueKeys) { var propType = contentType.PropertyTypes.FirstOrDefault(x => x.Alias == propKey); if (propType != null) { // It would be better to pass this off to the individual property editors // to validate themselves and pass the result down, however a lot of the // validation checking code in core seems to be internal so for now we'll // just replicate the mandatory / regex validation checks ourselves. // This does of course mean we will miss any custom validators a property // editor may have registered by itself, and it also means we can only // validate to a single depth so having a complex property editor in a // doc type could get passed validation if it can't be validated from it's // stored value alone. // Check mandatory if (propType.Mandatory) { if (propValues[propKey] == null) { yield return(new ValidationResult("Item " + (i + 1) + " '" + propType.Name + "' cannot be null", new[] { propKey })); } else if (propValues[propKey].ToString().IsNullOrWhiteSpace()) { yield return(new ValidationResult("Item " + (i + 1) + " '" + propType.Name + "' cannot be empty", new[] { propKey })); } } // Check regex if (!propType.ValidationRegExp.IsNullOrWhiteSpace() && propValues[propKey] != null && !propValues[propKey].ToString().IsNullOrWhiteSpace()) { var regex = new Regex(propType.ValidationRegExp); if (!regex.IsMatch(propValues[propKey].ToString())) { yield return(new ValidationResult("Item " + (i + 1) + " '" + propType.Name + "' is invalid, it does not match the correct pattern", new[] { propKey })); } } } } } }
public PropertyEditorValueEventArgs(PropertyEditor editor, object value) { this.editor = editor; this.value = value; }
public PropertyTab(string tabName, PropertyEditor owner) : base(owner) { Name = Header = tabName; Categories = new List <PropertyCategory>(); }
object EditorProperties(PropertyEditor propertyEditor) { var type = Application.TypesInfo.FindTypeInfo("DevExpress.XtraEditors.BaseEdit").Type; return type.GetProperty("Properties").GetValue(propertyEditor.Control, null); }
public virtual MemberInfo MapEditorToMember(PropertyEditor editor) { return(editor != null ? editor.EditedMember : null); }
public SerializableObjectPropertyEditorBuilder WithPropertyEditor(PropertyEditor propertyEditor) { _propertyEditor = propertyEditor; return(this); }
protected override void OnEditorRemoving(PropertyEditor editor) { base.OnEditorRemoving(editor); this.UpdatePrefabModifiedState(); }
protected override void OnEditorAdded(PropertyEditor editor) { base.OnEditorAdded(editor); this.UpdatePrefabModifiedState(editor); }
public MultiComboBoxEditorTemplate(PropertyEditor parent) : base(parent) { this.popupControl.PopupControlHost = this; this.popupControl.Closed += this.popupControl_Closed; }
public PropertyTab(string tabName, PropertyEditor owner) : base(owner) { Name = Header = tabName; Categories = new List<PropertyCategory>(); }
public ParamEditorView(ParamEditorScreen parent, int index) { _paramEditor = parent; _viewIndex = index; _propEditor = new PropertyEditor(parent.EditorActionManager); }
public bool Execute(string packageName, XmlNode xmlData) { IMediaService mediaService = ApplicationContext.Current.Services.MediaService; IContentService contentService = UmbracoContext.Current.Application.Services.ContentService; IContentTypeService contentTypeService = ApplicationContext.Current.Services.ContentTypeService; IFileService fileService = ApplicationContext.Current.Services.FileService; //ApplicationContext.Current.Services.DataTypeService. IDataTypeService dataTypeService = UmbracoContext.Current.Application.Services.DataTypeService; #region Create media List <int> productImageIds = new List <int>(); List <IMedia> productImages = new List <IMedia>(); try { //Create image files const string productImagesFolderName = "Product images"; string[] mediaInstallImages = Directory.GetFiles(HostingEnvironment.MapPath("~/installMedia")); IMedia productImagesFolder = mediaService.GetByLevel(1).FirstOrDefault(m => m.Name == productImagesFolderName); if (productImagesFolder == null) { productImagesFolder = mediaService.CreateMedia(productImagesFolderName, -1, "Folder"); mediaService.Save(productImagesFolder); } if (!productImagesFolder.Children().Any()) { foreach (string mediaInstallImage in mediaInstallImages) { string fileName = Path.GetFileName(mediaInstallImage); IMedia productImage = mediaService.CreateMedia(fileName, productImagesFolder.Id, "Image"); byte[] buffer = File.ReadAllBytes(Path.GetFullPath(mediaInstallImage)); using (MemoryStream strm = new MemoryStream(buffer)) { productImage.SetValue("umbracoFile", fileName, strm); mediaService.Save(productImage); productImages.Add(productImage); productImageIds.Add(productImage.Id); } } } else { productImageIds = productImagesFolder.Children().Select(c => c.Id).ToList(); } Directory.Delete(HostingEnvironment.MapPath("~/installMedia"), true); } catch (Exception ex) { LogHelper.Error <TeaCommerceStarterKitInstall>("Create media failed", ex); } #endregion #region Set up Tea Commerce Store store = null; try { //Get store or create it IReadOnlyList <Store> stores = StoreService.Instance.GetAll().ToList(); store = stores.FirstOrDefault(); if (store == null) { store = new Store("Starter Kit Store"); } store.ProductSettings.ProductVariantPropertyAlias = "variants"; store.Save(); foreach (PaymentMethod paymentMethod in PaymentMethodService.Instance.GetAll(store.Id).Where(p => p.Alias == "invoicing")) { PaymentMethodSetting setting = paymentMethod.Settings.FirstOrDefault(s => s.Key == "acceptUrl"); if (setting != null) { setting.Value = "/cart-content/confirmation/"; } paymentMethod.Save(); } } catch (Exception ex) { LogHelper.Error <TeaCommerceStarterKitInstall>("Setting up Tea Commerce failed", ex); } #endregion #region Create Templates List <ITemplate> templates = new List <ITemplate>(); try { string[] templateFiles = Directory.GetFiles(HostingEnvironment.MapPath("~/views")); foreach (string templateFile in templateFiles) { string fileName = Path.GetFileNameWithoutExtension(templateFile); string fileContent = File.ReadAllText(templateFile); templates.Add(fileService.CreateTemplateWithIdentity(fileName, fileContent)); } } catch (Exception ex) { LogHelper.Error <TeaCommerceStarterKitInstall>("Create templates failed", ex); } #endregion #region Set up content types IEnumerable <IDataTypeDefinition> allDataTypeDefinitions = dataTypeService.GetAllDataTypeDefinitions(); try { IDataTypeDefinition variantEditorDataTypeDefinition = allDataTypeDefinitions.FirstOrDefault(d => d.Name.ToLowerInvariant().Contains("variant editor")); variantEditorDataTypeDefinition.DatabaseType = DataTypeDatabaseType.Ntext; var preValDictionary = new Dictionary <string, object> { { "xpathOrNode", "{\"showXPath\": true,\"query\": \"$current/ancestor-or-self::frontpage/attributes\"}" }, { "variantDocumentType", "variant" }, { "extraListInformation", "sku,priceJMD" }, { "hideLabel", "1" }, }; var currVal = dataTypeService.GetPreValuesCollectionByDataTypeId(variantEditorDataTypeDefinition.Id); //we need to allow for the property editor to deserialize the prevalues PropertyEditor pe = PropertyEditorResolver.Current.PropertyEditors.SingleOrDefault(x => x.Alias == "TeaCommerce.VariantEditor"); var formattedVal = pe.PreValueEditor.ConvertEditorToDb(preValDictionary, currVal); dataTypeService.SaveDataTypeAndPreValues(variantEditorDataTypeDefinition, formattedVal); //dataTypeService.Save( variantEditorDataTypeDefinition ); variantEditorDataTypeDefinition = dataTypeService.GetDataTypeDefinitionById(variantEditorDataTypeDefinition.Id); } catch (Exception ex) { LogHelper.Error <TeaCommerceStarterKitInstall>("Set up content types failed", ex); } #endregion #region Create Document types ContentType attributeContentType = null, attributeGroupContentType = null, attributesContentType = null, cartStepContentType = null, cartContentType = null, variantContentType = null, productContentType = null, productListContentType = null, frontpageContentType = null; try { attributeContentType = new ContentType(-1); attributeContentType.Alias = "attribute"; attributeContentType.Name = "Attribute"; attributeContentType.Icon = "icon-t-shirt"; contentTypeService.Save(attributeContentType); attributeGroupContentType = new ContentType(-1); attributeGroupContentType.Alias = "attributeGroup"; attributeGroupContentType.Name = "Attribute group"; attributeGroupContentType.Icon = "icon-t-shirt color-orange"; attributeGroupContentType.AllowedContentTypes = new List <ContentTypeSort>() { new ContentTypeSort(attributeContentType.Id, 0) }; contentTypeService.Save(attributeGroupContentType); attributesContentType = new ContentType(-1); attributesContentType.Alias = "attributes"; attributesContentType.Name = "Attributes"; attributesContentType.Icon = "icon-t-shirt"; attributesContentType.AllowedContentTypes = new List <ContentTypeSort>() { new ContentTypeSort(attributeGroupContentType.Id, 0) }; contentTypeService.Save(attributesContentType); cartStepContentType = new ContentType(-1); cartStepContentType.Alias = "cartStep"; cartStepContentType.Name = "Cart step"; cartStepContentType.Icon = "icon-shopping-basket-alt-2 color-orange"; cartStepContentType.AllowedTemplates = templates.Where(t => t.Alias.ToLowerInvariant().Contains("cartstep") && !t.Alias.ToLowerInvariant().Contains("master")); contentTypeService.Save(cartStepContentType); cartContentType = new ContentType(-1); cartContentType.Alias = "cart"; cartContentType.Name = "Cart"; cartContentType.Icon = "icon-shopping-basket-alt-2"; cartContentType.AllowedContentTypes = new List <ContentTypeSort>() { new ContentTypeSort(cartStepContentType.Id, 0) }; cartContentType.AllowedTemplates = templates.Where(t => t.Alias.ToLowerInvariant().Contains("cartstep1")); contentTypeService.Save(cartContentType); variantContentType = CreateVariantContentType(allDataTypeDefinitions, contentTypeService); productContentType = CreateProductContentType(allDataTypeDefinitions, contentTypeService, templates); productListContentType = new ContentType(-1); productListContentType.Alias = "productList"; productListContentType.Name = "Product list"; productListContentType.Icon = "icon-tags"; productListContentType.AllowedContentTypes = new List <ContentTypeSort>() { new ContentTypeSort(productContentType.Id, 0) }; productListContentType.AllowedTemplates = templates.Where(t => t.Alias.ToLowerInvariant().Contains("productlist")); contentTypeService.Save(productListContentType); frontpageContentType = CreateFrontpageContentType(allDataTypeDefinitions, contentTypeService, templates); } catch (Exception ex) { LogHelper.Error <TeaCommerceStarterKitInstall>("Create templates failed", ex); } #endregion #region Create content try { Content frontPageContent = new Content("Home", -1, frontpageContentType); frontPageContent.Template = frontpageContentType.AllowedTemplates.First(); frontPageContent.SetValue("slider", string.Join(",", productImages.Select(p => "umb://media/" + p.Key.ToString().Replace("-", "")))); frontPageContent.SetValue("store", store.Id); contentService.SaveAndPublishWithStatus(frontPageContent, raiseEvents: false); #region Create Cart Content cartContent = new Content("Cart content", frontPageContent.Id, cartContentType); cartContent.Template = cartContentType.AllowedTemplates.First(); contentService.SaveAndPublishWithStatus(cartContent, raiseEvents: false); Content informationContent = new Content("Information", cartContent.Id, cartStepContentType); informationContent.Template = templates.First(t => t.Alias.ToLowerInvariant() == "cartstep2"); contentService.SaveAndPublishWithStatus(informationContent, raiseEvents: false); Content shippingPaymentContent = new Content("Shipping/Payment", cartContent.Id, cartStepContentType); shippingPaymentContent.Template = templates.First(t => t.Alias.ToLowerInvariant() == "cartstep3"); contentService.SaveAndPublishWithStatus(shippingPaymentContent, raiseEvents: false); Content acceptContent = new Content("Accept", cartContent.Id, cartStepContentType); acceptContent.Template = templates.First(t => t.Alias.ToLowerInvariant() == "cartstep4"); contentService.SaveAndPublishWithStatus(acceptContent, raiseEvents: false); Content paymentContent = new Content("Payment", cartContent.Id, cartStepContentType); contentService.SaveAndPublishWithStatus(paymentContent); Content confirmationContent = new Content("Confirmation", cartContent.Id, cartStepContentType); confirmationContent.Template = templates.First(t => t.Alias.ToLowerInvariant() == "cartstep6"); contentService.SaveAndPublishWithStatus(confirmationContent, raiseEvents: false); #endregion #region Create Attributes Content variantAttributesContent = new Content("Variant attributes", frontPageContent.Id, attributesContentType); contentService.SaveAndPublishWithStatus(variantAttributesContent, raiseEvents: false); Content colorContent = new Content("Color", variantAttributesContent.Id, attributeGroupContentType); contentService.SaveAndPublishWithStatus(colorContent, raiseEvents: false); Content sizeContent = new Content("Size", variantAttributesContent.Id, attributeGroupContentType); contentService.SaveAndPublishWithStatus(sizeContent, raiseEvents: false); Content blackContent = new Content("Black", colorContent.Id, attributeContentType); contentService.SaveAndPublishWithStatus(blackContent, raiseEvents: false); Content whiteContent = new Content("White", colorContent.Id, attributeContentType); contentService.SaveAndPublishWithStatus(whiteContent, raiseEvents: false); Content blueContent = new Content("Blue", colorContent.Id, attributeContentType); contentService.SaveAndPublishWithStatus(blueContent, raiseEvents: false); Content largeContent = new Content("Large", sizeContent.Id, attributeContentType); contentService.SaveAndPublishWithStatus(largeContent, raiseEvents: false); Content mediumContent = new Content("Medium", sizeContent.Id, attributeContentType); contentService.SaveAndPublishWithStatus(mediumContent, raiseEvents: false); Content smallContent = new Content("Small", sizeContent.Id, attributeContentType); contentService.SaveAndPublishWithStatus(smallContent, raiseEvents: false); #endregion #region Create Products Content expensiveYachtsContent = new Content("Expensive Yachts", frontPageContent.Id, productListContentType); expensiveYachtsContent.Template = productListContentType.AllowedTemplates.First(); contentService.SaveAndPublishWithStatus(expensiveYachtsContent, raiseEvents: false); Content veryAxpensiveYachtsContent = new Content("Very expensive Yachts", frontPageContent.Id, productListContentType); veryAxpensiveYachtsContent.Template = productListContentType.AllowedTemplates.First(); contentService.SaveAndPublishWithStatus(veryAxpensiveYachtsContent, raiseEvents: false); Content summerYachtContent = new Content("Summer Yacht", expensiveYachtsContent, productContentType); summerYachtContent.Template = productContentType.AllowedTemplates.First(); summerYachtContent.SetValue("image", "umb://media/" + productImages[0].Key.ToString().Replace("-", "")); summerYachtContent.SetValue("productName", "Summer Yacht"); summerYachtContent.SetValue("sku", "p0001"); summerYachtContent.SetValue("priceJMD", "500"); summerYachtContent.SetValue("description", "<p>This is the product description.</p>"); summerYachtContent.SetValue("variants", "{\"variants\": [],\"variantGroupsOpen\":{}}"); contentService.SaveAndPublishWithStatus(summerYachtContent, raiseEvents: false); Content yachtWithSailsContent = new Content("Yacht with sails", expensiveYachtsContent, productContentType); yachtWithSailsContent.Template = productContentType.AllowedTemplates.First(); yachtWithSailsContent.SetValue("image", "umb://media/" + productImages[1].Key.ToString().Replace("-", "")); yachtWithSailsContent.SetValue("productName", "Yacht with sails"); yachtWithSailsContent.SetValue("sku", "p0002"); yachtWithSailsContent.SetValue("priceJMD", "1000"); yachtWithSailsContent.SetValue("description", "<p>This is the product description.</p>"); yachtWithSailsContent.SetValue("variants", "{\"variants\": [],\"variantGroupsOpen\":{}}"); contentService.SaveAndPublishWithStatus(yachtWithSailsContent, raiseEvents: false); Content motorDrivenYachtContent = new Content("Motor driven Yacht", veryAxpensiveYachtsContent, productContentType); motorDrivenYachtContent.Template = productContentType.AllowedTemplates.First(); motorDrivenYachtContent.SetValue("image", "umb://media/" + productImages[2].Key.ToString().Replace("-", "")); motorDrivenYachtContent.SetValue("productName", "Motor driven Yacht"); motorDrivenYachtContent.SetValue("sku", "p0003"); motorDrivenYachtContent.SetValue("priceJMD", "1500"); motorDrivenYachtContent.SetValue("description", "<p>This is the product description.</p>"); motorDrivenYachtContent.SetValue("variants", "{\"variants\": [],\"variantGroupsOpen\":{}}"); contentService.SaveAndPublishWithStatus(motorDrivenYachtContent, raiseEvents: false); Content oneMastedYachtContent = new Content("One masted yacht", veryAxpensiveYachtsContent, productContentType); oneMastedYachtContent.Template = productContentType.AllowedTemplates.First(); oneMastedYachtContent.SetValue("image", "umb://media/" + productImages[3].Key.ToString().Replace("-", "")); oneMastedYachtContent.SetValue("productName", "One masted yacht"); oneMastedYachtContent.SetValue("sku", "p0004"); oneMastedYachtContent.SetValue("priceJMD", "2000"); oneMastedYachtContent.SetValue("description", "<p>This is the product description.</p>"); oneMastedYachtContent.SetValue("variants", "{\"variants\": [],\"variantGroupsOpen\":{}}"); contentService.SaveAndPublishWithStatus(oneMastedYachtContent, raiseEvents: false); #endregion frontPageContent.SetValue("featuredProducts", string.Join(",", new List <string> { "umb://document/" + summerYachtContent.Key.ToString().Replace("-", ""), "umb://document/" + yachtWithSailsContent.Key.ToString().Replace("-", ""), "umb://document/" + motorDrivenYachtContent.Key.ToString().Replace("-", ""), "umb://document/" + oneMastedYachtContent.Key.ToString().Replace("-", ""), })); contentService.SaveAndPublishWithStatus(frontPageContent, raiseEvents: false); } catch (Exception ex) { LogHelper.Error <TeaCommerceStarterKitInstall>("Create content failed", ex); } #endregion return(true); }
private void InitNullText(PropertyEditor propertyEditor) { ((BaseEdit)propertyEditor.Control).Properties.NullText = CaptionHelper.NullValueText; }
protected override float OnGetHeight(SharedInstance <T, TSerializer> behavior, fiGraphMetadata metadata) { return(PropertyEditor.Get(typeof(T), null).FirstEditor.GetElementHeight(GUIContent.none, behavior.Instance, metadata.Enter("Instance", behavior))); }
public object Draw(PropertyEditor propertyEditor) { if (!propertyEditor.info.CanRead) { return(null); } var value = propertyEditor.info.GetValue(target, null); if (value == null) { Editor.Label(propertyEditor.info.Name, "(" + propertyEditor.info.PropertyType.Name + ") null"); return(null); } // Array & List. if (!(value is string) && (value.GetType().IsArray || value is IEnumerable)) { return(PropertyEditorEnumerable(propertyEditor, (IEnumerable)value)); } // Base editors. if (value is bool) { return(PropertyEditorBool(propertyEditor, (bool)value)); } if (value is byte) { return(PropertyEditorUInt8(propertyEditor, (byte)value)); } if (value is decimal) { return(PropertyEditorDecimal(propertyEditor, (decimal)value)); } if (value is double) { return(PropertyEditorDouble(propertyEditor, (double)value)); } if (value is float) { return(PropertyEditorSingle(propertyEditor, (float)value)); } if (value is int) { return(PropertyEditorInt32(propertyEditor, (int)value)); } if (value is long) { return(PropertyEditorInt64(propertyEditor, (long)value)); } if (value is sbyte) { return(PropertyEditorInt8(propertyEditor, (sbyte)value)); } if (value is short) { return(PropertyEditorInt16(propertyEditor, (short)value)); } if (value is uint) { return(PropertyEditorUInt32(propertyEditor, (uint)value)); } if (value is ulong) { return(PropertyEditorUInt64(propertyEditor, (ulong)value)); } if (value is ushort) { return(PropertyEditorUInt16(propertyEditor, (ushort)value)); } if (value is string) { return(PropertyEditorString(propertyEditor, (string)value)); } if (value is Color) { return(PropertyEditorColor(propertyEditor, (Color)value)); } if (value is Control) { return(PropertyEditorControl(propertyEditor, (Control)value)); } if (value is Enum) { return(PropertyEditorEnum(propertyEditor, (Enum)value)); } // Complex types. if (propertyEditor.editor == null) { propertyEditor.editor = new ObjectEditor(value, propertyEditor.info.Name); propertyEditor.editor.backgroundRGB = MathHelper.Clamp(backgroundRGB - 25, 128, 255); } return(propertyEditor.editor.Draw()); }
/// <summary> /// Validates a null value or an empty json value /// </summary> /// <param name="value"></param> /// <param name="config"></param> /// <param name="preValues"></param> /// <param name="editor"></param> /// <returns></returns> public override IEnumerable <ValidationResult> Validate(object value, string config, PreValueCollection preValues, PropertyEditor editor) { if (value == null) { yield return(new ValidationResult("Value cannot be null", new[] { "value" })); } else { var asString = value.ToString(); if (asString.DetectIsEmptyJson()) { yield return(new ValidationResult("Value cannot be empty", new[] { "value" })); } if (asString.IsNullOrWhiteSpace()) { yield return(new ValidationResult("Value cannot be empty", new[] { "value" })); } } }
protected virtual void SetRange(PropertyEditor editor) { }
protected override void OnEdit(Rect rect, SharedInstance <T, TSerializer> behavior, fiGraphMetadata metadata) { behavior.Instance = PropertyEditor.Get(typeof(T), null).FirstEditor.Edit(rect, GUIContent.none, behavior.Instance, metadata.Enter("Instance", behavior)); }
public void OnGUI() { try { EditorGUIUtility.hierarchyMode = true; Type updatedType = _inspectedType; GUILayout.Label("Static Inspector", EditorStyles.boldLabel); { var label = new GUIContent("Inspected Type"); var typeEditor = PropertyEditor.Get(typeof(Type), null); updatedType = typeEditor.FirstEditor.EditWithGUILayout(label, _inspectedType, Metadata.Enter("TypeSelector", null)); } fiEditorGUILayout.Splitter(2); if (_inspectedType != null) { _inspectorScrollPosition = EditorGUILayout.BeginScrollView(_inspectorScrollPosition); var inspectedType = InspectedType.Get(_inspectedType); foreach (InspectedProperty staticProperty in inspectedType.GetProperties(InspectedMemberFilters.StaticInspectableMembers)) { var editorChain = PropertyEditor.Get(staticProperty.StorageType, staticProperty.MemberInfo); IPropertyEditor editor = editorChain.FirstEditor; GUIContent label = new GUIContent(staticProperty.Name); object currentValue = staticProperty.Read(null); EditorGUILayout.BeginHorizontal(); EditorGUILayout.GetControlRect(GUILayout.Width(8)); EditorGUILayout.BeginVertical(); GUI.enabled = staticProperty.CanWrite; object updatedValue = editor.EditWithGUILayout(label, currentValue, Metadata.Enter(staticProperty.Name, null)); if (staticProperty.CanWrite) { staticProperty.Write(null, updatedValue); } EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndScrollView(); } // For some reason, the type selection popup window cannot force // the rest of the Unity GUI to redraw. We do it here instead -- // this removes any delay after selecting the type in the popup // window and the type actually being displayed. if (fiEditorUtility.ShouldInspectorRedraw.Enabled) { Repaint(); } if (_inspectedType != updatedType) { _inspectedType = updatedType; Repaint(); } EditorGUIUtility.hierarchyMode = false; } catch (ExitGUIException) { } catch (Exception e) { Debug.LogError(e); } }
/// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1)); this.openDiagramDialog = new System.Windows.Forms.OpenFileDialog(); this.saveDiagramDialog = new System.Windows.Forms.SaveFileDialog(); this.panel2 = new System.Windows.Forms.Panel(); this.paletteGroupBar1 = new Syncfusion.Windows.Forms.Diagram.Controls.PaletteGroupBar(this.components); this.panel3 = new System.Windows.Forms.Panel(); this.propertyEditor1 = new Syncfusion.Windows.Forms.Diagram.Controls.PropertyEditor(this.components); this.panel4 = new System.Windows.Forms.Panel(); this.panel6 = new System.Windows.Forms.Panel(); this.diagram2 = new Syncfusion.Windows.Forms.Diagram.Controls.Diagram(this.components); this.model = new Syncfusion.Windows.Forms.Diagram.Model(this.components); this.panel5 = new System.Windows.Forms.Panel(); this.diagram1 = new Syncfusion.Windows.Forms.Diagram.Controls.Diagram(this.components); this.panel2.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.paletteGroupBar1)).BeginInit(); this.panel3.SuspendLayout(); this.panel4.SuspendLayout(); this.panel6.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.diagram2)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.model)).BeginInit(); this.panel5.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.diagram1)).BeginInit(); this.SuspendLayout(); // // openDiagramDialog // this.openDiagramDialog.Filter = "Diagram Files|*.edd|All files|*.*"; this.openDiagramDialog.Title = "Open Diagram"; // // saveDiagramDialog // this.saveDiagramDialog.FileName = "doc1"; this.saveDiagramDialog.Filter = "Diagram files|*.edd|All files|*.*"; this.saveDiagramDialog.Title = "SaveDiagram"; // // panel2 // this.panel2.Controls.Add(this.paletteGroupBar1); this.panel2.Dock = System.Windows.Forms.DockStyle.Left; this.panel2.Location = new System.Drawing.Point(0, 0); this.panel2.Name = "panel2"; this.panel2.Size = new System.Drawing.Size(211, 615); this.panel2.TabIndex = 1; // // paletteGroupBar1 // this.paletteGroupBar1.AllowDrop = true; this.paletteGroupBar1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(235)))), ((int)(((byte)(235))))); this.paletteGroupBar1.BeforeTouchSize = new System.Drawing.Size(211, 615); this.paletteGroupBar1.BorderColor = System.Drawing.Color.White; this.paletteGroupBar1.BorderStyle = System.Windows.Forms.BorderStyle.None; this.paletteGroupBar1.CollapseImage = ((System.Drawing.Image)(resources.GetObject("paletteGroupBar1.CollapseImage"))); this.paletteGroupBar1.Diagram = null; this.paletteGroupBar1.Dock = System.Windows.Forms.DockStyle.Fill; this.paletteGroupBar1.EditMode = false; this.paletteGroupBar1.ExpandButtonToolTip = null; this.paletteGroupBar1.ExpandImage = ((System.Drawing.Image)(resources.GetObject("paletteGroupBar1.ExpandImage"))); this.paletteGroupBar1.FlatLook = true; this.paletteGroupBar1.Font = new System.Drawing.Font("Segoe UI Semibold", 11.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.paletteGroupBar1.ForeColor = System.Drawing.Color.White; this.paletteGroupBar1.GroupBarDropDownToolTip = null; this.paletteGroupBar1.GroupBarItemHeight = 32; this.paletteGroupBar1.IndexOnVisibleItems = true; this.paletteGroupBar1.Location = new System.Drawing.Point(0, 0); this.paletteGroupBar1.MinimizeButtonToolTip = null; this.paletteGroupBar1.Name = "paletteGroupBar1"; this.paletteGroupBar1.NavigationPaneTooltip = null; this.paletteGroupBar1.PopupClientSize = new System.Drawing.Size(0, 0); this.paletteGroupBar1.Size = new System.Drawing.Size(211, 615); this.paletteGroupBar1.TabIndex = 1; this.paletteGroupBar1.Text = "paletteGroupBar1"; this.paletteGroupBar1.TextAlign = Syncfusion.Windows.Forms.Tools.TextAlignment.Left; this.paletteGroupBar1.VisualStyle = Syncfusion.Windows.Forms.VisualStyle.Metro; // // panel3 // this.panel3.Controls.Add(this.propertyEditor1); this.panel3.Dock = System.Windows.Forms.DockStyle.Right; this.panel3.Location = new System.Drawing.Point(697, 0); this.panel3.Name = "panel3"; this.panel3.Size = new System.Drawing.Size(253, 615); this.panel3.TabIndex = 0; // // propertyEditor1 // this.propertyEditor1.Diagram = null; this.propertyEditor1.Dock = System.Windows.Forms.DockStyle.Fill; this.propertyEditor1.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.propertyEditor1.Location = new System.Drawing.Point(0, 0); this.propertyEditor1.Name = "propertyEditor1"; this.propertyEditor1.Size = new System.Drawing.Size(253, 615); this.propertyEditor1.TabIndex = 0; // // panel4 // this.panel4.Controls.Add(this.panel6); this.panel4.Controls.Add(this.panel5); this.panel4.Dock = System.Windows.Forms.DockStyle.Fill; this.panel4.Location = new System.Drawing.Point(211, 0); this.panel4.Name = "panel4"; this.panel4.Size = new System.Drawing.Size(486, 615); this.panel4.TabIndex = 2; // // panel6 // this.panel6.Controls.Add(this.diagram2); this.panel6.Location = new System.Drawing.Point(0, 297); this.panel6.Name = "panel6"; this.panel6.Size = new System.Drawing.Size(482, 290); this.panel6.TabIndex = 0; // // diagram2 // this.diagram2.Controller.PasteOffset = new System.Drawing.SizeF(10F, 10F); this.diagram2.Dock = System.Windows.Forms.DockStyle.Fill; this.diagram2.HScroll = true; this.diagram2.LayoutManager = null; this.diagram2.Location = new System.Drawing.Point(0, 0); this.diagram2.MetroScrollBars = true; this.diagram2.Model = this.model; this.diagram2.Name = "diagram2"; this.diagram2.ScrollVirtualBounds = ((System.Drawing.RectangleF)(resources.GetObject("diagram2.ScrollVirtualBounds"))); this.diagram2.Size = new System.Drawing.Size(482, 290); this.diagram2.SmartSizeBox = false; this.diagram2.TabIndex = 0; this.diagram2.Text = "diagram2"; // // // this.diagram2.View.ClientRectangle = new System.Drawing.Rectangle(0, 0, 0, 0); this.diagram2.View.Controller = this.diagram2.Controller; this.diagram2.View.Grid.MinPixelSpacing = 4F; this.diagram2.View.ScrollVirtualBounds = ((System.Drawing.RectangleF)(resources.GetObject("resource.ScrollVirtualBounds"))); this.diagram2.View.ZoomType = Syncfusion.Windows.Forms.Diagram.ZoomType.Center; this.diagram2.VScroll = true; this.diagram2.Click += new System.EventHandler(this.diagram2_Click); // // model // this.model.BackgroundStyle.PathBrushStyle = Syncfusion.Windows.Forms.Diagram.PathGradientBrushStyle.RectangleCenter; this.model.DocumentScale.DisplayName = "No Scale"; this.model.DocumentScale.Height = 1F; this.model.DocumentScale.Width = 1F; this.model.DocumentSize.Height = 1169F; this.model.DocumentSize.Width = 827F; this.model.LineStyle.DashPattern = null; this.model.LineStyle.LineColor = System.Drawing.Color.White; this.model.LogicalSize = new System.Drawing.SizeF(827F, 1169F); this.model.ShadowStyle.Color = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(105)))), ((int)(((byte)(105)))), ((int)(((byte)(105))))); this.model.ShadowStyle.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(105)))), ((int)(((byte)(105)))), ((int)(((byte)(105))))); // // panel5 // this.panel5.Controls.Add(this.diagram1); this.panel5.Location = new System.Drawing.Point(0, 0); this.panel5.Name = "panel5"; this.panel5.Size = new System.Drawing.Size(482, 290); this.panel5.TabIndex = 0; // // diagram1 // this.diagram1.Controller.PasteOffset = new System.Drawing.SizeF(10F, 10F); this.diagram1.Dock = System.Windows.Forms.DockStyle.Fill; this.diagram1.HScroll = true; this.diagram1.LayoutManager = null; this.diagram1.Location = new System.Drawing.Point(0, 0); this.diagram1.MetroScrollBars = true; this.diagram1.Model = this.model; this.diagram1.Name = "diagram1"; this.diagram1.ScrollVirtualBounds = ((System.Drawing.RectangleF)(resources.GetObject("diagram1.ScrollVirtualBounds"))); this.diagram1.Size = new System.Drawing.Size(482, 290); this.diagram1.SmartSizeBox = false; this.diagram1.TabIndex = 0; this.diagram1.Text = "diagram1"; // // // this.diagram1.View.ClientRectangle = new System.Drawing.Rectangle(0, 0, 0, 0); this.diagram1.View.Controller = this.diagram1.Controller; this.diagram1.View.Grid.MinPixelSpacing = 4F; this.diagram1.View.ScrollVirtualBounds = ((System.Drawing.RectangleF)(resources.GetObject("resource.ScrollVirtualBounds1"))); this.diagram1.View.ZoomType = Syncfusion.Windows.Forms.Diagram.ZoomType.Center; this.diagram1.VScroll = true; this.diagram1.Click += new System.EventHandler(this.diagram1_Click); // // Form1 // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.BackColor = System.Drawing.SystemColors.Control; this.ClientSize = new System.Drawing.Size(950, 615); this.Controls.Add(this.panel4); this.Controls.Add(this.panel3); this.Controls.Add(this.panel2); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.Name = "Form1"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "Mutiple views"; this.Load += new System.EventHandler(this.Form1_Load); this.panel2.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.paletteGroupBar1)).EndInit(); this.panel3.ResumeLayout(false); this.panel4.ResumeLayout(false); this.panel6.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.diagram2)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.model)).EndInit(); this.panel5.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.diagram1)).EndInit(); this.ResumeLayout(false); }
public BitmaskEditorTemplate(PropertyEditor parent) : base(parent) { this.popupControl.PopupControlHost = this; this.popupControl.Closed += this.popupControl_Closed; }
public override void ClearContent() { base.ClearContent(); this.otherColEditor = null; }
protected virtual void SetPropertyEditorCaption(PropertyEditor propertyEditor, string caption) { propertyEditor.Caption = caption; }
public WideProperty(object instance, PropertyDescriptor descriptor, bool noHeader, PropertyEditor owner) : base(instance, descriptor, owner) { HeaderVisibility = noHeader ? Visibility.Collapsed : Visibility.Visible; }
protected void UpdateElementEditors(IDictionary[] values) { PropertyInfo indexer = typeof(IDictionary).GetProperty("Item"); int visibleElementCount = values.Where(o => o != null).Min(o => (int)o.Count); bool showOffset = false; if (visibleElementCount > 10) { this.offset = Math.Min(this.offset, visibleElementCount - 10); this.offsetEditor.Maximum = visibleElementCount - 10; visibleElementCount = 10; showOffset = true; } else { this.offset = 0; } if (this.addKeyEditor.ParentEditor == null) { this.AddPropertyEditor(this.addKeyEditor, 0); } if (showOffset && this.offsetEditor.ParentEditor == null) { this.AddPropertyEditor(this.offsetEditor, 1); } else if (!showOffset && this.offsetEditor.ParentEditor != null) { this.RemovePropertyEditor(this.offsetEditor); } this.internalEditors = showOffset ? 2 : 1; // Determine which keys are currently displayed int elemIndex = 0; this.displayedKeys = new object[visibleElementCount]; foreach (object key in values.Where(o => o != null).First().Keys) { if (elemIndex >= this.offset) { this.displayedKeys[elemIndex - this.offset] = key; } elemIndex++; if (elemIndex >= this.offset + visibleElementCount) { break; } } this.BeginUpdate(); // Add missing editors Type dictValueType = GetIDictionaryValueType(this.EditedType); Type reflectedDictValueType = PropertyEditor.ReflectDynamicType(dictValueType, values.Select(a => GetIDictionaryValueType(a.GetType()))); for (int i = this.internalEditors; i < visibleElementCount + this.internalEditors; i++) { object elementKey = this.displayedKeys[i - this.internalEditors]; Type reflectedElementValueType = PropertyEditor.ReflectDynamicType( reflectedDictValueType, values.Where(v => v != null).Select(v => indexer.GetValue(v, new object[] { elementKey }))); PropertyEditor elementEditor; // Retrieve and Update existing editor if (i < this.Children.Count()) { elementEditor = this.Children.ElementAt(i); if (elementEditor.EditedType != reflectedElementValueType) { // If the editor has the wrong type, we'll need to create a new one PropertyEditor oldEditor = elementEditor; elementEditor = this.ParentGrid.CreateEditor(reflectedElementValueType, this); this.AddPropertyEditor(elementEditor, oldEditor); this.RemovePropertyEditor(oldEditor); oldEditor.Dispose(); this.ParentGrid.ConfigureEditor(elementEditor); } } // Create a new editor else { elementEditor = this.ParentGrid.CreateEditor(reflectedElementValueType, this); this.AddPropertyEditor(elementEditor); this.ParentGrid.ConfigureEditor(elementEditor); if (!elementEditor.Hints.HasFlag(HintFlags.HasButton)) { elementEditor.Hints |= HintFlags.HasButton | HintFlags.ButtonEnabled; elementEditor.ButtonPressed += this.elementEditor_ButtonPressed; } } elementEditor.Getter = this.CreateElementValueGetter(indexer, elementKey); elementEditor.Setter = this.CreateElementValueSetter(indexer, elementKey); elementEditor.PropertyName = "[" + elementKey.ToString() + "]"; } // Remove overflowing editors for (int i = this.Children.Count() - (this.internalEditors + 1); i >= visibleElementCount; i--) { PropertyEditor child = this.Children.Last(); this.RemovePropertyEditor(child); child.ButtonPressed -= this.elementEditor_ButtonPressed; } this.EndUpdate(); }
protected override bool IsChildReadOnly(PropertyEditor childEditor) { if (childEditor == this.offsetEditor) return false; return base.IsChildReadOnly(childEditor); }
public OptionalProperty(object instance, PropertyDescriptor descriptor, string optionalPropertyName, PropertyEditor owner) : base(instance, descriptor, owner) { OptionalPropertyName = optionalPropertyName; }
protected virtual void Init(PropertyEditor propertyEditor) { if (!XpandModuleBase.IsHosted) { var editorItems = GetEditorItems(propertyEditor); editorItems.Clear(); var editorProperties = EditorProperties(propertyEditor); editorProperties.CallMethod("Init", propertyEditor.MemberInfo.MemberType); } }
public ProviderContext(PropertyGrid grid, PropertyEditor editor = null) { this.parentEditor = editor; this.parentGrid = editor != null ? editor.ParentGrid : grid; }
protected virtual void Init(PropertyEditor propertyEditor) { if (!Application.IsHosted()) { var editorItems = GetEditorItems(propertyEditor); editorItems.Clear(); var editorProperties = EditorProperties(propertyEditor); editorProperties.CallMethod("Init", propertyEditor.MemberInfo.MemberType); } }
public EditorTemplate(PropertyEditor parent) { this.parent = parent; }
public ComboBoxItemsBuilder WithPropertyEditor(PropertyEditor propertyEditor) { _propertyEditor = propertyEditor; return this; }
void UpdateEditor(ISupportControl supportControl) { if (supportControl == null) return; bool isChanged = false; var memberType = GetMemberType() ?? typeof(object); bool editObjectChanged = (_parameter != null) && (_parameter.Type != memberType); if (_propertyEditor.CurrentObject != null) { if ((_parameter == null) || (editObjectChanged) || supportControl.Control == null) { var application = _getApplicationAction.Invoke(); isChanged = true; _parameter = new MyParameter(memberType.Name, memberType); var paramList = new ParameterList { _parameter }; ParametersObject parametersObject = ParametersObject.CreateBoundObject(paramList); DetailView detailView = parametersObject.CreateDetailView(application.CreateObjectSpace(), application, true); detailView.ViewEditMode = GetViewEditMode(); _detailViewItems = ((PropertyEditor)detailView.Items[0]); _detailViewItems.CreateControl(); _detailViewItems.ControlValueChanged += detailViewItems_ControlValueChanged; } _parameter.CurrentValue = _propertyEditor.PropertyValue; } if ((isChanged || (supportControl.Control == null)) && (_detailViewItems != null)) { _detailViewItems.Refresh(); supportControl.Control = _findControl.Invoke(_detailViewItems); } }
public ComboBoxEditorTemplate(PropertyEditor parent) : base(parent) { this.popupControl.PopupControlHost = this; this.popupControl.Closed += this.popupControl_Closed; }
/// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm)); this.panel1 = new System.Windows.Forms.Panel(); this.toolStrip1 = new System.Windows.Forms.ToolStrip(); this.toolStripButton2 = new System.Windows.Forms.ToolStripButton(); this.toolStripButton3 = new System.Windows.Forms.ToolStripButton(); this.propertyEditor1 = new Syncfusion.Windows.Forms.Diagram.Controls.PropertyEditor(this.components); this.diagram1 = new Syncfusion.Windows.Forms.Diagram.Controls.Diagram(this.components); this.model1 = new Syncfusion.Windows.Forms.Diagram.Model(this.components); this.panel1.SuspendLayout(); this.toolStrip1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.diagram1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.model1)).BeginInit(); this.SuspendLayout(); // // panel1 // this.panel1.Controls.Add(this.toolStrip1); this.panel1.Dock = System.Windows.Forms.DockStyle.Top; this.panel1.Location = new System.Drawing.Point(0, 0); this.panel1.Name = "panel1"; this.panel1.Size = new System.Drawing.Size(754, 25); this.panel1.TabIndex = 0; // // toolStrip1 // this.toolStrip1.AutoSize = false; this.toolStrip1.BackColor = System.Drawing.SystemColors.Control; this.toolStrip1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; this.toolStrip1.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden; this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.toolStripButton2, this.toolStripButton3 }); this.toolStrip1.Location = new System.Drawing.Point(0, 0); this.toolStrip1.Name = "toolStrip1"; this.toolStrip1.Size = new System.Drawing.Size(754, 25); this.toolStrip1.TabIndex = 1; this.toolStrip1.Text = "toolStrip1"; this.toolStrip1.ItemClicked += new System.Windows.Forms.ToolStripItemClickedEventHandler(this.toolStrip1_ItemClicked); // // toolStripButton2 // this.toolStripButton2.ForeColor = System.Drawing.Color.MidnightBlue; this.toolStripButton2.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton2.Image"))); this.toolStripButton2.ImageTransparentColor = System.Drawing.Color.Magenta; this.toolStripButton2.Name = "toolStripButton2"; this.toolStripButton2.Size = new System.Drawing.Size(92, 22); this.toolStripButton2.Text = "Add Symbol"; //this.toolStripButton2.Click += new System.EventHandler(this.toolStripButton2_Click); // // toolStripButton3 // this.toolStripButton3.ForeColor = System.Drawing.Color.MidnightBlue; this.toolStripButton3.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton3.Image"))); this.toolStripButton3.ImageTransparentColor = System.Drawing.Color.Magenta; this.toolStripButton3.Name = "toolStripButton3"; this.toolStripButton3.Size = new System.Drawing.Size(58, 22); this.toolStripButton3.Text = "Clone"; // // propertyEditor1 // this.propertyEditor1.Diagram = this.diagram1; this.propertyEditor1.Dock = System.Windows.Forms.DockStyle.Right; this.propertyEditor1.Location = new System.Drawing.Point(507, 25); this.propertyEditor1.Name = "propertyEditor1"; this.propertyEditor1.Size = new System.Drawing.Size(247, 416); this.propertyEditor1.TabIndex = 1; // // diagram1 // this.diagram1.Controller.PasteOffset = new System.Drawing.SizeF(10F, 10F); this.diagram1.Dock = System.Windows.Forms.DockStyle.Fill; this.diagram1.LayoutManager = null; this.diagram1.Location = new System.Drawing.Point(0, 25); this.diagram1.Model = this.model1; this.diagram1.Name = "diagram1"; this.diagram1.ScrollVirtualBounds = ((System.Drawing.RectangleF)(resources.GetObject("diagram1.ScrollVirtualBounds"))); this.diagram1.Size = new System.Drawing.Size(507, 416); this.diagram1.SmartSizeBox = false; this.diagram1.TabIndex = 2; this.diagram1.Text = "diagram1"; // // // this.diagram1.View.BackgroundColor = System.Drawing.Color.White; this.diagram1.View.ClientRectangle = new System.Drawing.Rectangle(0, 0, 0, 0); this.diagram1.View.Controller = this.diagram1.Controller; this.diagram1.View.Grid.MinPixelSpacing = 4F; this.diagram1.View.Grid.Visible = false; this.diagram1.View.ScrollVirtualBounds = ((System.Drawing.RectangleF)(resources.GetObject("resource.ScrollVirtualBounds"))); this.diagram1.View.ZoomType = Syncfusion.Windows.Forms.Diagram.ZoomType.Center; //this.diagram1.Click += new System.EventHandler(this.diagram1_Click); // // model1 // this.model1.BackgroundStyle.PathBrushStyle = Syncfusion.Windows.Forms.Diagram.PathGradientBrushStyle.RectangleCenter; this.model1.DocumentScale.DisplayName = "No Scale"; this.model1.DocumentScale.Height = 1F; this.model1.DocumentScale.Width = 1F; this.model1.DocumentSize.Height = 1169F; this.model1.DocumentSize.Width = 827F; this.model1.LineStyle.DashPattern = null; this.model1.LineStyle.LineColor = System.Drawing.Color.Black; this.model1.LineStyle.LineWidth = 0F; this.model1.LogicalSize = new System.Drawing.SizeF(827F, 1169F); this.model1.ShadowStyle.Color = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(105)))), ((int)(((byte)(105)))), ((int)(((byte)(105))))); this.model1.ShadowStyle.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(105)))), ((int)(((byte)(105)))), ((int)(((byte)(105))))); // // MainForm // this.AutoScaleBaseSize = new System.Drawing.Size(6, 16); this.ClientSize = new System.Drawing.Size(754, 441); this.Controls.Add(this.diagram1); this.Controls.Add(this.propertyEditor1); this.Controls.Add(this.panel1); this.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.MaximizeBox = false; this.MinimizeBox = false; this.Name = "MainForm"; this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Show; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "Custom Symbol"; this.Load += new System.EventHandler(this.MainForm_Load); this.panel1.ResumeLayout(false); this.toolStrip1.ResumeLayout(false); this.toolStrip1.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.diagram1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.model1)).EndInit(); this.ResumeLayout(false); }
private void InitNullText(PropertyEditor propertyEditor) { ((BaseEdit)propertyEditor.Control).Properties.NullText = CaptionHelper.NullValueText; }
protected void UpdateElementEditors(IDictionary[] values, Type valueType) { PropertyInfo indexer = typeof(IDictionary).GetProperty("Item"); int visibleElementCount = values.Where(o => o != null).Min(o => (int)o.Count); bool showOffset = false; if (visibleElementCount > 10) { this.offset = Math.Min(this.offset, visibleElementCount - 10); this.offsetEditor.Maximum = visibleElementCount - 10; visibleElementCount = 10; showOffset = true; } else { this.offset = 0; } if (this.addKeyEditor.ParentEditor == null) { this.AddPropertyEditor(this.addKeyEditor, 0); } if (showOffset && this.offsetEditor.ParentEditor == null) { this.AddPropertyEditor(this.offsetEditor, 1); } else if (!showOffset && this.offsetEditor.ParentEditor != null) { this.RemovePropertyEditor(this.offsetEditor); } this.internalEditors = showOffset ? 2 : 1; // Determine which keys are currently displayed int elemIndex = 0; object[] keys = new object[visibleElementCount]; foreach (object key in values.Where(o => o != null).First().Keys) { if (elemIndex >= this.offset) { keys[elemIndex - this.offset] = key; } elemIndex++; if (elemIndex >= this.offset + visibleElementCount) { break; } } this.BeginUpdate(); // Add missing editors for (int i = this.internalEditors; i < visibleElementCount + this.internalEditors; i++) { PropertyEditor elementEditor; if (i < this.Children.Count()) { elementEditor = this.Children.ElementAt(i); } else { elementEditor = this.ParentGrid.CreateEditor(valueType, this); this.AddPropertyEditor(elementEditor); this.ParentGrid.ConfigureEditor(elementEditor); } elementEditor.Getter = this.CreateElementValueGetter(indexer, keys[i - this.internalEditors]); elementEditor.Setter = this.CreateElementValueSetter(indexer, keys[i - this.internalEditors]); elementEditor.PropertyName = "[" + keys[i - this.internalEditors].ToString() + "]"; } // Remove overflowing editors for (int i = this.Children.Count() - (this.internalEditors + 1); i >= visibleElementCount; i--) { PropertyEditor child = this.Children.Last(); this.RemovePropertyEditor(child); } this.EndUpdate(); }
/// <summary> /// Initializes a new instance of the <see cref="DefaultPropertyViewModelFactory"/> class. /// </summary> /// <param name="owner">The owner PropertyEditor of the factory. /// This is neccessary in order to get the PropertyTemplateSelector to work.</param> public DefaultPropertyViewModelFactory(PropertyEditor owner) { this.owner = owner; }
HelpInfo IHelpProvider.ProvideHoverHelp(Point localPos, ref bool captured) { // A dropdown is opened. Provide dropdown help. IPopupControlHost dropdownEdit = this.FocusEditor as IPopupControlHost; if (dropdownEdit != null && dropdownEdit.IsDropDownOpened) { EnumPropertyEditor enumEdit = dropdownEdit as EnumPropertyEditor; FlaggedEnumPropertyEditor enumFlagEdit = dropdownEdit as FlaggedEnumPropertyEditor; ObjectSelectorPropertyEditor objectSelectorEdit = dropdownEdit as ObjectSelectorPropertyEditor; // Its able to provide help. Redirect. if (dropdownEdit is IHelpProvider) { captured = true; Point dropdownEditorPos = this.GetEditorLocation(dropdownEdit as PropertyEditor, true); return((dropdownEdit as IHelpProvider).ProvideHoverHelp(new Point(localPos.X - dropdownEditorPos.X, localPos.Y - dropdownEditorPos.Y), ref captured)); } // Special case: Its a known basic dropdown. else if (enumEdit != null) { captured = true; if (enumEdit.DropDownHoveredName != null) { return(HelpInfo.FromMember(enumEdit.EditedType.GetField(enumEdit.DropDownHoveredName, ReflectionHelper.BindAll))); } else { FieldInfo field = enumEdit.EditedType.GetField(enumEdit.DisplayedValue.ToString(), ReflectionHelper.BindAll); if (field != null) { return(HelpInfo.FromMember(field)); } } } else if (enumFlagEdit != null) { captured = true; if (enumFlagEdit.DropDownHoveredItem != null) { return(HelpInfo.FromMember(enumFlagEdit.EditedType.GetField(enumFlagEdit.DropDownHoveredItem.Caption, ReflectionHelper.BindAll))); } else { FieldInfo field = enumFlagEdit.EditedType.GetField(enumFlagEdit.DisplayedValue.ToString(), ReflectionHelper.BindAll); if (field != null) { return(HelpInfo.FromMember(field)); } } } else if (objectSelectorEdit != null) { captured = true; if (objectSelectorEdit.DropDownHoveredObject != null) { return(HelpInfo.FromObject(objectSelectorEdit.DropDownHoveredObject.Value)); } else { return(HelpInfo.FromObject(objectSelectorEdit.DisplayedValue)); } } // No help available. return(null); } captured = false; // Pick an editor and see if it has access to an actual IHelpProvider PropertyEditor pickedEditor = this.PickEditorAt(localPos.X, localPos.Y, true); PropertyEditor helpEditor = pickedEditor; while (helpEditor != null) { Point helpEditorPos = this.GetEditorLocation(helpEditor, true); if (helpEditor is IHelpProvider) { IHelpProvider localProvider = helpEditor as IHelpProvider; HelpInfo localHelp = localProvider.ProvideHoverHelp(new Point(localPos.X - helpEditorPos.X, localPos.Y - helpEditorPos.Y), ref captured); if (localHelp != null) { return(localHelp); } } helpEditor = helpEditor.ParentEditor; } // If not, default to member or type information if (pickedEditor != null) { if (!string.IsNullOrEmpty(pickedEditor.PropertyDesc)) { return(HelpInfo.FromText(pickedEditor.PropertyName, pickedEditor.PropertyDesc)); } else if (pickedEditor.EditedMember != null) { return(HelpInfo.FromMember(pickedEditor.EditedMember)); } else if (pickedEditor.EditedType != null) { return(HelpInfo.FromMember(pickedEditor.EditedType)); } } return(null); }
public SerializableObjectPropertyEditorBuilder WithPropertyEditor(PropertyEditor propertyEditor) { _propertyEditor = propertyEditor; return this; }
public override void ConfigureEditor(PropertyEditor editor, object configureData = null) { IEnumerable <EditorHintAttribute> hintOverride = configureData as IEnumerable <EditorHintAttribute>; IEnumerable <EditorHintAttribute> parentHint = null; if (editor.ParentEditor != null) { IEnumerable <EditorHintAttribute> parentHintOverride = editor.ParentEditor.ConfigureData as IEnumerable <EditorHintAttribute>; if (editor.ParentEditor.EditedMember != null) { parentHint = editor.ParentEditor.EditedMember.GetEditorHints <EditorHintAttribute>(parentHintOverride); } else { parentHint = parentHintOverride; } } if (hintOverride == null && parentHint != null) { // No configuration data available? Allow to derive certain types from parent list or dictionary. if (editor.ParentEditor is IListPropertyEditor || editor.ParentEditor is IDictionaryPropertyEditor) { hintOverride = parentHint.Where(a => a is EditorHintDecimalPlacesAttribute || a is EditorHintIncrementAttribute || a is EditorHintRangeAttribute); } // That way we can specify the decimal places of an array of Vector2-structs and actually change those Vector2 editors. } // Invoke the PropertyEditor's configure method base.ConfigureEditor(editor, hintOverride); // Do some final configuration for editors that do not behave as intended by default. if (editor is MemberwisePropertyEditor) { MemberwisePropertyEditor memberEditor = editor as MemberwisePropertyEditor; memberEditor.MemberPredicate = this.EditorMemberPredicate; memberEditor.MemberAffectsOthers = this.EditorMemberAffectsOthers; memberEditor.MemberPropertySetter = this.EditorMemberPropertySetter; memberEditor.MemberFieldSetter = this.EditorMemberFieldSetter; } if (editor is IListPropertyEditor) { IListPropertyEditor listEditor = editor as IListPropertyEditor; listEditor.ListIndexSetter = this.EditorListIndexSetter; } if (editor is IDictionaryPropertyEditor) { IDictionaryPropertyEditor dictEditor = editor as IDictionaryPropertyEditor; dictEditor.DictionaryKeySetter = this.EditorDictionaryKeySetter; } var flagsAttrib = editor.EditedMember.GetEditorHint <EditorHintFlagsAttribute>(hintOverride); if (flagsAttrib != null) { editor.ForceWriteBack = (flagsAttrib.Flags & MemberFlags.ForceWriteback) == MemberFlags.ForceWriteback; if ((flagsAttrib.Flags & MemberFlags.ReadOnly) == MemberFlags.ReadOnly) { editor.Setter = null; } } if (editor is NumericPropertyEditor) { var rangeAttrib = editor.EditedMember.GetEditorHint <EditorHintRangeAttribute>(hintOverride); var incAttrib = editor.EditedMember.GetEditorHint <EditorHintIncrementAttribute>(hintOverride); var placesAttrib = editor.EditedMember.GetEditorHint <EditorHintDecimalPlacesAttribute>(hintOverride); NumericPropertyEditor numEditor = editor as NumericPropertyEditor; if (rangeAttrib != null) { numEditor.Maximum = rangeAttrib.Max; numEditor.Minimum = rangeAttrib.Min; } if (incAttrib != null) { numEditor.Increment = incAttrib.Increment; } if (placesAttrib != null) { numEditor.DecimalPlaces = placesAttrib.Places; } } }
public StringEditorTemplate(PropertyEditor parent) : base(parent) {}
HelpInfo IHelpProvider.ProvideHoverHelp(System.Drawing.Point localPos, ref bool captured) { PropertyEditor pickedEditor = this.PickEditorAt(this.Location.X + localPos.X, this.Location.Y + localPos.Y, true); if (this.showRelative) { if (pickedEditor == this.editorPos) { return(HelpInfo.FromMember(ReflectionInfo.Property_Transform_RelativePos)); } else if (pickedEditor == this.editorVel) { return(HelpInfo.FromMember(ReflectionInfo.Property_Transform_RelativeVel)); } else if (pickedEditor == this.editorScale) { return(HelpInfo.FromMember(ReflectionInfo.Property_Transform_RelativeScale)); } else if (pickedEditor == this.editorAngle) { return(HelpInfo.FromMember(ReflectionInfo.Property_Transform_RelativeAngle)); } else if (pickedEditor == this.editorAngleVel) { return(HelpInfo.FromMember(ReflectionInfo.Property_Transform_RelativeAngleVel)); } } else { if (pickedEditor == this.editorPos) { return(HelpInfo.FromMember(ReflectionInfo.Property_Transform_Pos)); } else if (pickedEditor == this.editorVel) { return(HelpInfo.FromMember(ReflectionInfo.Property_Transform_Vel)); } else if (pickedEditor == this.editorScale) { return(HelpInfo.FromMember(ReflectionInfo.Property_Transform_Scale)); } else if (pickedEditor == this.editorAngle) { return(HelpInfo.FromMember(ReflectionInfo.Property_Transform_Angle)); } else if (pickedEditor == this.editorAngleVel) { return(HelpInfo.FromMember(ReflectionInfo.Property_Transform_AngleVel)); } } if (pickedEditor == this.editorShowRelative) { return(HelpInfo.FromText("Show relative values?", "If true, the relative Transform values are displayed for editing. This is an editor property that does not affect object behaviour in any way.")); } else if (pickedEditor.EditedMember != null) { return(HelpInfo.FromMember(pickedEditor.EditedMember)); } else if (pickedEditor.EditedType != null) { return(HelpInfo.FromMember(pickedEditor.EditedType)); } return(null); }
public PropertyEditorEventArgs(PropertyEditor e) { this.editor = e; }
protected override void BeforeAutoCreateEditors() { base.BeforeAutoCreateEditors(); this.editorPos = this.ParentGrid.CreateEditor((typeof(Vector3)), this); if (this.editorPos != null) { this.editorPos.BeginUpdate(); this.editorPos.Getter = this.PosGetter; this.editorPos.Setter = this.PosSetter; this.editorPos.PropertyName = "Pos"; this.ParentGrid.ConfigureEditor(this.editorPos, new EditorHintAttribute[] { new EditorHintDecimalPlacesAttribute(0), new EditorHintIncrementAttribute(1) }); this.AddPropertyEditor(this.editorPos); this.editorPos.EndUpdate(); } this.editorVel = this.ParentGrid.CreateEditor(typeof(Vector3), this); if (this.editorVel != null) { this.editorVel.BeginUpdate(); this.editorVel.Getter = this.VelGetter; this.editorVel.PropertyName = "Vel"; this.ParentGrid.ConfigureEditor(this.editorVel); this.AddPropertyEditor(this.editorVel); this.editorVel.EndUpdate(); } this.editorScale = this.ParentGrid.CreateEditor(typeof(float), this); if (this.editorScale != null) { this.editorScale.BeginUpdate(); this.editorScale.Getter = this.ScaleGetter; this.editorScale.Setter = this.ScaleSetter; this.editorScale.PropertyName = "Scale"; this.ParentGrid.ConfigureEditor(this.editorScale); this.AddPropertyEditor(this.editorScale); this.editorScale.EndUpdate(); } this.editorAngle = this.ParentGrid.CreateEditor(typeof(float), this); if (this.editorAngle != null) { this.editorAngle.BeginUpdate(); this.editorAngle.Getter = this.AngleGetter; this.editorAngle.Setter = this.AngleSetter; this.editorAngle.PropertyName = "Angle"; this.ParentGrid.ConfigureEditor(this.editorAngle, new EditorHintAttribute[] { new EditorHintDecimalPlacesAttribute(1), new EditorHintIncrementAttribute(1), new EditorHintRangeAttribute(float.MinValue, float.MaxValue, 0.0f, 359.999f) }); this.AddPropertyEditor(this.editorAngle); this.editorAngle.EndUpdate(); } this.editorAngleVel = this.ParentGrid.CreateEditor(typeof(float), this); if (this.editorAngleVel != null) { this.editorAngleVel.BeginUpdate(); this.editorAngleVel.Getter = this.AngleVelGetter; this.editorAngleVel.PropertyName = "AngleVel"; this.ParentGrid.ConfigureEditor(this.editorAngleVel, new[] { new EditorHintIncrementAttribute(0.1f) }); this.AddPropertyEditor(this.editorAngleVel); this.editorAngleVel.EndUpdate(); } this.AddEditorForMember(ReflectionInfo.Property_Transform_DeriveAngle); this.AddEditorForMember(ReflectionInfo.Property_Transform_IgnoreParent); this.editorShowRelative = this.ParentGrid.CreateEditor(typeof(bool), this); if (editorShowRelative != null) { this.editorShowRelative.BeginUpdate(); this.editorShowRelative.Getter = this.ShowRelativeGetter; this.editorShowRelative.Setter = this.ShowRelativeSetter; this.editorShowRelative.PropertyName = "[ Relative values ]"; this.ParentGrid.ConfigureEditor(this.editorShowRelative); this.AddPropertyEditor(this.editorShowRelative); this.editorShowRelative.EndUpdate(); } }
public PropertyCategory(string categoryName, PropertyEditor owner) : base(owner) { Name = Header = categoryName; Properties = new List<PropertyBase>(); }
public IEnumerable <ValidationResult> Validate(object value, PreValueCollection preValues, PropertyEditor editor) { var json = value as JArray; if (json == null) { yield break; } //get all values in the array that are not empty (we'll remove empty values when persisting anyways) var groupedValues = json.OfType <JObject>() .Where(jItem => jItem["value"] != null) .Select((jItem, index) => new { value = jItem["value"].ToString(), index = index }) .Where(asString => asString.value.IsNullOrWhiteSpace() == false) .GroupBy(x => x.value); foreach (var g in groupedValues.Where(g => g.Count() > 1)) { yield return(new ValidationResult("The value " + g.Last().value + " must be unique", new[] { //we'll make the server field the index number of the value so it can be wired up to the view "item_" + g.Last().index.ToInvariantString() })); } }