internal void DeleteSymbolSpec(SymbolSpecificationViewModel a)
 {
     if (!SymbolSpecUsedInTree(a))
     {
         SymbolSpecificationList.Remove(a);
     }
 }
Ejemplo n.º 2
0
        internal SymbolSpecificationDialog(SymbolSpecificationViewModel viewModel)
        {
            _viewModel = viewModel;
            InitializeComponent();
            DataContext = viewModel;

            // AutomationDelegatingListView is defined in ServicesVisualStudio, which has
            // InternalsVisibleTo this project. But, the markup compiler doesn't consider the IVT
            // relationship, so declaring the AutomationDelegatingListView in XAML would require
            // duplicating that type in this project. Declaring and setting it here avoids the
            // markup compiler completely, allowing us to reference the internal
            // AutomationDelegatingListView without issue.

            symbolKindsListView = CreateAutomationDelegatingListView(nameof(SymbolSpecificationViewModel.SymbolKindList));
            symbolKindsContentControl.Content = symbolKindsListView;

            accessibilitiesListView = CreateAutomationDelegatingListView(nameof(SymbolSpecificationViewModel.AccessibilityList));
            accessibilitiesContentControl.Content = accessibilitiesListView;

            modifiersListView = CreateAutomationDelegatingListView(nameof(SymbolSpecificationViewModel.ModifierList));
            modifiersContentControl.Content = modifiersListView;

#pragma warning disable IDE0004 // Remove unnecessary cast - without the cast the delegate type would be Action<object, KeyEventArgs>.
            symbolKindsListView.AddHandler(PreviewKeyDownEvent, (KeyEventHandler)HandleSymbolKindsPreviewKeyDown, true);
            accessibilitiesListView.AddHandler(PreviewKeyDownEvent, (KeyEventHandler)HandleAccessibilitiesPreviewKeyDown, true);
            modifiersListView.AddHandler(PreviewKeyDownEvent, (KeyEventHandler)HandleModifiersPreviewKeyDown, true);
#pragma warning restore
        }
 public void AddItem()
 {
     var viewModel = new SymbolSpecificationViewModel(LanguageName, canBeDeleted: true, notificationService: _notificationService);
     var dialog = new SymbolSpecificationDialog(viewModel);
     if (dialog.ShowDialog().Value == true)
     {
         Items.Add(viewModel);
     }
 }
        internal SymbolSpecificationDialog(SymbolSpecificationViewModel viewModel)
        {
            _viewModel = viewModel;
            InitializeComponent();
            DataContext = viewModel;

            SymbolKinds.AddHandler(UIElement.PreviewKeyDownEvent, (KeyEventHandler)HandleSymbolKindsPreviewKeyDown, true);
            Accessibilities.AddHandler(UIElement.PreviewKeyDownEvent, (KeyEventHandler)HandleAccessibilitiesPreviewKeyDown, true);
            Modifiers.AddHandler(UIElement.PreviewKeyDownEvent, (KeyEventHandler)HandleModifiersPreviewKeyDown, true);
        }
        public void AddItem()
        {
            var viewModel = new SymbolSpecificationViewModel(LanguageName, canBeDeleted: true, notificationService: _notificationService);
            var dialog    = new SymbolSpecificationDialog(viewModel);

            if (dialog.ShowDialog().Value == true)
            {
                Items.Add(viewModel);
            }
        }
Ejemplo n.º 6
0
 private void CreateSymbolSpecification(object sender, RoutedEventArgs e)
 {
     var newSymbolSpecificationViewModel = new SymbolSpecificationViewModel(_namingStylesViewModel.LanguageName, _categories, _notificationService);
     var dialog = new SymbolSpecificationDialog(newSymbolSpecificationViewModel);
     var result = dialog.ShowModal();
     if (result == true)
     {
         _namingStylesViewModel.AddSymbolSpecification(newSymbolSpecificationViewModel);
         _viewModel.SelectedSymbolSpecificationIndex = _viewModel.SymbolSpecificationList.IndexOf(newSymbolSpecificationViewModel);
     }
 }
