Exemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the MainViewModel class.
        /// </summary>
        public MainViewModel()
        {
            if (IsInDesignMode)
            {
                // Code runs in Blend --> create design time data.
            }
            else
            {
                noLabel = new LabelViewModel(new LabelMock() { Text = "No label" }, this);

                openNote = new OpenNoteCommand(this);
                newNote = new NewNoteCommand(this);
                closeNote = new CloseNoteCommand(this);
                deleteNote = new DeleteNoteCommand(this);
                saveNote = new SaveNoteCommand(this);
                delayedSaveNote = new DelayedSaveNoteCommand(this);
                simpleSearch = new SimpleSearchCommand(this);
                search = new ComplexSearchCommand(this);
                toggleSearch = new ToggleAdvancedSearchCommand(this);
                hideSearch = new HideSearchViewCommand(this);
                hideComplexSearch = new HideComplexSearchCommand(this);

                OpenNotes.CollectionChanged += openNotes_CollectionChanged;
                SearchResults.CollectionChanged += searchResults_CollectionChanged;
            }
        }
 public LabelViewModel GetViewModel(ILabel model)
 {
     LabelViewModel vm;
     if (labelViewModels.ContainsKey(model.ID))
     {
         vm = labelViewModels[model.ID];
         vm.Model = model;
     }
     else
     {
         vm = new LabelViewModel(model, this);
     }
     return vm;
 }
 internal void RegisterViewModel(ILabel model, LabelViewModel vm)
 {
     if (labelViewModels.ContainsKey(model.ID) == false)
         labelViewModels.Add(model.ID, vm);
 }