Ejemplo n.º 1
0
 public object NewItem(IRibbonButtonInfo info, object view)
 {
     return(new TabItem()
     {
         Header = info.DisplayName,
         Content = view,
     });
 }
Ejemplo n.º 2
0
 public object NewItem(IRibbonButtonInfo info, object view)
 {
     return(new LayoutAnchorable
     {
         Title = info.Name,
         Content = view,
         CanClose = false,
         //CanAutoHide = false,
         //CanFloat = false,
         //CanHide = false,
     });
 }
Ejemplo n.º 3
0
 public static void AddViewToContentPanel <T>(IRibbonButtonInfo viewInfo, IContentPanel panel, Func <T, bool> predicate)
 {
     if (panel.IsLoaded())
     {
         bool shouldCreate = true;
         var  enumerator   = panel.GetEnumerator();
         try
         {
             while (enumerator.MoveNext())
             {
                 if (predicate((T)enumerator.Current))
                 {
                     shouldCreate = false;
                     break;
                 }
             }
         }
         finally
         {
             enumerator = null;
         }
         if (shouldCreate)
         {
             try
             {
                 var view = panel.GetView(viewInfo);
                 if (view != null)
                 {
                     if (view is IView seed)
                     {
                         seed.ID = viewInfo.ID;
                     }
                     panel.Add(panel.NewItem(viewInfo, view));
                 }
             }
             catch (Exception ex)
             {
                 mLogger.Warn($"Error while invoking addin:{viewInfo.Name}, type:{viewInfo.Type}, assembly:{viewInfo.Assembly}, due to:{ex}");
             }
         }
     }
 }
Ejemplo n.º 4
0
 public object GetView(IRibbonButtonInfo info)
 {
     return(RibbonButtonUtility.GetView(typeof(TabControl).AssemblyQualifiedName, ContentPanelModule.UnityContainer, info));
 }
Ejemplo n.º 5
0
        //去掉缓存
        //static Dictionary<string, object> views = new Dictionary<string, object>();
        public static object GetView(string assemblyQualifiedName, IUnityContainer container, IRibbonButtonInfo buttonInfo)
        {
            if (container == null || buttonInfo == null)
            {
                mLogger.Warn($"Can't resolve view, container:{container == null}, buttonInfo:{buttonInfo == null}");
                return(null);
            }

            var viewId = buttonInfo.ID;
            //if (views.TryGetValue(viewId, out object view))
            //{
            //    return view;
            //}

            var assembly = Assembly.Load(buttonInfo.Assembly);
            var view     = container.Resolve(assembly.GetType(buttonInfo.Type));

            //if (view != null)
            //{
            //    views[viewId] = view;
            //}
            return(view);
        }
Ejemplo n.º 6
0
        public static object GetView(string assemblyQualifiedName, IUnityContainer container, IRibbonButtonInfo buttonInfo)
        {
            if (container == null || buttonInfo == null)
            {
                mLogger.Warn($"Can't resolve view, container:{container == null}, buttonInfo:{buttonInfo == null}");
                return(null);
            }

            var viewId = $"{assemblyQualifiedName},{buttonInfo.Type}".ToGuid().ToString("B");

            if (views.TryGetValue(viewId, out object view))
            {
                return(view);
            }

            var assembly = Assembly.Load(buttonInfo.Assembly);

            view = container.Resolve(assembly.GetType(buttonInfo.Type));
            if (view != null)
            {
                views[viewId] = view;
            }
            return(view);
        }