예제 #1
0
 public PropertyValue(PropertyIdentifier propertyIdentifier, Option<uint> propertyArrayIndex, GenericValue value, Option<uint> priority)
 {
     this.PropertyIdentifier = propertyIdentifier;
     this.PropertyArrayIndex = propertyArrayIndex;
     this.Value = value;
     this.Priority = priority;
 }
예제 #2
0
        public Encodable getProperty(PropertyIdentifier pid, UnsignedInteger propertyArrayIndex)
        {
            Encodable result = getProperty(pid);

            if (propertyArrayIndex == null)
            {
                return(result);
            }

            if (!(result is SequenceOf))
            {
                throw new BACnetServiceException(ErrorClass.Property, ErrorCode.PropertyIsNotAnArray);
            }

            SequenceOf array = (SequenceOf )result;
            uint       index = propertyArrayIndex.Value;

            if (index == 0)
            {
                return(new UnsignedInteger((uint)array.Count));
            }

            if (index > array.getCount())
            {
                throw new BACnetServiceException(ErrorClass.Property, ErrorCode.InvalidArrayIndex);
            }

            return(array.Get((int)index));
        }
예제 #3
0
        public override object TranslatePropertyValue(ModelItem item, PropertyIdentifier identifier, object value)
        {
            if (item != null && identifier.DeclaringType.IsAssignableFrom(typeof(FrameworkElement)) && identifier.Name == "Resources")
            {
                var control   = (FrameworkElement)item.View.PlatformObject;
                var resources = (System.Windows.ResourceDictionary)value;

                var themeResources = General.GetThemeResources(control);

                if (themeResources == null)
                {
                    Elysium.Manager.RemoveCore(resources);
                }
                else
                {
                    if (themeResources.Source == ThemeResources.Inherited)
                    {
                        themeResources.Control = new WeakReference(control);
                    }
                    Elysium.Manager.ApplyCore(resources, themeResources);
                }
                return(resources);
            }

            return(base.TranslatePropertyValue(item, identifier, value));
        }
예제 #4
0
 public PropertyValue(PropertyIdentifier propertyIdentifier, Option <uint> propertyArrayIndex, GenericValue value, Option <uint> priority)
 {
     this.PropertyIdentifier = propertyIdentifier;
     this.PropertyArrayIndex = propertyArrayIndex;
     this.Value    = value;
     this.Priority = priority;
 }
예제 #5
0
        protected static Encodable readEncodable(ByteStream source, ObjectType objectType,
                                                 PropertyIdentifier propertyIdentifier, UnsignedInteger propertyArrayIndex, int contextId)
        {
            // A property array index of 0 indicates a request for the Length of an array.
            if (propertyArrayIndex != null && propertyArrayIndex.Value == 0)
            {
                return(readWrapped(source, typeof(UnsignedInteger), contextId));
            }

            if (!matchNonEndTag(source, contextId))
            {
                throw new BACnetErrorException(ErrorClass.Property, ErrorCode.MissingRequiredParameter);
            }

            PropertyTypeDefinition def = ObjectProperties.getPropertyTypeDefinition(objectType, propertyIdentifier);

            if (def == null)
            {
                return(new AmbiguousValue(source, contextId));
            }

            if (ObjectProperties.isCommandable(objectType, propertyIdentifier))
            {
                // If the object is commandable, it could be set to Null, so we need to treat it as ambiguous.
                AmbiguousValue amb = new AmbiguousValue(source, contextId);

                if (amb.IsNull)
                {
                    return(new Null());
                }

                // Try converting to the definition value.
                return((Encodable)amb.ConvertTo(def.Type));
            }

            if (propertyArrayIndex != null)
            {
                if (!def.IsSequence && !def.Type.IsSubclassOf(typeof(SequenceOf)))
                {
                    throw new BACnetErrorException(ErrorClass.Property, ErrorCode.PropertyIsNotAList);
                }
                if (def.Type.IsSubclassOf(typeof(SequenceOf)))
                {
                    return(readWrapped(source, def.InnerType, contextId));
                }
            }
            else
            {
                if (def.IsSequence)
                {
                    return(readSequenceOf(source, def.Type, contextId));
                }
                if (def.Type.IsSubclassOf(typeof(SequenceOf)))
                {
                    return(readSequenceType(source, def.Type, contextId));
                }
            }

            return(readWrapped(source, def.Type, contextId));
        }
 public ObjectPropertyReference(ObjectIdentifier objectIdentifier, PropertyIdentifier propertyIdentifier,
                                UnsignedInteger propertyArrayIndex)
 {
     this.ObjectIdentifier   = objectIdentifier;
     this.PropertyIdentifier = propertyIdentifier;
     this.PropertyArrayIndex = propertyArrayIndex;
 }
