Exemple #1
0
 public PrerequisitesSet(Focus focus)
 {
     this.Focus = focus;
     FociList   = new List <Focus>();
 }
Exemple #2
0
 private void NotificationMessageReceived(NotificationMessage msg)
 {
     if (!this.isShown || this.Filename == null)
     {
         //is not shown, do not manage
         return;
     }
     if (msg.Notification == "HideAddFocus")
     {
         System.Windows.Application.Current.Properties["Mode"] = null;
         AddFocusViewModel viewModel = msg.Sender as AddFocusViewModel;
         addFocusToList(viewModel.Focus);
         RaisePropertyChanged(() => FociList);
         DrawOnCanvas();
     }
     if (msg.Notification == "HideEditFocus")
     {
         System.Windows.Application.Current.Properties["Mode"] = null;
         EditGridDefinition();
         DrawOnCanvas();
     }
     if (msg.Notification == "DeleteFocus")
     {
         Focus Model = (Focus)msg.Sender;
         //Kill the set that might have this focus as parent
         foreach (Focus focus in FociList)
         {
             foreach (PrerequisitesSet set in focus.Prerequisite.ToList())
             {
                 if (set.FociList.Contains(Model))
                 {
                     set.DeleteSetRelations();
                 }
             }
         }
         FociList.Remove(Model);
         RaisePropertyChanged(() => FociList);
         EditGridDefinition();
         DrawOnCanvas();
     }
     if (msg.Notification == "AddFocusMutually")
     {
         System.Windows.Application.Current.Properties["Mode"] = "Mutually";
         Focus Model = (Focus)msg.Sender;
         selectedFocus    = Model;
         Model.IsSelected = true;
     }
     if (msg.Notification == "FinishAddFocusMutually")
     {
         Focus Model = (Focus)msg.Sender;
         if (selectedFocus != null && selectedFocus != Model &&
             FociList.Where((f) => f == Model).Any())
         {
             System.Windows.Application.Current.Properties["Mode"] = null;
             selectedFocus.IsSelected = false;
             var tempo = new MutuallyExclusiveSet(selectedFocus, Model);
             selectedFocus.MutualyExclusive.Add(tempo);
             Model.MutualyExclusive.Add(tempo);
             DrawOnCanvas();
         }
     }
     if (msg.Notification == "AddFocusPrerequisite")
     {
         System.Windows.Application.Current.Properties["Mode"] = "Prerequisite";
         Focus Model = (Focus)msg.Sender;
         selectedFocus    = Model;
         Model.IsSelected = true;
     }
     if (msg.Notification == "FinishAddFocusPrerequisite")
     {
         Focus Model = (Focus)msg.Sender;
         if (selectedFocus != null && selectedFocus != Model &&
             FociList.Where((f) => f == Model).Any())
         {
             System.Windows.Application.Current.Properties["Mode"] = null;
             string Type = (string)System.Windows.Application.Current.Properties["ModeParam"];
             System.Windows.Application.Current.Properties["ModeParam"] = null;
             selectedFocus.IsSelected = false;
             if (Type == "Required")
             {
                 //Create new set
                 PrerequisitesSet set = new PrerequisitesSet(selectedFocus);
                 set.FociList.Add(Model);
                 selectedFocus.Prerequisite.Add(set);
             }
             else
             {
                 //Create new set if no exist
                 if (!selectedFocus.Prerequisite.Any())
                 {
                     PrerequisitesSet set = new PrerequisitesSet(selectedFocus);
                     selectedFocus.Prerequisite.Add(set);
                 }
                 //Add Model to first Set
                 selectedFocus.Prerequisite.First().FociList.Add(Model);
             }
             RaisePropertyChanged(() => FociList);
             DrawOnCanvas();
         }
     }
     if (msg.Notification == "ContainerRenamed")
     {
         RaisePropertyChanged(() => Filename);
     }
 }