Example #1
0
        public ResourceElementVM(ResourceElementOptions options, ModuleDef ownerModule, bool canDeserialize)
        {
            this.origOptions    = options;
            this.canDeserialize = canDeserialize;

            this.booleanVM             = new BooleanVM(a => HasErrorUpdated());
            this.charVM                = new CharVM(a => HasErrorUpdated());
            this.byteVM                = new ByteVM(a => HasErrorUpdated());
            this.sbyteVM               = new SByteVM(a => HasErrorUpdated());
            this.int16VM               = new Int16VM(a => HasErrorUpdated());
            this.uint16VM              = new UInt16VM(a => HasErrorUpdated());
            this.int32VM               = new Int32VM(a => HasErrorUpdated());
            this.uint32VM              = new UInt32VM(a => HasErrorUpdated());
            this.int64VM               = new Int64VM(a => HasErrorUpdated());
            this.uint64VM              = new UInt64VM(a => HasErrorUpdated());
            this.singleVM              = new SingleVM(a => HasErrorUpdated());
            this.doubleVM              = new DoubleVM(a => HasErrorUpdated());
            this.decimalVM             = new DecimalVM(a => HasErrorUpdated());
            this.dateTimeVM            = new DateTimeVM(a => HasErrorUpdated());
            this.timeSpanVM            = new TimeSpanVM(a => HasErrorUpdated());
            this.userTypeVM            = new UserTypeVM(ownerModule, canDeserialize);
            this.resourceElementTypeVM = new EnumListVM(resourceElementTypeList, (a, b) => OnResourceElementTypeChanged());

            this.UserTypeVM.PropertyChanged += (s, e) => {
                if (e.PropertyName == "HasError")
                {
                    HasErrorUpdated();
                }
            };

            Reinitialize();
        }
Example #2
0
        public ResourceElementVM(ResourceElementOptions options, ModuleDef ownerModule, bool canDeserialize)
        {
            origOptions         = options;
            this.canDeserialize = canDeserialize;

            BooleanVM             = new BooleanVM(a => HasErrorUpdated());
            CharVM                = new CharVM(a => HasErrorUpdated());
            ByteVM                = new ByteVM(a => HasErrorUpdated());
            SByteVM               = new SByteVM(a => HasErrorUpdated());
            Int16VM               = new Int16VM(a => HasErrorUpdated());
            UInt16VM              = new UInt16VM(a => HasErrorUpdated());
            Int32VM               = new Int32VM(a => HasErrorUpdated());
            UInt32VM              = new UInt32VM(a => HasErrorUpdated());
            Int64VM               = new Int64VM(a => HasErrorUpdated());
            UInt64VM              = new UInt64VM(a => HasErrorUpdated());
            SingleVM              = new SingleVM(a => HasErrorUpdated());
            DoubleVM              = new DoubleVM(a => HasErrorUpdated());
            DecimalVM             = new DecimalVM(a => HasErrorUpdated());
            DateTimeVM            = new DateTimeVM(a => HasErrorUpdated());
            TimeSpanVM            = new TimeSpanVM(a => HasErrorUpdated());
            UserTypeVM            = new UserTypeVM(ownerModule, canDeserialize);
            ResourceElementTypeVM = new EnumListVM(resourceElementTypeList, (a, b) => OnResourceElementTypeChanged());

            UserTypeVM.PropertyChanged += (s, e) => {
                if (e.PropertyName == nameof(UserTypeVM.HasError))
                {
                    HasErrorUpdated();
                }
            };

            Reinitialize();
        }
