Exemple #1
0
        private void StatisticalComparisonOperationModel_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            var statOpModel = (StatisticalComparisonOperationModel)sender;

            if (e.PropertyName == statOpModel.GetPropertyName(() => statOpModel.Result))
            {
                var res = (AddComparisonResult)statOpModel.Result;
                if (res != null)
                {
                    if (!_comparisonIdToHypothesisViewModels.ContainsKey(res.ComparisonId))
                    {
                        var vm = new HypothesisViewModel();
                        vm.StatisticalComparisonSaveViewModel = _modelToSaveViewModel[statOpModel];
                        HypothesesViewModel.HypothesisViewModels.Add(vm);
                        _comparisonIdToHypothesisViewModels.Add(res.ComparisonId, vm);
                    }

                    _comparisonIdToHypothesisViewModels[res.ComparisonId].Decision = res.Decision[_riskOperationModel.RiskControlType];
                    //Debug.WriteLine(statOpModel.ExecutionId + ", " + statOpModel.ResultExecutionId);
                    if (statOpModel.ExecutionId == statOpModel.ResultExecutionId)
                    {
                        statOpModel.Decision = res.Decision[_riskOperationModel.RiskControlType];
                        if (HypothesesViewModel.HypothesisViewModels.Any())
                        {
                            if (HypothesesViewModel.HypothesisViewModels.Max(h => h.ViewOrdering) >= _comparisonIdToHypothesisViewModels[res.ComparisonId].ViewOrdering)
                            {
                                _comparisonIdToHypothesisViewModels[res.ComparisonId].ViewOrdering = HypothesesViewModel.HypothesisViewModels.Max(h => h.ViewOrdering) + 1;
                            }
                        }
                    }
                }
            }
        }
        void toggleDisplayed(HypothesisViewModel model)
        {
            var ts = TimeSpan.FromMilliseconds(300);

            // fade out
            if (!model.IsDisplayed)
            {
                if (_storyboards.ContainsKey(model))
                {
                    //_storyboards[kvp.Key].Stop();
                }
                ExponentialEase easingFunction = new ExponentialEase();
                easingFunction.EasingMode = EasingMode.EaseInOut;

                DoubleAnimation animation = new DoubleAnimation();
                animation.From           = _views[model].Opacity;
                animation.To             = 0;
                animation.EasingFunction = easingFunction;
                Storyboard storyboard = new Storyboard();
                storyboard.Children.Add(animation);
                Storyboard.SetTarget(animation, _views[model]);
                Storyboard.SetTargetProperty(animation, "Opacity");
                // storyboard.Duration = new Duration(ts);
                animation.Duration = new Duration(ts);
                storyboard.Begin();
                storyboard.Completed += (sender, o) =>
                {
                    _views[model].IsHitTestVisible = false;
                };
                _storyboards[model] = storyboard;
            }
            // fade in
            else
            {
                if (_storyboards.ContainsKey(model))
                {
                    // _storyboards[kvp.Key].Stop();
                }
                _views[model].IsHitTestVisible = true;

                ExponentialEase easingFunction = new ExponentialEase();
                easingFunction.EasingMode = EasingMode.EaseInOut;

                DoubleAnimation animation = new DoubleAnimation();
                animation.From           = _views[model].Opacity;
                animation.To             = 1;
                animation.EasingFunction = easingFunction;
                Storyboard storyboard = new Storyboard();
                storyboard.Children.Add(animation);
                Storyboard.SetTarget(animation, _views[model]);
                Storyboard.SetTargetProperty(animation, "Opacity");
                animation.Duration = new Duration(ts);
                storyboard.Begin();
                storyboard.Completed += (sender, o) =>
                {
                    _views[model].IsHitTestVisible = true;
                };
                _storyboards[model] = storyboard;
            }
        }
 private void HypothesisView_DataContextChanged(FrameworkElement sender, DataContextChangedEventArgs args)
 {
     if (_model != null)
     {
         _model.PropertyChanged -= _model_PropertyChanged;
     }
     if (args.NewValue is HypothesisViewModel)
     {
         _model = (HypothesisViewModel)args.NewValue;
         _model.PropertyChanged += _model_PropertyChanged;
         updateRendering();
     }
 }