private void GetDocuments(object param)
        {
            var documentViewModels = new FindDocumentViewModel();
            OnGetViewModels(documentViewModels);

            ViewModelContext.UiDispatcher.Invoke(
                () =>
                {
                    OpenDocuments.Clear();
                    documentViewModels.ViewModels.ForEach(vm =>
                    {
                        if (vm != this)
                        {
                            OpenDocuments.Add(vm);
                        }
                    });
                });
        }
示例#2
0
        /// <summary>
        /// Gets one or more view models based on settings in <see cref="FindDocumentViewModel"/>.
        /// A single view model can be fetched by navigation id, multiple view models can be 
        /// fetched by module name, and if neither navigation id or module name is provided then
        /// all document view models will be returned for all views. 
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="FindDocumentViewModel"/>.</param>
        private void GetViewModels(object sender, FindDocumentViewModel e)
        {
            if (String.IsNullOrEmpty(e.NavigationId)
                && String.IsNullOrEmpty(e.Module))
            {
                var documentViewModels = ViewContext.NavigationManager.GetAllViewModels();
                e.ViewModels = documentViewModels;
                return;
            }

            if (!String.IsNullOrEmpty(e.NavigationId))
            {
                var documentViewModel = ViewContext.NavigationManager.GetViewModel(e.NavigationId);
                e.ViewModel = documentViewModel;
            }

            if (!String.IsNullOrEmpty(e.Module))
            {
                var documentViewModels = ViewContext.NavigationManager.GetViewModels(e.Module);
                e.ViewModels = documentViewModels;
            }
        }
示例#3
0
 /// <summary>
 /// Raises the <see cref="GetViewModels"/> event which is handled on the DocumentViewBase
 /// to get one or more view models based on settings in <see cref="FindDocumentViewModel"/>.
 /// </summary>
 /// <param name="e">The <see cref="FindDocumentViewModel"/>.</param>
 protected void OnGetViewModels(FindDocumentViewModel e)
 {
     var getViewModels = GetViewModels;
     if (getViewModels != null)
     {
         getViewModels(this, e);
     }
 }