Beispiel #1
0
        protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
        {
            //Checks that there are no generics
            if (EnclosingType != null && EnclosingType.HasGenericParameters)
            {
                return;
            }

            //Shows the member selection window
            var win = new SelectMemberWindow(MemberFilter, SelectableMembers, DestinationModule, EnclosingType);

            if (win.ShowDialog().GetValueOrDefault(false))
            {
                //Selected member
                var member = win.SelectedMember;

                //Sets icon and text using an ILEditTreeNode
                var node = new ILEditTreeNode(member, true);
                ImgIcon.Source = (ImageSource)node.Icon;
                LblName.Text   = node.Text.ToString();

                //Updates the properties
                HasMember      = true;
                SelectedMember = member;
            }
        }
Beispiel #2
0
        private void GenericsCombo_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            //Checks that ther's exactly one item selected
            if (e.AddedItems == null || e.AddedItems.Count == 0)
            {
                return;
            }

            //The newly selected item
            var item = (ComboBoxItem)e.AddedItems[0];

            //Checks if it has the tag set
            if (item.Tag != null)
            {
                SelectedMember = (IMetadataTokenProvider)item.Tag;
                HasMember      = true;
            }
            else
            {
                //Shows the window to select the type
                var win = new SelectMemberWindow(MemberFilter, new[] { TokenType.TypeDef }, DestinationModule, EnclosingType);
                if (win.ShowDialog().GetValueOrDefault(false))
                {
                    //Creates the combo box item
                    var type = (TypeReference)win.SelectedMember;
                    var cbi  = new ComboBoxItem()
                    {
                        Content = GetContentForComboBoxItem(type), Tag = type
                    };

                    //Selects the new item
                    item.IsSelected = false;
                    var items = (ObservableCollection <ComboBoxItem>)GenericsCombo.ItemsSource;
                    items.Insert(items.Count - 1, cbi);
                    cbi.IsSelected = true;
                }
                //Restores the previously selected item
                else if (e.RemovedItems != null && e.RemovedItems.Count > 0)
                {
                    var exItem = (ComboBoxItem)e.RemovedItems[0];
                    item.IsSelected   = false;
                    exItem.IsSelected = true;
                }
                else
                {
                    item.IsSelected             = false;
                    GenericsCombo.SelectedIndex = -1;
                }
            }
        }
        protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
        {
            //Checks that there are no generics
            if (EnclosingType != null && EnclosingType.HasGenericParameters)
                return;

            //Shows the member selection window
            var win = new SelectMemberWindow(MemberFilter, SelectableMembers, DestinationModule, EnclosingType);
            if (win.ShowDialog().GetValueOrDefault(false))
            {
                //Selected member
                var member = win.SelectedMember;

                //Sets icon and text using an ILEditTreeNode
                var node = new ILEditTreeNode(member, true);
                ImgIcon.Source = (ImageSource)node.Icon;
                LblName.Text = node.Text.ToString();

                //Updates the properties
                HasMember = true;
                SelectedMember = member;
            }
        }
        private void GenericsCombo_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            //Checks that ther's exactly one item selected
            if (e.AddedItems == null || e.AddedItems.Count == 0)
                return;

            //The newly selected item
            var item = (ComboBoxItem)e.AddedItems[0];

            //Checks if it has the tag set
            if (item.Tag != null)
            {
                SelectedMember = (IMetadataTokenProvider)item.Tag;
                HasMember = true;
            }
            else
            {
                //Shows the window to select the type
                var win = new SelectMemberWindow(MemberFilter, new[] { TokenType.TypeDef }, DestinationModule, EnclosingType);
                if (win.ShowDialog().GetValueOrDefault(false))
                {
                    //Creates the combo box item
                    var type = (TypeReference)win.SelectedMember;
                    var cbi = new ComboBoxItem() { Content = GetContentForComboBoxItem(type), Tag = type };

                    //Selects the new item
                    item.IsSelected = false;
                    var items = (ObservableCollection<ComboBoxItem>)GenericsCombo.ItemsSource;
                    items.Insert(items.Count - 1, cbi);
                    cbi.IsSelected = true;
                }
                //Restores the previously selected item
                else if (e.RemovedItems != null && e.RemovedItems.Count > 0)
                {
                    var exItem = (ComboBoxItem)e.RemovedItems[0];
                    item.IsSelected = false;
                    exItem.IsSelected = true;
                }
                else
                {
                    item.IsSelected = false;
                    GenericsCombo.SelectedIndex = -1;
                }
            }
        }