Esempio n. 1
0
 public PEHeadersOptionsVM(Machine defaultMachine, Subsystem defaultSubsystem)
 {
     this.defaultMachine   = defaultMachine;
     this.defaultSubsystem = defaultSubsystem;
     Machine = new EnumListVM(machineList, (a, b) => {
         Characteristics = CharacteristicsHelper.GetCharacteristics(Characteristics ?? 0, (dnlib.PE.Machine)Machine.SelectedItem);
     });
     TimeDateStamp               = new NullableUInt32VM(a => HasErrorUpdated());
     PointerToSymbolTable        = new NullableUInt32VM(a => HasErrorUpdated());
     NumberOfSymbols             = new NullableUInt32VM(a => HasErrorUpdated());
     MajorLinkerVersion          = new NullableByteVM(a => HasErrorUpdated());
     MinorLinkerVersion          = new NullableByteVM(a => HasErrorUpdated());
     ImageBase                   = new NullableUInt64VM(a => HasErrorUpdated());
     SectionAlignment            = new NullableUInt32VM(a => HasErrorUpdated());
     FileAlignment               = new NullableUInt32VM(a => HasErrorUpdated());
     MajorOperatingSystemVersion = new NullableUInt16VM(a => HasErrorUpdated());
     MinorOperatingSystemVersion = new NullableUInt16VM(a => HasErrorUpdated());
     MajorImageVersion           = new NullableUInt16VM(a => HasErrorUpdated());
     MinorImageVersion           = new NullableUInt16VM(a => HasErrorUpdated());
     MajorSubsystemVersion       = new NullableUInt16VM(a => HasErrorUpdated());
     MinorSubsystemVersion       = new NullableUInt16VM(a => HasErrorUpdated());
     Win32VersionValue           = new NullableUInt32VM(a => HasErrorUpdated());
     SizeOfStackReserve          = new NullableUInt64VM(a => HasErrorUpdated());
     SizeOfStackCommit           = new NullableUInt64VM(a => HasErrorUpdated());
     SizeOfHeapReserve           = new NullableUInt64VM(a => HasErrorUpdated());
     SizeOfHeapCommit            = new NullableUInt64VM(a => HasErrorUpdated());
     LoaderFlags                 = new NullableUInt32VM(a => HasErrorUpdated());
     NumberOfRvaAndSizes         = new NullableUInt32VM(a => HasErrorUpdated());
 }
Esempio n. 2
0
        public GenericParamVM(GenericParamOptions options, ModuleDef ownerModule, IDecompilerService decompilerService, TypeDef ownerType, MethodDef ownerMethod)
        {
            this.ownerModule     = ownerModule;
            origOptions          = options;
            Number               = new UInt16VM(a => { OnPropertyChanged(nameof(FullName)); HasErrorUpdated(); });
            TypeDefOrRefAndCAsVM = new TypeDefOrRefAndCAsVM <GenericParamConstraint>(dnSpy_AsmEditor_Resources.EditGenericParameterConstraint, dnSpy_AsmEditor_Resources.CreateGenericParameterConstraint, ownerModule, decompilerService, ownerType, ownerMethod);
            CustomAttributesVM   = new CustomAttributesVM(ownerModule, decompilerService);
            GPVarianceVM         = new EnumListVM(EnumVM.Create(typeof(GPVariance)));

            var typeSigCreatorOptions = new TypeSigCreatorOptions(ownerModule, decompilerService)
            {
                IsLocal = false,
                CanAddGenericTypeVar   = true,
                CanAddGenericMethodVar = false,
                OwnerType   = ownerType,
                OwnerMethod = ownerMethod,
            };

            if (ownerType != null && ownerType.GenericParameters.Count == 0)
            {
                typeSigCreatorOptions.CanAddGenericTypeVar = false;
            }
            if (ownerMethod != null && ownerMethod.GenericParameters.Count > 0)
            {
                typeSigCreatorOptions.CanAddGenericMethodVar = true;
            }
            TypeSigCreator = new TypeSigCreatorVM(typeSigCreatorOptions);

            Reinitialize();
        }
Esempio n. 3
0
        public ExceptionHandlerVM(TypeSigCreatorOptions typeSigCreatorOptions, ExceptionHandlerOptions options)
        {
            this.typeSigCreatorOptions                    = typeSigCreatorOptions.Clone(dnSpy_AsmEditor_Resources.CreateAnExceptionCatchType);
            this.typeSigCreatorOptions.IsLocal            = false;
            this.typeSigCreatorOptions.NullTypeSigAllowed = true;
            origOptions   = options;
            HandlerTypeVM = new EnumListVM(exceptionHandlerTypeList);
            TryStartVM    = new ListVM <InstructionVM>((a, b) => OnSelectionChanged())
            {
                DataErrorInfoDelegate = VerifyInstruction
            };
            TryEndVM = new ListVM <InstructionVM>((a, b) => OnSelectionChanged())
            {
                DataErrorInfoDelegate = VerifyInstruction
            };
            FilterStartVM = new ListVM <InstructionVM>((a, b) => OnSelectionChanged())
            {
                DataErrorInfoDelegate = VerifyInstruction
            };
            HandlerStartVM = new ListVM <InstructionVM>((a, b) => OnSelectionChanged())
            {
                DataErrorInfoDelegate = VerifyInstruction
            };
            HandlerEndVM = new ListVM <InstructionVM>((a, b) => OnSelectionChanged())
            {
                DataErrorInfoDelegate = VerifyInstruction
            };

            Reinitialize();
        }
Esempio n. 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();
        }
Esempio n. 5
0
        public ExceptionHandlerVM(TypeSigCreatorOptions typeSigCreatorOptions, ExceptionHandlerOptions options)
        {
            this.typeSigCreatorOptions                    = typeSigCreatorOptions.Clone("Create an Exception Catch Type");
            this.typeSigCreatorOptions.IsLocal            = false;
            this.typeSigCreatorOptions.NullTypeSigAllowed = true;
            this.origOptions   = options;
            this.handlerTypeVM = new EnumListVM(exceptionHandlerTypeList);
            this.tryStartVM    = new ListVM <InstructionVM>((a, b) => OnSelectionChanged())
            {
                DataErrorInfoDelegate = VerifyInstruction
            };
            this.tryEndVM = new ListVM <InstructionVM>((a, b) => OnSelectionChanged())
            {
                DataErrorInfoDelegate = VerifyInstruction
            };
            this.filterStartVM = new ListVM <InstructionVM>((a, b) => OnSelectionChanged())
            {
                DataErrorInfoDelegate = VerifyInstruction
            };
            this.handlerStartVM = new ListVM <InstructionVM>((a, b) => OnSelectionChanged())
            {
                DataErrorInfoDelegate = VerifyInstruction
            };
            this.handlerEndVM = new ListVM <InstructionVM>((a, b) => OnSelectionChanged())
            {
                DataErrorInfoDelegate = VerifyInstruction
            };

            Reinitialize();
        }
Esempio n. 6
0
        public GenericParamVM(GenericParamOptions options, ModuleDef ownerModule, Language language, TypeDef ownerType, MethodDef ownerMethod)
        {
            this.ownerModule          = ownerModule;
            this.origOptions          = options;
            this.number               = new UInt16VM(a => { OnPropertyChanged("FullName"); HasErrorUpdated(); });
            this.typeDefOrRefAndCAsVM = new TypeDefOrRefAndCAsVM <GenericParamConstraint>("Edit Generic Parameter Constraint", "Create Generic Parameter Constraint", ownerModule, language, ownerType, ownerMethod);
            this.customAttributesVM   = new CustomAttributesVM(ownerModule, language);
            this.gpVarianceVM         = new EnumListVM(EnumVM.Create(typeof(GPVariance)));

            var typeSigCreatorOptions = new TypeSigCreatorOptions(ownerModule, language)
            {
                IsLocal = false,
                CanAddGenericTypeVar   = true,
                CanAddGenericMethodVar = false,
                OwnerType   = ownerType,
                OwnerMethod = ownerMethod,
            };

            if (ownerType != null && ownerType.GenericParameters.Count == 0)
            {
                typeSigCreatorOptions.CanAddGenericTypeVar = false;
            }
            if (ownerMethod != null && ownerMethod.GenericParameters.Count > 0)
            {
                typeSigCreatorOptions.CanAddGenericMethodVar = true;
            }
            this.typeSigCreator = new TypeSigCreatorVM(typeSigCreatorOptions);

            Reinitialize();
        }
Esempio n. 7
0
 public HexEditorAppSettingsVM(HexEditorSettings hexEditorSettings)
 {
     this.hexEditorSettings = hexEditorSettings;
     this.asciiEncodingVM   = new EnumListVM(asciiEncodingList, (a, b) => hexEditorSettings.AsciiEncoding = (AsciiEncoding)AsciiEncodingVM.SelectedItem);
     this.bytesGroupCountVM = new Int32VM(a => { HasErrorUpdated(); hexEditorSettings.BytesGroupCount = BytesGroupCountVM.Value; });
     this.bytesPerLineVM    = new Int32VM(a => { HasErrorUpdated(); hexEditorSettings.BytesPerLine = BytesPerLineVM.Value; })
     {
         Min = 0,
         Max = HexEditorSettings.MAX_BYTES_PER_LINE,
     };
     AsciiEncodingVM.SelectedItem = hexEditorSettings.AsciiEncoding;
     BytesGroupCountVM.Value      = hexEditorSettings.BytesGroupCount;
     BytesPerLineVM.Value         = hexEditorSettings.BytesPerLine;
     FontFamily = hexEditorSettings.FontFamily;
     Task.Factory.StartNew(() => {
         AppCulture.InitializeCulture();
         return(FontUtils.GetMonospacedFonts());
     })
     .ContinueWith(t => {
         var ex = t.Exception;
         if (!t.IsCanceled && !t.IsFaulted)
         {
             FontFamilies = t.Result;
         }
     }, CancellationToken.None, TaskContinuationOptions.None, TaskScheduler.FromCurrentSynchronizationContext());
 }
        protected GeneralAppSettingsPageBase(CommonEditorOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }
            this.options       = options;
            GroupSizeInBytesVM = new Int32VM(a => { }, useDecimal: true)
            {
                Min = 0, Max = int.MaxValue
            };
            HexOffsetFormatVM = new EnumListVM(hexOffsetFormatList);
            EncodingInfoVM    = new EnumListVM(Encoding.GetEncodings().OrderBy(a => a.DisplayName, StringComparer.CurrentCultureIgnoreCase).Select(a => new EnumVM(a, a.DisplayName)).ToArray());

            EnableHighlightCurrentLine         = options.EnableHighlightCurrentLine;
            HighlightCurrentValue              = options.HighlightCurrentValue;
            HighlightStructureUnderMouseCursor = options.HighlightStructureUnderMouseCursor;
            HighlightActiveColumn              = options.HighlightActiveColumn;
            ValuesLowerCaseHex       = options.ValuesLowerCaseHex;
            OffsetLowerCaseHex       = options.OffsetLowerCaseHex;
            EnableColorization       = options.EnableColorization;
            GroupSizeInBytesVM.Value = options.GroupSizeInBytes;
            HexOffsetFormat          = options.HexOffsetFormat;
            EncodingInfo             = GetEncodingInfo(options.EncodingCodePage) ?? GetEncodingInfo(Encoding.UTF8.CodePage) ?? (EncodingInfo)EncodingInfoVM.Items.FirstOrDefault()?.Value;
        }
Esempio n. 9
0
 public AssemblyOptionsVM(AssemblyOptions options, ModuleDef ownerModule, Language language)
 {
     this.ownerModule     = ownerModule;
     this.origOptions     = options;
     this.hashAlgorithmVM = new EnumListVM(hashAlgorithmList, (a, b) => OnPropertyChanged("AssemblyFullName"));
     this.contentTypeVM   = new EnumListVM(contentTypeList, (a, b) => OnPropertyChanged("AssemblyFullName"));
     this.versionMajor    = new UInt16VM(a => { HasErrorUpdated(); OnPropertyChanged("AssemblyFullName"); })
     {
         UseDecimal = true
     };
     this.versionMinor = new UInt16VM(a => { HasErrorUpdated(); OnPropertyChanged("AssemblyFullName"); })
     {
         UseDecimal = true
     };
     this.versionBuild = new UInt16VM(a => { HasErrorUpdated(); OnPropertyChanged("AssemblyFullName"); })
     {
         UseDecimal = true
     };
     this.versionRevision = new UInt16VM(a => { HasErrorUpdated(); OnPropertyChanged("AssemblyFullName"); })
     {
         UseDecimal = true
     };
     this.publicKey = new HexStringVM(a => { HasErrorUpdated(); OnPropertyChanged("AssemblyFullName"); UpdatePublicKeyFlag(); })
     {
         UpperCaseHex = false
     };
     this.customAttributesVM = new CustomAttributesVM(ownerModule, language);
     this.declSecuritiesVM   = new DeclSecuritiesVM(ownerModule, language, null, null);
     Reinitialize();
 }