Example #3
0
        void InitializeFrom(ResourceElementOptions options)
        {
            this.Name = options.Name;
            var code    = Convert(options.ResourceData.Code);
            var builtin = options.ResourceData as BuiltInResourceData;

            this.ResourceElementTypeVM.SelectedItem = code;
            switch (code)
            {
            case ResourceElementType.Null:          break;

            case ResourceElementType.String:        String = (string)builtin.Data; break;

            case ResourceElementType.Boolean:       BooleanVM.Value = (bool)builtin.Data; break;

            case ResourceElementType.Char:          CharVM.Value = (char)builtin.Data; break;

            case ResourceElementType.Byte:          ByteVM.Value = (byte)builtin.Data; break;

            case ResourceElementType.SByte:         SByteVM.Value = (sbyte)builtin.Data; break;

            case ResourceElementType.Int16:         Int16VM.Value = (short)builtin.Data; break;

            case ResourceElementType.UInt16:        UInt16VM.Value = (ushort)builtin.Data; break;

            case ResourceElementType.Int32:         Int32VM.Value = (int)builtin.Data; break;

            case ResourceElementType.UInt32:        UInt32VM.Value = (uint)builtin.Data; break;

            case ResourceElementType.Int64:         Int64VM.Value = (long)builtin.Data; break;

            case ResourceElementType.UInt64:        UInt64VM.Value = (ulong)builtin.Data; break;

            case ResourceElementType.Single:        SingleVM.Value = (float)builtin.Data; break;

            case ResourceElementType.Double:        DoubleVM.Value = (double)builtin.Data; break;

            case ResourceElementType.Decimal:       DecimalVM.Value = (decimal)builtin.Data; break;

            case ResourceElementType.DateTime:      DateTimeVM.Value = (DateTime)builtin.Data; break;

            case ResourceElementType.TimeSpan:      TimeSpanVM.Value = (TimeSpan)builtin.Data; break;

            case ResourceElementType.ByteArray:     Data = (byte[])builtin.Data; break;

            case ResourceElementType.Stream:        Data = (byte[])builtin.Data; break;

            case ResourceElementType.SerializedType:
                var binRes = (BinaryResourceData)options.ResourceData;
                UserTypeVM.TypeFullName = binRes.TypeName;
                UserTypeVM.SetData(binRes.Data);
                break;

            default: throw new InvalidOperationException();
            }
        }
Example #4
0
        public ResourceElementVM(ResourceElementOptions options, ModuleDef ownerModule, bool canDeserialize)
        {
            this.origOptions = options;
            this.canDeserialize = canDeserialize;

            this.booleanVM = new BooleanVM(a => HasErrorUpdated());
            this.charVM = new CharVM(a => HasErrorUpdated());
            this.byteVM = new ByteVM(a => HasErrorUpdated());
            this.sbyteVM = new SByteVM(a => HasErrorUpdated());
            this.int16VM = new Int16VM(a => HasErrorUpdated());
            this.uint16VM = new UInt16VM(a => HasErrorUpdated());
            this.int32VM = new Int32VM(a => HasErrorUpdated());
            this.uint32VM = new UInt32VM(a => HasErrorUpdated());
            this.int64VM = new Int64VM(a => HasErrorUpdated());
            this.uint64VM = new UInt64VM(a => HasErrorUpdated());
            this.singleVM = new SingleVM(a => HasErrorUpdated());
            this.doubleVM = new DoubleVM(a => HasErrorUpdated());
            this.decimalVM = new DecimalVM(a => HasErrorUpdated());
            this.dateTimeVM = new DateTimeVM(a => HasErrorUpdated());
            this.timeSpanVM = new TimeSpanVM(a => HasErrorUpdated());
            this.userTypeVM = new UserTypeVM(ownerModule, canDeserialize);
            this.resourceElementTypeVM = new EnumListVM(resourceElementTypeList, (a, b) => OnResourceElementTypeChanged());

            this.UserTypeVM.PropertyChanged += (s, e) => {
                if (e.PropertyName == "HasError")
                    HasErrorUpdated();
            };

            Reinitialize();
        }
