private static SubscriberInfo GetSubscriberInfo(SelectionModel options, bool isAllNews)
        {
            return(new SubscriberInfo()
            {
                EmailAddress = options.EmailAddress,
                IsAdminRegistration = false,
                IsAllNews = isAllNews,
                IsAsItHappens = options.NewsAsItHappens,
                IsDailyDigest = options.NewsDailyDigest,

                //TODO: Include in SelectionModel
                NotifyIfNewCategories = true,

                SubscribedCategories = new Dictionary <string, IList <string> >()
                {
                    { "ministries", options.Ministries?.ToArray() },
                    { "sectors", options.Sectors?.ToArray() },
                    { "tags", options.Tags?.ToArray() },
                    { "services", options.Services?.ToArray() },
                    { "emergency", options.Emergency?.ToArray() },
                    { "newsletters", options.Newsletters?.ToArray() },
                    { "media-distribution-lists", options.MediaDistributionLists?.Split(';') }
                }
            });
        }
        public static LegModel[] GenerateLegs(int legCount, int binPerLeg)
        {
            var rand = new Random();

            var legs = new LegModel[legCount];

            for (var legOrder = 1; legOrder <= legCount; legOrder++)
            {
                var selections = new SelectionModel[binPerLeg];
                for (var bin = 1; bin <= binPerLeg; bin++)
                {
                    var prob = rand.NextDouble();
                    selections[bin - 1] = new SelectionModel(bin, prob);
                }
                //normalised the probs
                var sumProbs = selections.Sum(s => s.Probability);
                foreach (var sel in selections)
                {
                    var newProb = sel.Probability / sumProbs;
                    sel.UpdateProbability(newProb);
                }

                var sumOfProbs = selections.Sum(s => s.Probability);
                Assert.That(sumOfProbs > 0.99);
                legs[legOrder - 1] = new LegModel(legOrder, selections);
            }

            return(legs);
        }
 public GroupedSample()
 {
     this.InitializeComponent();
     selectionModel        = (SelectionModel)Resources[nameof(selectionModel)];
     repeater.ItemsSource  = _groupedData;
     selectionModel.Source = _groupedData;
 }
Exemplo n.º 4
0
        protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
        {
            if (SelectionModel != null)
            {
                if (Keyboard.Modifiers.HasFlag(ModifierKeys.Shift) && !SelectionModel.SingleSelect)
                {
                    if (Keyboard.Modifiers.HasFlag(ModifierKeys.Control))
                    {
                        SelectionModel.DeselectRangeFromAnchor(RepeatedIndex);
                    }
                    else
                    {
                        SelectionModel.SelectRangeFromAnchor(RepeatedIndex);
                    }
                }
                else if (Keyboard.Modifiers.HasFlag(ModifierKeys.Control))
                {
                    if (SelectionModel.IsSelected(RepeatedIndex).Value)
                    {
                        SelectionModel.Deselect(RepeatedIndex);
                    }
                    else
                    {
                        SelectionModel.Select(RepeatedIndex);
                    }
                }
                else
                {
                    SelectionModel.Select(RepeatedIndex);
                    this.Focus();
                }
            }

            base.OnMouseLeftButtonDown(e);
        }
Exemplo n.º 5
0
        public ListBoxPageViewModel()
        {
            Items     = new ObservableCollection <string>(Enumerable.Range(1, 10000).Select(i => GenerateItem()));
            Selection = new SelectionModel <string>();
            Selection.Select(1);

            AddItemCommand = ReactiveCommand.Create(() => Items.Add(GenerateItem()));

            RemoveItemCommand = ReactiveCommand.Create(() =>
            {
                while (Selection.Count > 0)
                {
                    Items.Remove(Selection.SelectedItems.First());
                }
            });

            SelectRandomItemCommand = ReactiveCommand.Create(() =>
            {
                var random = new Random();

                using (Selection.BatchUpdate())
                {
                    Selection.Clear();
                    Selection.Select(random.Next(Items.Count - 1));
                }
            });
        }
Exemplo n.º 6
0
 public SessionHeaderViewModel(SessionPlace sessionPlace, Individual individual, SelectionModel selectionModel, Action showSession)
 {
     _sessionPlace   = sessionPlace;
     _individual     = individual;
     _selectionModel = selectionModel;
     _showSession    = showSession;
 }