Esempio n. 10
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();
        }
Esempio n. 11
0
 static void FixNativeTypeEnum(EnumListVM e, bool canHaveNotInitialized)
 {
     e.Items.RemoveAt(e.GetIndex(dnlib.DotNet.NativeType.NotInitialized));
     if (canHaveNotInitialized)
     {
         e.Items.Insert(0, new EnumVM(dnlib.DotNet.NativeType.NotInitialized, dnSpy_AsmEditor_Resources.MarshalType_EnumNotInitialized));
     }
 }
Esempio n. 12
0
 static void FixNativeTypeEnum(EnumListVM e, bool canHaveNotInitialized)
 {
     e.Items.RemoveAt(e.GetIndex(dnlib.DotNet.NativeType.NotInitialized));
     if (canHaveNotInitialized)
     {
         e.Items.Insert(0, new EnumVM(dnlib.DotNet.NativeType.NotInitialized, NOT_INITIALIZED_ENUM_VALUE));
     }
 }
Esempio n. 13
0
 public CANamedArgumentVM(ModuleDef ownerModule, CANamedArgument namedArg, TypeSigCreatorOptions options)
 {
     this.ownerModule            = ownerModule;
     this.originalNamedArg       = namedArg.Clone();
     this.constantTypeEnumListVM = new EnumListVM(ConstantTypeVM.CreateEnumArray(validTypes), (a, b) => OnConstantTypeChanged());
     this.namedArgTypeEnumListVM = new EnumListVM(EnumVM.Create(typeof(NamedArgType)), (a, b) => OnNamedArgTypeChanged());
     InitializeFrom(namedArg, options);
     this.modified = false;
 }
Esempio n. 14
0
		public MethodBodyVM(MethodBodyOptions options, ModuleDef ownerModule, Language language, TypeDef ownerType, MethodDef ownerMethod) {
			this.origOptions = options;

			this.nativeMethodBodyVM = new MethodBody.NativeMethodBodyVM(options.NativeMethodBodyOptions, false);
			NativeMethodBodyVM.PropertyChanged += (s, e) => HasErrorUpdated();
			this.cilBodyVM = new MethodBody.CilBodyVM(options.CilBodyOptions, ownerModule, language, ownerType, ownerMethod, false);
			CilBodyVM.PropertyChanged += (s, e) => HasErrorUpdated();
			this.methodBodyTypeVM = new EnumListVM(methodBodyTypeList, (a, b) => OnMethodBodyTypeChanged());

			Reinitialize();
		}
Esempio n. 15
0
		public MethodBodyVM(MethodBodyOptions options, ModuleDef ownerModule, IDecompilerService decompilerService, TypeDef ownerType, MethodDef ownerMethod) {
			origOptions = options;

			NativeMethodBodyVM = new MethodBody.NativeMethodBodyVM(options.NativeMethodBodyOptions, false);
			NativeMethodBodyVM.PropertyChanged += (s, e) => HasErrorUpdated();
			CilBodyVM = new MethodBody.CilBodyVM(options.CilBodyOptions, ownerModule, decompilerService, ownerType, ownerMethod, false);
			CilBodyVM.PropertyChanged += (s, e) => HasErrorUpdated();
			MethodBodyTypeVM = new EnumListVM(methodBodyTypeList, (a, b) => OnMethodBodyTypeChanged());

			Reinitialize();
		}
Esempio n. 16
0
        public TypeOptionsVM(TypeDefOptions options, ModuleDef ownerModule, IDecompilerService decompilerService, TypeDef ownerType)
        {
            this.ownerModule = ownerModule;
            var typeSigCreatorOptions = new TypeSigCreatorOptions(ownerModule, decompilerService)
            {
                IsLocal = false,
                CanAddGenericTypeVar   = true,
                CanAddGenericMethodVar = false,
                OwnerType = ownerType,
            };

            if (ownerType != null && ownerType.GenericParameters.Count == 0)
            {
                typeSigCreatorOptions.CanAddGenericTypeVar = false;
            }
            TypeSigCreator = new TypeSigCreatorVM(typeSigCreatorOptions);
            TypeSigCreator.PropertyChanged += typeSigCreator_PropertyChanged;

            CustomAttributesVM = new CustomAttributesVM(ownerModule, decompilerService, ownerType, null);
            DeclSecuritiesVM   = new DeclSecuritiesVM(ownerModule, decompilerService, ownerType, null);
            GenericParamsVM    = new GenericParamsVM(ownerModule, decompilerService, ownerType, null);
            InterfaceImplsVM   = new TypeDefOrRefAndCAsVM <InterfaceImpl>(dnSpy_AsmEditor_Resources.EditInterfaceImpl, dnSpy_AsmEditor_Resources.CreateInterfaceImpl, ownerModule, decompilerService, ownerType, null);

            origOptions   = options;
            IsNestedType  = (options.Attributes & TypeAttributes.VisibilityMask) > TypeAttributes.Public;
            TypeKind      = new EnumListVM(typeKindList, (a, b) => OnTypeKindChanged());
            TypeLayout    = new EnumListVM(typeLayoutList, (a, b) => InitializeTypeKind());
            TypeSemantics = new EnumListVM(typeSemanticsList, (a, b) => InitializeTypeKind());
            PackingSize   = new NullableUInt16VM(a => HasErrorUpdated());
            ClassSize     = new NullableUInt32VM(a => HasErrorUpdated());

            Types.TypeVisibility start, end;
            if (!IsNestedType)
            {
                start = Types.TypeVisibility.NotPublic;
                end   = Types.TypeVisibility.Public;
            }
            else
            {
                start = Types.TypeVisibility.NestedPublic;
                end   = Types.TypeVisibility.NestedFamORAssem;
            }
            for (var t = Types.TypeVisibility.NotPublic; t <= Types.TypeVisibility.NestedFamORAssem; t++)
            {
                if (t < start || t > end)
                {
                    TypeVisibility.Items.RemoveAt(TypeVisibility.GetIndex(t));
                }
            }

            InitializeTypeKind();
            TypeSigCreator.CanAddFnPtr = false;
            Reinitialize();
        }
Esempio n. 17
0
        public MethodBodyVM(MethodBodyOptions options, ModuleDef ownerModule, IDecompilerService decompilerService, TypeDef ownerType, MethodDef ownerMethod)
        {
            origOptions = options;

            NativeMethodBodyVM = new MethodBody.NativeMethodBodyVM(options.NativeMethodBodyOptions, false);
            NativeMethodBodyVM.PropertyChanged += (s, e) => HasErrorUpdated();
            CilBodyVM = new MethodBody.CilBodyVM(options.CilBodyOptions, ownerModule, decompilerService, ownerType, ownerMethod, false);
            CilBodyVM.PropertyChanged += (s, e) => HasErrorUpdated();
            MethodBodyTypeVM           = new EnumListVM(methodBodyTypeList, (a, b) => OnMethodBodyTypeChanged());

            Reinitialize();
        }
Esempio n. 18
0
        public MethodBodyVM(MethodBodyOptions options, ModuleDef ownerModule, Language language, TypeDef ownerType, MethodDef ownerMethod)
        {
            this.origOptions = options;

            this.nativeMethodBodyVM             = new MethodBody.NativeMethodBodyVM(options.NativeMethodBodyOptions);
            NativeMethodBodyVM.PropertyChanged += (s, e) => HasErrorUpdated();
            this.cilBodyVM             = new MethodBody.CilBodyVM(options.CilBodyOptions, ownerModule, language, ownerType, ownerMethod);
            CilBodyVM.PropertyChanged += (s, e) => HasErrorUpdated();
            this.methodBodyTypeVM      = new EnumListVM(methodBodyTypeList, (a, b) => OnMethodBodyTypeChanged());

            Reinitialize();
        }
Esempio n. 19
0
        public ExceptionHandlerVM(TypeSigCreatorOptions typeSigCreatorOptions, ExceptionHandlerOptions options)
        {
            this.typeSigCreatorOptions = typeSigCreatorOptions.Clone("Create an Exception Catch Type");
            this.typeSigCreatorOptions.IsLocal = false;
            this.typeSigCreatorOptions.NullTypeSigAllowed = true;
            this.origOptions = options;
            this.handlerTypeVM = new EnumListVM(exceptionHandlerTypeList);
            this.tryStartVM = new ListVM<InstructionVM>((a, b) => OnSelectionChanged()) { DataErrorInfoDelegate = VerifyInstruction };
            this.tryEndVM = new ListVM<InstructionVM>((a, b) => OnSelectionChanged()) { DataErrorInfoDelegate = VerifyInstruction };
            this.filterStartVM = new ListVM<InstructionVM>((a, b) => OnSelectionChanged()) { DataErrorInfoDelegate = VerifyInstruction };
            this.handlerStartVM = new ListVM<InstructionVM>((a, b) => OnSelectionChanged()) { DataErrorInfoDelegate = VerifyInstruction };
            this.handlerEndVM = new ListVM<InstructionVM>((a, b) => OnSelectionChanged()) { DataErrorInfoDelegate = VerifyInstruction };

            Reinitialize();
        }
Esempio n. 20
0
 public DeclSecurityVM(DeclSecurityOptions options, ModuleDef ownerModule, IDecompilerService decompilerService, TypeDef ownerType, MethodDef ownerMethod)
 {
     this.ownerModule                    = ownerModule;
     this.decompilerService              = decompilerService;
     this.ownerType                      = ownerType;
     this.ownerMethod                    = ownerMethod;
     origOptions                         = options;
     CustomAttributesVM                  = new CustomAttributesVM(ownerModule, decompilerService);
     CustomAttributesVM.PropertyChanged += CustomAttributesVM_PropertyChanged;
     DeclSecVerEnumList                  = new EnumListVM(declSecVerList, (a, b) => OnDeclSecVerChanged());
     SecurityActionEnumList              = new EnumListVM(secActList, (a, b) => OnSecurityActionChanged());
     SecurityAttributesVM                = new SecurityAttributesVM(ownerModule, decompilerService, ownerType, ownerMethod);
     SecurityAttributesVM.Collection.CollectionChanged += SecurityAttributesVM_CollectionChanged;
     Reinitialize();
 }
Esempio n. 21
0
 public DeclSecurityVM(DeclSecurityOptions options, ModuleDef ownerModule, Language language, TypeDef ownerType, MethodDef ownerMethod)
 {
     this.ownerModule                    = ownerModule;
     this.language                       = language;
     this.ownerType                      = ownerType;
     this.ownerMethod                    = ownerMethod;
     this.origOptions                    = options;
     this.customAttributesVM             = new CustomAttributesVM(ownerModule, language);
     CustomAttributesVM.PropertyChanged += CustomAttributesVM_PropertyChanged;
     this.declSecVerEnumListVM           = new EnumListVM(declSecVerList, (a, b) => OnDeclSecVerChanged());
     this.securityActionEnumListVM       = new EnumListVM(secActList, (a, b) => OnSecurityActionChanged());
     this.securityAttributesVM           = new SecurityAttributesVM(ownerModule, language, ownerType, ownerMethod);
     this.SecurityAttributesVM.Collection.CollectionChanged += SecurityAttributesVM_CollectionChanged;
     Reinitialize();
 }
Esempio n. 22
0
 public AssemblyOptionsVM(AssemblyOptions options, ModuleDef ownerModule, IDecompilerService decompilerService)
 {
     this.ownerModule = ownerModule;
     origOptions      = options;
     hashAlgorithmVM  = new EnumListVM(hashAlgorithmList, (a, b) => OnPropertyChanged(nameof(AssemblyFullName)));
     contentTypeVM    = new EnumListVM(contentTypeList, (a, b) => OnPropertyChanged(nameof(AssemblyFullName)));
     VersionMajor     = new UInt16VM(a => { HasErrorUpdated(); OnPropertyChanged(nameof(AssemblyFullName)); }, true);
     VersionMinor     = new UInt16VM(a => { HasErrorUpdated(); OnPropertyChanged(nameof(AssemblyFullName)); }, true);
     VersionBuild     = new UInt16VM(a => { HasErrorUpdated(); OnPropertyChanged(nameof(AssemblyFullName)); }, true);
     VersionRevision  = new UInt16VM(a => { HasErrorUpdated(); OnPropertyChanged(nameof(AssemblyFullName)); }, true);
     PublicKey        = new HexStringVM(a => { HasErrorUpdated(); OnPropertyChanged(nameof(AssemblyFullName)); UpdatePublicKeyFlag(); })
     {
         UpperCaseHex = false
     };
     CustomAttributesVM = new CustomAttributesVM(ownerModule, decompilerService);
     DeclSecuritiesVM   = new DeclSecuritiesVM(ownerModule, decompilerService, null, null);
     Reinitialize();
 }