예제 #7
0
        private void setPropertyImpl(PropertyIdentifier pid, Encodable value)
        {
            Encodable oldValue = (Encodable)properties[pid];

            properties[pid] = value;

            if (!value.Equals(oldValue))
            {
                // Check for subscriptions.
                if (ObjectCovSubscription.SendCovNotification(Id.ObjectType, pid, this.getCovIncrement()))
                {
                    //synchronized(covSubscriptions) {
                    long now = System.DateTime.Now.Ticks;
                    ObjectCovSubscription sub;
                    for (int i = covSubscriptions.Count - 1; i >= 0; i--)
                    {
                        sub = (ObjectCovSubscription)covSubscriptions[i];
                        if (sub.HasExpired(now))
                        {
                            covSubscriptions.RemoveAt(i);
                        }
                        else if (sub.IsNotificationRequired(pid, value))
                        {
                            sendCovNotification(sub, now);
                        }
                    }
                    //}
                }
            }
        }
        private PropertyRelation ParseRelation(JToken relationJson)
        {
            PropertyIdentifier from = new PropertyIdentifier(relationJson["sourceId"].Value <string>());
            PropertyIdentifier to   = new PropertyIdentifier(relationJson["targetId"].Value <string>());

            return(new PropertyRelation(from, to));
        }
예제 #9
0
 public ReadRangeRequest(ObjectId objectIdentifier, PropertyIdentifier propertyIdentifier, Option<uint> propertyArrayIndex, Option<RangeType> range)
 {
     this.ObjectIdentifier = objectIdentifier;
     this.PropertyIdentifier = propertyIdentifier;
     this.PropertyArrayIndex = propertyArrayIndex;
     this.Range = range;
 }
        private Property ParseProperty(JToken propertyJson)
        {
            var propertyIdentifier = new PropertyIdentifier(propertyJson["id"].Value <string>());
            var name = propertyJson["name"].Value <string>();

            return(new Property(propertyIdentifier, name));
        }
예제 #11
0
 public ReadPropertyAck(ObjectId objectIdentifier, PropertyIdentifier propertyIdentifier, Option<uint> propertyArrayIndex, GenericValue propertyValue)
 {
     this.ObjectIdentifier = objectIdentifier;
     this.PropertyIdentifier = propertyIdentifier;
     this.PropertyArrayIndex = propertyArrayIndex;
     this.PropertyValue = propertyValue;
 }
 public DeviceObjectPropertyReference(ObjectId objectIdentifier, PropertyIdentifier propertyIdentifier, Option <uint> propertyArrayIndex, Option <ObjectId> deviceIdentifier)
 {
     this.ObjectIdentifier   = objectIdentifier;
     this.PropertyIdentifier = propertyIdentifier;
     this.PropertyArrayIndex = propertyArrayIndex;
     this.DeviceIdentifier   = deviceIdentifier;
 }
예제 #13
0
        /// <summary>
        /// Analyze
        /// </summary>
        /// <param name="pageType">page Type</param>
        /// <returns></returns>
        public void Analyze(PageType pageType)
        {
            if (pageType == null)
            {
                throw new ArgumentNullException("pageType");
            }

            var pages = pageType.Pages;

            var skeletonExtractor = factory.SkeletonExtractor;
            pages.Accept(skeletonExtractor);
            var skeleton = skeletonExtractor.Result;
            if (skeleton == null)
            {
                return;
            }
            IdentifyMacros(skeleton, pageType);

            var builder = factory.Builder;
            var propertyIdentifier = new PropertyIdentifier(skeleton, builder);
            pages.Accept(propertyIdentifier); // sets properties on pages;

            pageType.Definitions.AddRange(propertyIdentifier.Definitions);
            var textTemplate = propertyIdentifier.PopulatedSkeleton.WriteTo();
            pageType.Template = new Template
            {
                Name = pageType.Name,
                Text = textTemplate,
                ID = Guid.NewGuid()
            };
        }
