Ejemplo n.º 1
0
        void ShowMenu(object parameter, InstructionOperandVM opvm, MenuCommandFlags flags)
        {
            var ctxMenu = new ContextMenu();

            MenuItem menuItem;

            if ((flags & (MenuCommandFlags.TypeDef | MenuCommandFlags.TypeRef)) != 0)
            {
                ctxMenu.Items.Add(menuItem = new MenuItem()
                {
                    Header  = "_Type...",
                    Command = new RelayCommand(a => AddType(opvm)),
                });
                MainWindow.CreateMenuItemImage(menuItem, typeof(MethodBodyControl).Assembly, "Class", BackgroundType.ContextMenuItem, true);
            }
            if ((flags & MenuCommandFlags.TypeSpec) != 0)
            {
                ctxMenu.Items.Add(menuItem = new MenuItem()
                {
                    Header  = "Type_Spec...",
                    Command = new RelayCommand(a => AddTypeSpec(opvm)),
                });
                MainWindow.CreateMenuItemImage(menuItem, typeof(MethodBodyControl).Assembly, "Generic", BackgroundType.ContextMenuItem, true);
            }
            if ((flags & MenuCommandFlags.MethodDef) != 0)
            {
                ctxMenu.Items.Add(menuItem = new MenuItem()
                {
                    Header  = "_Method...",
                    Command = new RelayCommand(a => AddMethodDef(opvm)),
                });
                MainWindow.CreateMenuItemImage(menuItem, typeof(MethodBodyControl).Assembly, "Method", BackgroundType.ContextMenuItem, true);
            }
            if ((flags & MenuCommandFlags.MethodMemberRef) != 0)
            {
                ctxMenu.Items.Add(new MenuItem()
                {
                    Header  = "M_ethod MemberRef...",
                    Command = new RelayCommand(a => AddMethodMemberRef(opvm)),
                });
            }
            if ((flags & MenuCommandFlags.MethodSpec) != 0)
            {
                ctxMenu.Items.Add(new MenuItem()
                {
                    Header  = "Met_hodSpec...",
                    Command = new RelayCommand(a => AddMethodSpec(opvm)),
                });
            }
            if ((flags & MenuCommandFlags.FieldDef) != 0)
            {
                ctxMenu.Items.Add(menuItem = new MenuItem()
                {
                    Header  = "_Field...",
                    Command = new RelayCommand(a => AddFieldDef(opvm)),
                });
                MainWindow.CreateMenuItemImage(menuItem, typeof(MethodBodyControl).Assembly, "Field", BackgroundType.ContextMenuItem, true);
            }
            if ((flags & MenuCommandFlags.FieldMemberRef) != 0)
            {
                ctxMenu.Items.Add(new MenuItem()
                {
                    Header  = "F_ield MemberRef...",
                    Command = new RelayCommand(a => AddFieldMemberRef(opvm)),
                });
            }

            ctxMenu.Placement       = PlacementMode.Bottom;
            ctxMenu.PlacementTarget = parameter as UIElement;
            ctxMenu.IsOpen          = true;
        }