Esempio n. 23
0
		public LocalSettingsVM(LocalHexSettings options) {
			this.origOptions = options;
			this.BytesGroupCountVM = new NullableInt32VM(a => HasErrorUpdated());
			this.BytesPerLineVM = new NullableInt32VM(a => HasErrorUpdated(), true) {
				Min = 0,
				Max = HexEditorSettings.MAX_BYTES_PER_LINE,
			};
			this.HexOffsetSizeVM = new Int32VM(a => HasErrorUpdated(), true) {
				Min = 0,
				Max = 64,
			};
			this.BaseOffsetVM = new UInt64VM(a => HasErrorUpdated());
			this.StartOffsetVM = new NullableUInt64VM(a => HasErrorUpdated());
			this.EndOffsetVM = new NullableUInt64VM(a => HasErrorUpdated());
			this.AsciiEncodingVM = new EnumListVM(asciiEncodingList);

			Reinitialize();
		}
Esempio n. 24
0
 public MethodSigCreatorVM(MethodSigCreatorOptions options)
 {
     this.options = options.Clone();
     this.title   = options.TypeSigCreatorOptions.Title;
     this.parametersCreateTypeSigArray = new CreateTypeSigArrayVM(options.TypeSigCreatorOptions.Clone(null), null);
     this.ParametersCreateTypeSigArray.TypeSigCollection.CollectionChanged += (s, e) => OnPropertyChanged("SignatureFullName");
     this.sentinelCreateTypeSigArray = new CreateTypeSigArrayVM(options.TypeSigCreatorOptions.Clone(null), null);
     this.SentinelCreateTypeSigArray.TypeSigCollection.CollectionChanged += (s, e) => OnPropertyChanged("SignatureFullName");
     this.sentinelCreateTypeSigArray.IsEnabled = CanHaveSentinel;
     this.genericParameterCount = new UInt32VM(0, a => {
         HasErrorUpdated();
         OnPropertyChanged("SignatureFullName");
         if (GenericParameterCount != null && !GenericParameterCount.HasError)
         {
             IsGeneric = GenericParameterCount.Value != 0;
         }
     })
     {
         Min = ModelUtils.COMPRESSED_UINT32_MIN,
         Max = ModelUtils.COMPRESSED_UINT32_MAX,
     };
     this.methodCallingConvVM = new EnumListVM(methodCallingConvList, (a, b) => {
         if (!IsMethodSig)
         {
             throw new InvalidOperationException();
         }
         CallingConvention = (CallingConvention & ~dnlib.DotNet.CallingConvention.Mask) |
                             (dnlib.DotNet.CallingConvention)(MethodCallingConv) MethodCallingConv.SelectedItem;
     });
     if (!CanHaveSentinel)
     {
         MethodCallingConv.Items.RemoveAt(MethodCallingConv.GetIndex(DnlibDialogs.MethodCallingConv.VarArg));
         MethodCallingConv.Items.RemoveAt(MethodCallingConv.GetIndex(DnlibDialogs.MethodCallingConv.NativeVarArg));
     }
     if (IsMethodSig)
     {
         MethodCallingConv.SelectedItem = DnlibDialogs.MethodCallingConv.Default;
     }
     else
     {
         CallingConvention = (CallingConvention & ~dnlib.DotNet.CallingConvention.Mask) | dnlib.DotNet.CallingConvention.Property;
     }
     ReturnType = options.TypeSigCreatorOptions.OwnerModule.CorLibTypes.Void;
 }
Esempio n. 25
0
 public MarshalTypeVM(ModuleDef ownerModule, IDecompilerService decompilerService, TypeDef ownerType, MethodDef ownerMethod)
 {
     NativeType = new EnumListVM(nativeTypeList, (a, b) => { OnNativeTypeChanged(); TypeStringUpdated(); });
     FixNativeTypeEnum(NativeType, false);
     RawMarshalType_Data              = new HexStringVM(a => { HasErrorUpdated(); TypeStringUpdated(); });
     FixedSysStringMarshalType_Size   = new NullableCompressedUInt32(a => { HasErrorUpdated(); TypeStringUpdated(); });
     SafeArrayMarshalType_VariantType = new EnumListVM(variantTypeList, (a, b) => { OnSafeArrayMarshalTypeIsEnabledChanged(); TypeStringUpdated(); });
     SafeArrayMarshalType_UserDefinedSubType_TypeSigCreator = CreateTypeSigCreatorVM(ownerModule, decompilerService, ownerType, ownerMethod, true, safeArrayMarshalType_userDefinedSubType_typeSigCreator_PropertyChanged);
     FixedArrayMarshalType_Size       = new NullableCompressedUInt32(a => { OnFixedArrayMarshalTypeIsEnabledChanged(); TypeStringUpdated(); });
     FixedArrayMarshalType_NativeType = new EnumListVM(nativeTypeList, (a, b) => { OnFixedArrayMarshalTypeIsEnabledChanged(); TypeStringUpdated(); });
     FixNativeTypeEnum(FixedArrayMarshalType_NativeType, true);
     ArrayMarshalType_NativeType = new EnumListVM(nativeTypeList, (a, b) => { OnArrayMarshalTypeIsEnabledChanged(); TypeStringUpdated(); });
     FixNativeTypeEnum(ArrayMarshalType_NativeType, true);
     ArrayMarshalType_ParamNum = new NullableCompressedUInt32(a => { OnArrayMarshalTypeIsEnabledChanged(); TypeStringUpdated(); });
     ArrayMarshalType_NumElems = new NullableCompressedUInt32(a => { OnArrayMarshalTypeIsEnabledChanged(); TypeStringUpdated(); });
     ArrayMarshalType_Flags    = new NullableCompressedUInt32(a => { OnArrayMarshalTypeIsEnabledChanged(); TypeStringUpdated(); });
     CustomMarshalType_CustMarshaler_TypeSigCreator = CreateTypeSigCreatorVM(ownerModule, decompilerService, ownerType, ownerMethod, true, customMarshalType_custMarshaler_typeSigCreator_PropertyChanged);
     InterfaceMarshalType_IidParamIndex             = new NullableCompressedUInt32(a => { HasErrorUpdated(); TypeStringUpdated(); });
 }
Esempio n. 26
0
 protected AdvancedAppSettingsPageBase(ICommonEditorOptions options)
 {
     this.options                   = options ?? throw new ArgumentNullException(nameof(options));
     BlockStructureLineKindVM       = new EnumListVM(blockStructureLineKindList);
     ReferenceHighlighting          = options.ReferenceHighlighting;
     HighlightRelatedKeywords       = options.HighlightRelatedKeywords;
     HighlightMatchingBrace         = options.BraceMatching;
     LineSeparators                 = options.LineSeparators;
     ShowBlockStructure             = options.ShowBlockStructure;
     BlockStructureLineKind         = options.BlockStructureLineKind;
     CompressEmptyOrWhitespaceLines = options.CompressEmptyOrWhitespaceLines;
     CompressNonLetterLines         = options.CompressNonLetterLines;
     MinimumLineSpacing             = options.RemoveExtraTextLineVerticalPixels;
     SelectionMargin                = options.SelectionMargin;
     GlyphMargin            = options.GlyphMargin;
     MouseWheelZoom         = options.EnableMouseWheelZoom;
     ZoomControl            = options.ZoomControl;
     ForceClearTypeIfNeeded = options.ForceClearTypeIfNeeded;
 }
Esempio n. 27
0
 public MarshalTypeVM(ModuleDef ownerModule, Language language, TypeDef ownerType, MethodDef ownerMethod)
 {
     this.nativeTypeVM = new EnumListVM(nativeTypeList, (a, b) => { OnNativeTypeChanged(); TypeStringUpdated(); });
     FixNativeTypeEnum(this.NativeType, false);
     this.rawMarshalType_data                = new HexStringVM(a => { HasErrorUpdated(); TypeStringUpdated(); });
     this.fixedSysStringMarshalType_size     = new NullableCompressedUInt32(a => { HasErrorUpdated(); TypeStringUpdated(); });
     this.safeArrayMarshalType_variantTypeVM = new EnumListVM(variantTypeList, (a, b) => { OnSafeArrayMarshalTypeIsEnabledChanged(); TypeStringUpdated(); });
     this.safeArrayMarshalType_userDefinedSubType_typeSigCreator = CreateTypeSigCreatorVM(ownerModule, language, ownerType, ownerMethod, true, safeArrayMarshalType_userDefinedSubType_typeSigCreator_PropertyChanged);
     this.fixedArrayMarshalType_size         = new NullableCompressedUInt32(a => { OnFixedArrayMarshalTypeIsEnabledChanged(); TypeStringUpdated(); });
     this.fixedArrayMarshalType_nativeTypeVM = new EnumListVM(nativeTypeList, (a, b) => { OnFixedArrayMarshalTypeIsEnabledChanged(); TypeStringUpdated(); });
     FixNativeTypeEnum(FixedArrayMarshalType_NativeType, true);
     this.arrayMarshalType_nativeTypeVM = new EnumListVM(nativeTypeList, (a, b) => { OnArrayMarshalTypeIsEnabledChanged(); TypeStringUpdated(); });
     FixNativeTypeEnum(ArrayMarshalType_NativeType, true);
     this.arrayMarshalType_paramNum = new NullableCompressedUInt32(a => { OnArrayMarshalTypeIsEnabledChanged(); TypeStringUpdated(); });
     this.arrayMarshalType_numElems = new NullableCompressedUInt32(a => { OnArrayMarshalTypeIsEnabledChanged(); TypeStringUpdated(); });
     this.arrayMarshalType_flags    = new NullableCompressedUInt32(a => { OnArrayMarshalTypeIsEnabledChanged(); TypeStringUpdated(); });
     this.customMarshalType_custMarshaler_typeSigCreator = CreateTypeSigCreatorVM(ownerModule, language, ownerType, ownerMethod, true, customMarshalType_custMarshaler_typeSigCreator_PropertyChanged);
     this.interfaceMarshalType_iidParamIndex             = new NullableCompressedUInt32(a => { HasErrorUpdated(); TypeStringUpdated(); });
 }
Esempio n. 28
0
        public LocalSettingsVM(LocalHexSettings options)
        {
            this.origOptions = options;
            this.bytesGroupCountVM = new NullableInt32VM(a => HasErrorUpdated());
            this.bytesPerLineVM = new NullableInt32VM(a => HasErrorUpdated(), true) {
                Min = 0,
                Max = HexEditorSettings.MAX_BYTES_PER_LINE,
            };
            this.hexOffsetSizeVM = new Int32VM(a => HasErrorUpdated(), true) {
                Min = 0,
                Max = 64,
            };
            this.baseOffsetVM = new UInt64VM(a => HasErrorUpdated());
            this.startOffsetVM = new NullableUInt64VM(a => HasErrorUpdated());
            this.endOffsetVM = new NullableUInt64VM(a => HasErrorUpdated());
            this.asciiEncodingVM = new EnumListVM(asciiEncodingList);

            Reinitialize();
        }
Esempio n. 29
0
        protected AdvancedAppSettingsPageBase(CommonEditorOptions options)
        {
            this.options       = options ?? throw new ArgumentNullException(nameof(options));
            ColumnLine0VM      = new EnumListVM(hexColumnLineKindList);
            ColumnLine1VM      = new EnumListVM(hexColumnLineKindList);
            ColumnGroupLine0VM = new EnumListVM(hexColumnLineKindList);
            ColumnGroupLine1VM = new EnumListVM(hexColumnLineKindList);

            ShowColumnLines = options.ShowColumnLines;
            RemoveExtraTextLineVerticalPixels = options.RemoveExtraTextLineVerticalPixels;
            SelectionMargin      = options.SelectionMargin;
            GlyphMargin          = options.GlyphMargin;
            ZoomControl          = options.ZoomControl;
            EnableMouseWheelZoom = options.EnableMouseWheelZoom;
            ColumnLine0          = options.ColumnLine0;
            ColumnLine1          = options.ColumnLine1;
            ColumnGroupLine0     = options.ColumnGroupLine0;
            ColumnGroupLine1     = options.ColumnGroupLine1;
        }
Esempio n. 30
0
        public HexSettingsVM()
        {
            var task = new Task <FontFamily[]>(FontUtils.GetMonospacedFonts);

            task.Start();
            task.ContinueWith(continuation => {
                App.Current.Dispatcher.Invoke(DispatcherPriority.Normal, (Action)(() => {
                    this.Fonts = task.Result;
                    if (continuation.Exception != null)
                    {
                        foreach (var ex in continuation.Exception.InnerExceptions)
                        {
                            MainWindow.Instance.ShowMessageBox(ex.ToString());
                        }
                    }
                }));
            });
            this.asciiEncodingVM = new EnumListVM(asciiEncodingList);
        }
