コード例 #1
0
        private void RefreshList()
        {
            var list = m_hostWindow.GetList();

            list.Items.Clear();
            for (int i = 0; i < MAX_DISPLAY_ACTION; i++)
            {
                int idx = m_page * MAX_DISPLAY_ACTION + i;
                if (idx == m_availableMethods.Count)
                {
                    break;
                }

                var                currentMethod = m_availableMethods[idx];
                string             title         = Regex.Replace(currentMethod.MethodName, REG_TITLE_RULES, "");
                string             description   = null;
                ImageSource        icon          = null;
                IQuickPluginMethod plugin        = currentMethod.GetPluginInterface();
                // 如果是一个加载项,可以调用其函数获取
                if (plugin != null)
                {
                    description = plugin.GetDescription(this);
                    ImageSource tmp      = null;
                    bool        needIcon = plugin.GetIcon(this, out tmp);
                    if (needIcon)
                    {
                        icon = tmp;
                    }
                    else
                    {
                        icon = QuickUIResource.GetDefaultPluginIcon();
                    }
                }
                else
                {
                    description = currentMethod.MethodDescription;
                    if (!m_isGlobalModel) //非全局的情况下,使用当前应用程序的图标
                    {
                        icon = m_bitmapSourceCache;
                    }
                }

                QuickListItem item = new QuickListItem(title, description, icon);
                item.CreateListBoxItemTo(m_hostWindow.GetList());
            }
            if (GetSelectedIndex() == -1 && m_hostWindow.GetList().HasItems)
            {
                m_hostWindow.GetList().SelectedIndex = 0;
            }

            AutoResize();
        }
コード例 #2
0
        public void Init()
        {
            var list = m_host.GetList();

            foreach (var i in QuickConfig.ThisConfig.ContextMenuList)
            {
                QuickListItem item = new QuickListItem(i.Name, null, null);
                item.Tag = i;
                item.CreateListBoxItemTo(list);
            }
            list.ListItemClicked += itemClicked;


            m_host.GetList().KeyUp += ListOnKeyUp;
        }