예제 #1
0
 public void Main(MgaProject project, MgaFCO currentobj, MgaFCOs selectedobjs, ComponentStartMode startMode)
 {
     // create a checker instance
     var ch = new Framework.Checker(currentobj, project, null);
     var checkerWindow = new RuleView(ch);
     checkerWindow.ShowDialog();
 }
        public void Main(MgaProject project, MgaFCO currentobj, MgaFCOs selectedobjs, ComponentStartMode startMode)
        {
            // create a checker instance
            var ch            = new Framework.Checker(currentobj, project, null);
            var checkerWindow = new RuleView(ch);

            checkerWindow.ShowDialog();
        }
예제 #3
0
 public RuleView(Checker checker)
 {
     InitializeComponent();
     DataContext = new RuleViewModel(checker, this);
 }
예제 #4
0
        public RuleViewModel(Checker checker, Window window)
        {
            _window = window;
            _checker = checker;

            // list the name of the interpreters
            var interpreterNames = new List<string>()
            {
                "CyPhy2Modelica_v2",
                "CyPhyPET"
            };

            // these are the path, where the dll could be.
            // the search order is important.
            var searchLocations = new List<string>()
            {
                 META.VersionInfo.MetaPath + @"\bin\{0}.dll",
                 META.VersionInfo.MetaPath + @"\src\{0}\bin\Release\{0}.dll",
                 META.VersionInfo.MetaPath + @"\src\{0}\bin\Debug\{0}.dll",
            };

            // add all found dlls into this list then load them.
            var dllsToLoad = new List<string>();
            dllsToLoad.Add("DesignConsistencyChecker.dll");

            // search for the dlls
            foreach (var interpreterName in interpreterNames)
            {
                foreach (var searchLocation in searchLocations)
                {
                    var interpreterLocation = string.Format(searchLocation, interpreterName);
                    if (File.Exists(interpreterLocation))
                    {
                        dllsToLoad.Add(interpreterLocation);
                        break;
                    }
                }
            }

            //_ruleLoadTask = Task.Factory.StartNew(() =>
                                      //{
                                      //    IsRulesLoading = true;
                                            _checker.RegisterRuleDlls(dllsToLoad);
                                      //}).ContinueWith(o => { IsRulesLoading = false; });

            IsModelElementsLoading = true;
            _window.ContentRendered += (o, e) =>
                                           {
                                               _checker.RefreshChildrenCache();
                                               IsModelElementsLoading = false;
                                           };

            if (_checker.Model != null && _checker.Model.Meta != null)
            {
                ContextName = _checker.Model.Name;
                ContextType = _checker.Model.Meta.Name;
            }
            else
            {
                ContextName = ContextType = "_";
            }

            CheckCommand=new DelegateCommand(ExecuteCheckCommand, CanExecuteCheck);
            
            RuleList = new ObservableCollection<RuleWrapper>(checker.GetRegisteredRules.Select(x=>new RuleWrapper(x)));

            Feedbacks = new ObservableCollection<OutputMessageDescriptor>();
            TagList = new ObservableCollection<TagWrapper>(checker.AllTags.Select(x=>new TagWrapper(x){IsSelected = false}));

            foreach (var tagWrapper in TagList)
            {
                tagWrapper.SelectionChanged += (o, e) => { RefreshselectedRules(); };
            }


            //SelectAllRules = new DelegateCommand(o =>
            //                                         {
            //                                             foreach (var rule in RuleList)
            //                                             {
            //                                                 rule.IsSelected = true;
            //                                             }
            //                                         }, o => RuleList.Any(x=>!x.IsSelected));

            //DeselectAllRules = new DelegateCommand(o =>
            //{
            //    foreach (var rule in RuleList)
            //    {
            //        rule.IsSelected = false;
            //    }
            //}, o => RuleList.Any(x => x.IsSelected));

            CloseCommand = new DelegateCommand(o => _window.Close(),o=>true);

            foreach (var rule in RuleList)
            {
                rule.PropertyChanged += (o, e) =>
                {
                    if (e.PropertyName == "IsSelected")
                    {
                        CheckCommand.CanExecute(null);
                        OnPropertyChanged(()=>IsAllSelected);
                        //SelectAllRules.CanExecute(null);
                        //DeselectAllRules.CanExecute(null);
                    }
                };
            }

            //SelectDeselectAllCommand = new DelegateCommand(o =>
            //                                                   {
            //                                                       var c = o as CheckBox;
            //                                                   }, o=>true);

            CheckCommand.CanExecute(null);
            //SelectAllRules.CanExecute(null);
            //DeselectAllRules.CanExecute(null);
        }