Ejemplo n.º 7
0
        private void CreateSymbolSpecification(object sender, RoutedEventArgs e)
        {
            var newSymbolSpecificationViewModel = new SymbolSpecificationViewModel(_namingStylesViewModel.LanguageName, _categories, _notificationService);
            var dialog = new SymbolSpecificationDialog(newSymbolSpecificationViewModel);
            var result = dialog.ShowModal();

            if (result == true)
            {
                _namingStylesViewModel.AddSymbolSpecification(newSymbolSpecificationViewModel);
                _viewModel.SelectedSymbolSpecificationIndex = _viewModel.SymbolSpecificationList.IndexOf(newSymbolSpecificationViewModel);
            }
        }
        public void EditItem(INamingStylesInfoDialogViewModel item)
        {
            var symbolSpecificationViewModel = (SymbolSpecificationViewModel)item;

            var symbolSpecification = ((SymbolSpecificationViewModel)item).GetSymbolSpecification();
            var viewModel = new SymbolSpecificationViewModel(LanguageName, symbolSpecification, symbolSpecificationViewModel.CanBeDeleted, _notificationService);
            var dialog = new SymbolSpecificationDialog(viewModel);
            if (dialog.ShowDialog().Value == true)
            {
                symbolSpecificationViewModel.ItemName = viewModel.ItemName;
                symbolSpecificationViewModel.AccessibilityList = viewModel.AccessibilityList;
                symbolSpecificationViewModel.ModifierList = viewModel.ModifierList;
                symbolSpecificationViewModel.SymbolKindList = viewModel.SymbolKindList;
            }
        }
        public void EditItem(INamingStylesInfoDialogViewModel item)
        {
            var symbolSpecificationViewModel = (SymbolSpecificationViewModel)item;

            var symbolSpecification = ((SymbolSpecificationViewModel)item).GetSymbolSpecification();
            var viewModel           = new SymbolSpecificationViewModel(LanguageName, symbolSpecification, symbolSpecificationViewModel.CanBeDeleted, _notificationService);
            var dialog = new SymbolSpecificationDialog(viewModel);

            if (dialog.ShowDialog().Value == true)
            {
                symbolSpecificationViewModel.ItemName          = viewModel.ItemName;
                symbolSpecificationViewModel.AccessibilityList = viewModel.AccessibilityList;
                symbolSpecificationViewModel.ModifierList      = viewModel.ModifierList;
                symbolSpecificationViewModel.SymbolKindList    = viewModel.SymbolKindList;
            }
        }
Ejemplo n.º 10
0
        internal NamingRuleTreeItemViewModel(
            string name,
            SymbolSpecificationViewModel symbolSpec,
            NamingStyleViewModel namingStyle,
            EnforcementLevel enforcementLevel,
            NamingStylesOptionPageControlViewModel vm)
        {
            this.EnforcementLevel       = enforcementLevel;
            this._title                 = name;
            this.symbolSpec             = symbolSpec;
            this.namingStyle            = namingStyle;
            this._namingStylesViewModel = vm;

            this.children = new ChildRuleCollection(this);
            this.children.CollectionChanged += OnChildrenCollectionChanged;
        }
Ejemplo n.º 11
0
        private void ConfigureSymbolSpecifications(object sender, RoutedEventArgs e)
        {
            if (_viewModel.SelectedSymbolSpecificationIndex >= 0)
            {
                var symbolSpecificationViewModel = _viewModel.SymbolSpecificationList.GetItemAt(_viewModel.SelectedSymbolSpecificationIndex) as SymbolSpecificationViewModel;
                var symbolSpecificationClone     = new SymbolSpecificationViewModel(_namingStylesViewModel.LanguageName, _categories, symbolSpecificationViewModel.GetSymbolSpecification(), _notificationService);

                var dialog = new SymbolSpecificationDialog(symbolSpecificationClone);
                var result = dialog.ShowModal();
                if (result == true)
                {
                    symbolSpecificationViewModel.ModifierList      = symbolSpecificationClone.ModifierList;
                    symbolSpecificationViewModel.SymbolKindList    = symbolSpecificationClone.SymbolKindList;
                    symbolSpecificationViewModel.AccessibilityList = symbolSpecificationClone.AccessibilityList;
                    symbolSpecificationViewModel.SymbolSpecName    = symbolSpecificationClone.SymbolSpecName;
                    symbolSpecificationViewModel.CustomTagList     = symbolSpecificationClone.CustomTagList;
                }
            }
        }