예제 #14
0
 public ListOfSelectionCriteriaType(PropertyIdentifier propertyIdentifier, Option <uint> propertyArrayIndex, RelationSpecifierType relationSpecifier, GenericValue comparisonValue)
 {
     this.PropertyIdentifier = propertyIdentifier;
     this.PropertyArrayIndex = propertyArrayIndex;
     this.RelationSpecifier  = relationSpecifier;
     this.ComparisonValue    = comparisonValue;
 }
예제 #15
0
 public static Property Unresolved(PropertyIdentifier propertyIdentifier, DeclaredType type)
 {
     return(new Property(propertyIdentifier, type)
     {
         IsResolved = false
     });
 }
 public DeviceObjectPropertyReference(ObjectId objectIdentifier, PropertyIdentifier propertyIdentifier, Option<uint> propertyArrayIndex, Option<ObjectId> deviceIdentifier)
 {
     this.ObjectIdentifier = objectIdentifier;
     this.PropertyIdentifier = propertyIdentifier;
     this.PropertyArrayIndex = propertyArrayIndex;
     this.DeviceIdentifier = deviceIdentifier;
 }
예제 #17
0
 public static Property Unresolved(PropertyIdentifier propertyIdentifier, DeclaredType type, PropertyInfo declaration, IReferencable returnType)
 {
     return(new Property(propertyIdentifier, type)
     {
         IsResolved = false, declaration = declaration, ReturnType = returnType
     });
 }
        /// <summary>
        ///     Translate property value at design time.
        /// </summary>
        /// <param name="identifier">The property to translate.</param>
        /// <param name="value">Value of the property.</param>
        /// <returns>Translated value of the property at design time.</returns>
        /// <param name="item">The model item whose property is to be translated.</param>
        public override object TranslatePropertyValue(ModelItem item, PropertyIdentifier identifier, object value)
#endif
        {
            Debug.Assert(
                item != null && !IsIdentifierEmpty(identifier) && typeof(bool).IsAssignableFrom(value.GetType()),
                "TranslatePropetyValue is called with invalid parameters!");
            Debug.Assert(
                typeof(T).IsAssignableFrom(item.ItemType),
                GetType() + " shouldn't be applied to this model item!");
            Debug.Assert(
                Identifiers.ContainsKey(item.ItemType) && Identifiers[item.ItemType] == identifier,
                "The passed in PropertyIdentifier isn't registered!");

            if (item != null && !IsIdentifierEmpty(identifier))
            {
                Type type = item.ItemType;
                PropertyIdentifier property;
                if (Identifiers.TryGetValue(type, out property) && property == identifier)
                {
#if SILVERLIGHT
                    return((bool)value || InSelection);
#else
                    return((bool)value);
#endif
                }
            }

#if SILVERLIGHT
            return(base.TranslatePropertyValue(item, identifier, value));
#else
            return(base.TranslatePropertyValue(item, identifier, value));
#endif
        }
예제 #19
0
 public ReadRangeRequest(ObjectId objectIdentifier, PropertyIdentifier propertyIdentifier, Option <uint> propertyArrayIndex, Option <RangeType> range)
 {
     this.ObjectIdentifier   = objectIdentifier;
     this.PropertyIdentifier = propertyIdentifier;
     this.PropertyArrayIndex = propertyArrayIndex;
     this.Range = range;
 }
