Beispiel #1
0
        internal TaskPaneTabCreator(ISwApplication app, IServiceProvider svcProvider, TaskPaneSpec spec)
        {
            m_App         = app;
            m_SvcProvider = svcProvider;

            m_ControlProvider = m_SvcProvider.GetService <ITaskPaneControlProvider>();

            Spec = spec ?? new TaskPaneSpec();
        }
        public ISwTaskPane <TControl> CreateTaskPane <TControl>(TaskPaneSpec spec)
        {
            if (spec == null)
            {
                spec = new TaskPaneSpec();
            }

            return(new SwTaskPane <TControl>(new TaskPaneTabCreator <TControl>(Application, m_SvcProvider, spec), Logger));
        }
Beispiel #3
0
        public ISwTaskPane <TControl> CreateTaskPane <TControl>(TaskPaneSpec spec)
        {
            if (spec == null)
            {
                spec = new TaskPaneSpec();
            }

            var taskPane = new SwTaskPane <TControl>(new TaskPaneTabCreator <TControl>(Application, m_SvcProvider, spec), Logger);

            taskPane.Disposed += OnItemDisposed;

            m_Disposables.Add(taskPane);

            return(taskPane);
        }
Beispiel #4
0
        public static IXEnumTaskPane <TControl, TEnum> CreateTaskPane <TControl, TEnum>(this IXExtension ext)
            where TEnum : Enum
        {
            var spec = new TaskPaneSpec();

            spec.InitFromEnum <TEnum>();
            spec.Buttons = Enum.GetValues(typeof(TEnum)).Cast <TEnum>().Select(
                c =>
            {
                var btn = new TaskPaneEnumButtonSpec <TEnum>(Convert.ToInt32(c));
                btn.InitFromEnum(c);
                btn.Value = c;
                c.TryGetAttribute <TaskPaneStandardIconAttribute>(a => btn.StandardIcon = a.StandardIcon);
                return(btn);
            }).ToArray();

            return(new EnumTaskPane <TControl, TEnum>(ext.CreateTaskPane <TControl>(spec)));
        }
Beispiel #5
0
 public static ISwTaskPane <TControl> CreateTaskPaneWpf <TControl>(this ISwAddInEx addIn, TaskPaneSpec spec = null)
     where TControl : System.Windows.UIElement => addIn.CreateTaskPane <TControl>(spec);
Beispiel #6
0
 public static ISwTaskPane <TControl> CreateTaskPaneWinForm <TControl>(this ISwAddInEx addIn, TaskPaneSpec spec = null)
     where TControl : System.Windows.Forms.Control => addIn.CreateTaskPane <TControl>(spec);
Beispiel #7
0
        public ISwTaskPane <TControl> CreateTaskPane <TControl>(TaskPaneSpec spec)
        {
            if (spec == null)
            {
                spec = new TaskPaneSpec();
            }

            ITaskpaneView CreateTaskPaneView(IIconsCreator iconConv, IXImage icon, string title)
            {
                if (icon == null)
                {
                    if (spec.Icon != null)
                    {
                        icon = spec.Icon;
                    }
                }

                if (string.IsNullOrEmpty(title))
                {
                    if (spec != null)
                    {
                        title = spec.Title;
                    }
                }

                if (Application.Sw.SupportsHighResIcons(CompatibilityUtils.HighResIconsScope_e.TaskPane))
                {
                    string[] taskPaneIconImages = null;

                    if (icon != null)
                    {
                        taskPaneIconImages = iconConv.ConvertIcon(new TaskPaneHighResIcon(icon));
                    }

                    return(Application.Sw.CreateTaskpaneView3(taskPaneIconImages, title));
                }
                else
                {
                    var taskPaneIconImage = "";

                    if (icon != null)
                    {
                        taskPaneIconImage = iconConv.ConvertIcon(new TaskPaneIcon(icon)).First();
                    }

                    return(Application.Sw.CreateTaskpaneView2(taskPaneIconImage, title));
                }
            }

            using (var iconConv = m_SvcProvider.GetService <IIconsCreator>())
            {
                var taskPane = CustomControlHelper.HostControl <TControl, SwTaskPane <TControl> >(
                    (c, h, t, i) =>
                {
                    var v = CreateTaskPaneView(iconConv, i, t);

                    if (!v.DisplayWindowFromHandle(h.Handle.ToInt32()))
                    {
                        throw new NetControlHostException(h.Handle);
                    }

                    return(new SwTaskPane <TControl>(Application.Sw, v, c, spec, m_SvcProvider));
                },
                    (p, t, i) =>
                {
                    var v    = CreateTaskPaneView(iconConv, i, t);
                    var ctrl = (TControl)v.AddControl(p, "");

                    if (ctrl == null)
                    {
                        throw new ComControlHostException(p);
                    }

                    return(new SwTaskPane <TControl>(Application.Sw, v, ctrl, spec, m_SvcProvider));
                });

                m_Disposables.Add(taskPane);

                return(taskPane);
            }
        }
Beispiel #8
0
 IXTaskPane <TControl> IXExtension.CreateTaskPane <TControl>(TaskPaneSpec spec)
 => CreateTaskPane <TControl>(spec);