Ejemplo n.º 12
0
        private void ConfigureSymbolSpecifications(object sender, RoutedEventArgs e)
        {
            if (_viewModel.SelectedSymbolSpecificationIndex >= 0)
            {
                var symbolSpecificationViewModel = _viewModel.SymbolSpecificationList.GetItemAt(_viewModel.SelectedSymbolSpecificationIndex) as SymbolSpecificationViewModel;
                var symbolSpecificationClone = new SymbolSpecificationViewModel(_namingStylesViewModel.LanguageName, _categories, symbolSpecificationViewModel.GetSymbolSpecification(), _notificationService);

                var dialog = new SymbolSpecificationDialog(symbolSpecificationClone);
                var result = dialog.ShowModal();
                if (result == true)
                {
                    symbolSpecificationViewModel.ModifierList = symbolSpecificationClone.ModifierList;
                    symbolSpecificationViewModel.SymbolKindList = symbolSpecificationClone.SymbolKindList;
                    symbolSpecificationViewModel.AccessibilityList = symbolSpecificationClone.AccessibilityList;
                    symbolSpecificationViewModel.SymbolSpecName = symbolSpecificationClone.SymbolSpecName;
                    symbolSpecificationViewModel.CustomTagList = symbolSpecificationClone.CustomTagList;
                }
            }
        }
        private void SymbolSpecificationList_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            var item = ((FrameworkElement)e.OriginalSource).DataContext as SymbolSpecificationViewModel;

            if (item != null)
            {
                var itemClone = new SymbolSpecificationViewModel(_viewModel.LanguageName, _categories, item.GetSymbolSpecification(), _notificationService);

                var dialog = new SymbolSpecificationDialog(itemClone);
                var result = dialog.ShowModal();
                if (result == true)
                {
                    item.ModifierList      = itemClone.ModifierList;
                    item.SymbolKindList    = itemClone.SymbolKindList;
                    item.AccessibilityList = itemClone.AccessibilityList;
                    item.SymbolSpecName    = itemClone.SymbolSpecName;
                    item.CustomTagList     = itemClone.CustomTagList;
                }
            }
        }
Ejemplo n.º 14
0
        public NamingRuleDialogViewModel(
            string title,
            SymbolSpecificationViewModel symbolSpecification,
            IList <SymbolSpecificationViewModel> symbolSpecificationList,
            NamingStyleViewModel namingStyle,
            IList <NamingStyleViewModel> namingStyleList,
            NamingRuleTreeItemViewModel parent,
            IList <NamingRuleTreeItemViewModel> allowableParentList,
            EnforcementLevel enforcementLevel,
            INotificationService notificationService)
        {
            this._notificationService = notificationService;

            this._title = title;

            this._symbolSpecificationList          = new CollectionView(symbolSpecificationList);
            this._selectedSymbolSpecificationIndex = symbolSpecificationList.IndexOf(symbolSpecification);

            this._namingStyleList  = new CollectionView(namingStyleList);
            this._namingStyleIndex = namingStyleList.IndexOf(namingStyle);

            allowableParentList.Insert(0, new NamingRuleTreeItemViewModel("-- None --"));
            this._parentRuleList  = new CollectionView(allowableParentList);
            this._parentRuleIndex = parent != null?allowableParentList.IndexOf(parent) : 0;

            if (_parentRuleIndex < 0)
            {
                _parentRuleIndex = 0;
            }

            _enforcementLevelsList = new List <EnforcementLevel>
            {
                new EnforcementLevel(DiagnosticSeverity.Hidden),
                new EnforcementLevel(DiagnosticSeverity.Info),
                new EnforcementLevel(DiagnosticSeverity.Warning),
                new EnforcementLevel(DiagnosticSeverity.Error),
            };

            _enforcementLevelIndex = _enforcementLevelsList.IndexOf(_enforcementLevelsList.Single(e => e.Value == enforcementLevel.Value));
        }
