public void RegisterCustomTaskPanes(IRibbonViewModel ribbonViewModel, object view, object viewContext)
        {
            var registersCustomTaskPanes = ribbonViewModel as IRegisterCustomTaskPane;
            if (registersCustomTaskPanes == null) return;

            if (!registrationInfo.ContainsKey(ribbonViewModel))
            {
                registersCustomTaskPanes.RegisterTaskPanes((controlFactory, title, initiallyVisible) =>
                {
                    var taskPaneRegistrationInfo = new TaskPaneRegistrationInfo(controlFactory, title);
                    if (!registrationInfo.ContainsKey(ribbonViewModel))
                        registrationInfo.Add(ribbonViewModel, new List<TaskPaneRegistrationInfo>());
                    registrationInfo[ribbonViewModel].Add(taskPaneRegistrationInfo);

                    var taskPane = Register(view, taskPaneRegistrationInfo);
                    var taskPaneAdapter = new OneToManyCustomTaskPaneAdapter(taskPane, viewContext)
                    {
                        Visible = initiallyVisible
                    };

                    if (!ribbonTaskPanes.ContainsKey(ribbonViewModel))
                        ribbonTaskPanes.Add(ribbonViewModel, new List<OneToManyCustomTaskPaneAdapter>());

                    if (!windowToTaskPaneLookup.ContainsKey(view))
                        windowToTaskPaneLookup.Add(view, new List<IRibbonViewModel>());

                    ribbonTaskPanes[ribbonViewModel].Add(taskPaneAdapter);
                    windowToTaskPaneLookup[view].Add(ribbonViewModel);
                    return taskPaneAdapter;
                });
            }
            else
            {
                var adapters = ribbonTaskPanes[ribbonViewModel];
                foreach (var taskPaneAdapter in adapters)
                {
                    if (!taskPaneAdapter.ViewRegistered(view))
                    {
                        foreach (var taskPaneRegistrationInfo in registrationInfo[ribbonViewModel])
                        {
                            taskPaneAdapter.Add(Register(view, taskPaneRegistrationInfo));
                        }
                    }
                    else
                        taskPaneAdapter.Refresh(view);
                }
            }

            foreach (var oneToManyCustomTaskPaneAdapter in windowToTaskPaneLookup[view]
                .Except(new[] { ribbonViewModel })
                .SelectMany(viewModelToHide => ribbonTaskPanes[viewModelToHide]))
            {
                oneToManyCustomTaskPaneAdapter.HideIfVisible();
            }

            foreach (var toRestore in ribbonTaskPanes[ribbonViewModel])
            {
                toRestore.RestoreIfNeeded();
            }
        }
        public void RegisterCustomTaskPanes(IRibbonViewModel ribbonViewModel, object view, object viewContext)
        {
            var registersCustomTaskPanes = ribbonViewModel as IRegisterCustomTaskPane;

            if (registersCustomTaskPanes == null)
            {
                return;
            }

            if (!registrationInfo.ContainsKey(ribbonViewModel))
            {
                registersCustomTaskPanes.RegisterTaskPanes((controlFactory, title, initiallyVisible) =>
                {
                    var taskPaneRegistrationInfo = new TaskPaneRegistrationInfo(controlFactory, title);
                    if (!registrationInfo.ContainsKey(ribbonViewModel))
                    {
                        registrationInfo.Add(ribbonViewModel, new List <TaskPaneRegistrationInfo>());
                    }
                    registrationInfo[ribbonViewModel].Add(taskPaneRegistrationInfo);

                    var taskPane        = Register(view, taskPaneRegistrationInfo);
                    var taskPaneAdapter = new OneToManyCustomTaskPaneAdapter(taskPane, viewContext)
                    {
                        Visible = initiallyVisible
                    };

                    if (!ribbonTaskPanes.ContainsKey(ribbonViewModel))
                    {
                        ribbonTaskPanes.Add(ribbonViewModel, new List <OneToManyCustomTaskPaneAdapter>());
                    }

                    ribbonTaskPanes[ribbonViewModel].Add(taskPaneAdapter);
                    return(taskPaneAdapter);
                });
            }
            else
            {
                var adapters = ribbonTaskPanes[ribbonViewModel];
                foreach (var taskPaneAdapter in adapters)
                {
                    if (!taskPaneAdapter.ViewRegistered(view))
                    {
                        foreach (var taskPaneRegistrationInfo in registrationInfo[ribbonViewModel])
                        {
                            taskPaneAdapter.Add(Register(view, taskPaneRegistrationInfo));
                        }
                    }
                    else
                    {
                        taskPaneAdapter.Refresh(view);
                    }
                }
            }
        }
        public void RegisterCustomTaskPanes(IRibbonViewModel ribbonViewModel, object view, object viewContext)
        {
            var registersCustomTaskPanes = ribbonViewModel as IRegisterCustomTaskPane;
            if (registersCustomTaskPanes == null) return;

            if (!registrationInfo.ContainsKey(ribbonViewModel))
            {
                registersCustomTaskPanes.RegisterTaskPanes(
                    (controlFactory, title, initiallyVisible) =>
                        {
                            var taskPaneRegistrationInfo = new TaskPaneRegistrationInfo(controlFactory, title);
                            if (!registrationInfo.ContainsKey(ribbonViewModel))
                                registrationInfo.Add(ribbonViewModel, new List<TaskPaneRegistrationInfo>());
                            registrationInfo[ribbonViewModel].Add(taskPaneRegistrationInfo);

                            var taskPane = Register(view, taskPaneRegistrationInfo);
                            var taskPaneAdapter = new OneToManyCustomTaskPaneAdapter(taskPane, viewContext)
                            {
                                Visible = initiallyVisible
                            };

                            if (!ribbonTaskPanes.ContainsKey(ribbonViewModel))
                                ribbonTaskPanes.Add(ribbonViewModel, new List<OneToManyCustomTaskPaneAdapter>());

                            ribbonTaskPanes[ribbonViewModel].Add(taskPaneAdapter);
                            return taskPaneAdapter;
                        });
            }
            else
            {
                var adapters = ribbonTaskPanes[ribbonViewModel];
                foreach (var taskPaneAdapter in adapters)
                {
                    if (!taskPaneAdapter.ViewRegistered(view))
                    {
                        foreach (var taskPaneRegistrationInfo in registrationInfo[ribbonViewModel])
                        {
                            taskPaneAdapter.Add(Register(view, taskPaneRegistrationInfo));
                        }
                    }
                    else
                        taskPaneAdapter.Refresh(view);
                }
            }
        }
