示例#1
0
        private void updateFirstAndAddLastEntry(double?lastEntryMinimum = null)
        {
            var values = _numericField.GetValues(_populationDataCollector);

            if (_fixedLimitDTOs.Count == 0)
            {
                _fixedLimitDTOs.Add(newDTO());
            }

            var firstDTO = _fixedLimitDTOs[0];

            firstDTO.CanDelete = false;
            firstDTO.Minimum   = _numericField.ValueInDisplayUnit(values.Min());

            double?minimumInDisplayUnit = null;

            if (lastEntryMinimum != null)
            {
                minimumInDisplayUnit = _numericField.ValueInDisplayUnit(lastEntryMinimum.Value);
            }

            //Last item
            _fixedLimitDTOs.Add(newDTO(canDelete: false, canAdd: false,
                                       maximumInDisplayUnit: _numericField.ValueInDisplayUnit(values.Max()),
                                       maximumEditable: false, minimumInDisplayUnit: minimumInDisplayUnit));
        }
示例#2
0
        public void AddOutputMapping()
        {
            var newOutputMapping = new OutputMapping();

            _parameterIdentification.AddOutputMapping(newOutputMapping);
            _allOutputMappingDTOs.Add(mapFrom(newOutputMapping));
            OnStatusChanged();
        }
 private void addToSelection(Compound compoundAdded)
 {
     if (compoundAdded == null)
     {
         return;
     }
     _compoundSelectionDTOs.Add(mapFrom(compoundAdded, isSelected: true));
 }
示例#4
0
        public void NotifyListSerializationTest()
        {
            NotifyList <NotifyTestItem> list = new NotifyList <NotifyTestItem>();

            list.Add(new NotifyTestItem("Test1"));
            list.Add(new NotifyTestItem("Test2"));

            var deserializedList = JsonConvert.DeserializeObject(JsonConvert.SerializeObject(list));

            Assert.AreEqual("Test1", list[0].Value);
            Assert.AreEqual("Test2", list[1].Value);
        }
        private void rebind()
        {
            if (IsLatched)
            {
                return;
            }
            _metaDataDTOList = new NotifyList <MetaDataDTO>();
            _allDataRepositories.ToList().IntersectingMetaData().Each(x => _metaDataDTOList.Add(createDTO(x)));
            _view.BindToMetaData(_metaDataDTOList);

            _view.MolWeightEditable = _observedDataConfiguration.MolWeightAlwaysEditable || !_allDataRepositories.Any(x => x.ExtendedProperties.Contains(Captions.Molecule));

            var molWeightParameter    = retrieveUniqueMolWeightParameter();
            var shouldBindToMolWeight = molWeightParameter != null && _observedDataConfiguration.MolWeightVisible;

            _view.MolWeightVisible = shouldBindToMolWeight;

            if (shouldBindToMolWeight)
            {
                _view.BindToMolWeight(molWeightParameter);
            }

            var lowerLimitsOfQuantification = retrieveLLOQs().ToList();

            if (lowerLimitsOfQuantification.Count == 1)
            {
                _view.BindToLLOQ(lowerLimitsOfQuantification.First());
            }
        }
