Пример #1
0
        internal static IXImage GetCommandIcon(this CommandItemInfo info)
        {
            Image icon = null;

            try
            {
                if (File.Exists(info.IconPath))
                {
                    icon = Image.FromFile(info.IconPath);
                }
            }
            catch
            {
            }

            if (icon == null)
            {
                if (info is CommandMacroInfo)
                {
                    icon = Resources.macro_icon_default;
                }
                else if (info is CommandGroupInfo)
                {
                    icon = Resources.group_icon_default;
                }
            }

            return(new MacroButtonIcon(icon));
        }
Пример #2
0
        internal static IXImage GetCommandIcon(this CommandItemInfo info, IIconsProvider[] iconsProviders)
        {
            IXImage icon = null;

            try
            {
                var provider = iconsProviders.FirstOrDefault(p => p.Matches(info.IconPath));

                if (provider != null)
                {
                    icon = provider.GetIcon(info.IconPath);
                }
            }
            catch
            {
            }

            if (icon == null)
            {
                if (info is CommandMacroInfo)
                {
                    icon = new ImageEx(ImageIcon.ImageToByteArray(Resources.macro_icon_default),
                                       Resources.macro_vector);
                }
                else if (info is CommandGroupInfo)
                {
                    icon = new ImageEx(ImageIcon.ImageToByteArray(Resources.group_icon_default),
                                       Resources.macros_vector);
                }
            }

            return(icon);
        }
Пример #3
0
        internal static IXImage GetCommandIcon(this CommandItemInfo info, IIconsProvider[] iconsProviders, IFilePathResolver pathResolver, string workDir)
        {
            IXImage icon = null;

            try
            {
                if (!string.IsNullOrEmpty(info.IconPath))
                {
                    var iconPath = pathResolver.Resolve(info.IconPath, workDir);

                    var provider = iconsProviders.FirstOrDefault(p => p.Matches(iconPath));

                    if (provider != null)
                    {
                        icon = provider.GetIcon(iconPath);
                    }
                }
            }
            catch
            {
            }

            if (icon == null)
            {
                if (info is CommandMacroInfo)
                {
                    icon = new ImageEx(Resources.macro_icon_default.GetBytes(),
                                       Resources.macro_vector);
                }
                else if (info is CommandGroupInfo)
                {
                    icon = new ImageEx(Resources.group_icon_default.GetBytes(),
                                       Resources.macros_vector);
                }
            }

            return(icon);
        }
Пример #4
0
        private void ResolveEmptyName(CommandItemInfo info, string nameTemplate, List <string> usedNames, out string title, out string tooltip)
        {
            title   = info.Title;
            tooltip = info.Description;

            if (string.IsNullOrEmpty(title))
            {
                title = nameTemplate;
                int i = 0;

                while (usedNames.Contains(title, StringComparer.CurrentCultureIgnoreCase))
                {
                    title = $"{nameTemplate}{++i}";
                }

                usedNames.Add(title);
            }

            if (string.IsNullOrEmpty(tooltip))
            {
                tooltip = title;
            }
        }