Beispiel #1
0
        /// <summary>
        /// Locates an appropriate <see cref="ISmartPartInfo"/> compatible with the type
        /// TSmartPartInfo, and calls <see cref="Show(object, ISmartPartInfo)"/>.
        /// </summary>
        /// <exception cref="ArgumentException">The smartPart cannot be
        /// assigned to TSmartPart.</exception>
        /// <remarks>
        /// If <see cref="WorkItem"/> is not null, <see cref="Microsoft.Practices.CompositeUI.WorkItem.GetSmartPartInfo{TSmartPartInfo}(object)"/> will
        /// be called for the TSmartPartInfo concrete type. If no value is returned,
        /// it will be called again for a generic <see cref="SmartPartInfo"/>. Finally, if no generic info
        /// is registered either, a new default instance of the TSmartPartInfo will
        /// be used by calling the <see cref="CreateDefaultSmartPartInfo"/> method and finally passed to
        /// the <see cref="Show(object, ISmartPartInfo)"/> overload.
        /// </remarks>
        public void Show(object smartPart)
        {
            Guard.ArgumentNotNull(smartPart, "smartPart");
            object originalSmartPart = smartPart;

            if (smartPart is UIElement)
            {
                smartPart = elementHosts.Wrap(smartPart as UIElement);
            }
            ThrowIfUnsupportedSP(smartPart);

            TSmartPart typedSmartPart = (TSmartPart)smartPart;

            // Behavior is slightly different than the other overload, as we don't want to
            // reapply the SPI in this case.
            if (smartParts.Contains(typedSmartPart))
            {
                Activate(smartPart);
            }
            else
            {
                ISmartPartInfo         info     = null;
                ISmartPartInfoProvider provider = originalSmartPart as ISmartPartInfoProvider;

                if (workItem != null)
                {
                    info = workItem.GetSmartPartInfo <TSmartPartInfo>(originalSmartPart);
                    if (info == null && provider != null)
                    {
                        info = provider.GetSmartPartInfo(typeof(TSmartPartInfo));
                    }
                    if (info == null)
                    {
                        info = workItem.GetSmartPartInfo <WPFSmartPartInfo>(originalSmartPart);
                    }
                    if (info == null && provider != null)
                    {
                        info = provider.GetSmartPartInfo(typeof(WPFSmartPartInfo));
                    }
                }
                else if (provider != null)
                {
                    info = provider.GetSmartPartInfo(typeof(TSmartPartInfo));
                    if (info == null)
                    {
                        info = provider.GetSmartPartInfo(typeof(WPFSmartPartInfo));
                    }
                }

                if (info == null)
                {
                    info = CreateDefaultSmartPartInfo(typedSmartPart);
                }

                Show(typedSmartPart, info);
            }
        }
Beispiel #2
0
        public ISmartPartInfo GetSmartPartInfo(Type smartPartInfoType)
        {
            ISmartPartInfoProvider provider = masterWorkspace.ActiveSmartPart as ISmartPartInfoProvider;

            if (provider != null)
            {
                return(provider.GetSmartPartInfo(typeof(SmartPartInfo)));
            }
            else
            {
                return(new SmartPartInfo());
            }
        }