Esempio n. 31
0
        public SearchControlVM(IImageManager imageManager, IFileSearcherCreator fileSearcherCreator, IFileTreeView fileTreeView, ISearchSettings searchSettings)
        {
            this.imageManager                           = imageManager;
            this.fileSearcherCreator                    = fileSearcherCreator;
            this.fileTreeView                           = fileTreeView;
            this.searchSettings                         = searchSettings;
            this.searchSettings.PropertyChanged        += SearchSettings_PropertyChanged;
            this.delayedSearch                          = new DelayedAction(DEFAULT_DELAY_SEARCH_MS, DelayStartSearch);
            this.searchTypeVMs                          = new ObservableCollection <SearchTypeVM>();
            this.searchResults                          = new ObservableCollection <ISearchResult>();
            this.searchResultsCollectionView            = (ListCollectionView)CollectionViewSource.GetDefaultView(searchResults);
            this.searchResultsCollectionView.CustomSort = new SearchResult_Comparer();
            this.searchLocationVM                       = new EnumListVM(searchLocationList, (a, b) => Restart());
            this.searchLocationVM.SelectedItem          = SearchLocation.AllFiles;

            Add(SearchType.AssemblyDef, dnSpy_Resources.SearchWindow_Assembly, "Assembly", null, VisibleMembersFlags.AssemblyDef);
            Add(SearchType.ModuleDef, dnSpy_Resources.SearchWindow_Module, "AssemblyModule", null, VisibleMembersFlags.ModuleDef);
            Add(SearchType.Namespace, dnSpy_Resources.SearchWindow_Namespace, "Namespace", null, VisibleMembersFlags.Namespace);
            Add(SearchType.TypeDef, dnSpy_Resources.SearchWindow_Type, "Class", dnSpy_Resources.SearchWindow_Type_Key, VisibleMembersFlags.TypeDef);
            Add(SearchType.FieldDef, dnSpy_Resources.SearchWindow_Field, "Field", dnSpy_Resources.SearchWindow_Field_Key, VisibleMembersFlags.FieldDef);
            Add(SearchType.MethodDef, dnSpy_Resources.SearchWindow_Method, "Method", dnSpy_Resources.SearchWindow_Method_Key, VisibleMembersFlags.MethodDef);
            Add(SearchType.PropertyDef, dnSpy_Resources.SearchWindow_Property, "Property", dnSpy_Resources.SearchWindow_Property_Key, VisibleMembersFlags.PropertyDef);
            Add(SearchType.EventDef, dnSpy_Resources.SearchWindow_Event, "Event", dnSpy_Resources.SearchWindow_Event_Key, VisibleMembersFlags.EventDef);
            Add(SearchType.ParamDef, dnSpy_Resources.SearchWindow_Parameter, "Parameter", dnSpy_Resources.SearchWindow_Parameter_Key, VisibleMembersFlags.ParamDef);
            Add(SearchType.Local, dnSpy_Resources.SearchWindow_Local, "Local", dnSpy_Resources.SearchWindow_Local_Key, VisibleMembersFlags.Local);
            Add(SearchType.ParamLocal, dnSpy_Resources.SearchWindow_ParameterLocal, "Parameter", dnSpy_Resources.SearchWindow_ParameterLocal_Key, VisibleMembersFlags.ParamDef | VisibleMembersFlags.Local);
            Add(SearchType.AssemblyRef, dnSpy_Resources.SearchWindow_AssemblyRef, "AssemblyReference", null, VisibleMembersFlags.AssemblyRef);
            Add(SearchType.ModuleRef, dnSpy_Resources.SearchWindow_ModuleRef, "ModuleReference", null, VisibleMembersFlags.ModuleRef);
            Add(SearchType.Resource, dnSpy_Resources.SearchWindow_Resource, "Resource", dnSpy_Resources.SearchWindow_Resource_Key, VisibleMembersFlags.Resource | VisibleMembersFlags.ResourceElement);
            Add(SearchType.GenericTypeDef, dnSpy_Resources.SearchWindow_Generic, "Generic", null, VisibleMembersFlags.GenericTypeDef);
            Add(SearchType.NonGenericTypeDef, dnSpy_Resources.SearchWindow_NonGeneric, "Class", null, VisibleMembersFlags.NonGenericTypeDef);
            Add(SearchType.EnumTypeDef, dnSpy_Resources.SearchWindow_Enum, "Enum", null, VisibleMembersFlags.EnumTypeDef);
            Add(SearchType.InterfaceTypeDef, dnSpy_Resources.SearchWindow_Interface, "Interface", null, VisibleMembersFlags.InterfaceTypeDef);
            Add(SearchType.ClassTypeDef, dnSpy_Resources.SearchWindow_Class, "Class", null, VisibleMembersFlags.ClassTypeDef);
            Add(SearchType.StructTypeDef, dnSpy_Resources.SearchWindow_Struct, "Struct", null, VisibleMembersFlags.StructTypeDef);
            Add(SearchType.DelegateTypeDef, dnSpy_Resources.SearchWindow_Delegate, "Delegate", null, VisibleMembersFlags.DelegateTypeDef);
            Add(SearchType.Member, dnSpy_Resources.SearchWindow_Member, "Property", dnSpy_Resources.SearchWindow_Member_Key, VisibleMembersFlags.MethodDef | VisibleMembersFlags.FieldDef | VisibleMembersFlags.PropertyDef | VisibleMembersFlags.EventDef);
            Add(SearchType.Any, dnSpy_Resources.SearchWindow_AllAbove, "Class", dnSpy_Resources.SearchWindow_AllAbove_Key, VisibleMembersFlags.TreeViewAll | VisibleMembersFlags.ParamDef | VisibleMembersFlags.Local);
            Add(SearchType.Literal, dnSpy_Resources.SearchWindow_Literal, "Literal", dnSpy_Resources.SearchWindow_Literal_Key, VisibleMembersFlags.MethodBody | VisibleMembersFlags.FieldDef | VisibleMembersFlags.ParamDef | VisibleMembersFlags.PropertyDef | VisibleMembersFlags.Resource | VisibleMembersFlags.ResourceElement | VisibleMembersFlags.Attributes);

            this.SelectedSearchTypeVM = SearchTypeVMs.First(a => a.SearchType == SearchType.TypeDef);
        }
Esempio n. 32
0
        public SaveModuleOptionsVM(IDsDocument document)
        {
            this.document      = document;
            Module             = document.ModuleDef;
            PEHeadersOptions   = new PEHeadersOptionsVM(Module.Machine, GetSubsystem(Module.Kind));
            Cor20HeaderOptions = new Cor20HeaderOptionsVM();
            MetaDataOptions    = new MetaDataOptionsVM();

            PEHeadersOptions.PropertyChanged   += (s, e) => HasErrorUpdated();
            Cor20HeaderOptions.PropertyChanged += (s, e) => HasErrorUpdated();
            MetaDataOptions.PropertyChanged    += (s, e) => HasErrorUpdated();

            ModuleKind = new EnumListVM(moduleKindList, (a, b) => {
                OnPropertyChanged(nameof(Extension));
                PEHeadersOptions.Subsystem.SelectedItem = GetSubsystem((dnlib.DotNet.ModuleKind)ModuleKind.SelectedItem);
                PEHeadersOptions.Characteristics        = CharacteristicsHelper.GetCharacteristics(PEHeadersOptions.Characteristics ?? 0, (dnlib.DotNet.ModuleKind)ModuleKind.SelectedItem);
            });

            Reinitialize();
        }
Esempio n. 33
0
        public SearchControlVM(IDocumentSearcherProvider fileSearcherProvider, IDocumentTreeView documentTreeView, ISearchSettings searchSettings)
        {
            this.fileSearcherProvider       = fileSearcherProvider;
            this.documentTreeView           = documentTreeView;
            SearchSettings                  = searchSettings;
            searchSettings.PropertyChanged += SearchSettings_PropertyChanged;
            delayedSearch = new DelayedAction(DEFAULT_DELAY_SEARCH_MS, DelayStartSearch);
            SearchTypeVMs = new ObservableCollection <SearchTypeVM>();
            SearchResults = new ObservableCollection <ISearchResult>();
            searchResultsCollectionView            = (ListCollectionView)CollectionViewSource.GetDefaultView(SearchResults);
            searchResultsCollectionView.CustomSort = new SearchResult_Comparer();
            SearchLocationVM = new EnumListVM(searchLocationList, (a, b) => Restart());
            SearchLocationVM.SelectedItem = SearchLocation.AllFiles;

            Add(SearchType.AssemblyDef, dnSpy_Resources.SearchWindow_Assembly, DsImages.Assembly, null, VisibleMembersFlags.AssemblyDef);
            Add(SearchType.ModuleDef, dnSpy_Resources.SearchWindow_Module, DsImages.ModulePublic, null, VisibleMembersFlags.ModuleDef);
            Add(SearchType.Namespace, dnSpy_Resources.SearchWindow_Namespace, DsImages.Namespace, null, VisibleMembersFlags.Namespace);
            Add(SearchType.TypeDef, dnSpy_Resources.SearchWindow_Type, DsImages.ClassPublic, dnSpy_Resources.SearchWindow_Type_Key, VisibleMembersFlags.TypeDef);
            Add(SearchType.FieldDef, dnSpy_Resources.SearchWindow_Field, DsImages.FieldPublic, dnSpy_Resources.SearchWindow_Field_Key, VisibleMembersFlags.FieldDef);
            Add(SearchType.MethodDef, dnSpy_Resources.SearchWindow_Method, DsImages.MethodPublic, dnSpy_Resources.SearchWindow_Method_Key, VisibleMembersFlags.MethodDef);
            Add(SearchType.PropertyDef, dnSpy_Resources.SearchWindow_Property, DsImages.Property, dnSpy_Resources.SearchWindow_Property_Key, VisibleMembersFlags.PropertyDef);
            Add(SearchType.EventDef, dnSpy_Resources.SearchWindow_Event, DsImages.EventPublic, dnSpy_Resources.SearchWindow_Event_Key, VisibleMembersFlags.EventDef);
            Add(SearchType.ParamDef, dnSpy_Resources.SearchWindow_Parameter, DsImages.Parameter, dnSpy_Resources.SearchWindow_Parameter_Key, VisibleMembersFlags.ParamDef);
            Add(SearchType.Local, dnSpy_Resources.SearchWindow_Local, DsImages.LocalVariable, dnSpy_Resources.SearchWindow_Local_Key, VisibleMembersFlags.Local);
            Add(SearchType.ParamLocal, dnSpy_Resources.SearchWindow_ParameterLocal, DsImages.LocalVariable, dnSpy_Resources.SearchWindow_ParameterLocal_Key, VisibleMembersFlags.ParamDef | VisibleMembersFlags.Local);
            Add(SearchType.AssemblyRef, dnSpy_Resources.SearchWindow_AssemblyRef, DsImages.Reference, null, VisibleMembersFlags.AssemblyRef);
            Add(SearchType.ModuleRef, dnSpy_Resources.SearchWindow_ModuleRef, DsImages.Reference, null, VisibleMembersFlags.ModuleRef);
            Add(SearchType.Resource, dnSpy_Resources.SearchWindow_Resource, DsImages.Dialog, dnSpy_Resources.SearchWindow_Resource_Key, VisibleMembersFlags.Resource | VisibleMembersFlags.ResourceElement);
            Add(SearchType.GenericTypeDef, dnSpy_Resources.SearchWindow_Generic, DsImages.Template, null, VisibleMembersFlags.GenericTypeDef);
            Add(SearchType.NonGenericTypeDef, dnSpy_Resources.SearchWindow_NonGeneric, DsImages.ClassPublic, null, VisibleMembersFlags.NonGenericTypeDef);
            Add(SearchType.EnumTypeDef, dnSpy_Resources.SearchWindow_Enum, DsImages.EnumerationPublic, null, VisibleMembersFlags.EnumTypeDef);
            Add(SearchType.InterfaceTypeDef, dnSpy_Resources.SearchWindow_Interface, DsImages.InterfacePublic, null, VisibleMembersFlags.InterfaceTypeDef);
            Add(SearchType.ClassTypeDef, dnSpy_Resources.SearchWindow_Class, DsImages.ClassPublic, null, VisibleMembersFlags.ClassTypeDef);
            Add(SearchType.StructTypeDef, dnSpy_Resources.SearchWindow_Struct, DsImages.StructurePublic, null, VisibleMembersFlags.StructTypeDef);
            Add(SearchType.DelegateTypeDef, dnSpy_Resources.SearchWindow_Delegate, DsImages.DelegatePublic, null, VisibleMembersFlags.DelegateTypeDef);
            Add(SearchType.Member, dnSpy_Resources.SearchWindow_Member, DsImages.Property, dnSpy_Resources.SearchWindow_Member_Key, VisibleMembersFlags.MethodDef | VisibleMembersFlags.FieldDef | VisibleMembersFlags.PropertyDef | VisibleMembersFlags.EventDef);
            Add(SearchType.Any, dnSpy_Resources.SearchWindow_AllAbove, DsImages.ClassPublic, dnSpy_Resources.SearchWindow_AllAbove_Key, VisibleMembersFlags.TreeViewAll | VisibleMembersFlags.ParamDef | VisibleMembersFlags.Local);
            Add(SearchType.Literal, dnSpy_Resources.SearchWindow_Literal, DsImages.ConstantPublic, dnSpy_Resources.SearchWindow_Literal_Key, VisibleMembersFlags.MethodBody | VisibleMembersFlags.FieldDef | VisibleMembersFlags.ParamDef | VisibleMembersFlags.PropertyDef | VisibleMembersFlags.Resource | VisibleMembersFlags.ResourceElement | VisibleMembersFlags.Attributes);

            SelectedSearchTypeVM = SearchTypeVMs.First(a => a.SearchType == SearchType.Any);
        }