示例#6
0
        private JournalPageDTO addJournalPage(JournalPage journalPage, Func <JournalPage, string> descriptionFunc = null)
        {
            var dto = _mapper.MapFrom(journalPage, descriptionFunc);

            _allJournalPageDTOs.Add(dto);
            return(dto);
        }
 public void Handle(AddSchemaToProtocolEvent eventToHandle)
 {
     if (!canHandle(eventToHandle))
     {
         return;
     }
     _allSchemas.Add(_schemaDTOMapper.MapFrom(eventToHandle.Entity));
     OnStatusChanged();
 }
 protected override void Context()
 {
     sut = new NotifyList <IAnInterface>();
     _implementation0 = new AnImplementation {
         FirstName = "aaa"
     };
     sut.Add(_implementation0);
     _reference = new WeakReference(_implementation0);
 }
        protected override void Context()
        {
            sut = new NotifyList <IAnInterface>();
            _implementation0 = new AnImplementation {
                FirstName = "aaa"
            };
            _implementation1 = new AnImplementation {
                FirstName = "toto"
            };
            _implementation2 = new AnImplementation {
                FirstName = "tata"
            };
            sut.Add(_implementation0);
            sut.Add(_implementation1);
            sut.Add(_implementation2);

            sut.CollectionChanged += (o, e) =>
            {
                _eventWasRaised  = true;
                _action          = e.Action;
                _changeEventArgs = e;
            };
        }
        public void InitializeWith(IPopulationAnalysisField populationAnalysisField, IPopulationDataCollector populationDataCollector)
        {
            _dataField = populationAnalysisField as PopulationAnalysisDataField <string>;

            //this should never happen
            if (_dataField == null)
            {
                throw new ArgumentException(PKSimConstants.Error.GroupingCannotBeUsedWithFieldOfType(populationAnalysisField.DataType, GroupingDefinitions.ValueMapping.DisplayName));
            }

            _groupingDefinition = new ValueMappingGroupingDefinition(populationAnalysisField.Name);
            var values = _dataField.GetValues(populationDataCollector).Distinct().ToList();

            values.Each(v => _mapping.Add(mapFrom(v)));
        }
示例#11
0
        private void updateNotificationWith(IEnumerable <NotificationMessageDTO> notificationMessages)
        {
            _allNotifications = new NotifyList <NotificationMessageDTO>(_allNotifications);


            notificationMessages.Where(notificationIsVisible).Each(m =>
            {
                if (!_allNotifications.Contains(m))
                {
                    _allNotifications.Add(m);
                }
            });

            bindToView();
        }
示例#12
0
        public void Handle(FormulaInvalidEvent eventToHandle)
        {
            var notificationMessageDTO = _notificationMessageMapper.MapFrom(eventToHandle.Formula, eventToHandle.BuildingBlock);

            notificationMessageDTO.NotificationMessage.Message = eventToHandle.Message;
            if (_allNotifications.Contains(notificationMessageDTO))
            {
                _allNotifications[_allNotifications.IndexOf(notificationMessageDTO)].NotificationMessage.Message = eventToHandle.Message;
            }
            else
            {
                _allNotifications.Add(notificationMessageDTO);
            }

            updateNotificationCount();
        }
示例#13
0
        public BodyNode(WorldObject world, BodyDefSerialized x) :
            base(x.Name, 3)
        {
            Body = x.Body;
            Name = x.Name;

            for (int i = 0; i < x.FixtureIDs.Count; ++i)
            {
                var fixture = world.Fixtures[x.FixtureIDs[i]];
                _fixtures.Add(fixture);
            }

            _mass = Body.ComputeMass(OnlyFixtures);

            _fixtures.ObjectsAdded   += new EventHandler(_fixtures_ObjectsAdded);
            _fixtures.ObjectsRemoved += new EventHandler(_fixtures_ObjectsRemoved);
        }
示例#14
0
        public void NotifyList_AddNew_Class_With_Events()
        {
            _ObservableList.Add(null);

            AttachEventRecorders(_ObservableList);
            var added = (ObservableClass)_ObservableList.AddNew();

            Assert.AreEqual(0, added.Value);

            Assert.AreEqual(1, _ListChanged.CallCount);
            Assert.AreEqual(ListChangedType.ItemAdded, _ListChanged.Args.ListChangedType);
            Assert.AreEqual(1, _ListChanged.Args.NewIndex);
            Assert.AreEqual(-1, _ListChanged.Args.OldIndex);
            Assert.AreEqual(null, _ListChanged.Args.PropertyDescriptor);

            Assert.AreEqual(1, _CollectionChanged.CallCount);
        }