Beispiel #3
0
        /// <summary>
        /// Locates an appropriate <see cref="ISmartPartInfo"/> compatible with the type
        /// TSmartPartInfo, and calls <see cref="Show(object, ISmartPartInfo)"/>.
        /// </summary>
        /// <exception cref="ArgumentException">The smartPart cannot be
        /// assigned to TSmartPart.</exception>
        /// <remarks>
        /// If <see cref="WorkItem"/> is not null, <see cref="Microsoft.Practices.CompositeUI.WorkItem.GetSmartPartInfo{TSmartPartInfo}(object)"/> will
        /// be called for the TSmartPartInfo concrete type. If no value is returned,
        /// it will be called again for a generic <see cref="SmartPartInfo"/>. Finally, if no generic info
        /// is registered either, a new default instance of the TSmartPartInfo will
        /// be used by calling the <see cref="CreateDefaultSmartPartInfo"/> method and finally passed to
        /// the <see cref="Show(object, ISmartPartInfo)"/> overload.
        /// </remarks>
        public bool Show(object smartPart)
        {
            Guard.ArgumentNotNull(smartPart, "smartPart");
            ThrowIfUnsupportedSP(smartPart);

            TSmartPart typedSmartPart = (TSmartPart)smartPart;

            // Behavior is slightly different than the other overload, as we don't want to
            // reapply the SPI in this case.
            if (smartParts.Contains(typedSmartPart))
            {
                return(Activate(smartPart));
            }
            else
            {
                ISmartPartInfo         info     = null;
                ISmartPartInfoProvider provider = smartPart as ISmartPartInfoProvider;

                if (workItem != null)
                {
                    info = workItem.GetSmartPartInfo <TSmartPartInfo>(smartPart);
                    if (info == null && provider != null)
                    {
                        info = provider.GetSmartPartInfo(typeof(TSmartPartInfo));
                    }
                    if (info == null)
                    {
                        info = workItem.GetSmartPartInfo <SmartPartInfo>(smartPart);
                    }
                    if (info == null && provider != null)
                    {
                        info = provider.GetSmartPartInfo(typeof(SmartPartInfo));
                    }
                }
                else if (provider != null)
                {
                    info = provider.GetSmartPartInfo(typeof(TSmartPartInfo));
                    if (info == null)
                    {
                        info = provider.GetSmartPartInfo(typeof(SmartPartInfo));
                    }
                }

                if (info == null)
                {
                    info = CreateDefaultSmartPartInfo(typedSmartPart);
                }

                return(Show(typedSmartPart, info));
            }
        }
        public ISmartPartInfo GetSmartPartInfo(Type smartPartInfoType)
        {
            if (dialogList.Count > 0)
            {
                ISmartPartInfoProvider provider = dialogList[0] as ISmartPartInfoProvider;

                if (provider != null)
                {
                    return(provider.GetSmartPartInfo(smartPartInfoType));
                }
            }

            return(null);
        }
        public void Show(object smartPart)
        {
            ISmartPartInfoProvider provider = smartPart as ISmartPartInfoProvider;

            if (provider != null)
            {
                ISmartPartInfo info = provider.GetSmartPartInfo(typeof(IconSmartPartInfo));
                if (info != null)
                {
                    Show(smartPart, info);
                }
            }
            else
            {
                _deckWorkspace.Show(smartPart);
            }
            OnSmartPartActivated(smartPart);
        }
        private ISmartPartInfo GetDialogSmartPartInfo()
        {
            ISmartPartInfoProvider provider = dialogWorkspace.ActiveSmartPart as ISmartPartInfoProvider;
            ISmartPartInfo         info     = null;

            if (provider != null)
            {
                info = provider.GetSmartPartInfo(typeof(SmartPartInfo));
            }
            else
            {
                info = new SmartPartInfo()
                {
                    Title = "??", Description = ""
                }
            };
            return(info);
        }
Beispiel #7
0
        public void SaveUserSettings(DashboardSettingsRepository settings)
        {
            if (!_settingsSaved)
            {
                if (_presenter.Settings == null)
                {
                    settings.ActivationLinks.Clear();

                    int count = 0;

                    foreach (DocumentWindow document in dashboardWorkspace.DocumentWindows)
                    {
                        document.Name = string.Format("Window{0}", count);
                        count++;

                        ISmartPartInfoProvider provider = document.Content as ISmartPartInfoProvider;

                        if (provider != null)
                        {
                            ISmartPartInfo info = provider.GetSmartPartInfo(typeof(ShellSmartPartInfo));

                            ShellSmartPartInfo shellSmartPartInfo = info as ShellSmartPartInfo;

                            if (shellSmartPartInfo != null && shellSmartPartInfo.Hyperlink != null)
                            {
                                settings.ActivationLinks.Add(shellSmartPartInfo.Hyperlink);
                            }
                        }
                    }

                    DockSiteLayoutSerializer serializer = new DockSiteLayoutSerializer();
                    serializer.SerializationBehavior = DockSiteSerializationBehavior.All;
                    settings.Layout = serializer.SaveToString(dashboardWorkspace);
                }
                _settingsSaved = true;
            }
        }
Beispiel #8
0
        public ISmartPartInfo GetSmartPartInfo(Type smartPartInfoType)
        {
            ISmartPartInfoProvider ensoureProvider = this;

            return(infoProvider.GetSmartPartInfo(smartPartInfoType));
        }
        ISmartPartInfo ISmartPartInfoProvider.GetSmartPartInfo(Type smartPartInfoType)
        {
            ISmartPartInfoProvider ensureProvider = this;

            return(this.infoProvider.GetSmartPartInfo(smartPartInfoType));
        }