Esempio n. 34
0
        public LocalSettingsVM(LocalGroupOptions options, LocalGroupOptions defaultOptions)
        {
            origOptions         = options;
            this.defaultOptions = defaultOptions;
            BytesPerLineVM      = new Int32VM(a => HasErrorUpdated(), true)
            {
                Min = HexBufferLineFormatterOptions.MinBytesPerLine,
                Max = HexBufferLineFormatterOptions.MaxBytesPerLine,
            };
            OffsetBitSizeVM = new Int32VM(a => HasErrorUpdated(), true)
            {
                Min = HexBufferLineFormatterOptions.MinOffsetBitSize,
                Max = HexBufferLineFormatterOptions.MaxOffsetBitSize,
            };
            BasePositionVM           = new UInt64VM(a => HasErrorUpdated());
            StartPositionVM          = new UInt64VM(a => HasErrorUpdated());
            EndPositionVM            = new UInt64VM(a => HasErrorUpdated());
            HexValuesDisplayFormatVM = new EnumListVM(hexValuesDisplayFormatList);

            Reinitialize();
        }
Esempio n. 35
0
 public ModuleOptionsVM(ModuleDef module, ModuleOptions options, Language language)
 {
     this.module = module;
     this.options = new ModuleOptions();
     this.origOptions = options;
     moduleKindVM = new EnumListVM(SaveModule.SaveModuleOptionsVM.moduleKindList, (a, b) => {
         Characteristics = SaveModule.CharacteristicsHelper.GetCharacteristics(Characteristics, (dnlib.DotNet.ModuleKind)ModuleKind.SelectedItem);
     });
     this.machineVM = new EnumListVM(SaveModule.PEHeadersOptionsVM.machineList, (a, b) => {
         Characteristics = SaveModule.CharacteristicsHelper.GetCharacteristics(Characteristics, (dnlib.PE.Machine)Machine.SelectedItem);
     });
     mvid = new NullableGuidVM(a => HasErrorUpdated());
     encId = new NullableGuidVM(a => HasErrorUpdated());
     encBaseId = new NullableGuidVM(a => HasErrorUpdated());
     clrVersionVM = new EnumListVM(NetModuleOptionsVM.clrVersionList, (a, b) => OnClrVersionChanged());
     clrVersionVM.Items.Add(new EnumVM(Module.ClrVersion.Unknown, "Unknown"));
     clrVersionVM.SelectedItem = Module.ClrVersion.Unknown;
     cor20HeaderRuntimeVersion = new NullableUInt32VM(a => { HasErrorUpdated(); UpdateClrVersion(); });
     tablesHeaderVersion = new NullableUInt16VM(a => { HasErrorUpdated(); UpdateClrVersion(); });
     nativeEntryPointRva = new UInt32VM(a => HasErrorUpdated());
     customAttributesVM = new CustomAttributesVM(module, language);
     Reinitialize();
 }
Esempio n. 36
0
        public GenericParamVM(GenericParamOptions options, ModuleDef ownerModule, Language language, TypeDef ownerType, MethodDef ownerMethod)
        {
            this.ownerModule = ownerModule;
            this.origOptions = options;
            this.number = new UInt16VM(a => { OnPropertyChanged("FullName"); HasErrorUpdated(); });
            this.typeDefOrRefAndCAsVM = new TypeDefOrRefAndCAsVM<GenericParamConstraint>("Edit Generic Parameter Constraint", "Create Generic Parameter Constraint", ownerModule, language, ownerType, ownerMethod);
            this.customAttributesVM = new CustomAttributesVM(ownerModule, language);
            this.gpVarianceVM = new EnumListVM(EnumVM.Create(typeof(GPVariance)));

            var typeSigCreatorOptions = new TypeSigCreatorOptions(ownerModule, language) {
                IsLocal = false,
                CanAddGenericTypeVar = true,
                CanAddGenericMethodVar = false,
                OwnerType = ownerType,
                OwnerMethod = ownerMethod,
            };
            if (ownerType != null && ownerType.GenericParameters.Count == 0)
                typeSigCreatorOptions.CanAddGenericTypeVar = false;
            if (ownerMethod != null && ownerMethod.GenericParameters.Count > 0)
                typeSigCreatorOptions.CanAddGenericMethodVar = true;
            this.typeSigCreator = new TypeSigCreatorVM(typeSigCreatorOptions);

            Reinitialize();
        }
Esempio n. 37
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();
		}
Esempio n. 38
0
		public SearchControlVM(IDocumentSearcherProvider fileSearcherProvider, IDocumentTreeView documentTreeView, ISearchSettings searchSettings) {
			this.fileSearcherProvider = fileSearcherProvider;
			this.documentTreeView = documentTreeView;
			SearchSettings = searchSettings;
			searchSettings.PropertyChanged += SearchSettings_PropertyChanged;
			delayedSearch = new DelayedAction(DEFAULT_DELAY_SEARCH_MS, DelayStartSearch);
			SearchTypeVMs = new ObservableCollection<SearchTypeVM>();
			SearchResults = new ObservableCollection<ISearchResult>();
			searchResultsCollectionView = (ListCollectionView)CollectionViewSource.GetDefaultView(SearchResults);
			searchResultsCollectionView.CustomSort = new SearchResult_Comparer();
			SearchLocationVM = new EnumListVM(searchLocationList, (a, b) => Restart());
			SearchLocationVM.SelectedItem = SearchLocation.AllFiles;

			Add(SearchType.AssemblyDef, dnSpy_Resources.SearchWindow_Assembly, DsImages.Assembly, null, VisibleMembersFlags.AssemblyDef);
			Add(SearchType.ModuleDef, dnSpy_Resources.SearchWindow_Module, DsImages.ModulePublic, null, VisibleMembersFlags.ModuleDef);
			Add(SearchType.Namespace, dnSpy_Resources.SearchWindow_Namespace, DsImages.Namespace, null, VisibleMembersFlags.Namespace);
			Add(SearchType.TypeDef, dnSpy_Resources.SearchWindow_Type, DsImages.ClassPublic, dnSpy_Resources.SearchWindow_Type_Key, VisibleMembersFlags.TypeDef);
			Add(SearchType.FieldDef, dnSpy_Resources.SearchWindow_Field, DsImages.FieldPublic, dnSpy_Resources.SearchWindow_Field_Key, VisibleMembersFlags.FieldDef);
			Add(SearchType.MethodDef, dnSpy_Resources.SearchWindow_Method, DsImages.MethodPublic, dnSpy_Resources.SearchWindow_Method_Key, VisibleMembersFlags.MethodDef);
			Add(SearchType.PropertyDef, dnSpy_Resources.SearchWindow_Property, DsImages.Property, dnSpy_Resources.SearchWindow_Property_Key, VisibleMembersFlags.PropertyDef);
			Add(SearchType.EventDef, dnSpy_Resources.SearchWindow_Event, DsImages.EventPublic, dnSpy_Resources.SearchWindow_Event_Key, VisibleMembersFlags.EventDef);
			Add(SearchType.ParamDef, dnSpy_Resources.SearchWindow_Parameter, DsImages.Parameter, dnSpy_Resources.SearchWindow_Parameter_Key, VisibleMembersFlags.ParamDef);
			Add(SearchType.Local, dnSpy_Resources.SearchWindow_Local, DsImages.LocalVariable, dnSpy_Resources.SearchWindow_Local_Key, VisibleMembersFlags.Local);
			Add(SearchType.ParamLocal, dnSpy_Resources.SearchWindow_ParameterLocal, DsImages.LocalVariable, dnSpy_Resources.SearchWindow_ParameterLocal_Key, VisibleMembersFlags.ParamDef | VisibleMembersFlags.Local);
			Add(SearchType.AssemblyRef, dnSpy_Resources.SearchWindow_AssemblyRef, DsImages.Reference, null, VisibleMembersFlags.AssemblyRef);
			Add(SearchType.ModuleRef, dnSpy_Resources.SearchWindow_ModuleRef, DsImages.Reference, null, VisibleMembersFlags.ModuleRef);
			Add(SearchType.Resource, dnSpy_Resources.SearchWindow_Resource, DsImages.Dialog, dnSpy_Resources.SearchWindow_Resource_Key, VisibleMembersFlags.Resource | VisibleMembersFlags.ResourceElement);
			Add(SearchType.GenericTypeDef, dnSpy_Resources.SearchWindow_Generic, DsImages.Template, null, VisibleMembersFlags.GenericTypeDef);
			Add(SearchType.NonGenericTypeDef, dnSpy_Resources.SearchWindow_NonGeneric, DsImages.ClassPublic, null, VisibleMembersFlags.NonGenericTypeDef);
			Add(SearchType.EnumTypeDef, dnSpy_Resources.SearchWindow_Enum, DsImages.EnumerationPublic, null, VisibleMembersFlags.EnumTypeDef);
			Add(SearchType.InterfaceTypeDef, dnSpy_Resources.SearchWindow_Interface, DsImages.InterfacePublic, null, VisibleMembersFlags.InterfaceTypeDef);
			Add(SearchType.ClassTypeDef, dnSpy_Resources.SearchWindow_Class, DsImages.ClassPublic, null, VisibleMembersFlags.ClassTypeDef);
			Add(SearchType.StructTypeDef, dnSpy_Resources.SearchWindow_Struct, DsImages.StructurePublic, null, VisibleMembersFlags.StructTypeDef);
			Add(SearchType.DelegateTypeDef, dnSpy_Resources.SearchWindow_Delegate, DsImages.DelegatePublic, null, VisibleMembersFlags.DelegateTypeDef);
			Add(SearchType.Member, dnSpy_Resources.SearchWindow_Member, DsImages.Property, dnSpy_Resources.SearchWindow_Member_Key, VisibleMembersFlags.MethodDef | VisibleMembersFlags.FieldDef | VisibleMembersFlags.PropertyDef | VisibleMembersFlags.EventDef);
			Add(SearchType.Any, dnSpy_Resources.SearchWindow_AllAbove, DsImages.ClassPublic, dnSpy_Resources.SearchWindow_AllAbove_Key, VisibleMembersFlags.TreeViewAll | VisibleMembersFlags.ParamDef | VisibleMembersFlags.Local);
			Add(SearchType.Literal, dnSpy_Resources.SearchWindow_Literal, DsImages.ConstantPublic, dnSpy_Resources.SearchWindow_Literal_Key, VisibleMembersFlags.MethodBody | VisibleMembersFlags.FieldDef | VisibleMembersFlags.ParamDef | VisibleMembersFlags.PropertyDef | VisibleMembersFlags.Resource | VisibleMembersFlags.ResourceElement | VisibleMembersFlags.Attributes);

			SelectedSearchTypeVM = SearchTypeVMs.First(a => a.SearchType == SearchType.Any);
		}