Ejemplo n.º 2
0
        void ShowMenu(object parameter, InstructionOperandVM opvm, MenuCommandFlags flags)
        {
            var ctxMenu = new ContextMenu();

            ctxMenu.SetResourceReference(DsImage.BackgroundBrushProperty, "ContextMenuRectangleFill");

            MenuItem menuItem;

            if ((flags & (MenuCommandFlags.TypeDef | MenuCommandFlags.TypeRef)) != 0)
            {
                ctxMenu.Items.Add(menuItem = new MenuItem()
                {
                    Header  = dnSpy_AsmEditor_Resources.EditOperand_Type,
                    Command = new RelayCommand(a => AddType(opvm)),
                });
                Add16x16Image(menuItem, DsImages.ClassPublic, true);
            }
            if ((flags & MenuCommandFlags.TypeSpec) != 0)
            {
                ctxMenu.Items.Add(menuItem = new MenuItem()
                {
                    Header  = dnSpy_AsmEditor_Resources.EditOperand_TypeSpec,
                    Command = new RelayCommand(a => AddTypeSpec(opvm)),
                });
                Add16x16Image(menuItem, DsImages.Template, true);
            }
            if ((flags & MenuCommandFlags.MethodDef) != 0)
            {
                ctxMenu.Items.Add(menuItem = new MenuItem()
                {
                    Header  = dnSpy_AsmEditor_Resources.EditOperand_Method,
                    Command = new RelayCommand(a => AddMethodDef(opvm)),
                });
                Add16x16Image(menuItem, DsImages.MethodPublic, true);
            }
            if ((flags & MenuCommandFlags.MethodMemberRef) != 0)
            {
                ctxMenu.Items.Add(new MenuItem()
                {
                    Header  = dnSpy_AsmEditor_Resources.EditOperand_Method_MemberRef,
                    Command = new RelayCommand(a => AddMethodMemberRef(opvm)),
                });
            }
            if ((flags & MenuCommandFlags.MethodSpec) != 0)
            {
                ctxMenu.Items.Add(new MenuItem()
                {
                    Header  = dnSpy_AsmEditor_Resources.EditOperand_MethodSpec,
                    Command = new RelayCommand(a => AddMethodSpec(opvm)),
                });
            }
            if ((flags & MenuCommandFlags.FieldDef) != 0)
            {
                ctxMenu.Items.Add(menuItem = new MenuItem()
                {
                    Header  = dnSpy_AsmEditor_Resources.EditOperand_Field,
                    Command = new RelayCommand(a => AddFieldDef(opvm)),
                });
                Add16x16Image(menuItem, DsImages.FieldPublic, true);
            }
            if ((flags & MenuCommandFlags.FieldMemberRef) != 0)
            {
                ctxMenu.Items.Add(new MenuItem()
                {
                    Header  = dnSpy_AsmEditor_Resources.EditOperand_Field_MemberRef,
                    Command = new RelayCommand(a => AddFieldMemberRef(opvm)),
                });
            }

            ctxMenu.Placement       = PlacementMode.Bottom;
            ctxMenu.PlacementTarget = parameter as UIElement;
            ctxMenu.IsOpen          = true;
        }
Ejemplo n.º 3
0
        void ShowMenu(object parameter, InstructionOperandVM opvm, MenuCommandFlags flags)
        {
            var ctxMenu = new ContextMenu();

            MenuItem menuItem;

            if ((flags & (MenuCommandFlags.TypeDef | MenuCommandFlags.TypeRef)) != 0)
            {
                ctxMenu.Items.Add(menuItem = new MenuItem()
                {
                    Header  = dnSpy_AsmEditor_Resources.EditOperand_Type,
                    Command = new RelayCommand(a => AddType(opvm)),
                });
                Add16x16Image(menuItem, "Class", true, true);
            }
            if ((flags & MenuCommandFlags.TypeSpec) != 0)
            {
                ctxMenu.Items.Add(menuItem = new MenuItem()
                {
                    Header  = dnSpy_AsmEditor_Resources.EditOperand_TypeSpec,
                    Command = new RelayCommand(a => AddTypeSpec(opvm)),
                });
                Add16x16Image(menuItem, "Generic", true, true);
            }
            if ((flags & MenuCommandFlags.MethodDef) != 0)
            {
                ctxMenu.Items.Add(menuItem = new MenuItem()
                {
                    Header  = dnSpy_AsmEditor_Resources.EditOperand_Method,
                    Command = new RelayCommand(a => AddMethodDef(opvm)),
                });
                Add16x16Image(menuItem, "Method", true, true);
            }
            if ((flags & MenuCommandFlags.MethodMemberRef) != 0)
            {
                ctxMenu.Items.Add(new MenuItem()
                {
                    Header  = dnSpy_AsmEditor_Resources.EditOperand_Method_MemberRef,
                    Command = new RelayCommand(a => AddMethodMemberRef(opvm)),
                });
            }
            if ((flags & MenuCommandFlags.MethodSpec) != 0)
            {
                ctxMenu.Items.Add(new MenuItem()
                {
                    Header  = dnSpy_AsmEditor_Resources.EditOperand_MethodSpec,
                    Command = new RelayCommand(a => AddMethodSpec(opvm)),
                });
            }
            if ((flags & MenuCommandFlags.FieldDef) != 0)
            {
                ctxMenu.Items.Add(menuItem = new MenuItem()
                {
                    Header  = dnSpy_AsmEditor_Resources.EditOperand_Field,
                    Command = new RelayCommand(a => AddFieldDef(opvm)),
                });
                Add16x16Image(menuItem, "Field", true, true);
            }
            if ((flags & MenuCommandFlags.FieldMemberRef) != 0)
            {
                ctxMenu.Items.Add(new MenuItem()
                {
                    Header  = dnSpy_AsmEditor_Resources.EditOperand_Field_MemberRef,
                    Command = new RelayCommand(a => AddFieldMemberRef(opvm)),
                });
            }

            ctxMenu.Placement       = PlacementMode.Bottom;
            ctxMenu.PlacementTarget = parameter as UIElement;
            ctxMenu.IsOpen          = true;
        }