Ejemplo n.º 1
0
 private void NewOrder(PropertyChangedMessage <OrderVM> obj)
 {
     App.Current.Dispatcher.Invoke(() =>
     {
         Orders.Add(obj.NewValue);
     });
 }
Ejemplo n.º 2
0
        private void ChangeContainer(PropertyChangedMessage <ViewMode> obj)
        {
            var newViewMode = obj.NewValue;

            CurrentViewMode = newViewMode;
            ToggleEditingContainer();
        }
Ejemplo n.º 3
0
 public void SendPropertyChangedMessage(PropertyChangedMessage message)
 {
     if (PropChangedMessageRecevied != null)
     {
         PropChangedMessageRecevied(this, new PropertyChangedMessageEventArgs(message));
     }
 }
Ejemplo n.º 4
0
            private void UpdateList(PropertyChangedMessage <Person> obj)
            {
                var person         = obj.NewValue;
                var observedPerson = People.FirstOrDefault(i => i.Id == person.Id);

                //add person if new to persist
                if (observedPerson == null && !person.IsEmpty)
                {
                    People.Add(person);
                    _peopleService.AddPerson(person);
                }
                //if found and delete flag set
                if (person.Delete)
                {
                    People.Remove(person);
                    _peopleService.RemovePerson(person);
                }
                //if found, do an update
                else if (observedPerson != null)
                {
                    observedPerson.FirstName = person.FirstName;
                    observedPerson.LastName  = person.LastName;
                    observedPerson.Birthday  = person.Birthday;
                    observedPerson.Email     = person.Email;
                    observedPerson.Delete    = person.Delete;

                    _peopleService.UpdatePerson(person);
                }
            }