Esempio n. 39
0
		public ConstantTypeVM(ModuleDef ownerModule, object value, ConstantType[] validConstants, bool allowNullString, bool arraysCanBeNull, TypeSigCreatorOptions options = null) {
			if (options == null) {
				IList<ConstantType> clist = validConstants;
				if (clist.IndexOf(ConstantType.Type) >= 0 ||
					clist.IndexOf(ConstantType.TypeArray) >= 0 ||
					clist.IndexOf(ConstantType.ObjectArray) >= 0) {
					throw new ArgumentNullException();
				}
			}
			this.arraysCanBeNull = arraysCanBeNull;
			var list = validConstants.Select(a => typeToEnumVM[a]);
			this.constantTypeEnumListVM = new EnumListVM(list, (a, b) => OnConstantChanged());
			this.boolean = new BooleanVM(a => FieldUpdated());
			this.@char = new CharVM(a => FieldUpdated());
			this.@sbyte = new SByteVM(a => FieldUpdated());
			this.@byte = new ByteVM(a => FieldUpdated());
			this.int16 = new Int16VM(a => FieldUpdated());
			this.uint16 = new UInt16VM(a => FieldUpdated());
			this.int32 = new Int32VM(a => FieldUpdated());
			this.uint32 = new UInt32VM(a => FieldUpdated());
			this.int64 = new Int64VM(a => FieldUpdated());
			this.uint64 = new UInt64VM(a => FieldUpdated());
			this.single = new SingleVM(a => FieldUpdated());
			this.@double = new DoubleVM(a => FieldUpdated());
			this.@string = new StringVM(a => FieldUpdated(), allowNullString);
			this.@enum = new EnumDataFieldVM(ownerModule, a => FieldUpdated());
			this.type = new TypeSigVM(a => FieldUpdated(), options);
			this.objectArray = new ObjectListDataFieldVM(ownerModule, a => FieldUpdated(), options);
			this.booleanArray = new BooleanListDataFieldVM(a => FieldUpdated());
			this.charArray = new CharListDataFieldVM(a => FieldUpdated());
			this.sbyteArray = new SByteListDataFieldVM(a => FieldUpdated());
			this.byteArray = new ByteListDataFieldVM(a => FieldUpdated());
			this.int16Array = new Int16ListDataFieldVM(a => FieldUpdated());
			this.uint16Array = new UInt16ListDataFieldVM(a => FieldUpdated());
			this.int32Array = new Int32ListDataFieldVM(a => FieldUpdated());
			this.uint32Array = new UInt32ListDataFieldVM(a => FieldUpdated());
			this.int64Array = new Int64ListDataFieldVM(a => FieldUpdated());
			this.uint64Array = new UInt64ListDataFieldVM(a => FieldUpdated());
			this.singleArray = new SingleListDataFieldVM(a => FieldUpdated());
			this.doubleArray = new DoubleListDataFieldVM(a => FieldUpdated());
			this.stringArray = new StringListDataFieldVM(a => FieldUpdated());
			this.enumArray = new EnumListDataFieldVM(ownerModule, a => FieldUpdated());
			this.typeArray = new TypeSigListDataFieldVM(a => FieldUpdated(), options);
			this.Value = value;
		}
		protected AdvancedAppSettingsPageBase(ICommonEditorOptions options) {
			if (options == null)
				throw new ArgumentNullException(nameof(options));
			this.options = options;
			BlockStructureLineKindVM = new EnumListVM(blockStructureLineKindList);
			ReferenceHighlighting = options.ReferenceHighlighting;
			HighlightRelatedKeywords = options.HighlightRelatedKeywords;
			HighlightMatchingBrace = options.BraceMatching;
			LineSeparators = options.LineSeparators;
			ShowBlockStructure = options.ShowBlockStructure;
			BlockStructureLineKind = options.BlockStructureLineKind;
			CompressEmptyOrWhitespaceLines = options.CompressEmptyOrWhitespaceLines;
			CompressNonLetterLines = options.CompressNonLetterLines;
			MinimumLineSpacing = options.RemoveExtraTextLineVerticalPixels;
			SelectionMargin = options.SelectionMargin;
			GlyphMargin = options.GlyphMargin;
			MouseWheelZoom = options.EnableMouseWheelZoom;
			ZoomControl = options.ZoomControl;
			ForceClearTypeIfNeeded = options.ForceClearTypeIfNeeded;
		}
Esempio n. 41
0
		static void FixNativeTypeEnum(EnumListVM e, bool canHaveNotInitialized) {
			e.Items.RemoveAt(e.GetIndex(dnlib.DotNet.NativeType.NotInitialized));
			if (canHaveNotInitialized)
				e.Items.Insert(0, new EnumVM(dnlib.DotNet.NativeType.NotInitialized, dnSpy_AsmEditor_Resources.MarshalType_EnumNotInitialized));
		}
Esempio n. 42
0
 public HexEditorAppSettingsVM(HexEditorSettings hexEditorSettings)
 {
     this.hexEditorSettings = hexEditorSettings;
     this.asciiEncodingVM = new EnumListVM(asciiEncodingList, (a, b) => hexEditorSettings.AsciiEncoding = (AsciiEncoding)AsciiEncodingVM.SelectedItem);
     this.bytesGroupCountVM = new Int32VM(a => { HasErrorUpdated(); hexEditorSettings.BytesGroupCount = BytesGroupCountVM.Value; });
     this.bytesPerLineVM = new Int32VM(a => { HasErrorUpdated(); hexEditorSettings.BytesPerLine = BytesPerLineVM.Value; }) {
         Min = 0,
         Max = HexEditorSettings.MAX_BYTES_PER_LINE,
     };
     AsciiEncodingVM.SelectedItem = hexEditorSettings.AsciiEncoding;
     BytesGroupCountVM.Value = hexEditorSettings.BytesGroupCount;
     BytesPerLineVM.Value = hexEditorSettings.BytesPerLine;
     FontFamily = hexEditorSettings.FontFamily;
     Task.Factory.StartNew(() => {
         AppCulture.InitializeCulture();
         return FontUtils.GetMonospacedFonts();
     })
     .ContinueWith(t => {
         var ex = t.Exception;
         if (!t.IsCanceled && !t.IsFaulted)
             FontFamilies = t.Result;
     }, CancellationToken.None, TaskContinuationOptions.None, TaskScheduler.FromCurrentSynchronizationContext());
 }
Esempio n. 43
0
		public DeclSecurityVM(DeclSecurityOptions options, ModuleDef ownerModule, IDecompilerService decompilerService, TypeDef ownerType, MethodDef ownerMethod) {
			this.ownerModule = ownerModule;
			this.decompilerService = decompilerService;
			this.ownerType = ownerType;
			this.ownerMethod = ownerMethod;
			origOptions = options;
			CustomAttributesVM = new CustomAttributesVM(ownerModule, decompilerService);
			CustomAttributesVM.PropertyChanged += CustomAttributesVM_PropertyChanged;
			DeclSecVerEnumList = new EnumListVM(declSecVerList, (a, b) => OnDeclSecVerChanged());
			SecurityActionEnumList = new EnumListVM(secActList, (a, b) => OnSecurityActionChanged());
			SecurityAttributesVM = new SecurityAttributesVM(ownerModule, decompilerService, ownerType, ownerMethod);
			SecurityAttributesVM.Collection.CollectionChanged += SecurityAttributesVM_CollectionChanged;
			Reinitialize();
		}
Esempio n. 44
0
		public LocalSettingsVM(LocalGroupOptions options, LocalGroupOptions defaultOptions) {
			origOptions = options;
			this.defaultOptions = defaultOptions;
			BytesPerLineVM = new Int32VM(a => HasErrorUpdated(), true) {
				Min = HexBufferLineProviderOptions.MinBytesPerLine,
				Max = HexBufferLineProviderOptions.MaxBytesPerLine,
			};
			OffsetBitSizeVM = new Int32VM(a => HasErrorUpdated(), true) {
				Min = HexBufferLineProviderOptions.MinOffsetBitSize,
				Max = HexBufferLineProviderOptions.MaxOffsetBitSize,
			};
			BasePositionVM = new UInt64VM(a => HasErrorUpdated());
			StartPositionVM = new UInt64VM(a => HasErrorUpdated());
			EndPositionVM = new UInt64VM(a => HasErrorUpdated());
			HexValuesDisplayFormatVM = new EnumListVM(hexValuesDisplayFormatList);

			Reinitialize();
		}
Esempio n. 45
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();
        }
Esempio n. 46
0
 public DeclSecurityVM(DeclSecurityOptions options, ModuleDef ownerModule, Language language, TypeDef ownerType, MethodDef ownerMethod)
 {
     this.ownerModule = ownerModule;
     this.language = language;
     this.ownerType = ownerType;
     this.ownerMethod = ownerMethod;
     this.origOptions = options;
     this.customAttributesVM = new CustomAttributesVM(ownerModule, language);
     CustomAttributesVM.PropertyChanged += CustomAttributesVM_PropertyChanged;
     this.declSecVerEnumListVM = new EnumListVM(declSecVerList, (a, b) => OnDeclSecVerChanged());
     this.securityActionEnumListVM = new EnumListVM(secActList, (a, b) => OnSecurityActionChanged());
     this.securityAttributesVM = new SecurityAttributesVM(ownerModule, language, ownerType, ownerMethod);
     this.SecurityAttributesVM.Collection.CollectionChanged += SecurityAttributesVM_CollectionChanged;
     Reinitialize();
 }
		protected AdvancedAppSettingsPageBase(CommonEditorOptions options) {
			if (options == null)
				throw new ArgumentNullException(nameof(options));
			this.options = options;
			ColumnLine0VM = new EnumListVM(hexColumnLineKindList);
			ColumnLine1VM = new EnumListVM(hexColumnLineKindList);
			ColumnGroupLine0VM = new EnumListVM(hexColumnLineKindList);
			ColumnGroupLine1VM = new EnumListVM(hexColumnLineKindList);

			ShowColumnLines = options.ShowColumnLines;
			RemoveExtraTextLineVerticalPixels = options.RemoveExtraTextLineVerticalPixels;
			SelectionMargin = options.SelectionMargin;
			GlyphMargin = options.GlyphMargin;
			ZoomControl = options.ZoomControl;
			EnableMouseWheelZoom = options.EnableMouseWheelZoom;
			ColumnLine0 = options.ColumnLine0;
			ColumnLine1 = options.ColumnLine1;
			ColumnGroupLine0 = options.ColumnGroupLine0;
			ColumnGroupLine1 = options.ColumnGroupLine1;
		}
Esempio n. 48
0
 public HexSettingsVM()
 {
     var task = new Task<FontFamily[]>(FontUtils.GetMonospacedFonts);
     task.Start();
     task.ContinueWith(continuation => {
         App.Current.Dispatcher.Invoke(DispatcherPriority.Normal, (Action)(() => {
             this.Fonts = task.Result;
             if (continuation.Exception != null) {
                 foreach (var ex in continuation.Exception.InnerExceptions)
                     MainWindow.Instance.ShowMessageBox(ex.ToString());
             }
         }));
     });
     this.asciiEncodingVM = new EnumListVM(asciiEncodingList);
 }
Esempio n. 49
0
		public SaveModuleOptionsVM(LoadedAssembly asm) {
			this.loadedAssembly = asm;
			this.module = asm.ModuleDefinition;
			this.peHeadersOptions = new PEHeadersOptionsVM(module.Machine, GetSubsystem(module.Kind));
			this.cor20HeaderOptions = new Cor20HeaderOptionsVM();
			this.metaDataOptions = new MetaDataOptionsVM();

			this.peHeadersOptions.PropertyChanged += (s, e) => HasErrorUpdated();
			this.cor20HeaderOptions.PropertyChanged += (s, e) => HasErrorUpdated();
			this.metaDataOptions.PropertyChanged += (s, e) => HasErrorUpdated();

			moduleKindVM = new EnumListVM(moduleKindList, (a, b) => {
				OnPropertyChanged("Extension");
				PEHeadersOptions.Subsystem.SelectedItem = GetSubsystem((dnlib.DotNet.ModuleKind)ModuleKind.SelectedItem);
				PEHeadersOptions.Characteristics = CharacteristicsHelper.GetCharacteristics(PEHeadersOptions.Characteristics ?? 0, (dnlib.DotNet.ModuleKind)ModuleKind.SelectedItem);
			});

			Reinitialize();
		}
Esempio n. 50
0
		public GenericParamVM(GenericParamOptions options, ModuleDef ownerModule, IDecompilerService decompilerService, TypeDef ownerType, MethodDef ownerMethod) {
			this.ownerModule = ownerModule;
			origOptions = options;
			Number = new UInt16VM(a => { OnPropertyChanged(nameof(FullName)); HasErrorUpdated(); });
			TypeDefOrRefAndCAsVM = new TypeDefOrRefAndCAsVM<GenericParamConstraint>(dnSpy_AsmEditor_Resources.EditGenericParameterConstraint, dnSpy_AsmEditor_Resources.CreateGenericParameterConstraint, ownerModule, decompilerService, ownerType, ownerMethod);
			CustomAttributesVM = new CustomAttributesVM(ownerModule, decompilerService);
			GPVarianceVM = new EnumListVM(EnumVM.Create(typeof(GPVariance)));

			var typeSigCreatorOptions = new TypeSigCreatorOptions(ownerModule, decompilerService) {
				IsLocal = false,
				CanAddGenericTypeVar = true,
				CanAddGenericMethodVar = false,
				OwnerType = ownerType,
				OwnerMethod = ownerMethod,
			};
			if (ownerType != null && ownerType.GenericParameters.Count == 0)
				typeSigCreatorOptions.CanAddGenericTypeVar = false;
			if (ownerMethod != null && ownerMethod.GenericParameters.Count > 0)
				typeSigCreatorOptions.CanAddGenericMethodVar = true;
			TypeSigCreator = new TypeSigCreatorVM(typeSigCreatorOptions);

			Reinitialize();
		}