Exemplo n.º 7
0
        private void OnselectionModelChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            if (e.PropertyName == "SelectedIndices")
            {
                bool?oldValue  = IsSelected;
                var  indexPath = GetIndexPath();
                bool?newValue  = IsRealized(indexPath) ? SelectionModel.IsSelectedAt(indexPath) : false;

                if (oldValue != newValue)
                {
                    IsSelected = newValue;
                    bool oldValueAsBool = oldValue.HasValue && oldValue.Value;
                    bool newValueAsBool = newValue.HasValue && newValue.Value;
                    if (oldValueAsBool != newValueAsBool)
                    {
                        // AutomationEvents.PropertyChanged is used as a value that means dont raise anything
                        AutomationEvents eventToRaise =
                            oldValueAsBool ?
                            (SelectionModel.SingleSelect ? AutomationEvents.PropertyChanged : AutomationEvents.SelectionItemPatternOnElementRemovedFromSelection) :
                            (SelectionModel.SingleSelect ? AutomationEvents.SelectionItemPatternOnElementSelected : AutomationEvents.SelectionItemPatternOnElementAddedToSelection);

                        if (eventToRaise != AutomationEvents.PropertyChanged && AutomationPeer.ListenerExists(eventToRaise))
                        {
                            var peer = FrameworkElementAutomationPeer.CreatePeerForElement(this);
                            peer.RaiseAutomationEvent(eventToRaise);
                        }
                    }
                }
            }
        }
Exemplo n.º 8
0
        protected override void OnKeyUp(KeyEventArgs e)
        {
            if (SelectionModel != null)
            {
                if (e.Key == Key.Escape)
                {
                    SelectionModel.ClearSelection();
                }
                else if (e.Key == Key.Space)
                {
                    Select();
                }
                else if (!SelectionModel.SingleSelect)
                {
                    var isShiftPressed = Keyboard.Modifiers.HasFlag(ModifierKeys.Shift);
                    var isCtrlPressed  = Keyboard.Modifiers.HasFlag(ModifierKeys.Control);
                    if (e.Key == Key.A && isCtrlPressed)
                    {
                        SelectionModel.SelectAll();
                    }
                    else if (isShiftPressed)
                    {
                        SelectionModel.SelectRangeFromAnchor(GetGroupIndex(), RepeatedIndex);
                    }
                }
            }

            base.OnKeyUp(e);
        }
Exemplo n.º 9
0
        private void OnselectionModelChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            if (e.PropertyName == "SelectedIndices")
            {
                bool oldValue   = IsSelected;
                var  groupIndex = GetGroupIndex();
                bool newValue   = groupIndex >= 0 ? SelectionModel.IsSelected(groupIndex, RepeatedIndex).Value : false;

                if (oldValue != newValue)
                {
                    IsSelected = newValue;

                    // AutomationEvents.PropertyChanged is used as a value that means dont raise anything
                    AutomationEvents eventToRaise =
                        oldValue ?
                        (SelectionModel.SingleSelect ? AutomationEvents.PropertyChanged : AutomationEvents.SelectionItemPatternOnElementRemovedFromSelection) :
                        (SelectionModel.SingleSelect ? AutomationEvents.SelectionItemPatternOnElementSelected : AutomationEvents.SelectionItemPatternOnElementAddedToSelection);

                    if (eventToRaise != AutomationEvents.PropertyChanged && AutomationPeer.ListenerExists(eventToRaise))
                    {
                        var peer = FrameworkElementAutomationPeer.CreatePeerForElement(this);
                        peer.RaiseAutomationEvent(eventToRaise);
                    }
                }
            }
        }
Exemplo n.º 10
0
        public static AvailableSessionsViewModel CreateViewModel(
            Time time,
            Individual individual,
            SelectionModel selectionModel)
        {
            Frame frame = null;

            if (Window.Current != null)
            {
                frame = Window.Current.Content as Frame;
            }

            Action showSession = () =>
            {
                if (frame != null)
                {
                    frame.Navigate(typeof(SessionView));
                }
            };

            Func <SessionPlace, SessionHeaderViewModel> newSessionHeaderViewModel = sessionPlace =>
                                                                                    new SessionHeaderViewModel(sessionPlace, individual, selectionModel, showSession);

            return(new AvailableSessionsViewModel(time, newSessionHeaderViewModel));
        }
