コード例 #1
0
        public AddProfileViewModel(DelcomConfiguration delcomConfiguration, ObservableCollection<DelcomProfileViewModel> existingProfiles, IMediator mediator)
        {
            this.existingProfiles = existingProfiles;
            this.mediator = mediator;

            var emptyProfile = (MonitoringProfile)delcomConfiguration.GenerateEmptyProfile();
            NewProfile = new DelcomProfileViewModel(emptyProfile);
                
            CloneProfileCommand = new DelegateCommand<DelcomProfileViewModel>(CloneProfile, p => p != null);
            SaveProfileCommand = new DelegateCommand<DelcomProfileViewModel>(SaveProfile, CanSaveProfile);
        }
コード例 #2
0
 private void CloneProfile(DelcomProfileViewModel profileToClone)
 {
     var profile = (MonitoringProfile)NewProfile.GetProfile();
     profile.States.Clear();
     NewProfile.States.Clear();
     foreach (var state in profileToClone.States)
     {
         var profileState = new ProfileState
         {
             BuildState = state.BuildState,
             Green = state.Green,
             Yellow = state.Yellow,
             Red = state.Red,
             Flash = state.Flash
         };
         profile.States.Add(profileState);
         NewProfile.States.Add(new ProfileStateViewModel(profileState));
     }
 }
コード例 #3
0
 private void SaveProfile(DelcomProfileViewModel profileViewModel)
 {
     mediator.Publish(new ProfileAddedEvent(profileViewModel.GetProfile()));
 }
コード例 #4
0
 private bool CanSaveProfile(DelcomProfileViewModel profile)
 {
     return profile != null && !string.IsNullOrWhiteSpace(profile.Name);
 }