예제 #20
0
 public Property(PropertyIdentifier identifier, DeclaredType type)
     : base(identifier)
 {
     Type   = type;
     HasGet = identifier.HasGet;
     HasSet = identifier.HasSet;
 }
        /// <summary>
        /// Translate property value at design time.
        /// </summary>
        /// <param name="item">The model item whose property is to be translated.</param>
        /// <param name="identifier">The property to translate.</param>
        /// <param name="value">Value of the property.</param>
        /// <returns>Translated value of the property at design time.</returns>
        public override object TranslatePropertyValue(
            ModelItem item,
            PropertyIdentifier identifier,
            object value)
        {
            Debug.Assert(
                item != null && !identifier.IsEmpty && typeof(bool).IsAssignableFrom(value.GetType()),
                "TranslatePropetyValue is called with invalid parameters!");
            Debug.Assert(
                typeof(T).IsAssignableFrom(item.ItemType),
                this.GetType().ToString() + " shouldn't be applied to this model item!");

            if (item != null && !identifier.IsEmpty)
            {
                Type type = item.ItemType;
                PropertyIdentifier property;
                do
                {
                    if (Identifiers.TryGetValue(type, out property) && property == identifier)
                    {
                        return((bool)value || InSelection);
                    }
                }while ((type = type.BaseType) != typeof(object));
            }

            return(base.TranslatePropertyValue(item, identifier, value));
        }
예제 #22
0
 public ReadPropertyAck(ObjectId objectIdentifier, PropertyIdentifier propertyIdentifier, Option <uint> propertyArrayIndex, GenericValue propertyValue)
 {
     this.ObjectIdentifier   = objectIdentifier;
     this.PropertyIdentifier = propertyIdentifier;
     this.PropertyArrayIndex = propertyArrayIndex;
     this.PropertyValue      = propertyValue;
 }
예제 #23
0
 public AddListElementRequest(ObjectId objectIdentifier, PropertyIdentifier propertyIdentifier, Option<uint> propertyArrayIndex, GenericValue listOfElements)
 {
     this.ObjectIdentifier = objectIdentifier;
     this.PropertyIdentifier = propertyIdentifier;
     this.PropertyArrayIndex = propertyArrayIndex;
     this.ListOfElements = listOfElements;
 }
예제 #24
0
 public AddListElementRequest(ObjectId objectIdentifier, PropertyIdentifier propertyIdentifier, Option <uint> propertyArrayIndex, GenericValue listOfElements)
 {
     this.ObjectIdentifier   = objectIdentifier;
     this.PropertyIdentifier = propertyIdentifier;
     this.PropertyArrayIndex = propertyArrayIndex;
     this.ListOfElements     = listOfElements;
 }
예제 #25
0
 public override bool HasValueTranslation(Type itemType, PropertyIdentifier property)
 {
     if (itemType == null)
     {
         throw new ArgumentNullException("itemType");
     }
     if (!this._disposed)
     {
         IEnumerable <DesignModeValueProvider> providersInCallOrder = this.GetFeatureProvidersInCallOrder(itemType);
         if (providersInCallOrder != null)
         {
             foreach (DesignModeValueProvider modeValueProvider in providersInCallOrder)
             {
                 foreach (PropertyIdentifier id in (Collection <PropertyIdentifier>)modeValueProvider.Properties)
                 {
                     if (this.IdentifiersMatch(property, id))
                     {
                         return(true);
                     }
                 }
             }
         }
     }
     return(false);
 }