Exemple #4
0
        public void RegisterCustomTaskPanes(IRibbonViewModel ribbonViewModel, object view, object viewContext)
        {
            var registersCustomTaskPanes = ribbonViewModel as IRegisterCustomTaskPane;

            if (registersCustomTaskPanes == null)
            {
                return;
            }

            if (!registrationInfo.ContainsKey(ribbonViewModel))
            {
                registersCustomTaskPanes.RegisterTaskPanes((controlFactory, title, initiallyVisible) =>
                {
                    var taskPaneRegistrationInfo = new TaskPaneRegistrationInfo(controlFactory, title);
                    if (!registrationInfo.ContainsKey(ribbonViewModel))
                    {
                        registrationInfo.Add(ribbonViewModel, new List <TaskPaneRegistrationInfo>());
                    }
                    registrationInfo[ribbonViewModel].Add(taskPaneRegistrationInfo);

                    var taskPane        = Register(view, taskPaneRegistrationInfo);
                    var taskPaneAdapter = new OneToManyCustomTaskPaneAdapter(taskPane, viewContext)
                    {
                        Visible = initiallyVisible
                    };

                    if (!ribbonTaskPanes.ContainsKey(ribbonViewModel))
                    {
                        ribbonTaskPanes.Add(ribbonViewModel, new List <OneToManyCustomTaskPaneAdapter>());
                    }

                    if (!windowToTaskPaneLookup.ContainsKey(view))
                    {
                        windowToTaskPaneLookup.Add(view, new List <IRibbonViewModel>());
                    }

                    ribbonTaskPanes[ribbonViewModel].Add(taskPaneAdapter);
                    windowToTaskPaneLookup[view].Add(ribbonViewModel);
                    return(taskPaneAdapter);
                });
            }
            else
            {
                var adapters = ribbonTaskPanes[ribbonViewModel];
                foreach (var taskPaneAdapter in adapters)
                {
                    if (!taskPaneAdapter.ViewRegistered(view))
                    {
                        foreach (var taskPaneRegistrationInfo in registrationInfo[ribbonViewModel])
                        {
                            taskPaneAdapter.Add(Register(view, taskPaneRegistrationInfo));
                        }
                    }
                    else
                    {
                        taskPaneAdapter.Refresh(view);
                    }
                }
            }

            foreach (var oneToManyCustomTaskPaneAdapter in windowToTaskPaneLookup[view]
                     .Except(new[] { ribbonViewModel })
                     .SelectMany(viewModelToHide => ribbonTaskPanes[viewModelToHide]))
            {
                oneToManyCustomTaskPaneAdapter.HideIfVisible();
            }

            foreach (var toRestore in ribbonTaskPanes[ribbonViewModel])
            {
                toRestore.RestoreIfNeeded();
            }
        }
Exemple #5
0
        private CustomTaskPane Register(object view, TaskPaneRegistrationInfo taskPaneRegistrationInfo)
        {
            var taskPane = customTaskPaneCollection.Value.Add(taskPaneRegistrationInfo.ControlFactory(), taskPaneRegistrationInfo.Title, view);

            return(taskPane);
        }
        private CustomTaskPane Register(object view, TaskPaneRegistrationInfo taskPaneRegistrationInfo)
        {
            var taskPane = customTaskPaneCollection().Add(taskPaneRegistrationInfo.ControlFactory(), taskPaneRegistrationInfo.Title, view);

            return taskPane;
        }