Example #5
0
        IResourceData CreateResourceData()
        {
            var code = (ResourceElementType)this.ResourceElementTypeVM.SelectedItem;

            switch (code)
            {
            case ResourceElementType.Null:          return(new BuiltInResourceData((ResourceTypeCode)code, null));

            case ResourceElementType.String:        return(new BuiltInResourceData((ResourceTypeCode)code, String));

            case ResourceElementType.Boolean:       return(new BuiltInResourceData((ResourceTypeCode)code, BooleanVM.Value));

            case ResourceElementType.Char:          return(new BuiltInResourceData((ResourceTypeCode)code, CharVM.Value));

            case ResourceElementType.Byte:          return(new BuiltInResourceData((ResourceTypeCode)code, ByteVM.Value));

            case ResourceElementType.SByte:         return(new BuiltInResourceData((ResourceTypeCode)code, SByteVM.Value));

            case ResourceElementType.Int16:         return(new BuiltInResourceData((ResourceTypeCode)code, Int16VM.Value));

            case ResourceElementType.UInt16:        return(new BuiltInResourceData((ResourceTypeCode)code, UInt16VM.Value));

            case ResourceElementType.Int32:         return(new BuiltInResourceData((ResourceTypeCode)code, Int32VM.Value));

            case ResourceElementType.UInt32:        return(new BuiltInResourceData((ResourceTypeCode)code, UInt32VM.Value));

            case ResourceElementType.Int64:         return(new BuiltInResourceData((ResourceTypeCode)code, Int64VM.Value));

            case ResourceElementType.UInt64:        return(new BuiltInResourceData((ResourceTypeCode)code, UInt64VM.Value));

            case ResourceElementType.Single:        return(new BuiltInResourceData((ResourceTypeCode)code, SingleVM.Value));

            case ResourceElementType.Double:        return(new BuiltInResourceData((ResourceTypeCode)code, DoubleVM.Value));

            case ResourceElementType.Decimal:       return(new BuiltInResourceData((ResourceTypeCode)code, DecimalVM.Value));

            case ResourceElementType.DateTime:      return(new BuiltInResourceData((ResourceTypeCode)code, DateTimeVM.Value));

            case ResourceElementType.TimeSpan:      return(new BuiltInResourceData((ResourceTypeCode)code, TimeSpanVM.Value));

            case ResourceElementType.ByteArray: return(new BuiltInResourceData((ResourceTypeCode)code, Data ?? new byte[0]));

            case ResourceElementType.Stream:        return(new BuiltInResourceData((ResourceTypeCode)code, Data ?? new byte[0]));

            case ResourceElementType.SerializedType: return(new BinaryResourceData(new UserResourceType(UserTypeVM.TypeFullName, ResourceTypeCode.UserTypes), UserTypeVM.GetSerializedData()));

            default: throw new InvalidOperationException();
            }
        }
Example #6
0
		public ResourceElementVM(ResourceElementOptions options, ModuleDef ownerModule, bool canDeserialize) {
			origOptions = options;
			this.canDeserialize = canDeserialize;

			BooleanVM = new BooleanVM(a => HasErrorUpdated());
			CharVM = new CharVM(a => HasErrorUpdated());
			ByteVM = new ByteVM(a => HasErrorUpdated());
			SByteVM = new SByteVM(a => HasErrorUpdated());
			Int16VM = new Int16VM(a => HasErrorUpdated());
			UInt16VM = new UInt16VM(a => HasErrorUpdated());
			Int32VM = new Int32VM(a => HasErrorUpdated());
			UInt32VM = new UInt32VM(a => HasErrorUpdated());
			Int64VM = new Int64VM(a => HasErrorUpdated());
			UInt64VM = new UInt64VM(a => HasErrorUpdated());
			SingleVM = new SingleVM(a => HasErrorUpdated());
			DoubleVM = new DoubleVM(a => HasErrorUpdated());
			DecimalVM = new DecimalVM(a => HasErrorUpdated());
			DateTimeVM = new DateTimeVM(a => HasErrorUpdated());
			TimeSpanVM = new TimeSpanVM(a => HasErrorUpdated());
			UserTypeVM = new UserTypeVM(ownerModule, canDeserialize);
			ResourceElementTypeVM = new EnumListVM(resourceElementTypeList, (a, b) => OnResourceElementTypeChanged());

			UserTypeVM.PropertyChanged += (s, e) => {
				if (e.PropertyName == nameof(UserTypeVM.HasError))
					HasErrorUpdated();
			};

			Reinitialize();
		}