Наследование: System.Windows.DependencyObject
Пример #1
0
        private UserControl CreateControlByType(InstanceMember instanceMember, Type type)
        {
            UserControl controlToAdd = null;

            if (instanceMember.PreferredDisplayer != null)
            {
                controlToAdd = (UserControl)Activator.CreateInstance(instanceMember.PreferredDisplayer);
            }

            if (controlToAdd == null)
            {
                foreach (var kvp in mTypeDisplayerAssociation)
                {
                    if (kvp.Key(type))
                    {
                        controlToAdd = (UserControl)Activator.CreateInstance(kvp.Value);
                    }
                }
            }

            if(controlToAdd == null && instanceMember.CustomOptions.Count != 0)
            {
                controlToAdd = new ComboBoxDisplay();
            }

            if (controlToAdd == null)
            {
                controlToAdd = new TextBoxDisplay();
            }

            IDataUi display = (IDataUi)controlToAdd;
            display.InstanceMember = instanceMember;

            return controlToAdd;
        }
        bool IsFilePropertyHidden(InstanceMember member)
        {
            ArrowIntentComponentVm owner = member.Instance as ArrowIntentComponentVm;

            bool isFile = owner.GlueItemType == DataTypes.GlueItemType.File ||
                ((owner.GlueItemType == DataTypes.GlueItemType.NamedObject) && owner.IsFileRequirement == DataTypes.CharacteristicRequirement.MustBe);

            return !isFile;

        }
        bool IsHiddenDelegate(InstanceMember member)
        {
            ArrowIntentComponentVm owner = member.Instance as ArrowIntentComponentVm;

            return owner.GlueItemType != DataTypes.GlueItemType.NamedObject;


            //return false;
            //return ((InstanceMember)component).GlueItemType != DataTypes.GlueItemType.NamedObject;
        }
 public bool GetEffectiveIsHidden(InstanceMember instance)
 {
     if (IsHiddenDelegate != null)
     {
         return IsHiddenDelegate(instance);
     }
     else
     {
         return mSetIsHidden;
     }
 }
Пример #5
0
        private void TryCreateCategoryAndInstanceFor(MemberInfo memberInfo)
        {
            if (ShouldCreateUiFor(memberInfo.GetMemberType(), memberInfo.Name))
            {
                
                string categoryName = GetCategoryFor(memberInfo);

                MemberCategory memberCategory = GetOrInstantiateAndAddMemberCategory(categoryName);

                InstanceMember newMember = new InstanceMember(memberInfo.Name, Instance);
                newMember.AfterSetByUi += HandleInstanceMemberSetByUi;
                newMember.BeforeSetByUi += HandleInstanceMemberBeforeSetByUi;
                newMember.Category = memberCategory;
                memberCategory.Members.Add(newMember);
            }
        }
Пример #6
0
        public bool TryGetInstanceMember(string name, out InstanceMember member, out MemberCategory category)
        {
            member = null;
            category = null;

            foreach (var possibleCategory in this.Categories)
            {
                if (member != null)
                {
                    break;
                }
                foreach (var possibleMember in possibleCategory.Members)
                {
                    if (possibleMember.Name == name)
                    {
                        member = possibleMember;
                        category = possibleCategory;
                        break;
                    }
                }
            }
            return member != null;
        }
Пример #7
0
        private void ApplyDisplayPropertyToInstanceMember(InstanceMemberDisplayProperties displayProperties, InstanceMember member, MemberCategory category)
        {
            if (displayProperties.IsHiddenDelegate != null && mMembersWithOptionalVisibility.ContainsKey(member) == false)
            {
                mMembersWithOptionalVisibility.Add(member, displayProperties.IsHiddenDelegate);
            }

            //if (displayProperties.GetEffectiveIsHidden(member.Instance))
            // let's instead just use the hidden property - we will apply functions after
            if (displayProperties.IsHidden)
            {
                category.Members.Remove(member);
            }
            else
            {
                // Put an if-statement for debugging
                if (member.PreferredDisplayer != displayProperties.PreferredDisplayer)
                {
                    member.PreferredDisplayer = displayProperties.PreferredDisplayer;
                }
                member.DisplayName = displayProperties.DisplayName;
                if (!string.IsNullOrEmpty(displayProperties.Category) && category.Name != displayProperties.Category)
                {
                    category.Members.Remove(member);

                    MemberCategory newCategory = GetOrInstantiateAndAddMemberCategory(displayProperties.Category);
                    member.Category = newCategory;
                    newCategory.Members.Add(member);
                }

            }
        }
Пример #8
0
 private MemberCategory GetCategoryIfVisible(InstanceMember instanceMember)
 {
     foreach (var category in Categories)
     {
         if (category.Members.Contains(instanceMember))
         {
             return category;
         }
     }
     return null;
 }
Пример #9
0
        private void UpdateColorCategory(List<MemberCategory> categories)
        {
            var category = categories.FirstOrDefault(item => item.Name == "Rendering");

            if(category != null)
            {
                string redVariableName;
                string greenVariableName;
                string blueVariableName;
                GetRedGreenBlueVarNames(out redVariableName, out greenVariableName, out blueVariableName);

                var redVar = category.Members.FirstOrDefault(item => item.Name == redVariableName);
                var greenVar = category.Members.FirstOrDefault(item => item.Name == greenVariableName);
                var blueVar = category.Members.FirstOrDefault(item => item.Name == blueVariableName);

                if (redVar != null && greenVar != null && blueVar != null)
                {
                    InstanceMember instanceMember = new InstanceMember("Color", null);
                    instanceMember.PreferredDisplayer = typeof(Gum.Controls.DataUi.ColorDisplay);
                    instanceMember.CustomGetTypeEvent += (arg) => typeof(Microsoft.Xna.Framework.Color);
                    instanceMember.CustomGetEvent += GetCurrentColor;
                    instanceMember.CustomSetEvent += SetCurrentColor;

                    // so color updates
                    redVar.PropertyChanged += delegate
                    { 
                        instanceMember.SimulateValueChanged();
                    };
                    greenVar.PropertyChanged += delegate { instanceMember.SimulateValueChanged(); };
                    blueVar.PropertyChanged += delegate { instanceMember.SimulateValueChanged(); };

                    category.Members.Add(instanceMember);

                }
            }
        }