Exemplo n.º 11
0
        /// <summary>
        /// When a textblock shape is selected make a preview of the selected table.
        /// </summary>
        /// <param name="model">SelectionModel.</param>
        private void HandleSelectionModelChanged(object model)
        {
            SelectionModel selectionModel = model as SelectionModel;

            if (selectionModel.Selected.Count != 0)
            {
                var selected = selectionModel.Selected[0];
                // FIXME: Handle when more than one.
                propertyGrid.CurrentObject = selected;
                //propertyGrid.Populate();
                if (selected is TextBlockShape)
                {
                    string title = (selected as TextBlockShape).Title;
                    populateGrid(morphose.GetModel().DB.GetTable(title));
                }
                else if (selected is EllipseShape)
                {
                    for (int i = 0; i < schemaV.Scene.Shapes.Count; i++)
                    {
                        Shape block = schemaV.Scene.Shapes[0];
                        if (block is TextBlockShape)
                        {
                            string title = (block as TextBlockShape).Title;
                            ViewFilterResults(new Filter(1, Filter.ConditionRelations.LessThan),
                                              morphose.GetModel().DB.GetTable(title));
                        }
                    }
                }
            }
        }
Exemplo n.º 12
0
        public void Assigning_Selection_Should_Set_Item_IsSelected()
        {
            var items = new[]
            {
                new ListBoxItem(),
                new ListBoxItem(),
                new ListBoxItem(),
            };

            var target = new TestSelector
            {
                Items    = items,
                Template = Template(),
            };

            target.ApplyTemplate();
            target.Presenter.ApplyTemplate();

            var selection = new SelectionModel {
                Source = items
            };

            selection.SelectRange(new IndexPath(0), new IndexPath(1));
            target.Selection = selection;

            Assert.True(items[0].IsSelected);
            Assert.True(items[1].IsSelected);
            Assert.False(items[2].IsSelected);
        }
Exemplo n.º 13
0
        public async Task <string> Save(Guid token, SelectionModel options, bool allNews)
        {
            SubscriberInfo info = GetSubscriberInfo(options, allNews);

            await Repository.ApiClient.Subscribe.UpdateNewsOnDemandEmailSubscriptionWithPreferencesAsync(token, Repository.APIVersion, info);

            return("Your changes have been successfully saved");
        }
Exemplo n.º 14
0
 [SetUp] public void SetUp()
 {
     _filters               = new JetListViewFilterCollection();
     _nodeCollection        = new JetListViewNodeCollection(_filters);
     _model                 = new MultipleSelectionModel(_nodeCollection);
     _selectionStateChanges = new ArrayList();
     _activeNodeChanges     = 0;
 }
Exemplo n.º 15
0
 public TreeViewSample()
 {
     this.InitializeComponent();
     selectionModel                  = (SelectionModel)Resources[nameof(selectionModel)];
     rootRepeater.ItemsSource        = _data;
     selectionModel.Source           = _data;
     selectionModel.PropertyChanged += SelectionModel_PropertyChanged;
 }
Exemplo n.º 16
0
 private void OnSelectionChanged(SelectionModel sender, SelectionModelSelectionChangedEventArgs args)
 {
     if (AutomationPeer.ListenerExists(AutomationEvents.SelectionPatternOnInvalidated))
     {
         var peer = (SelectionContainerAutomationPeer)FrameworkElementAutomationPeer.CreatePeerForElement(this);
         peer.SelectionChanged(args);
     }
 }
Exemplo n.º 17
0
 public FolderCopyViewModel(IDispatcherWrapper dispatcher, IFolderSearcher folderSearcher, IRandomFolderSelector folderSelector, IFolderCopier folderCopier, ISerializationHelper serializationHelper, IDialogService dialogService, IOpenerHelper openerHelper)
     : base(dispatcher ?? new DispatcherWrapper(), serializationHelper ?? new SerializationHelper(), dialogService ?? new DialogService(), openerHelper ?? new OpenerHelper())
 {
     _folderSearcher = folderSearcher ?? new FolderSearcher();
     _folderSelector = folderSelector ?? new RandomFolderSelector();
     _folderCopier   = folderCopier ?? new FolderCopier();
     SelectionModel  = new SelectionModel(0, 100, UnitSize.GB);
     Model           = new SourceDestinationModel <CopyRepresenter>();
 }