Esempio n. 51
0
		public AppSettingsPageImpl(IBackgroundImageSettingsService backgroundImageSettingsService, IPickFilename pickFilename, IPickDirectory pickDirectory, ImageSettingsInfo[] settings) {
			if (backgroundImageSettingsService == null)
				throw new ArgumentNullException(nameof(backgroundImageSettingsService));
			if (pickFilename == null)
				throw new ArgumentNullException(nameof(pickFilename));
			if (pickDirectory == null)
				throw new ArgumentNullException(nameof(pickDirectory));
			if (settings == null)
				throw new ArgumentNullException(nameof(settings));
			if (settings.Length == 0)
				throw new ArgumentException();
			Debug.Assert(settings.All(a => a.Lazy.Value.UserVisible));
			this.backgroundImageSettingsService = backgroundImageSettingsService;
			this.pickFilename = pickFilename;
			this.pickDirectory = pickDirectory;
			Settings = new ObservableCollection<Settings>(settings.OrderBy(a => a.Lazy.Value.UIOrder).Select(a => new Settings(a)));
			stretchVM = new EnumListVM(EnumVM.Create(false, typeof(Stretch)), (a, b) => currentItem.RawSettings.Stretch = (Stretch)stretchVM.SelectedItem);
			stretchDirectionVM = new EnumListVM(stretchDirectionList, (a, b) => currentItem.RawSettings.StretchDirection = (StretchDirection)stretchDirectionVM.SelectedItem);
			imagePlacementVM = new EnumListVM(imagePlacementList, (a, b) => currentItem.RawSettings.ImagePlacement = (ImagePlacement)imagePlacementVM.SelectedItem);
			opacityVM = new DoubleVM(a => { if (!opacityVM.HasError) currentItem.RawSettings.Opacity = FilterOpacity(opacityVM.Value); });
			horizontalOffsetVM = new DoubleVM(a => { if (!horizontalOffsetVM.HasError) currentItem.RawSettings.HorizontalOffset = FilterOffset(horizontalOffsetVM.Value); });
			verticalOffsetVM = new DoubleVM(a => { if (!verticalOffsetVM.HasError) currentItem.RawSettings.VerticalOffset = FilterOffset(verticalOffsetVM.Value); });
			leftMarginWidthPercentVM = new DoubleVM(a => { if (!leftMarginWidthPercentVM.HasError) currentItem.RawSettings.LeftMarginWidthPercent = FilterMarginPercent(leftMarginWidthPercentVM.Value); });
			rightMarginWidthPercentVM = new DoubleVM(a => { if (!rightMarginWidthPercentVM.HasError) currentItem.RawSettings.RightMarginWidthPercent = FilterMarginPercent(rightMarginWidthPercentVM.Value); });
			topMarginHeightPercentVM = new DoubleVM(a => { if (!topMarginHeightPercentVM.HasError) currentItem.RawSettings.TopMarginHeightPercent = FilterMarginPercent(topMarginHeightPercentVM.Value); });
			bottomMarginHeightPercentVM = new DoubleVM(a => { if (!bottomMarginHeightPercentVM.HasError) currentItem.RawSettings.BottomMarginHeightPercent = FilterMarginPercent(bottomMarginHeightPercentVM.Value); });
			maxHeightVM = new DoubleVM(a => { if (!maxHeightVM.HasError) currentItem.RawSettings.MaxHeight = FilterLength(maxHeightVM.Value); });
			maxWidthVM = new DoubleVM(a => { if (!maxWidthVM.HasError) currentItem.RawSettings.MaxWidth = FilterLength(maxWidthVM.Value); });
			zoomVM = new DoubleVM(a => { if (!zoomVM.HasError) currentItem.RawSettings.Zoom = FilterZoom(zoomVM.Value); });
			intervalVM = new DefaultConverterVM<TimeSpan>(a => { if (!intervalVM.HasError) currentItem.RawSettings.Interval = intervalVM.Value; });
			CurrentItem = Settings.FirstOrDefault(a => a.Id == backgroundImageSettingsService.LastSelectedId) ?? Settings[0];
		}
Esempio n. 52
0
 public AssemblyOptionsVM(AssemblyOptions options, ModuleDef ownerModule, Language language)
 {
     this.ownerModule = ownerModule;
     this.origOptions = options;
     this.hashAlgorithmVM = new EnumListVM(hashAlgorithmList, (a, b) => OnPropertyChanged("AssemblyFullName"));
     this.contentTypeVM = new EnumListVM(contentTypeList, (a, b) => OnPropertyChanged("AssemblyFullName"));
     this.versionMajor = new UInt16VM(a => { HasErrorUpdated(); OnPropertyChanged("AssemblyFullName"); }) { UseDecimal = true };
     this.versionMinor = new UInt16VM(a => { HasErrorUpdated(); OnPropertyChanged("AssemblyFullName"); }) { UseDecimal = true };
     this.versionBuild = new UInt16VM(a => { HasErrorUpdated(); OnPropertyChanged("AssemblyFullName"); }) { UseDecimal = true };
     this.versionRevision = new UInt16VM(a => { HasErrorUpdated(); OnPropertyChanged("AssemblyFullName"); }) { UseDecimal = true };
     this.publicKey = new HexStringVM(a => { HasErrorUpdated(); OnPropertyChanged("AssemblyFullName"); UpdatePublicKeyFlag(); }) { UpperCaseHex = false };
     this.customAttributesVM = new CustomAttributesVM(ownerModule, language);
     this.declSecuritiesVM = new DeclSecuritiesVM(ownerModule, language, null, null);
     Reinitialize();
 }
Esempio n. 53
0
		static void FixNativeTypeEnum(EnumListVM e, bool canHaveNotInitialized) {
			e.Items.RemoveAt(e.GetIndex(dnlib.DotNet.NativeType.NotInitialized));
			if (canHaveNotInitialized)
				e.Items.Insert(0, new EnumVM(dnlib.DotNet.NativeType.NotInitialized, NOT_INITIALIZED_ENUM_VALUE));
		}
Esempio n. 54
0
 public PEHeadersOptionsVM(Machine defaultMachine, Subsystem defaultSubsystem)
 {
     this.defaultMachine = defaultMachine;
     this.defaultSubsystem = defaultSubsystem;
     this.machineVM = new EnumListVM(machineList, (a, b) => {
         Characteristics = CharacteristicsHelper.GetCharacteristics(Characteristics ?? 0, (dnlib.PE.Machine)Machine.SelectedItem);
     });
     this.timeDateStamp = new NullableUInt32VM(a => HasErrorUpdated());
     this.majorLinkerVersion = new NullableByteVM(a => HasErrorUpdated());
     this.minorLinkerVersion = new NullableByteVM(a => HasErrorUpdated());
     this.imageBase = new NullableUInt64VM(a => HasErrorUpdated());
     this.sectionAlignment = new NullableUInt32VM(a => HasErrorUpdated());
     this.fileAlignment = new NullableUInt32VM(a => HasErrorUpdated());
     this.majorOperatingSystemVersion = new NullableUInt16VM(a => HasErrorUpdated());
     this.minorOperatingSystemVersion = new NullableUInt16VM(a => HasErrorUpdated());
     this.majorImageVersion = new NullableUInt16VM(a => HasErrorUpdated());
     this.minorImageVersion = new NullableUInt16VM(a => HasErrorUpdated());
     this.majorSubsystemVersion = new NullableUInt16VM(a => HasErrorUpdated());
     this.minorSubsystemVersion = new NullableUInt16VM(a => HasErrorUpdated());
     this.win32VersionValue = new NullableUInt32VM(a => HasErrorUpdated());
     this.sizeOfStackReserve = new NullableUInt64VM(a => HasErrorUpdated());
     this.sizeOfStackCommit = new NullableUInt64VM(a => HasErrorUpdated());
     this.sizeOfHeapReserve = new NullableUInt64VM(a => HasErrorUpdated());
     this.sizeOfHeapCommit = new NullableUInt64VM(a => HasErrorUpdated());
     this.loaderFlags = new NullableUInt32VM(a => HasErrorUpdated());
     this.numberOfRvaAndSizes = new NullableUInt32VM(a => HasErrorUpdated());
 }
Esempio n. 55
0
		public MarshalTypeVM(ModuleDef ownerModule, IDecompilerService decompilerService, TypeDef ownerType, MethodDef ownerMethod) {
			NativeType = new EnumListVM(nativeTypeList, (a, b) => { OnNativeTypeChanged(); TypeStringUpdated(); });
			FixNativeTypeEnum(NativeType, false);
			RawMarshalType_Data = new HexStringVM(a => { HasErrorUpdated(); TypeStringUpdated(); });
			FixedSysStringMarshalType_Size = new NullableCompressedUInt32(a => { HasErrorUpdated(); TypeStringUpdated(); });
			SafeArrayMarshalType_VariantType = new EnumListVM(variantTypeList, (a, b) => { OnSafeArrayMarshalTypeIsEnabledChanged(); TypeStringUpdated(); });
			SafeArrayMarshalType_UserDefinedSubType_TypeSigCreator = CreateTypeSigCreatorVM(ownerModule, decompilerService, ownerType, ownerMethod, true, safeArrayMarshalType_userDefinedSubType_typeSigCreator_PropertyChanged);
			FixedArrayMarshalType_Size = new NullableCompressedUInt32(a => { OnFixedArrayMarshalTypeIsEnabledChanged(); TypeStringUpdated(); });
			FixedArrayMarshalType_NativeType = new EnumListVM(nativeTypeList, (a, b) => { OnFixedArrayMarshalTypeIsEnabledChanged(); TypeStringUpdated(); });
			FixNativeTypeEnum(FixedArrayMarshalType_NativeType, true);
			ArrayMarshalType_NativeType = new EnumListVM(nativeTypeList, (a, b) => { OnArrayMarshalTypeIsEnabledChanged(); TypeStringUpdated(); });
			FixNativeTypeEnum(ArrayMarshalType_NativeType, true);
			ArrayMarshalType_ParamNum = new NullableCompressedUInt32(a => { OnArrayMarshalTypeIsEnabledChanged(); TypeStringUpdated(); });
			ArrayMarshalType_NumElems = new NullableCompressedUInt32(a => { OnArrayMarshalTypeIsEnabledChanged(); TypeStringUpdated(); });
			ArrayMarshalType_Flags = new NullableCompressedUInt32(a => { OnArrayMarshalTypeIsEnabledChanged(); TypeStringUpdated(); });
			CustomMarshalType_CustMarshaler_TypeSigCreator = CreateTypeSigCreatorVM(ownerModule, decompilerService, ownerType, ownerMethod, true, customMarshalType_custMarshaler_typeSigCreator_PropertyChanged);
			InterfaceMarshalType_IidParamIndex = new NullableCompressedUInt32(a => { HasErrorUpdated(); TypeStringUpdated(); });
		}