Ejemplo n.º 5
0
 private void ShowLoginIfNotSigned(PropertyChangedMessage <bool> isSigned)
 {
     if (!isSigned.NewValue)
     {
         var login = new LoginView();
         login.ShowDialog();
     }
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Broadcasts a PropertyChangedMessage using either the instance of
 /// the Messenger that was passed to this class (if available)
 /// or the Messenger's default instance.
 /// </summary>
 /// <typeparam name="T">The type of the property that
 /// changed.</typeparam>
 /// <param name="oldValue">The value of the property before it
 /// changed.</param>
 /// <param name="newValue">The value of the property after it
 /// changed.</param>
 /// <param name="propertyName">The name of the property that
 /// changed.</param>
 protected virtual void Broadcast <T>(T oldValue, T newValue, string propertyName)
 {
     if (this.Notification != null)
     {
         PropertyChangedMessage <T> message = new PropertyChangedMessage <T>(this, oldValue, newValue, propertyName);
         this.Notification.Publish <PropertyChangedMessage <T> >(this.TopicID, message);
     }
 }
Ejemplo n.º 7
0
 private void ShowLoginIfNotSigned(PropertyChangedMessage<bool> isSigned)
 {
     if(!isSigned.NewValue)
     {
         var login = new LoginView();
         login.ShowDialog();
     }
 }
Ejemplo n.º 8
0
 private void ReceivePropertyChangedMessage(PropertyChangedMessage <DateTime> message)
 {
     if (message.PropertyName
         == OldTestViewModel.LastChanged2PropertyName)
     {
         DateTimeContent = message.Content;
     }
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Get new value of MainViewModel list setting change
 /// </summary>
 /// <param name="propertyDetails"></param>
 private void SearchListSettingMainViewModelChanged(PropertyChangedMessage <List <SettingItems> > propertyDetails)
 {
     if (propertyDetails.PropertyName == nameof(ListSetting))
     {
         ListSetting = propertyDetails.NewValue;
         logger.Info("SettingViewModel|SearchMainViewModelListSettingChanged()");
     }
 }
        public void OnPropertyChangedMessageReceived(PropertyChangedMessage message)
        {
            if (ReferenceEquals(this, message.Sender))
            {
                return;
            }

            AddPropertyChange(message.PropertyName, message.Sender.GetType());
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Sends the property changed message and raises this object's PropertyChanged event.
        /// </summary>
        /// <typeparam name="T">The type of the property that has a new value</typeparam>
        /// <param name="propertyExpression">A Lambda expression representing the property that has a new value.</param>
        /// <param name="oldValue">The old property value.</param>
        /// <param name="newValue">The new property value.</param>
        protected void SendPropertyChangedMessage <T>(Expression <Func <T> > propertyExpression, object oldValue, object newValue)
        {
            var propertyName = ReflectionHelper.ExtractPropertyName(propertyExpression);

            RaisePropertyChanged(propertyName);

            var message = new PropertyChangedMessage(this, propertyName, oldValue, newValue);

            Messenger.Current.PublishAsync(message);
        }
 /// <summary>
 /// Opens the Create Routine User Control
 /// </summary>
 /// <param name="obj"></param>
 public void OpenCreateRoutinePage(PropertyChangedMessage <string> obj)
 {
     // Continues if the propertyName matches
     if (obj.PropertyName == "OpenCreateRoutine")
     {
         // Sets the overlay effect on
         IsOverlayEffectUsed        = true;
         IsCreateRoutinePageVisible = true;
     }
 }
Ejemplo n.º 13
0
        private void HandleStatus(PropertyChangedMessage <string> message)
        {
            var child = ((ItemInfoViewModel)message.Sender);

            if (Children.Contains(child) &&
                (message.PropertyName == nameof(ItemInfoViewModel.Status)))
            {
                Status = child.Status;
            }
        }
Ejemplo n.º 14
0
        private void HandleBusyChild(PropertyChangedMessage <bool> message)
        {
            var child = ((ItemInfoViewModel)message.Sender);

            if (Children.Contains(child) &&
                (message.PropertyName == nameof(ItemInfoViewModel.IsBusy)))
            {
                IsBusy = child.IsBusy;
            }
        }
 /// <summary>
 /// Changes the selected routine and updates the routine exercises
 /// </summary>
 /// <param name="message"></param>
 public void ChangeExercisePage(PropertyChangedMessage <string> message)
 {
     // Continues if the propertyName matches
     if (message.PropertyName == "OpenRoutine")
     {
         // User selected some routine
         IsExercisePageVisible = true;
         // Sends the MVVM light message to populate the exercise list
         MessengerInstance.Send(new PropertyChangedMessage <string>("", message.NewValue, "GetExercises"));
     }
 }
Ejemplo n.º 16
0
 private void generateInfo(PropertyChangedMessage <string> obj)
 {
     //obj.NewValue -> message sent from OverviewVM
     MsgImage = new BitmapImage(new Uri(obj.NewValue.Split(';')[0], UriKind.Relative));
     InfoMsg  = obj.NewValue.Split(';')[1];
     IsInfo   = true;
     //ShowBorder = Visibility.Visible;
     timer.Interval = new TimeSpan(0, 0, 2);
     timer.Tick    += Timer_Tick;
     timer.Start();
 }
Ejemplo n.º 17
0
        public void ProcessMessage(PropertyChangedMessage <MessageItem> message)
        {
            MessageItem item = message.NewValue;

            Messages.Add(item);
            new Thread(() =>
            {
                Thread.Sleep(5000);
                Application.Current.Dispatcher.Invoke(() => { Messages.Remove(item); });
            }).Start();
        }
Ejemplo n.º 18
0
        private void ValidChanged(bool old)
        {
            if (old == IsValid)
            {
                return;
            }

            RaisePropertyChanged(nameof(IsValid));
            var message = new PropertyChangedMessage <bool>(this, old, IsValid, nameof(IsValid));

            Messenger.Default.Send(message);
        }
Ejemplo n.º 19
0
        /// <summary>A helper method that acts as a receiver for messages.</summary>
        /// <param name="message">The received message.</param>
        private void ReceivePropertyChangedMessage(PropertyChangedMessage <int> message)
        {
            DummyViewModel testSubject = message.Sender as DummyViewModel;

            if (testSubject != null)
            {
                if (message.PropertyName == "IntegerValue" && message.OldValue == testSubject.OriginalIntegerValue && message.NewValue == testSubject.IntegerValue)
                {
                    testSubject.IsHandledByMessage = true;
                }
            }
        }
Ejemplo n.º 20
0
        private void ChangeDetailView(PropertyChangedMessage <MessageContent> obj)
        {
            //Change ViewModle
            CurrentVm = navService.NavigateTo(obj.NewValue.ViewModelName);

            //Pass bearer Token
            if (obj.NewValue.Param != null)
            {
                //Send Guid to ViewModel -- die Zielview hört auf den identifier "VieModelNameIdentifier"
                messenger.Send <PropertyChangedMessage <MessageContent> >(new PropertyChangedMessage <MessageContent>(null, obj.NewValue, ""), obj.NewValue.ViewModelName + "Identifier");
            }
        }
Ejemplo n.º 21
0
        protected virtual void Broadcast(object oldValue, object newValue, string propertyName)
        {
            var message = new PropertyChangedMessage(this, this, oldValue, newValue, propertyName);

            if (MessengerInstance != null)
            {
                MessengerInstance.Send(message);
            }
            else
            {
                GalaSoft.MvvmLight.Messaging.Messenger.Default.Send(message);
            }
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Broadcasts a PropertyChangedMessage using either the instance of
        /// the Messenger that was passed to this class (if available)
        /// or the Messenger's default instance.
        /// </summary>
        /// <typeparam name="T">The type of the property that
        /// changed.</typeparam>
        /// <param name="oldValue">The value of the property before it
        /// changed.</param>
        /// <param name="newValue">The value of the property after it
        /// changed.</param>
        /// <param name="propertyName">The name of the property that
        /// changed.</param>
        protected virtual void Broadcast <T>(T oldValue, T newValue, string propertyName)
        {
            var message = new PropertyChangedMessage <T>(this, oldValue, newValue, propertyName);

            if (MessengerInstance != null)
            {
                MessengerInstance.Send(message);
            }
            else
            {
                Messenger.Default.Send(message);
            }
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Callback from the the messenger
        /// </summary>
        /// <param name="geometryMessage"></param>
        private void MapViewModelChanged(PropertyChangedMessage <LiteMapViewModel> mapViewModelMessage)
        {
            if (mapViewModelMessage.PropertyName == LiteMapsViewModel.CurrentMapPropertyName)
            {
                var model = mapViewModelMessage.NewValue;

                if (model != null)
                {
                    // Set the activate Map View for the printViewModel
                    this.MapView = model;
                }
            }
        }
Ejemplo n.º 24
0
        private void RouteMessage(PropertyChangedMessage <bool> pcm)
        {
            if (pcm.PropertyName == "Render")
            {
                if (pcm.Sender is ARenderable)
                {
                    UpdateRenderPipeLine(pcm.Sender as ARenderable, pcm.NewValue);
                }

                else
                {
                    UpdateRenderPipeLine();
                }
            }
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Event handler for dataset IsSelected property changed.
        /// When dataset is selected/unselected, update can executes.
        /// </summary>
        /// <param name="args">The message changed arguments, containing the new value.</param>
        private void UpdateDatasetSelection(PropertyChangedMessage <bool> args)
        {
            if (args.Sender is DatasetInformationViewModel && args.PropertyName == "IsSelected")
            {   // Make sure that this message is for DatasetInformationViewModel.IsSelected
                this.FindMsFeaturesCommand.RaiseCanExecuteChanged();
                this.PlotMsFeaturesCommand.RaiseCanExecuteChanged();
                this.PlotAlignedFeaturesCommand.RaiseCanExecuteChanged();

                // Add an event listener to update CanCreateXics whenever the Datasets collection changes
                this.CanCreateXics = this.Datasets
                                     .Where(dataset => dataset.IsSelected)
                                     .Select(dataset => RawLoaderFactory.CreateFileReader(dataset.Dataset.RawFile.Path, dataset.DatasetId))
                                     .Any(reader => reader != null && reader is ISpectraProvider);
            }
        }
Ejemplo n.º 26
0
        public void Test_ObservableRecipient_Broadcast()
        {
            var messenger = new Messenger();
            var viewmodel = new SomeRecipient <int>(messenger);

            PropertyChangedMessage <int> message = null;

            messenger.Register <PropertyChangedMessage <int> >(messenger, m => message = m);

            viewmodel.Data = 42;

            Assert.IsNotNull(message);
            Assert.AreSame(message.Sender, viewmodel);
            Assert.AreEqual(message.OldValue, 0);
            Assert.AreEqual(message.NewValue, 42);
            Assert.AreEqual(message.PropertyName, nameof(SomeRecipient <int> .Data));
        }
Ejemplo n.º 27
0
 public void DeselectRoutines(PropertyChangedMessage <string> message)
 {
     if (message.PropertyName == "DeselectRoutines")
     {
         foreach (var routine in RoutinesList)
         {
             if (routine.Id != message.NewValue)
             {
                 routine.IsSelected = false;
             }
             else
             {
                 routine.IsSelected = true;
             }
         }
     }
 }
Ejemplo n.º 28
0
 private void ReportChanged(PropertyChangedMessage <ReportVM> message)
 {
     if (message.Sender is MainViewModel && message.PropertyName == "SelectedReport")
     {
         _selectedReport = message.NewValue;
         if (_selectedReport != null)
         {
             LoadReport(_selectedReport);
             gridEdit.Visibility = Visibility.Visible;
         }
         else
         {
             _designer.Report = null;
             _designer.InitReport();
             gridEdit.Visibility = Visibility.Hidden;
         }
     }
 }
Ejemplo n.º 29
0
        private async Task UpdateLoadingStatusAsync(PropertyChangedMessage <bool> message)
        {
            if (message.PropertyName != nameof(ViewModelBase.IsLoading))
            {
                return;
            }

            var bar = StatusBar.GetForCurrentView();

            if (message.NewValue)
            {
                bar.ProgressIndicator.Text = Loc.GetLocalizedString(Localized.Loading);
                await bar.ProgressIndicator.ShowAsync();
            }
            else
            {
                await bar.ProgressIndicator.HideAsync();
            }
        }
Ejemplo n.º 30
0
        /// <summary>
        /// Callback from the the messenger when the mapview model changes
        /// </summary>
        private void MapViewModelChanged(PropertyChangedMessage <LiteMapViewModel> mapViewModelMessage)
        {
            if (mapViewModelMessage.PropertyName == LiteMapsViewModel.CurrentMapPropertyName)
            {
                var model = mapViewModelMessage.NewValue;

                if (model != null)
                {
                    this.MapViewModel = model;

                    // Set the newMapLayerViewModel to one that knows about the new MapViewModel
                    NewMapLayerViewModel = new LiteNewMapLayerViewModel(model, Messenger);

                    var removeVisibility = model.MapType == LiteMapType.User ? Visibility.Visible : Visibility.Collapsed;
                    foreach (var themeLayer in this.ThemeLayers)
                    {
                        themeLayer.RemoveVisibility = removeVisibility;
                    }
                }
            }
        }
Ejemplo n.º 31
0
        /// <summary>
        /// Event handler that is triggered when a feature is toggled.
        /// </summary>
        /// <param name="arg">Event arguments.</param>
        private void FeatureSelectionChanged(PropertyChangedMessage <bool> arg)
        {
            var umcLightViewModel = arg.Sender as UMCLightViewModel;

            if (umcLightViewModel != null)
            {
                foreach (var series in this.XicPlotModel.Series)
                {
                    var lineSeries = series as LineSeries;
                    if (lineSeries != null && lineSeries.ItemsSource.Any())
                    {
                        var msfeature = lineSeries.ItemsSource.First() as MSFeatureLight;
                        if (msfeature != null && msfeature.GroupId == umcLightViewModel.UMCLight.GroupId)
                        {
                            lineSeries.IsVisible = arg.NewValue;
                        }
                    }
                }

                this.XicPlotModel.InvalidatePlot(true);
            }
        }
        /// <summary>
        /// Selects an exercise
        /// </summary>
        /// <param name="obj"></param>
        private void SelectExercises(PropertyChangedMessage <AvailableExerciseListItemViewModel> obj)
        {
            // Checks if the object is null
            if (obj != null)
            {
                // Checks the property name
                if (obj.PropertyName == "ExerciseSelected")
                {
                    // Creates new exercise from the object value
                    var exercise = obj.NewValue;

                    bool doesExist = false;
                    // If the list is empty, add the exercise
                    if (SelectedExercisesList.ToList().Count == 0)
                    {
                        SelectedExercisesList.Add(exercise);
                    }
                    // Else looks for the exercise in the Selected Exercises List
                    else
                    {
                        // Using .ToList() to execute enumeration operation
                        foreach (var selectedExercise in SelectedExercisesList.ToList())
                        {
                            // If exercise already exists in this list that means the exercise was deselected
                            if (exercise.Id == selectedExercise.Id)
                            {
                                doesExist = true;
                                SelectedExercisesList.Remove(selectedExercise);
                            }
                        }

                        if (doesExist == false)
                        {
                            SelectedExercisesList.Add(exercise);
                        }
                    }
                }
            }
        }
Ejemplo n.º 33
0
 private void GeoDataModelPropertyChanged(PropertyChangedMessage<GeoPoint> message)
 {
     Model.Datum = message.NewValue.Datum;
     Model.Location = message.NewValue;
 }
Ejemplo n.º 34
0
 private void UriChanged(PropertyChangedMessage<MediaEntry> message)
 {
     MediaElement.Stop();
     MediaElement.Source = new Uri(message.NewValue.FullPath, UriKind.RelativeOrAbsolute);
     MediaElement.Play();
 }
Ejemplo n.º 35
0
 private void ReceivePropertyChangedMessage(PropertyChangedMessage<DateTime> message)
 {
     if (message.PropertyName
         == OldTestViewModel.LastChanged2PropertyName)
     {
         DateTimeContent = message.Content;
     }
 }
        // Helpers

        private void ExecuteTest(object sender, object target)
        {
            const string PropertyName1 = "MyProperty1";
            const string PropertyName2 = "MyProperty2";
            const string TestNewContent1 = "abcd";
            const string TestNewContent2 = "efgh";
            const string TestOldContent1 = "ijkl";
            const string TestOldContent2 = "mnop";

            string receivedNewContent1 = null;
            string receivedNewContent2 = null;
            string receivedOldContent1 = null;
            string receivedOldContent2 = null;

            object receivedSender = null;
            object receivedTarget = null;

            Messenger.Reset();

            Messenger.Default.Register<PropertyChangedMessage<string>>(this,
                                                                       m =>
                                                                       {
                                                                           receivedSender = m.Sender;
                                                                           receivedTarget = m.Target;

                                                                           if (m.PropertyName == PropertyName1)
                                                                           {
                                                                               receivedNewContent1 = m.NewValue;
                                                                               receivedOldContent1 = m.OldValue;
                                                                               return;
                                                                           }

                                                                           if (m.PropertyName == PropertyName2)
                                                                           {
                                                                               receivedNewContent2 = m.NewValue;
                                                                               receivedOldContent2 = m.OldValue;
                                                                               return;
                                                                           }
                                                                       });

            Assert.AreEqual(null, receivedNewContent1);
            Assert.AreEqual(null, receivedOldContent1);
            Assert.AreEqual(null, receivedNewContent2);
            Assert.AreEqual(null, receivedOldContent2);

            PropertyChangedMessage<string> propertyMessage1;
            PropertyChangedMessage<string> propertyMessage2;

            if (sender == null)
            {
                propertyMessage1 = new PropertyChangedMessage<string>(TestOldContent1, TestNewContent1, PropertyName1);
                propertyMessage2 = new PropertyChangedMessage<string>(TestOldContent2, TestNewContent2, PropertyName2);
            }
            else
            {
                if (target == null)
                {
                    propertyMessage1 = new PropertyChangedMessage<string>(sender,
                                                                          TestOldContent1,
                                                                          TestNewContent1,
                                                                          PropertyName1);
                    propertyMessage2 = new PropertyChangedMessage<string>(sender,
                                                                          TestOldContent2,
                                                                          TestNewContent2,
                                                                          PropertyName2);
                }
                else
                {
                    propertyMessage1 = new PropertyChangedMessage<string>(sender,
                                                                          target,
                                                                          TestOldContent1,
                                                                          TestNewContent1,
                                                                          PropertyName1);
                    propertyMessage2 = new PropertyChangedMessage<string>(sender,
                                                                          target,
                                                                          TestOldContent2,
                                                                          TestNewContent2,
                                                                          PropertyName2);
                }
            }

            Messenger.Default.Send(propertyMessage1);

            Assert.AreEqual(sender, receivedSender);
            Assert.AreEqual(target, receivedTarget);
            Assert.AreEqual(TestOldContent1, receivedOldContent1);
            Assert.AreEqual(TestNewContent1, receivedNewContent1);
            Assert.AreEqual(null, receivedOldContent2);
            Assert.AreEqual(null, receivedNewContent2);

            receivedTarget = null;
            receivedSender = null;

            Messenger.Default.Send(propertyMessage2);

            Assert.AreEqual(sender, receivedSender);
            Assert.AreEqual(target, receivedTarget);
            Assert.AreEqual(TestOldContent1, receivedOldContent1);
            Assert.AreEqual(TestNewContent1, receivedNewContent1);
            Assert.AreEqual(TestOldContent2, receivedOldContent2);
            Assert.AreEqual(TestNewContent2, receivedNewContent2);
        }