예제 #26
0
        public override object TranslatePropertyValue(ModelItem item, PropertyIdentifier identifier, object value)
        {
            if (item != null && identifier.DeclaringType.IsAssignableFrom(typeof(FrameworkElement)) && identifier.Name == "Resources")
            {
                var control   = (FrameworkElement)item.View.PlatformObject;
                var resources = (ResourceDictionary)value;

                var theme         = Parameters.Manager.GetTheme(control);
                var accentBrush   = Parameters.Manager.GetAccentBrush(control);
                var contrastBrush = Parameters.Manager.GetContrastBrush(control);

                if (theme == null && accentBrush == null && contrastBrush == null)
                {
                    Elysium.Manager.RemoveCore(resources);
                }
                else
                {
                    Theme           controlTheme;
                    SolidColorBrush controlAcentBrush;
                    SolidColorBrush controlContrastBrush;

                    Elysium.Manager.ApplyCore(
                        resources,
                        theme ?? (control.TryGetTheme(out controlTheme) ? (Theme?)controlTheme : Elysium.Manager.DefaultTheme),
                        accentBrush ?? (control.TryGetAccentBrush(out controlAcentBrush) ? controlAcentBrush : Elysium.Manager.DefaultAccentBrush),
                        contrastBrush ?? (control.TryGetContrastBrush(out controlContrastBrush) ? controlContrastBrush : Elysium.Manager.DefaultContrastBrush));
                }
                return(resources);
            }

            return(base.TranslatePropertyValue(item, identifier, value));
        }
        protected override ModelProperty Find(PropertyIdentifier value, bool throwOnError)
        {
            ModelProperty modelProperty = this.Find(value.Name, false);

            if (modelProperty != (ModelProperty)null)
            {
                return(modelProperty);
            }
            Type type1 = value.DeclaringType;

            if (type1 == (Type)null)
            {
                type1 = this.sceneNode.ViewModel.ExtensibilityManager.ResolveType(value.DeclaringTypeIdentifier);
            }
            if (!type1.IsAssignableFrom(this.sceneNode.TargetType))
            {
                IType type2 = this.sceneNode.ProjectContext.GetType(type1);
                if (type2 != null)
                {
                    IProperty property = type2.GetMember(MemberType.AttachedProperty | MemberType.DependencyProperty, value.Name, MemberAccessTypes.All) as IProperty;
                    if (property != null)
                    {
                        return((ModelProperty) new SceneNodeModelProperty(this.sceneNode.ModelItem, property));
                    }
                }
            }
            if (throwOnError)
            {
                throw new ArgumentException(string.Format((IFormatProvider)CultureInfo.CurrentCulture, StringTable.ExtensibilityPropertyNotFoundException, new object[1]
                {
                    (object)value.Name
                }));
            }
            return((ModelProperty)null);
        }
예제 #28
0
 public WritePropertyRequest(ObjectId objectIdentifier, PropertyIdentifier propertyIdentifier, Option<uint> propertyArrayIndex, GenericValue propertyValue, Option<byte> priority)
 {
     this.ObjectIdentifier = objectIdentifier;
     this.PropertyIdentifier = propertyIdentifier;
     this.PropertyArrayIndex = propertyArrayIndex;
     this.PropertyValue = propertyValue;
     this.Priority = priority;
 }
예제 #29
0
 public ReadPropertyAck(ObjectIdentifier eventObjectIdentifier, PropertyIdentifier propertyIdentifier,
                        UnsignedInteger propertyArrayIndex, Encodable value)
 {
     EventObjectIdentifier = eventObjectIdentifier;
     PropertyIdentifier    = propertyIdentifier;
     PropertyArrayIndex    = propertyArrayIndex;
     Value = value;
 }
예제 #30
0
 public PropertyValue(PropertyIdentifier propertyIdentifier, UnsignedInteger propertyArrayIndex, Encodable value,
                      UnsignedInteger priority)
 {
     this.PropertyIdentifier = propertyIdentifier;
     this.PropertyArrayIndex = propertyArrayIndex;
     this.Value    = value;
     this.Priority = priority;
 }
예제 #31
0
        public void ToString_Returns_NotEmptyString()
        {
            var from             = new PropertyIdentifier("from");
            var to               = new PropertyIdentifier("to");
            var propertyRelation = new PropertyRelation(from, to);

            Assert.False(string.IsNullOrEmpty(propertyRelation.ToString()));
        }
예제 #32
0
 public WritePropertyRequest(ObjectId objectIdentifier, PropertyIdentifier propertyIdentifier, Option <uint> propertyArrayIndex, GenericValue propertyValue, Option <byte> priority)
 {
     this.ObjectIdentifier   = objectIdentifier;
     this.PropertyIdentifier = propertyIdentifier;
     this.PropertyArrayIndex = propertyArrayIndex;
     this.PropertyValue      = propertyValue;
     this.Priority           = priority;
 }
예제 #33
0
 protected void InvalidateProperty(ModelItem item, PropertyIdentifier property)
 {
     if (item == null)
     {
         throw new ArgumentNullException("item");
     }
     item.Context.Services.GetRequiredService <ValueTranslationService>().InvalidateProperty(item, property);
 }