Exemplo n.º 18
0
        public ScheduleSlotViewModel(Time time, Individual individual, Schedule schedule, SelectionModel selection)
        {
            _time       = time;
            _individual = individual;
            _schedule   = schedule;
            _selection  = selection;

            _sessionPlace = new Dependent <SessionPlace>(() => SessionPlace);
        }
Exemplo n.º 19
0
 public IList <SearchLogic> CreateAll(SelectionModel viewModel)
 {
     return(new List <SearchLogic>
     {
         new SongSearchLogic(viewModel),
         new AlbumSearchLogic(viewModel),
         new ArtistSearchLogic(viewModel)
     });
 }
Exemplo n.º 20
0
 public MyScheduleViewModel(
     Conference conference,
     SelectionModel selection,
     Func <Day, ScheduleDayViewModel> newScheduleDay)
 {
     _conference     = conference;
     _selection      = selection;
     _newScheduleDay = newScheduleDay;
 }
 public ReloadDefaultHudDataCommand(LocationModel locationModel, PlaceHolderCollectionModel placeHolderCollection,
                                    SelectionModel selectionModel, LayoutIOModel layoutIO, SelectedProfileModel selectedProfile)
 {
     this.locationModel         = locationModel;
     this.placeHolderCollection = placeHolderCollection;
     this.selectionModel        = selectionModel;
     this.layoutIO        = layoutIO;
     this.selectedProfile = selectedProfile;
 }
Exemplo n.º 22
0
 public MainViewModel(
     SynchronizationService synchronizationService,
     SearchModel search,
     SelectionModel selection)
 {
     _synchronizationService = synchronizationService;
     _search    = search;
     _selection = selection;
 }
Exemplo n.º 23
0
        public ActionResult Report(SelectionModel selectionModel)
        {
            var orders = from p in db.Orders
                         where p.Date >= selectionModel.DateStart && p.Date <= selectionModel.DateEnd
                         select p;

            ViewBag.ReportResult = orders;
            return(View("ReportView"));
        }
Exemplo n.º 24
0
        public JsonResult UpdateSelection(SelectionModel model)
        {
            if (ModelState.IsValid)
            {
                var newId = this.tradingContentService.AddOrUpdateSelection(model);
                return(Json(new { id = newId, label = model.Label }, JsonRequestBehavior.DenyGet));
            }

            return(null);
        }
        public void CreateSelectionViewModel(ChoixBoissonSucreMugViewModel selection)
        {
            SelectionModel selectionModel = new SelectionModel
            {
                FkBoissonM       = selection.Boisson.IdM,
                FkQuantiteSucreM = selection.Sucre.IdM,
                MugPersonM       = selection.MugPerso
            };

            selectionModel.CreatSelectionModel(selectionModel);
        }
Exemplo n.º 26
0
        [SetUp] public void SetUp()
        {
            _nodeCollection   = new JetListViewNodeCollection(null);
            _columnCollection = new JetListViewColumnCollection();
            _selectionModel   = new MultipleSelectionModel(_nodeCollection);
            _rowListRenderer  = new RowListRenderer(_nodeCollection, _selectionModel);
            _rowRenderer      = new MockRowRenderer(_columnCollection);

            _incSearcher             = new IncrementalSearcher(_nodeCollection, _rowListRenderer, _selectionModel);
            _incSearcher.RowRenderer = _rowRenderer;
        }
Exemplo n.º 27
0
        public TreeViewPageViewModel()
        {
            _root = new Node();

            Items     = _root.Children;
            Selection = new SelectionModel();
            Selection.SelectionChanged += SelectionChanged;

            AddItemCommand    = ReactiveCommand.Create(AddItem);
            RemoveItemCommand = ReactiveCommand.Create(RemoveItem);
        }