示例#15
0
        public async void Run(IBackgroundTaskInstance taskInstance)
        {
            deferral_ = taskInstance.GetDeferral();
            Debug.WriteLine("NotifyTask started");
            try
            {
                var file = await ApplicationData.Current.LocalFolder.CreateFileAsync("UserSession.dat", CreationCollisionOption.OpenIfExists);

                var r = await FileIO.ReadTextAsync(file);

                if (string.IsNullOrEmpty(r))
                {
                    return;
                }
                if (r.Length < 100)
                {
                    return;
                }
                string User = "******"; string Pass = "******";
                InstaApi = InstaApiBuilder.CreateBuilder()
                           .SetUser(new UserSessionData {
                    UserName = User, Password = Pass
                })
                           .UseLogger(new DebugLogger(LogLevel.Exceptions))
                           .Build();
                InstaApi.LoadStateDataFromStream(r);
                if (!InstaApi.IsUserAuthenticated)
                {
                    await InstaApi.LoginAsync();
                }
                if (!InstaApi.IsUserAuthenticated)
                {
                    return;
                }
                var activities = await InstaApi.GetRecentActivityAsync(PaginationParameters.MaxPagesToLoad(1));

                Notifies = await Load();

                if (Notifies == null)
                {
                    Notifies = new NotifyList();
                }
                if (activities.Succeeded)
                {
                    const int MAX = 9;
                    int       ix  = 0;
                    foreach (var item in activities.Value.Items)
                    {
                        var text = item.Text;
                        if (item.Text.Contains(" "))
                        {
                            text = text.Substring(text.IndexOf(" ") + 1);
                            text = text.TrimStart();
                        }
                        if (!Notifies.IsExists(text))
                        {
                            try
                            {
                                var n = new NotifyClass
                                {
                                    IsShowing      = false,
                                    ProfileId      = item.ProfileId,
                                    ProfilePicture = item.ProfileImage,
                                    Text           = text,
                                    TimeStamp      = item.TimeStamp.ToString(),
                                    Type           = item.Type,
                                };

                                if (item.InlineFollow == null)
                                {
                                    var user = await InstaApi.GetUserInfoByIdAsync(item.ProfileId);

                                    if (user.Succeeded)
                                    {
                                        n.Username = user.Value.Username;
                                    }
                                }
                                else
                                {
                                    n.Username       = item.InlineFollow.User.UserName;
                                    n.IsFollowingYou = item.InlineFollow.IsFollowing;
                                }
                                Notifies.Add(n);
                            }
                            catch { }
                        }
                        ix++;
                        if (ix > MAX)
                        {
                            break;
                        }
                    }
                    var list = Notifies;
                    list.Reverse();
                    for (int i = 0; i < list.Count; i++)
                    {
                        var item = list[i];
                        if (!string.IsNullOrEmpty(item.Username))
                        {
                            if (!item.IsShowing)
                            {
                                NotifyHelper.CreateNotifyAction($"@{item.Username}",
                                                                item.Text,
                                                                item.ProfilePicture);
                                Notifies[i].IsShowing = true;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Notify ex: " + ex.Message);
                Debug.WriteLine("Source: " + ex.Source);
                Debug.WriteLine("StackTrace: " + ex.StackTrace);
            }
            await Save();

            await Task.Delay(1000);

            deferral_.Complete();
        }
示例#16
0
        public void NotifyList_Add_Struct_With_Events()
        {
            _IntList.Add(9);

            AttachEventRecorders(_IntList);
            _IntList.Add(10);

            Assert.AreEqual(1, _ListChanged.CallCount);
            Assert.AreEqual(ListChangedType.ItemAdded, _ListChanged.Args.ListChangedType);
            Assert.AreEqual(1, _ListChanged.Args.NewIndex);
            Assert.AreEqual(-1, _ListChanged.Args.OldIndex);
            Assert.AreEqual(null, _ListChanged.Args.PropertyDescriptor);

            Assert.AreEqual(1, _CollectionChanged.CallCount);
        }
 public void NewMetaDataAdded()
 {
     _metaDataDTOList.Add(createDTO(name: string.Empty, value: string.Empty));
 }