예제 #34
0
 public DeviceObjectPropertyValue(ObjectId deviceIdentifier, ObjectId objectIdentifier, PropertyIdentifier propertyIdentifier, Option<uint> arrayIndex, GenericValue value)
 {
     this.DeviceIdentifier = deviceIdentifier;
     this.ObjectIdentifier = objectIdentifier;
     this.PropertyIdentifier = propertyIdentifier;
     this.ArrayIndex = arrayIndex;
     this.Value = value;
 }
        private static bool IsIdentifierEmpty(PropertyIdentifier identifier)
        {
#if SILVERLIGHT
            return(identifier.IsEmpty);
#else
            return(String.IsNullOrEmpty(identifier.Name));
#endif
        }
예제 #36
0
 public DeviceObjectPropertyReference(ObjectIdentifier objectIdentifier, PropertyIdentifier propertyIdentifier,
                                      UnsignedInteger propertyArrayIndex, ObjectIdentifier deviceIdentifier)
 {
     ObjectIdentifier   = objectIdentifier;
     PropertyIdentifier = propertyIdentifier;
     PropertyArrayIndex = propertyArrayIndex;
     DeviceIdentifier   = deviceIdentifier;
 }
예제 #37
0
 protected static Encodable readOptionalEncodable(ByteStream source, ObjectType objectType,
                                                  PropertyIdentifier propertyIdentifier, int contextId)
 {
     if (readStart(source) != contextId)
     {
         return(null);
     }
     return(readEncodable(source, objectType, propertyIdentifier, null, contextId));
 }
예제 #38
0
        static AccordionItemIsSelectedDesignModeValueProvider()
        {
#if SILVERLIGHT
            _propertyIdentifier = new PropertyIdentifier(typeof(SSWC.AccordionItem), "IsSelected");
#else
            _propertyIdentifier = new PropertyIdentifier(SSWC.AccordionItem.IsSelectedProperty);
#endif
            Identifiers.Add(typeof(SSWC.AccordionItem), _propertyIdentifier);
        }
예제 #39
0
 public ReadRangeAck(ObjectId objectIdentifier, PropertyIdentifier propertyIdentifier, Option<uint> propertyArrayIndex, ResultFlags resultFlags, uint itemCount, ReadOnlyArray<GenericValue> itemData, Option<uint> firstSequenceNumber)
 {
     this.ObjectIdentifier = objectIdentifier;
     this.PropertyIdentifier = propertyIdentifier;
     this.PropertyArrayIndex = propertyArrayIndex;
     this.ResultFlags = resultFlags;
     this.ItemCount = itemCount;
     this.ItemData = itemData;
     this.FirstSequenceNumber = firstSequenceNumber;
 }
 /// <summary>
 ///     Create a DataTemplate for the given control bound to the given data source property
 /// </summary>
 internal static ModelItem CreateDataTemplate(EditingContext context, TypeIdentifier controlToTemplateTypeId, PropertyIdentifier controlPropertyId, string datasourcePropertyName)
 {
     ModelItem controlToTemplate = ModelFactory.CreateItem(context, controlToTemplateTypeId);
     ModelItem controlBinding = ModelFactory.CreateItem(context, PlatformTypes.Binding.TypeId);
     controlBinding.Properties[PlatformTypes.Binding.PathProperty].SetValue(datasourcePropertyName);
     controlToTemplate.Properties[controlPropertyId].SetValue(controlBinding);
     ModelItem dataTemplate = ModelFactory.CreateItem(context, PlatformTypes.DataTemplate.TypeId);
     dataTemplate.Content.SetValue(controlToTemplate);
     return dataTemplate;
 }