Exemplo n.º 28
0
        protected void HandleDesignerCurrentSheetChanged(ISheet sheet)
        {
            SelectionModel selection = (sheet as Sheet <Gdk.Event, Cairo.Context, SolidV.MVC.Model>).Model.GetSubModel <SelectionModel>();

            if (selection != currentSelectionModel)
            {
                currentSelectionModel.ModelChanged -= HandleSelectionModelChanged;
            }
            currentSelectionModel = selection;
            currentSelectionModel.ModelChanged += HandleSelectionModelChanged;
        }
Exemplo n.º 29
0
 public ScheduleTimeViewModel(
     Time time,
     Individual individual,
     SelectionModel selection,
     Func <Time, Schedule, ScheduleSlotViewModel> newScheduleSlot)
 {
     _time            = time;
     _individual      = individual;
     _selection       = selection;
     _newScheduleSlot = newScheduleSlot;
 }
Exemplo n.º 30
0
        public override void Do()
        {
            SelectionModel sm = (Designer.CurrentSheet as Sheet <Gdk.Event, Cairo.Context, SolidV.MVC.Model>).Model.GetSubModel <SelectionModel>();

            for (int i = 0; i < sm.Selected.Count - 1; i++)
            {
                BinaryRelationShape binaryRelation = (BinaryRelationShape)NewShape.DeepCopy();
                binaryRelation.From = sm.Selected[i];
                binaryRelation.To   = sm.Selected[i + 1];
                Designer.AddShapes(binaryRelation);
            }
        }
Exemplo n.º 31
0
        public void CreateFirstGeneration()
        {
            //!!! Долго

            Ticker ticker = new Ticker
            {
                Id = 1,
                Name = "sber",
                Code = "sber",
            };
            TimeFrame timeFrame = new TimeFrame
            {
                Id = 10,
                Name = "10",
                ToMinute = 10
            };
            StrategyInfo strategyInfo = new StrategyInfo
            {
                Id = 20,
                Name = "Mock",
                TypeName = "RMarket.Examples.Strategies.StrategyMock, RMarket.Examples"
            };

            SelectionModel selection = new SelectionModel
            {
                Id = 30,
                Name = "TestSelection",
                TickerId = ticker.Id,
                Ticker = ticker,
                TimeFrameId = timeFrame.Id,
                TimeFrame=timeFrame,
                StrategyInfoId = strategyInfo.Id,
                StrategyInfo=strategyInfo,
                AmountResults = 10,
                Balance = 1000,
                CreateDate = new DateTime(2016, 1, 1),
                DateFrom = new DateTime(2016, 1, 1),
                DateTo = new DateTime(2016, 1, 10),
                Description = "for test",
                GroupID = new Guid("7ada9499-cb8e-44ad-862a-a93920ff4760"),
                Slippage = 0.01M,
                Rent = 0.1M,
                SelectionParams = new List<ParamSelection>
                {
                    new ParamSelection
                    {
                        FieldName="Param1",
                        TypeName = "System.Int32",
                        ValueMin = 6,
                        ValueMax=10
                    },
                    new ParamSelection
                    {
                        FieldName="Param2",
                        ValueMin = (byte)1,
                        TypeName = "System.Byte",
                        ValueMax=(byte)5
                    },
                    new ParamSelection
                    {
                        FieldName="OtherParam",
                        TypeName = "System.Boolean",
                        ValueMin = true,
                        ValueMax=true
                    }
                    //Добавить вещественный
                }
            };

            List<InstanceModel> instances1 = OptimizationHelper.CreateFirstGeneration(selection);

            Assert.AreEqual(10, instances1.Count);
            Assert.AreEqual(1, instances1[0].TickerId);
            Assert.AreEqual(10, instances1[0].TimeFrameId);
            Assert.AreEqual(20, instances1[0].StrategyInfoId);
            Assert.AreEqual(30, instances1[0].SelectionId);

            Assert.AreEqual(true, instances1[0].StrategyParams.Any(p=>p.FieldName== "OtherParam" && (bool)p.FieldValue==true));
            Assert.AreEqual(true, instances1[0].StrategyParams.Any(p=>p.FieldName== "Param1" && (int)p.FieldValue >= 6 && (int)p.FieldValue <= 10));
            Assert.AreEqual(true, instances1[0].StrategyParams.Where(p=>p.FieldName == "Param2").Single().FieldValue.GetType() == typeof(byte));

        }