public override FrameworkElement GetControl(DataPreviewPluginArgument arg)
        {
            PropertyViewControl grid = new PropertyViewControl();

            grid.DataContext = arg;
            return(grid);
        }
Beispiel #2
0
        /// <summary>
        /// 将控件转换为TabItem,便于显示到界面上
        /// </summary>
        /// <param name="arg"></param>
        /// <returns></returns>
        public FrameworkElement ToControl(DataPreviewPluginArgument arg)
        {
            TabItem ti = new TabItem();

            if (!string.IsNullOrWhiteSpace(PluginInfo.Icon))      //设置了图标
            {
                try
                {
                    Image img = new Image();
                    img.Source  = new BitmapImage(new Uri(PluginInfo.Icon, UriKind.RelativeOrAbsolute));
                    img.Stretch = System.Windows.Media.Stretch.UniformToFill;
                    img.Width   = img.Height = 16;
                    img.ToolTip = PluginInfo.Name;
                    ti.Header   = img;
                }
                catch (Exception)
                {
                }
            }
            if (ti.Header == null)
            {
                ti.Header = PluginInfo.Name;
            }
            ti.Content = GetControl(arg);
            return(ti);
        }
        public override FrameworkElement GetControl(DataPreviewPluginArgument arg)
        {
            ImageViewControl ctrl = new ImageViewControl();

            ctrl.DataContext = arg;
            return(ctrl);
        }
Beispiel #4
0
        public override FrameworkElement GetControl(DataPreviewPluginArgument arg)
        {
            MediaPlayerControl grid = new MediaPlayerControl();

            grid.IsAudioFormat = false;
            grid.DataContext   = arg;
            return(grid);
        }
        /// <summary>
        /// 根据当前选择的数据获取视图列表
        /// </summary>
        /// <param name="pluginId"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public IEnumerable <AbstractDataPreviewPlugin> GetView(DataPreviewPluginArgument arg)
        {
            if (arg.CurrentData == null)
            {
                return(new List <AbstractDataPreviewPlugin>());
            }

            if (arg.CurrentData is string file)     //如果是字符串则认为是文件,此时通过文件后缀名判断
            {
                if (string.IsNullOrEmpty(file) || !System.IO.File.Exists(file))
                {
                    return(new List <AbstractDataPreviewPlugin>());
                }
                string ext   = System.IO.Path.GetExtension(file);
                var    views = Plugins.Where(p =>
                                             ((DataPreviewPluginInfo)p.PluginInfo).ViewType.Any(v => (v.PluginId == "*.*" || v.PluginId.Replace("*", "").Split('|').Any(e => e.Equals(ext, StringComparison.OrdinalIgnoreCase)))))
                               .OrderByDescending(iv => iv.PluginInfo.OrderIndex)
                               .ToList();
                return(views);
            }
            else   //否则认为是数据对象,此时通过类型判断
            {
                if (arg.Type == null || arg.PluginId == null)
                {
                    arg.Type = arg.PluginId = "*";
                    //return new List<AbstractDataPreviewPlugin>();
                }
                string typeName = (arg.Type is Type) ? ((Type)arg.Type).Name : arg.Type.ToSafeString();
                var    views    = Plugins.Where(p =>
                                                ((DataPreviewPluginInfo)p.PluginInfo).ViewType.Any(v => (v.PluginId.Equals(arg.PluginId) || v.PluginId == "*") && (v.TypeName.Equals(typeName) || v.TypeName == "*")))
                                  .OrderByDescending(iv => iv.PluginInfo.OrderIndex)
                                  .ToList();

                return(views);
            }
        }
Beispiel #6
0
 /// <summary>
 /// 获取显示的插件控件
 /// </summary>
 /// <param name="arg"></param>
 /// <returns></returns>
 public abstract FrameworkElement GetControl(DataPreviewPluginArgument arg);