예제 #41
0
 public ActionCommand(Option<ObjectId> deviceIdentifier, ObjectId objectIdentifier, PropertyIdentifier propertyIdentifier, Option<uint> propertyArrayIndex, GenericValue propertyValue, Option<uint> priority, Option<uint> postDelay, bool quitOnFailure, bool writeSuccessful)
 {
     this.DeviceIdentifier = deviceIdentifier;
     this.ObjectIdentifier = objectIdentifier;
     this.PropertyIdentifier = propertyIdentifier;
     this.PropertyArrayIndex = propertyArrayIndex;
     this.PropertyValue = propertyValue;
     this.Priority = priority;
     this.PostDelay = postDelay;
     this.QuitOnFailure = quitOnFailure;
     this.WriteSuccessful = writeSuccessful;
 }
		public override object TranslatePropertyValue(PropertyIdentifier identifier, object value)
		{
			if (identifier.DependencyProperty == PieChart.ItemsSourceProperty)
			{
				List<PieChartDesignModeData> data = new List<PieChartDesignModeData>();
				data.Add(new PieChartDesignModeData { Value = 1 });
				data.Add(new PieChartDesignModeData { Value = 2 });
				data.Add(new PieChartDesignModeData { Value = 5 });

				return data;
			}
			else if (identifier.DependencyProperty == PieChart.IndependentValuePathProperty)
			{
				return "Value";
			}

			return base.TranslatePropertyValue(identifier, value);
		}
        public override object TranslatePropertyValue(ModelItem item, PropertyIdentifier identifier, object value)
        {
            MessageBox.Show($"name: {identifier.Name}\r\n" +
                            $"value: {value}\r\n" +
                            $"type: {value?.GetType()}\r\n" +
                            $"item.View: {item.View}\r\n" +
                            $"item.GetCurrentValue(): {item.GetCurrentValue()}");
            if (identifier.DeclaringType == BackgroundPropertyIdentifier.DeclaringType)
            {
                using (var editingScope = item.BeginEdit())
                {
                    var button = item.GetCurrentValue() as Button;
                    button?.SetValue(Control.BackgroundProperty, value);
                }

                return value;
            }

            return base.TranslatePropertyValue(item, identifier, value);
        }
        /// <summary>
        /// Capture property changes made by the user and return the design time value.
        /// </summary>
        /// <param name="item">The model item for a TabControl.</param>
        /// <param name="identifier">The property that the user is changing the value of.</param>
        /// <param name="value">The new value that the user is giving the property.</param>
        /// <returns>The value to set the property to in the designer.</returns>
        public override object TranslatePropertyValue(ModelItem item, PropertyIdentifier identifier, object value)
        {
            if (identifier == MyPlatformTypes.TabControl.SelectedIndexProperty)
            {
                // if SelectedIndex has been modified from XAML/PB, we use that as the value for selectedIndex
                // otherwise we determine the index of active tabItem and return that as the selected Index   

                // TabControl's DMVP gets called when user changes SelectedIndex from XAML/PB and whenever TabControl gets created/recreated.
                // TabControl gets recreated when its items collection is updated (adding/removing tabs)

                // **************Scenario 1:TabItem is added/removed
                // When a tabItem is added or removed, TabItemAdornerProvider updates the selection for TabItems and we want to retain that selection
                // This is done by updating DesignTimeSelectedIndex value each time selection for Tabitem is updated and we use this value in TabControls DMVP

                // *************Scenario 2:User hasa updated SelectedIndex value from XAML/PB
                // Here we want to use the updated value of SelectedIndex that gets passed into TabControl DMVP
                // To distinguish between the scenario where Tabcontrol is recreated(Scenario 1) and the case where user has simply updated SelectedIndex property value
                // we maintain another DesignerProperty called as CurrentSelectedIndexValueProperty, which stores current value of SelectedIndex that has been serialized
                // We compare CurrentSelectedIndexValueProperty with new value that is passed in to determine whether user has updated SelectedIndex from XAML/PB
                // If this is the case, we should use updated value of SelectedIndex that user has set and update TabItem selection too

                if (GetCurrentSelectedIndexPropertyValue(item) != (int)value)
                {
                    // this is Scenario 2: User has updated SelectedIndex value from XAML/PB
                    SetCurrentSelectedIndexPropertyValue(item, (int)value);
                    if (item.Content.Collection != null && (int)value >= 0 && (int)value < item.Content.Collection.Count)
                    {
                        ModelItem tabItem = item.Content.Collection[(int)value];
                        TabItemDesignModeValueProvider.SetDesignTimeIsSelected(tabItem, true);
                        return value;
                    }
                }

                // If control flows till here, then its Scenario 1: TabItem is added/removed
                int selectedIndex = GetDesignTimeSelectedIndex(item);

                if (selectedIndex != -1)
                {
                    return selectedIndex;
                }
                else if (item.Properties[identifier].IsSet)
                {
                    return value;
                }
                else
                {
                    return 0;
                }
            }

            return base.TranslatePropertyValue(item, identifier, value);
        }
 public override object TranslatePropertyValue(ModelItem item, PropertyIdentifier identifier, object value)
 {
     var modelProperty = item.Properties["Background"];
     modelProperty.SetValue(Colors.HotPink);
     return base.TranslatePropertyValue(item, identifier, value);
 }