Esempio n. 56
0
		public TypeOptionsVM(TypeDefOptions options, ModuleDef ownerModule, IDecompilerService decompilerService, TypeDef ownerType) {
			this.ownerModule = ownerModule;
			var typeSigCreatorOptions = new TypeSigCreatorOptions(ownerModule, decompilerService) {
				IsLocal = false,
				CanAddGenericTypeVar = true,
				CanAddGenericMethodVar = false,
				OwnerType = ownerType,
			};
			if (ownerType != null && ownerType.GenericParameters.Count == 0)
				typeSigCreatorOptions.CanAddGenericTypeVar = false;
			TypeSigCreator = new TypeSigCreatorVM(typeSigCreatorOptions);
			TypeSigCreator.PropertyChanged += typeSigCreator_PropertyChanged;

			CustomAttributesVM = new CustomAttributesVM(ownerModule, decompilerService, ownerType, null);
			DeclSecuritiesVM = new DeclSecuritiesVM(ownerModule, decompilerService, ownerType, null);
			GenericParamsVM = new GenericParamsVM(ownerModule, decompilerService, ownerType, null);
			InterfaceImplsVM = new TypeDefOrRefAndCAsVM<InterfaceImpl>(dnSpy_AsmEditor_Resources.EditInterfaceImpl, dnSpy_AsmEditor_Resources.CreateInterfaceImpl, ownerModule, decompilerService, ownerType, null);

			origOptions = options;
			IsNestedType = (options.Attributes & TypeAttributes.VisibilityMask) > TypeAttributes.Public;
			TypeKind = new EnumListVM(typeKindList, (a, b) => OnTypeKindChanged());
			TypeLayout = new EnumListVM(typeLayoutList, (a, b) => InitializeTypeKind());
			TypeSemantics = new EnumListVM(typeSemanticsList, (a, b) => InitializeTypeKind());
			PackingSize = new NullableUInt16VM(a => HasErrorUpdated());
			ClassSize = new NullableUInt32VM(a => HasErrorUpdated());

			Types.TypeVisibility start, end;
			if (!IsNestedType) {
				start = Types.TypeVisibility.NotPublic;
				end = Types.TypeVisibility.Public;
			}
			else {
				start = Types.TypeVisibility.NestedPublic;
				end = Types.TypeVisibility.NestedFamORAssem;
			}
			for (var t = Types.TypeVisibility.NotPublic; t <= Types.TypeVisibility.NestedFamORAssem; t++) {
				if (t < start || t > end)
					TypeVisibility.Items.RemoveAt(TypeVisibility.GetIndex(t));
			}

			InitializeTypeKind();
			TypeSigCreator.CanAddFnPtr = false;
			Reinitialize();
		}
Esempio n. 57
0
		public MarshalTypeVM(ModuleDef ownerModule, ILanguageManager languageManager, TypeDef ownerType, MethodDef ownerMethod) {
			this.nativeTypeVM = new EnumListVM(nativeTypeList, (a, b) => { OnNativeTypeChanged(); TypeStringUpdated(); });
			FixNativeTypeEnum(this.NativeType, false);
			this.rawMarshalType_data = new HexStringVM(a => { HasErrorUpdated(); TypeStringUpdated(); });
			this.fixedSysStringMarshalType_size = new NullableCompressedUInt32(a => { HasErrorUpdated(); TypeStringUpdated(); });
			this.safeArrayMarshalType_variantTypeVM = new EnumListVM(variantTypeList, (a, b) => { OnSafeArrayMarshalTypeIsEnabledChanged(); TypeStringUpdated(); });
			this.safeArrayMarshalType_userDefinedSubType_typeSigCreator = CreateTypeSigCreatorVM(ownerModule, languageManager, ownerType, ownerMethod, true, safeArrayMarshalType_userDefinedSubType_typeSigCreator_PropertyChanged);
			this.fixedArrayMarshalType_size = new NullableCompressedUInt32(a => { OnFixedArrayMarshalTypeIsEnabledChanged(); TypeStringUpdated(); });
			this.fixedArrayMarshalType_nativeTypeVM = new EnumListVM(nativeTypeList, (a, b) => { OnFixedArrayMarshalTypeIsEnabledChanged(); TypeStringUpdated(); });
			FixNativeTypeEnum(FixedArrayMarshalType_NativeType, true);
			this.arrayMarshalType_nativeTypeVM = new EnumListVM(nativeTypeList, (a, b) => { OnArrayMarshalTypeIsEnabledChanged(); TypeStringUpdated(); });
			FixNativeTypeEnum(ArrayMarshalType_NativeType, true);
			this.arrayMarshalType_paramNum = new NullableCompressedUInt32(a => { OnArrayMarshalTypeIsEnabledChanged(); TypeStringUpdated(); });
			this.arrayMarshalType_numElems = new NullableCompressedUInt32(a => { OnArrayMarshalTypeIsEnabledChanged(); TypeStringUpdated(); });
			this.arrayMarshalType_flags = new NullableCompressedUInt32(a => { OnArrayMarshalTypeIsEnabledChanged(); TypeStringUpdated(); });
			this.customMarshalType_custMarshaler_typeSigCreator = CreateTypeSigCreatorVM(ownerModule, languageManager, ownerType, ownerMethod, true, customMarshalType_custMarshaler_typeSigCreator_PropertyChanged);
			this.interfaceMarshalType_iidParamIndex = new NullableCompressedUInt32(a => { HasErrorUpdated(); TypeStringUpdated(); });
		}
Esempio n. 58
0
		public SearchControlVM(IImageManager imageManager, IFileSearcherCreator fileSearcherCreator, IFileTreeView fileTreeView, ISearchSettings searchSettings) {
			this.imageManager = imageManager;
			this.fileSearcherCreator = fileSearcherCreator;
			this.fileTreeView = fileTreeView;
			this.searchSettings = searchSettings;
			this.searchSettings.PropertyChanged += SearchSettings_PropertyChanged;
			this.delayedSearch = new DelayedAction(DEFAULT_DELAY_SEARCH_MS, DelayStartSearch);
			this.searchTypeVMs = new ObservableCollection<SearchTypeVM>();
			this.searchResults = new ObservableCollection<ISearchResult>();
			this.searchResultsCollectionView = (ListCollectionView)CollectionViewSource.GetDefaultView(searchResults);
			this.searchResultsCollectionView.CustomSort = new SearchResult_Comparer();
			this.searchLocationVM = new EnumListVM(searchLocationList, (a, b) => Restart());
			this.searchLocationVM.SelectedItem = SearchLocation.AllFiles;

			Add(SearchType.AssemblyDef, dnSpy_Resources.SearchWindow_Assembly, "Assembly", null, VisibleMembersFlags.AssemblyDef);
			Add(SearchType.ModuleDef, dnSpy_Resources.SearchWindow_Module, "AssemblyModule", null, VisibleMembersFlags.ModuleDef);
			Add(SearchType.Namespace, dnSpy_Resources.SearchWindow_Namespace, "Namespace", null, VisibleMembersFlags.Namespace);
			Add(SearchType.TypeDef, dnSpy_Resources.SearchWindow_Type, "Class", dnSpy_Resources.SearchWindow_Type_Key, VisibleMembersFlags.TypeDef);
			Add(SearchType.FieldDef, dnSpy_Resources.SearchWindow_Field, "Field", dnSpy_Resources.SearchWindow_Field_Key, VisibleMembersFlags.FieldDef);
			Add(SearchType.MethodDef, dnSpy_Resources.SearchWindow_Method, "Method", dnSpy_Resources.SearchWindow_Method_Key, VisibleMembersFlags.MethodDef);
			Add(SearchType.PropertyDef, dnSpy_Resources.SearchWindow_Property, "Property", dnSpy_Resources.SearchWindow_Property_Key, VisibleMembersFlags.PropertyDef);
			Add(SearchType.EventDef, dnSpy_Resources.SearchWindow_Event, "Event", dnSpy_Resources.SearchWindow_Event_Key, VisibleMembersFlags.EventDef);
			Add(SearchType.ParamDef, dnSpy_Resources.SearchWindow_Parameter, "Parameter", dnSpy_Resources.SearchWindow_Parameter_Key, VisibleMembersFlags.ParamDef);
			Add(SearchType.Local, dnSpy_Resources.SearchWindow_Local, "Local", dnSpy_Resources.SearchWindow_Local_Key, VisibleMembersFlags.Local);
			Add(SearchType.ParamLocal, dnSpy_Resources.SearchWindow_ParameterLocal, "Parameter", dnSpy_Resources.SearchWindow_ParameterLocal_Key, VisibleMembersFlags.ParamDef | VisibleMembersFlags.Local);
			Add(SearchType.AssemblyRef, dnSpy_Resources.SearchWindow_AssemblyRef, "AssemblyReference", null, VisibleMembersFlags.AssemblyRef);
			Add(SearchType.ModuleRef, dnSpy_Resources.SearchWindow_ModuleRef, "ModuleReference", null, VisibleMembersFlags.ModuleRef);
			Add(SearchType.Resource, dnSpy_Resources.SearchWindow_Resource, "Resource", dnSpy_Resources.SearchWindow_Resource_Key, VisibleMembersFlags.Resource | VisibleMembersFlags.ResourceElement);
			Add(SearchType.GenericTypeDef, dnSpy_Resources.SearchWindow_Generic, "Generic", null, VisibleMembersFlags.GenericTypeDef);
			Add(SearchType.NonGenericTypeDef, dnSpy_Resources.SearchWindow_NonGeneric, "Class", null, VisibleMembersFlags.NonGenericTypeDef);
			Add(SearchType.EnumTypeDef, dnSpy_Resources.SearchWindow_Enum, "Enum", null, VisibleMembersFlags.EnumTypeDef);
			Add(SearchType.InterfaceTypeDef, dnSpy_Resources.SearchWindow_Interface, "Interface", null, VisibleMembersFlags.InterfaceTypeDef);
			Add(SearchType.ClassTypeDef, dnSpy_Resources.SearchWindow_Class, "Class", null, VisibleMembersFlags.ClassTypeDef);
			Add(SearchType.StructTypeDef, dnSpy_Resources.SearchWindow_Struct, "Struct", null, VisibleMembersFlags.StructTypeDef);
			Add(SearchType.DelegateTypeDef, dnSpy_Resources.SearchWindow_Delegate, "Delegate", null, VisibleMembersFlags.DelegateTypeDef);
			Add(SearchType.Member, dnSpy_Resources.SearchWindow_Member, "Property", dnSpy_Resources.SearchWindow_Member_Key, VisibleMembersFlags.MethodDef | VisibleMembersFlags.FieldDef | VisibleMembersFlags.PropertyDef | VisibleMembersFlags.EventDef);
			Add(SearchType.Any, dnSpy_Resources.SearchWindow_AllAbove, "Class", dnSpy_Resources.SearchWindow_AllAbove_Key, VisibleMembersFlags.TreeViewAll | VisibleMembersFlags.ParamDef | VisibleMembersFlags.Local);
			Add(SearchType.Literal, dnSpy_Resources.SearchWindow_Literal, "Literal", dnSpy_Resources.SearchWindow_Literal_Key, VisibleMembersFlags.MethodBody | VisibleMembersFlags.FieldDef | VisibleMembersFlags.ParamDef | VisibleMembersFlags.PropertyDef | VisibleMembersFlags.Resource | VisibleMembersFlags.ResourceElement | VisibleMembersFlags.Attributes);

			this.SelectedSearchTypeVM = SearchTypeVMs.First(a => a.SearchType == SearchType.Any);
		}
Esempio n. 59
0
		public CANamedArgumentVM(ModuleDef ownerModule, CANamedArgument namedArg, TypeSigCreatorOptions options) {
			this.ownerModule = ownerModule;
			originalNamedArg = namedArg.Clone();
			ConstantTypeEnumList = new EnumListVM(ConstantTypeVM.CreateEnumArray(validTypes), (a, b) => OnConstantTypeChanged());
			NamedArgTypeEnumList = new EnumListVM(namedArgTypeEnumList, (a, b) => OnNamedArgTypeChanged());
			InitializeFrom(namedArg, options);
			modified = false;
		}
Esempio n. 60
0
		public ModuleOptionsVM(ModuleDef module, ModuleOptions options, IDecompilerService decompilerService) {
			this.module = module;
			this.options = new ModuleOptions();
			origOptions = options;
			ModuleKind = new EnumListVM(SaveModule.SaveModuleOptionsVM.moduleKindList, (a, b) => {
				Characteristics = SaveModule.CharacteristicsHelper.GetCharacteristics(Characteristics, (dnlib.DotNet.ModuleKind)ModuleKind.SelectedItem);
			});
			Machine = new EnumListVM(SaveModule.PEHeadersOptionsVM.machineList, (a, b) => {
				Characteristics = SaveModule.CharacteristicsHelper.GetCharacteristics(Characteristics, (dnlib.PE.Machine)Machine.SelectedItem);
			});
			Mvid = new NullableGuidVM(a => HasErrorUpdated());
			EncId = new NullableGuidVM(a => HasErrorUpdated());
			EncBaseId = new NullableGuidVM(a => HasErrorUpdated());
			ClrVersion = new EnumListVM(NetModuleOptionsVM.clrVersionList, (a, b) => OnClrVersionChanged());
			ClrVersion.Items.Add(new EnumVM(Module.ClrVersion.Unknown, dnSpy_AsmEditor_Resources.Unknown));
			ClrVersion.SelectedItem = Module.ClrVersion.Unknown;
			Cor20HeaderRuntimeVersion = new NullableUInt32VM(a => { HasErrorUpdated(); UpdateClrVersion(); });
			TablesHeaderVersion = new NullableUInt16VM(a => { HasErrorUpdated(); UpdateClrVersion(); });
			NativeEntryPointRva = new UInt32VM(a => HasErrorUpdated());
			CustomAttributesVM = new CustomAttributesVM(module, decompilerService);
			Reinitialize();
		}