public void SetProperty(ComponentProperty property, PropertyUnion value) { if (m_propertyValues.ContainsKey(property)) { m_propertyValues[property] = value; } }
private void OnValueChanged() { var v = new Vector3(GetFloat(X.Value), GetFloat(Y.Value), GetFloat(Z.Value)); var q = GetQuaternionRotation(v); ComponentProperty.SetValue(Component, q); }
public override void UpdateValues(bool editorWindowIsActive) { var value = (Quaternion)ComponentProperty.GetValue(Component); var xStr = value.X.ToString(); var yStr = value.Y.ToString(); var zStr = value.Z.ToString(); var wStr = value.W.ToString(); if ((!editorWindowIsActive || !X.IsFocused) && GetFloat(X.Value) != value.X) { X.Value = value.X; } if ((!editorWindowIsActive || !Y.IsFocused) && GetFloat(Y.Value) != value.Y) { Y.Value = value.Y; } if ((!editorWindowIsActive || !Z.IsFocused) && GetFloat(Z.Value) != value.Z) { Z.Value = value.Z; } if ((!editorWindowIsActive || !W.IsFocused) && GetFloat(W.Value) != value.W) { W.Value = value.W; } }
public IColumn CreateColumn(ComponentProperty property) { Column column = new Column(property.Name); column.IsNullable = false; var options = property.ValidationOptions; if (options.MaximumLength.HasValue) { column.Size = options.MaximumLength.Value; } if (options.IntegerDigits.HasValue) { column.Precision = options.IntegerDigits.Value + (options.FractionalDigits ?? 0); } if (options.FractionalDigits.HasValue) { column.Scale = options.FractionalDigits.Value; } column.IsReadOnly = false; column.OriginalDataType = ArchAngel.Interfaces.ProjectOptions.TypeMappings.Utility.GetDefaultDatabaseType(column.Database.DatabaseType.ToString(), property.Type); column.IsNullable = property.Type.Trim().EndsWith("?"); return(column); }
private void ReadDeclarationSection(XElement declaration, XNamespace ns, LoadContext lc, ComponentDescription description) { IXmlLineInfo line = declaration as IXmlLineInfo; // Read meta nodes foreach (var metaElement in declaration.Elements(ns + "meta")) { ReadMetaNode(metaElement, lc, description); } // Check all required metadata was set if (String.IsNullOrEmpty(description.ComponentName)) { lc.Errors.Add(new LoadError(lc.FileName, line.LineNumber, line.LinePosition, LoadErrorCategory.Error, "Component name is required")); } //Read properties List <ComponentProperty> properties = new List <ComponentProperty>(); foreach (var propertyElement in declaration.Elements(ns + "property")) { ScanPropertyNode(propertyElement, lc); } foreach (var propertyElement in declaration.Elements(ns + "property")) { ComponentProperty property = ReadPropertyNode(propertyElement, lc); properties.Add(property); } description.Properties = properties.ToArray(); // Read flags List <Conditional <FlagOptions> > flagOptions = new List <Conditional <FlagOptions> >(); foreach (var flagGroup in declaration.Elements(ns + "flags")) { var flags = ReadFlagOptionNode(flagGroup, lc); if (flags != null) { flagOptions.Add(flags); } } description.Flags = flagOptions.ToArray(); // Read configurations var componentConfigurations = new List <ComponentConfiguration>(); var configurations = declaration.Element(ns + "configurations"); if (configurations != null) { foreach (var node in configurations.Elements(ns + "configuration")) { ComponentConfiguration newConfiguration = ReadConfigurationNode(node, description); componentConfigurations.Add(newConfiguration); } } description.Metadata.Configurations.AddRange(componentConfigurations); }
public ComponentPropertyMarker(ComponentProperty representedProperty) { if (representedProperty == null) { throw new ArgumentNullException("representedProperty"); } RepresentedProperty = representedProperty; }
public override void UpdateValues(bool editorWindowIsActive) { var value = (float)ComponentProperty.GetValue(Component); if ((!editorWindowIsActive || !Value.IsFocused) && GetFloat(Value.Value) != value) { Value.Value = value; } }
//private static SQLServer.UniDbTypes ConvertToDatabaseType(Property property) //{ // if ((property.Type == "System.String" || property.Type == "string") && // (property.ValidationOptions.MaximumLength.HasValue && property.ValidationOptions.MaximumLength > 0)) // { // return SQLServer.UniDbTypes.NVarChar; // } // return SQLServer.ConvertCLRTypeNameToSQLTypeName(property.Type); //} private SQLServer.UniDbTypes ConvertToDatabaseType(ComponentProperty property) { if ((property.Type == "System.String" || property.Type == "string") && (property.ValidationOptions.MaximumLength.HasValue && property.ValidationOptions.MaximumLength > 0)) { return(SQLServer.UniDbTypes.NVarChar); } return(SQLServer.ConvertCLRTypeNameToSQLTypeName(property.Type)); }
private void SerialiseComponentPropertyInternal(ComponentProperty property, XmlWriter writer) { writer.WriteStartElement("Property"); writer.WriteElementString("Name", property.Name ?? ""); writer.WriteElementString("Type", property.Type ?? "object"); SerialiseValidationOptions(property.ValidationOptions, writer); ProcessScriptBase(property, writer); writer.WriteEndElement(); }
public override void UpdateValues(bool editorWindowIsActive) { var value = (bool)ComponentProperty.GetValue(Component); if (Value.IsChecked != value) { Value.IsChecked = value; } }
public override void DetachFromModel() { if (Detached || property == null) return; property.PropertyChanged -= property_PropertyChanged; property = null; Detached = true; form.Clear(); }
public ComponentProperty Save(ComponentProperty componentProperty) { if (componentProperty.Id == Guid.Empty) { componentProperty.Id = Guid.NewGuid(); } HibernateTemplate.Save(componentProperty); return(componentProperty); }
private void InitializeComponent() { // resolve property descriptor to a value object appointmentImage = _imageStyleProperty.GetValue(_objectItem); // get inner properties using converter to get proper property type converters PropertyDescriptorCollection properties = _imageStyleProperty.Converter.GetProperties(appointmentImage); PropertyDescriptor source = properties[ImageStyle.SourcePropertyName]; PropertyDescriptor value = properties[ImageStyle.ValuePropertyName]; PropertyDescriptor mimeType = properties[ImageStyle.MimeTypePropertyName]; HorizontalPanel panel1 = new HorizontalPanel(); using (new SuspendLayoutTransaction(this)) using (new SuspendLayoutTransaction(panel1)) { panel1.AutoSize = AutoSize = true; panel1.Margin = Utils.UpdateMarginByIndent(System.Windows.Forms.Padding.Empty, _serviceProvider, 1); // // _imageStyleLabel // ControlGroupHeadingLabel _imageStyleLabel = new ControlGroupHeadingLabel(_serviceProvider); _imageStyleLabel.Dock = DockStyle.Top; _imageStyleLabel.Text = Resources.ImageLabel; // // sourceEditor // sourceEditor = new TypedValueEditor(_serviceProvider, Resources.SourceLabel, ComponentProperty.Create(source, appointmentImage)); sourceEditor.Validated += OnImageEditorChanged; sourceEditor.Margin = System.Windows.Forms.Padding.Empty; // // value Value // valueEditor = new TypedValueEditor(_serviceProvider, Resources.ValueTypeLabel, ComponentProperty.Create(value, appointmentImage)); valueEditor.Validated += OnImageEditorChanged; valueEditor.Margin = Utils.UpdateMarginByIndent(System.Windows.Forms.Padding.Empty, valueEditor.ControlInfo, 1); // //style Value // mimeTypeEditor = new TypedValueEditor(_serviceProvider, Resources.MimeTypeLabel, ComponentProperty.Create(mimeType, appointmentImage)); mimeTypeEditor.Validated += OnImageEditorChanged; mimeTypeEditor.Margin = System.Windows.Forms.Padding.Empty; panel1.Controls.Add(sourceEditor); panel1.Controls.Add(mimeTypeEditor); Controls.Add(_imageStyleLabel); Controls.Add(panel1); Controls.Add(valueEditor); } isInitialized = true; }
private void InitializeComponent() { // resolve property descriptor to a value object appointmentImage = _lineStyleProperty.GetValue(_objectItem); // get inner properties using converter to get proper property type converters PropertyDescriptorCollection properties = _lineStyleProperty.Converter.GetProperties(appointmentImage); PropertyDescriptor color = properties[DesignLineStyle.LineColorPropertyName]; PropertyDescriptor width = properties[DesignLineStyle.LineWidthPropertyName]; PropertyDescriptor style = properties[DesignLineStyle.LineStylePropertyName]; using (new SuspendLayoutTransaction(this)) { this.AutoSize = true; // // _imageStyleLabel // ControlGroupHeadingLabel lineStyleLabel = new ControlGroupHeadingLabel(_serviceProvider); lineStyleLabel.Dock = DockStyle.Top; lineStyleLabel.Text = Resources.LineStyleLabel; Controls.Add(lineStyleLabel); HorizontalPanel horzPanel = new HorizontalPanel(); horzPanel.AutoSize = true; horzPanel.Dock = DockStyle.Top; horzPanel.Margin = Utils.UpdateMarginByIndent(System.Windows.Forms.Padding.Empty, _serviceProvider, 1); Controls.Add(horzPanel); // // styleEditor // styleEditor = new TypedValueEditor(_serviceProvider, Resources.LineStyle, ComponentProperty.Create(style, appointmentImage)); styleEditor.Validated += OnLineStyleEditorChanged; styleEditor.Margin = System.Windows.Forms.Padding.Empty; horzPanel.Controls.Add(styleEditor); // // widthEditor // widthEditor = new TypedValueEditor(_serviceProvider, Resources.LineWidth, ComponentProperty.Create(width, appointmentImage)); widthEditor.Validated += OnLineStyleEditorChanged; widthEditor.Margin = System.Windows.Forms.Padding.Empty; horzPanel.Controls.Add(widthEditor); // // colorEditor // colorEditor = new TypedValueEditor(_serviceProvider, Resources.LineColor, ComponentProperty.Create(color, appointmentImage)); colorEditor.Validated += OnLineStyleEditorChanged; colorEditor.Margin = Utils.UpdateMarginByIndent(System.Windows.Forms.Padding.Empty, colorEditor.ControlInfo, 1); Controls.Add(colorEditor); } isInitialized = true; }
public void AttachToModel(ComponentProperty obj) { if(!Detached) DetachFromModel(); property = obj; Detached = false; property.PropertyChanged += property_PropertyChanged; SetupForm(); }
private void gridViewProperties_CellEndEdit(object sender, DataGridViewCellEventArgs e) { var row = gridViewProperties.Rows[e.RowIndex]; if (e.ColumnIndex == PropertyNameColumn.Index) { ComponentProperty changedProperty = row.Tag as ComponentProperty; PropertyNameChanged.RaiseEventEx(this, new GenericEventArgs <ComponentProperty>(changedProperty)); } }
public void Form_Events_Are_Attached_To() { IPropertyForm form = MockRepository.GenerateMock <IPropertyForm>(); ComponentProperty obj = MockRepository.GenerateMock <ComponentProperty>(); IMainPanel panel = MockRepository.GenerateMock <IMainPanel>(); //new ComponentPropertyPresenter(panel, form); form.AssertWasCalled(f => f.DatatypeChanged += null, c => c.IgnoreArguments()); form.AssertWasCalled(f => f.PropertyNameChanged += null, c => c.IgnoreArguments()); }
public PropertyUnion GetProperty(ComponentProperty property) { if (m_propertyValues.ContainsKey(property)) { return(m_propertyValues[property]); } else { return(null); } }
public string GetFormattedProperty(ComponentProperty property) { if (m_propertyValues.ContainsKey(property)) { return(property.Format(this, m_propertyValues[property])); } else { return(null); } }
public void Property_Changed_Registered() { IPropertyForm form = MockRepository.GenerateMock <IPropertyForm>(); ComponentProperty obj = MockRepository.GenerateMock <ComponentProperty>(); IMainPanel panel = MockRepository.GenerateMock <IMainPanel>(); //ComponentPropertyPresenter presenter = new ComponentPropertyPresenter(panel, form); //presenter.AttachToModel(obj); obj.AssertWasCalled(o => o.PropertyChanged += null, c => c.IgnoreArguments()); }
public void AddProperty(ComponentProperty prop) { properties.Add(prop); prop.Specification = this; foreach (var impl in implementedComponents) { impl.AddProperty(new ComponentPropertyMarker(prop)); } PropertiesChanged.RaiseEvent(this, new CollectionChangeEvent <ComponentProperty>(CollectionChangeAction.Addition, prop)); }
public override void DetachFromModel() { if (Detached || property == null) { return; } property.PropertyChanged -= property_PropertyChanged; property = null; Detached = true; form.Clear(); }
public void Show_Property_Grid_Called() { IPropertyForm form = MockRepository.GenerateMock <IPropertyForm>(); ComponentProperty obj = MockRepository.GenerateMock <ComponentProperty>(); IMainPanel panel = MockRepository.GenerateMock <IMainPanel>(); //ComponentPropertyPresenter presenter = new ComponentPropertyPresenter(panel, form); //presenter.AttachToModel(obj); //presenter.Show(); //panel.AssertWasCalled(p => p.ShowPropertyGrid(form)); }
private void AddNewColumnPropertyMappingRow(ComponentProperty property) { var row = new DataGridViewRow(); row.Tag = property; gridViewProperties.AllowUserToAddRows = true; row.CreateCells(gridViewProperties); row.Cells[PropertyNameColumn.Index].Value = property.Name; gridViewProperties.Rows.Add(row); gridViewProperties.AllowUserToAddRows = false; }
public void AttachToModel(ComponentProperty obj) { if (!Detached) { DetachFromModel(); } property = obj; Detached = false; property.PropertyChanged += property_PropertyChanged; SetupForm(); }
public static ExtentionPropertyDto GetExtentionProperty(ComponentProperty property) { if (property == null) { return(null); } return(new ExtentionPropertyDto() { Name = property.Name, Value = property.Value, Type = property.DataType }); }
private void gridViewProperties_CellContentClick(object sender, DataGridViewCellEventArgs e) { ComponentProperty property = gridViewProperties.Rows[e.RowIndex].Tag as ComponentProperty; if (e.ColumnIndex == DeletePropertyColumn.Index) { DeleteProperty.RaiseEventEx(this, new GenericEventArgs <ComponentProperty>(property)); } else if (e.ColumnIndex == EditPropertyColumn.Index) { EditProperty.RaiseEventEx(this, new GenericEventArgs <ComponentProperty>(property)); } }
public override void UpdateValues(bool editorWindowIsActive) { var value = (Vector2)ComponentProperty.GetValue(Component); if ((!editorWindowIsActive || !X.IsFocused) && GetFloat(X.Value) != value.X) { X.Value = value.X; } if ((!editorWindowIsActive || !Y.IsFocused) && GetFloat(Y.Value) != value.Y) { Y.Value = value.Y; } }
public void ReadXmlWithOneProperty(ComponentPropertyBag propertyBag, ComponentProperty property, string xml, XmlReader reader, Exception e) { "Given a component property bag" .x(() => { propertyBag = new ComponentPropertyBag(); }); "And xml containing one property" .x(() => { property = new ComponentProperty { Name = "NameOfTheProperty", Value = "ValueOfTheProperty", ValueType = "ValueTypeOfTheProperty" }; var properties = new List <ComponentProperty> { property }; xml = BuildXml(properties); }); "And a reader for the xml" .x(() => { reader = XmlReader.Create(new StringReader(xml)); reader.MoveToContent(); }); "When reading the xml" .x(() => e = Record.Exception(() => propertyBag.ReadXml(reader))); "Then the code should not throw an exception" .x(() => e.Should().BeNull()); "And the property bag contains one property" .x(() => { propertyBag.FirstOrDefault().Should().NotBeNull(); }); "And the properties should be as expected" .x(() => { propertyBag[0].Name.Should().Be(property.Name); propertyBag[0].ValueType.Should().Be(property.ValueType); propertyBag[0].Value.Should().Be(property.Value); }); }
public ElementNameAndOutputEditor(IServiceProvider serviceProvider, CalendarDesigner designer, bool hasAutoOption) { if (serviceProvider == null) { throw new ArgumentNullException("serviceProvider"); } if (designer == null) { throw new ArgumentNullException("designer"); } _serviceProvider = serviceProvider; _designer = designer; hasAuto = hasAutoOption; elementOutput = ComponentProperty.Create(_designer.ReportItem, ReportItemDesignerBase.DataElementOutputPropertyName); InitializeComponent(); }
private static Entity ParseEntity(XmlNode ObjectNode) { float Width = float.Parse(ObjectNode.Attributes["width"].Value); float Height = float.Parse(ObjectNode.Attributes["height"].Value); float X = float.Parse(ObjectNode.Attributes["x"].Value); float Y = float.Parse(ObjectNode.Attributes["y"].Value); string BlueprintName = ObjectNode.Attributes["type"].Value.Trim(); string EntityName = ObjectNode.Attributes["name"] == null ? null : ObjectNode.Attributes["name"].Value.Trim(); EntityBlueprint Blueprint = EntityBlueprint.GetBlueprint(BlueprintName); Entity Entity = Blueprint.CreateEntity(); if (!String.IsNullOrWhiteSpace(EntityName)) { Entity.Name = EntityName; } Entity.Position = new Vector2(X, Y); Entity.Size = new Vector2(Width, Height); foreach (XmlNode PropertiesNode in ObjectNode.SelectNodes("properties")) { foreach (XmlNode PropertyNode in PropertiesNode.SelectNodes("property")) { string Name = PropertyNode.Attributes["name"].Value.Trim(); // So, this is quite a hack. // Tiled doesn't allow us to re-order properties; it's all alphabetical. // So we just support sticking a # in front of the property to make it go to the top of the list, and then ignore that #. while (Name.FirstOrDefault() == '#') { Name = Name.Substring(1); } string Value = PropertyNode.Attributes["value"].Value.Trim(); string[] NamePropertySplit = Name.Split('.'); if (NamePropertySplit.Length != 2) { throw new FormatException("Expected object property name to be in the format of 'PathComponent.Nodes'."); } string ComponentName = NamePropertySplit[0].Trim(); string PropertyName = NamePropertySplit[1].Trim(); ComponentArgument Argument = ComponentArgument.Parse(Value).Single(); ComponentProperty ParsedProperty = new ComponentProperty(ComponentName, PropertyName, Argument); var Component = Entity.Components[ComponentName]; ParsedProperty.ApplyValue(Component); } } return(Entity); }
public override void UpdateValues(bool editorWindowIsActive) { var quaternion = (Quaternion)ComponentProperty.GetValue(Component); var value = GetEulerRotation(quaternion); if ((!editorWindowIsActive || !X.IsFocused) && GetFloat(X.Value) != value.X) { X.Value = value.X; } if ((!editorWindowIsActive || !Y.IsFocused) && GetFloat(Y.Value) != value.Y) { Y.Value = value.Y; } if ((!editorWindowIsActive || !Z.IsFocused) && GetFloat(Z.Value) != value.Z) { Z.Value = value.Z; } }
private static void SetPropertyInfoFromParsedCode(List<Class> possibleClasses, ComponentProperty property) { foreach (var possibleClass in possibleClasses) { var possibleProperty = possibleClass.Properties.FirstOrDefault(p => p.Name == property.Name); if (possibleProperty != null) { // We have successfully found the property. Get the information we need from it. property.Type = possibleProperty.DataType.ToString(); } } }
public string GetPropertyName(ComponentProperty property) { int index = properties.IndexOf(property); return gridViewProperties.Rows[index].Cells[PropertyNameColumn.Index].Value as string; }
public static Property Clone(Property target) { Property prop = null; int id = target.PropertyId; PropertyBag bag = target.Owner; switch (target.PropertyType) { case (int)PropertyKind.WispObject: prop = new WispProperty(target.Name, id, ((WispProperty)target).Value, bag); break; case (int)PropertyKind.WispArray: prop = new WispArrayProperty(target.Name, id, ((WispArrayProperty)target).Value, bag); break; case (int)PropertyKind.Int32: prop = new Int32Property(target.Name, id, ((Int32Property)target).Value, bag); break; case (int)PropertyKind.String: prop = new StringProperty(target.Name, id, ((StringProperty)target).Value, bag); break; case (int)PropertyKind.Bool: prop = new BoolProperty(target.Name, id, ((BoolProperty)target).Value, bag); break; case (int)PropertyKind.Guid: prop = new GuidProperty(target.Name, id, ((GuidProperty)target).Value, bag); break; case (int)PropertyKind.Single: prop = new SingleProperty(target.Name, id, ((SingleProperty)target).Value, bag); break; case (int)PropertyKind.Int32Array: prop = new Int32ArrayProperty(target.Name, id, ((Int32ArrayProperty)target).Value, bag); break; case (int)PropertyKind.StringArray: prop = new StringArrayProperty(target.Name, id, ((StringArrayProperty)target).Value, bag); break; case (int)PropertyKind.DateTime: prop = new DateTimeProperty(target.Name, id, ((DateTimeProperty)target).Value, bag); break; case (int)PropertyKind.GuidArray: prop = new GuidArrayProperty(target.Name, id, ((GuidArrayProperty)target).Value, bag); break; case (int)PropertyKind.Double: prop = new DoubleProperty(target.Name, id, ((DoubleProperty)target).Value, bag); break; case (int)PropertyKind.Byte: prop = new ByteProperty(target.Name, id, ((ByteProperty)target).Value, bag); break; case (int)PropertyKind.Component: prop = new ComponentProperty(target.Name, id, ((ComponentProperty)target).Value, bag); break; case (int)PropertyKind.SingleArray: prop = new SingleArrayProperty(target.Name, id, ((SingleArrayProperty)target).Value, bag); break; case (int)PropertyKind.Int64: prop = new Int64Property(target.Name, id, ((Int64Property)target).Value, bag); break; case (int)PropertyKind.ComponentArray: prop = new ComponentArrayProperty(target.Name, id, ((ComponentArrayProperty)target).Value, bag); break; case (int)PropertyKind.DateTimeArray: prop = new DateTimeArrayProperty(target.Name, id, ((DateTimeArrayProperty)target).Value, bag); break; case (int)PropertyKind.ByteArray: prop = new ByteArrayProperty(target.Name, id, ((ByteArrayProperty)target).Value, bag); break; case (int)PropertyKind.DoubleArray: prop = new DoubleArrayProperty(target.Name, id, ((DoubleArrayProperty)target).Value, bag); break; case (int)PropertyKind.Int16Array: prop = new Int16ArrayProperty(target.Name, id, ((Int16ArrayProperty)target).Value, bag); break; case (int)PropertyKind.Int16: prop = new Int16Property(target.Name, id, ((Int16Property)target).Value, bag); break; case (int)PropertyKind.Int64Array: prop = new Int64ArrayProperty(target.Name, id, ((Int64ArrayProperty)target).Value, bag); break; case (int)PropertyKind.BoolArray: prop = new BoolArrayProperty(target.Name, id, ((BoolArrayProperty)target).Value, bag); break; } prop.Name = target.Name; return prop; }