예제 #46
0
 public WritePropertyRequest(ObjectId objectIdentifier, PropertyIdentifier propertyIdentifier, Option<uint> propertyArrayIndex, GenericValue propertyValue)
     : this(objectIdentifier, propertyIdentifier, propertyArrayIndex, propertyValue, Option<byte>.None)
 {
 }
예제 #47
0
 public ObjectPropertyReference(ObjectId objectIdentifier, PropertyIdentifier propertyIdentifier, Option<uint> propertyArrayIndex)
 {
     this.ObjectIdentifier = objectIdentifier;
     this.PropertyIdentifier = propertyIdentifier;
     this.PropertyArrayIndex = propertyArrayIndex;
 }
 public ListOfSelectionCriteriaType(PropertyIdentifier propertyIdentifier, Option<uint> propertyArrayIndex, RelationSpecifierType relationSpecifier, GenericValue comparisonValue)
 {
     this.PropertyIdentifier = propertyIdentifier;
     this.PropertyArrayIndex = propertyArrayIndex;
     this.RelationSpecifier = relationSpecifier;
     this.ComparisonValue = comparisonValue;
 }
예제 #49
0
 public PropertyReference(PropertyIdentifier propertyIdentifier, Option<uint> propertyArrayIndex)
 {
     this.PropertyIdentifier = propertyIdentifier;
     this.PropertyArrayIndex = propertyArrayIndex;
 }
예제 #50
0
 public ListOfResultsType(PropertyIdentifier propertyIdentifier, Option<uint> propertyArrayIndex, ReadResultType readResult)
 {
     this.PropertyIdentifier = propertyIdentifier;
     this.PropertyArrayIndex = propertyArrayIndex;
     this.ReadResult = readResult;
 }
예제 #51
0
 public PropertyReference(PropertyIdentifier propertyId)
     : this(propertyId, Option<uint>.None)
 {
 }
예제 #52
0
 /// <summary>
 /// Utility method to invalidate a property.
 /// </summary>
 /// <param name="item">The model item.</param>
 /// <param name="propertyIdentifier">The property to be invalidated.</param>
 internal static void InvalidateProperty(ModelItem item, PropertyIdentifier propertyIdentifier)
 {
     item.Context.Services.GetRequiredService<ValueTranslationService>().InvalidateProperty(item, propertyIdentifier);
 }
예제 #53
0
 public ReadPropertyRequest(ObjectId objectIdentifier, PropertyIdentifier propertyIdentifier, Option<uint> propertyArrayIndex)
 {
     this.ObjectIdentifier = objectIdentifier;
     this.PropertyIdentifier = propertyIdentifier;
     this.PropertyArrayIndex = propertyArrayIndex;
 }
        /// <summary>
        /// Capture property changes made by the user and return the design time value.
        /// </summary>
        /// <param name="item">The ModelItem representing a TabItem.</param>
        /// <param name="identifier">The property that the user is changing the value of. </param>
        /// <param name="value">The new value that the user is giving the property.</param>
        /// <returns>The value to set the property to in the designer.</returns>
        public override object TranslatePropertyValue(ModelItem item, PropertyIdentifier identifier, object value)
        {
            if (identifier == MyPlatformTypes.TabItem.IsSelectedProperty)
            {
                bool isSelected = false;
                isSelected = GetDesignTimeIsSelected(item);

                return isSelected | (bool)value;
            }

            return base.TranslatePropertyValue(item, identifier, value);
        }
 public PropertyIdAttribute(PropertyIdentifier propertyIdentifier)
     : base((ushort)propertyIdentifier)
 {
 }