private static void createRightExampleMenu(ExampleOperationViewModel exampleOperationViewModel) { var attachmentViewModel = exampleOperationViewModel.AttachementViewModels.First( avm => avm.AttachmentOrientation == AttachmentOrientation.Right); var menuViewModel = new MenuViewModel { AttachmentOrientation = attachmentViewModel.AttachmentOrientation, NrColumns = 3, NrRows = 1 }; var sliderItem = new MenuItemViewModel { MenuViewModel = menuViewModel, Row = 0, ColumnSpan = 1, RowSpan = 1, Column = 0, Position = exampleOperationViewModel.Position, Size = new Vec(100, 50), TargetSize = new Vec(100, 50), IsAlwaysDisplayed = false, IsWidthBoundToParent = false, IsHeightBoundToParent = false }; var attr1 = new SliderMenuItemComponentViewModel { Label = "dummy slider", Value = exampleOperationViewModel.ExampleOperationModel.DummyValue, MinValue = 1, MaxValue = 100 }; attr1.PropertyChanged += (sender, args) => { var model = sender as SliderMenuItemComponentViewModel; if (args.PropertyName == model.GetPropertyName(() => model.FinalValue)) { exampleOperationViewModel.ExampleOperationModel.DummyValue = model.FinalValue; } attachmentViewModel.ActiveStopwatch.Restart(); }; sliderItem.MenuItemComponentViewModel = attr1; menuViewModel.MenuItemViewModels.Add(sliderItem); attachmentViewModel.MenuViewModel = menuViewModel; }
private void hypothesisButton_Click(object sender, RoutedEventArgs e) { if (_hypothesisMenuView == null) { _hypothesisMenuViewModel = new MenuViewModel { AttachmentOrientation = AttachmentOrientation.Left, NrColumns = 5, NrRows = 4, MoveOnHide = true }; var sliderItem = new MenuItemViewModel { MenuViewModel = _hypothesisMenuViewModel, Row = 0, ColumnSpan = 1, RowSpan = 1, Column = 0, Position = new Pt(menuHypothesisGrid.ActualWidth, 0), Size = new Vec(100, 50), TargetSize = new Vec(100, 50), IsAlwaysDisplayed = false, IsWidthBoundToParent = false, IsHeightBoundToParent = false }; var attr1 = new SliderMenuItemComponentViewModel { Label = "alpha", Value = 500, MinValue = 1, MaxValue = 1000, Formatter = d => { return(Math.Round(d / 100.0, 1).ToString("F2") + "%"); } }; attr1.PropertyChanged += (sender2, args) => { var model = sender2 as SliderMenuItemComponentViewModel; if (args.PropertyName == model.GetPropertyName(() => model.FinalValue)) { var tt = Math.Round(model.FinalValue / 100.0, 1) * 100.0; //exampleOperationViewModel.ExampleOperationModel.DummyValue = model.FinalValue; } }; sliderItem.MenuItemComponentViewModel = attr1; _hypothesisMenuViewModel.MenuItemViewModels.Add(sliderItem); // FDR var toggles = new List <ToggleMenuItemComponentViewModel>(); var items = new List <MenuItemViewModel>(); var count = 0; var col = 1; foreach (var riskCtrlType in new[] { RiskControlType.PCER, RiskControlType.Bonferroni, RiskControlType.AdaBonferroni, RiskControlType.HolmBonferroni, RiskControlType.BHFDR, RiskControlType.SeqFDR, RiskControlType.AlphaFDR, RiskControlType.BestFootForward, RiskControlType.BetaFarsighted, RiskControlType.GammaFixed, RiskControlType.DeltaHopeful, RiskControlType.EpsilonHybrid, RiskControlType.PsiSupport }) { var toggleMenuItem = new MenuItemViewModel { MenuViewModel = _hypothesisMenuViewModel, Row = count % 4, RowSpan = 0, Position = new Pt(menuHypothesisGrid.ActualWidth, 0), Column = col, Size = new Vec(75, 50), TargetSize = new Vec(75, 50) }; //toggleMenuItem.Position = attachmentItemViewModel.Position; var toggle = new ToggleMenuItemComponentViewModel { Label = riskCtrlType.ToString(), IsChecked = HypothesesViewController.Instance.RiskOperationModel.RiskControlType == riskCtrlType }; toggles.Add(toggle); toggleMenuItem.MenuItemComponentViewModel = toggle; toggleMenuItem.MenuItemComponentViewModel.PropertyChanged += (sender2, args2) => { var model = sender2 as ToggleMenuItemComponentViewModel; if (args2.PropertyName == model.GetPropertyName(() => model.IsChecked)) { if (model.IsChecked) { HypothesesViewController.Instance.RiskOperationModel.RiskControlType = riskCtrlType; foreach (var tg in model.OtherToggles) { tg.IsChecked = false; } } } }; _hypothesisMenuViewModel.MenuItemViewModels.Add(toggleMenuItem); items.Add(toggleMenuItem); count++; if (count % 4 == 0) { col += 1; } } foreach (var mi in items) { (mi.MenuItemComponentViewModel as ToggleMenuItemComponentViewModel).OtherToggles.AddRange(toggles.Where(ti => ti != mi.MenuItemComponentViewModel)); } if (_hypothesisMenuView != null) { menuHypothesisGrid.Children.Remove(_hypothesisMenuView); } _hypothesisMenuView = new MenuView { DataContext = _hypothesisMenuViewModel }; _hypothesisMenuViewModel.AnkerPosition = new Pt(menuHypothesisGrid.ActualWidth, -((_hypothesisMenuViewModel.NrRows - 1) * 50 + (_hypothesisMenuViewModel.NrRows - 1) * 4)); _hypothesisMenuViewModel.HidePosition = new Pt(menuHypothesisGrid.ActualWidth, 54); menuHypothesisGrid.Children.Add(_hypothesisMenuView); } _hypothesisMenuViewModel.IsDisplayed = !_hypothesisMenuViewModel.IsDisplayed; }