public IRibbonViewModel ResolveInstanceFor(object view)
        {
            var context = viewContextProvider.GetContextForView(view) ?? NullContext.Instance;

            //Sometimes can happen that view provider has not got events to tell us about a new view
            // so we will have to try and create it
            if (!contextToViewModelLookup.ContainsKey(context))
            {
                var ribbonTypeForView = viewContextProvider.GetRibbonTypeForView(view);
                var newViewEventArgs  = new NewViewEventArgs(view, context, ribbonTypeForView);

                var viewModel = GetOrCreateViewModel(newViewEventArgs.RibbonType, newViewEventArgs.ViewContext, newViewEventArgs.ViewInstance);
                if (newViewEventArgs.ViewInstance != null)
                {
                    customTaskPaneRegister.RegisterCustomTaskPanes(viewModel, newViewEventArgs.ViewInstance, context);
                }
            }

            if (contextToViewModelLookup.ContainsKey(context))
            {
                return(contextToViewModelLookup[context]);
            }

            return(null);
        }
Ejemplo n.º 2
0
        public IRibbonViewModel ResolveInstanceFor(object view)
        {
            var context = viewContextProvider.GetContextForView(view) ?? NullContext.Instance;

            //Sometimes can happen that view provider has not got events to tell us about a new view
            // so we will have to try and create it
            if (!contextToViewModelLookup.ContainsKey(context))
            {
                var ribbonTypeForView = viewContextProvider.GetRibbonTypeForView(view);
                var newViewEventArgs  = new NewViewEventArgs(view, context, ribbonTypeForView);

                GetOrCreateViewModel(newViewEventArgs);
            }

            return(contextToViewModelLookup[context]);
        }