コード例 #1
0
            public bool Invoke(IEnumerable<object> items, InputSource inputSource, bool preview)
            {
                NamingRuleTreeItemViewModel[] selectedRules = items.OfType<NamingRuleTreeItemViewModel>().ToArray();

                // When a single Naming Rule is invoked using the mouse, expanding/collapse it in the tree
                if (selectedRules.Length == 1)
                {
                    var selectedRule = selectedRules[0];
                    if (selectedRule.NamingStylesViewModel == null)
                    {
                        return false;
                    }

                    var viewModel = new NamingRuleDialogViewModel(
                        selectedRule._title,
                        selectedRule.symbolSpec,
                        selectedRule.NamingStylesViewModel.SymbolSpecificationList,
                        selectedRule.namingStyle,
                        selectedRule.NamingStylesViewModel.NamingStyleList,
                        selectedRule.parent,
                        selectedRule.NamingStylesViewModel.CreateAllowableParentList(selectedRule),
                        selectedRule.EnforcementLevel,
                        selectedRule.NamingStylesViewModel.notificationService);
                    var dialog = new NamingRuleDialog(viewModel, selectedRule.NamingStylesViewModel, selectedRule.NamingStylesViewModel.categories, selectedRule.NamingStylesViewModel.notificationService);
                    var result = dialog.ShowModal();
                    if (result == true)
                    {
                        selectedRule.namingStyle = viewModel.NamingStyleList.GetItemAt(viewModel.NamingStyleIndex) as NamingStyleViewModel;
                        selectedRule.symbolSpec = viewModel.SymbolSpecificationList.GetItemAt(viewModel.SelectedSymbolSpecificationIndex) as SymbolSpecificationViewModel;
                        selectedRule.Title = viewModel.Title;
                        selectedRule.EnforcementLevel = viewModel.EnforcementLevelsList[viewModel.EnforcementLevelIndex];
                        selectedRule.NotifyPropertyChanged(nameof(selectedRule.Text));

                        if (viewModel.ParentRuleIndex == 0)
                        {
                            if (selectedRule.Parent != selectedRule.NamingStylesViewModel.rootNamingRule)
                            {
                                selectedRule.Parent.Children.Remove(selectedRule);
                                selectedRule.NamingStylesViewModel.rootNamingRule.Children.Add(selectedRule);
                            }
                        }
                        else
                        {
                            var newParent = viewModel.ParentRuleList.GetItemAt(viewModel.ParentRuleIndex) as NamingRuleTreeItemViewModel;
                            if (newParent != selectedRule.Parent)
                            {
                                selectedRule.Parent.Children.Remove(selectedRule);
                                newParent.Children.Add(selectedRule);
                            }
                        }
                    }

                    return true;
                }

                return false;
            }
コード例 #2
0
            public bool Invoke(IEnumerable <object> items, InputSource inputSource, bool preview)
            {
                NamingRuleTreeItemViewModel[] selectedRules = items.OfType <NamingRuleTreeItemViewModel>().ToArray();

                // When a single Naming Rule is invoked using the mouse, expanding/collapse it in the tree
                if (selectedRules.Length == 1)
                {
                    var selectedRule = selectedRules[0];
                    if (selectedRule.NamingStylesViewModel == null)
                    {
                        return(false);
                    }

                    var viewModel = new NamingRuleDialogViewModel(
                        selectedRule._title,
                        selectedRule.symbolSpec,
                        selectedRule.NamingStylesViewModel.SymbolSpecificationList,
                        selectedRule.namingStyle,
                        selectedRule.NamingStylesViewModel.NamingStyleList,
                        selectedRule.parent,
                        selectedRule.NamingStylesViewModel.CreateAllowableParentList(selectedRule),
                        selectedRule.EnforcementLevel,
                        selectedRule.NamingStylesViewModel.notificationService);
                    var dialog = new NamingRuleDialog(viewModel, selectedRule.NamingStylesViewModel, selectedRule.NamingStylesViewModel.categories, selectedRule.NamingStylesViewModel.notificationService);
                    var result = dialog.ShowModal();
                    if (result == true)
                    {
                        selectedRule.namingStyle      = viewModel.NamingStyleList.GetItemAt(viewModel.NamingStyleIndex) as NamingStyleViewModel;
                        selectedRule.symbolSpec       = viewModel.SymbolSpecificationList.GetItemAt(viewModel.SelectedSymbolSpecificationIndex) as SymbolSpecificationViewModel;
                        selectedRule.Title            = viewModel.Title;
                        selectedRule.EnforcementLevel = viewModel.EnforcementLevelsList[viewModel.EnforcementLevelIndex];
                        selectedRule.NotifyPropertyChanged(nameof(selectedRule.Text));

                        if (viewModel.ParentRuleIndex == 0)
                        {
                            if (selectedRule.Parent != selectedRule.NamingStylesViewModel.rootNamingRule)
                            {
                                selectedRule.Parent.Children.Remove(selectedRule);
                                selectedRule.NamingStylesViewModel.rootNamingRule.Children.Add(selectedRule);
                            }
                        }
                        else
                        {
                            var newParent = viewModel.ParentRuleList.GetItemAt(viewModel.ParentRuleIndex) as NamingRuleTreeItemViewModel;
                            if (newParent != selectedRule.Parent)
                            {
                                selectedRule.Parent.Children.Remove(selectedRule);
                                newParent.Children.Add(selectedRule);
                            }
                        }
                    }

                    return(true);
                }

                return(false);
            }
コード例 #3
0
        private void AddRule_Click(object sender, RoutedEventArgs e)
        {
            var viewModel = new NamingRuleDialogViewModel(
                string.Empty,
                null,
                _viewModel.SymbolSpecificationList,
                null,
                _viewModel.NamingStyleList,
                null,
                _viewModel.CreateAllowableParentList(_viewModel.rootNamingRule),
                new EnforcementLevel(DiagnosticSeverity.Hidden),
                _notificationService);
            var dialog = new NamingRuleDialog(viewModel, _viewModel, _categories, _notificationService);
            var result = dialog.ShowModal();

            if (result == true)
            {
                _viewModel.AddNamingRule(viewModel);
            }
        }
コード例 #4
0
 private void AddRule_Click(object sender, RoutedEventArgs e)
 {
     var viewModel = new NamingRuleDialogViewModel(
         string.Empty,
         null,
         _viewModel.SymbolSpecificationList,
         null,
         _viewModel.NamingStyleList,
         null,
         _viewModel.CreateAllowableParentList(_viewModel.rootNamingRule),
         new EnforcementLevel(DiagnosticSeverity.Hidden),
         _notificationService);
     var dialog = new NamingRuleDialog(viewModel, _viewModel, _categories, _notificationService);
     var result = dialog.ShowModal();
     if (result == true)
     {
         _viewModel.AddNamingRule(viewModel);
     }
 }