Ejemplo n.º 15
0
        public NamingRuleDialogViewModel(
            string title,
            SymbolSpecificationViewModel symbolSpecification,
            IList<SymbolSpecificationViewModel> symbolSpecificationList,
            NamingStyleViewModel namingStyle,
            IList<NamingStyleViewModel> namingStyleList,
            NamingRuleTreeItemViewModel parent,
            IList<NamingRuleTreeItemViewModel> allowableParentList,
            EnforcementLevel enforcementLevel,
            INotificationService notificationService)
        {
            this._notificationService = notificationService;

            this._title = title;
            
            this._symbolSpecificationList = new CollectionView(symbolSpecificationList);
            this._selectedSymbolSpecificationIndex = symbolSpecificationList.IndexOf(symbolSpecification);

            this._namingStyleList = new CollectionView(namingStyleList);
            this._namingStyleIndex = namingStyleList.IndexOf(namingStyle);

            allowableParentList.Insert(0, new NamingRuleTreeItemViewModel("-- None --"));
            this._parentRuleList = new CollectionView(allowableParentList);
            this._parentRuleIndex = parent != null ? allowableParentList.IndexOf(parent) : 0;
            if (_parentRuleIndex < 0)
            {
                _parentRuleIndex = 0;
            }

            _enforcementLevelsList = new List<EnforcementLevel>
                {
                    new EnforcementLevel(DiagnosticSeverity.Hidden),
                    new EnforcementLevel(DiagnosticSeverity.Info),
                    new EnforcementLevel(DiagnosticSeverity.Warning),
                    new EnforcementLevel(DiagnosticSeverity.Error),
                };

            _enforcementLevelIndex = _enforcementLevelsList.IndexOf(_enforcementLevelsList.Single(e => e.Value == enforcementLevel.Value));
        }
 private bool SymbolSpecUsedInTree(SymbolSpecificationViewModel a)
 {
     return(rootNamingRule.Children.Any(c => c.symbolSpec == a || SymbolSpecUsedInTree(a, c)));
 }
 internal void DeleteSymbolSpec(SymbolSpecificationViewModel a)
 {
     if (!SymbolSpecUsedInTree(a))
     {
         SymbolSpecificationList.Remove(a);
     }
 }
 private bool SymbolSpecUsedInTree(SymbolSpecificationViewModel a)
 {
     return rootNamingRule.Children.Any(c => c.symbolSpec == a || SymbolSpecUsedInTree(a, c));
 }
 private bool SymbolSpecUsedInTree(SymbolSpecificationViewModel a, NamingRuleTreeItemViewModel c)
 {
     return c.Children.Any(child => child.symbolSpec == a || SymbolSpecUsedInTree(a, child));
 }
 internal void AddSymbolSpecification(SymbolSpecificationViewModel viewModel)
 {
     SymbolSpecificationList.Add(viewModel);
 }
 private bool SymbolSpecUsedInTree(SymbolSpecificationViewModel a, NamingRuleTreeItemViewModel c)
 {
     return(c.Children.Any(child => child.symbolSpec == a || SymbolSpecUsedInTree(a, child)));
 }
 internal void AddSymbolSpecification(SymbolSpecificationViewModel viewModel)
 {
     SymbolSpecificationList.Add(viewModel);
 }
        private void SymbolSpecificationList_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            var item = ((FrameworkElement)e.OriginalSource).DataContext as SymbolSpecificationViewModel;
            if (item != null)
            {
                var itemClone = new SymbolSpecificationViewModel(_viewModel.LanguageName, _categories, item.GetSymbolSpecification(), _notificationService);

                var dialog = new SymbolSpecificationDialog(itemClone);
                var result = dialog.ShowModal();
                if (result == true)
                {
                    item.ModifierList = itemClone.ModifierList;
                    item.SymbolKindList = itemClone.SymbolKindList;
                    item.AccessibilityList = itemClone.AccessibilityList;
                    item.SymbolSpecName = itemClone.SymbolSpecName;
                    item.CustomTagList = itemClone.CustomTagList;
                }
            }
        }