예제 #1
0
        /// <summary>
        /// 跳转至指定分类的插件。
        /// </summary>
        /// <param name="pluginType">分类插件。</param>
        /// <param name="classifys">分类集合。</param>
        /// <param name="parameterValues">需要为该界面插件设置的参数默认值,如无参数可不设置。</param>
        /// <returns></returns>
        public ClassifyPluginView LoadView(ClassifyPluginType pluginType, Classify[] classifys, params ParameterValue[] parameterValues)
        {
            ClassifyPluginView view = null;

            foreach (ViewBase v in this.Views)
            {
                if (v is ClassifyPluginView)
                {
                    ClassifyPluginView dv = v as ClassifyPluginView;
                    if (dv.PluginType.Equals(pluginType))
                    {
                        if (dv.Classifys.Length == classifys.Length)
                        {
                            bool bolIsEqually = true;
                            for (int intIndex = 0; intIndex < classifys.Length; intIndex++)
                            {
                                if (dv.Classifys[intIndex].Equals(classifys[intIndex]) == false)
                                {
                                    bolIsEqually = false;
                                    break;
                                }
                            }

                            if (bolIsEqually)
                            {
                                view = v as ClassifyPluginView;
                                break;
                            }
                        }
                    }
                }
            }

            if (view == null)
            {
                view = new ClassifyPluginView(this, pluginType, classifys);
                if (parameterValues != null && parameterValues.Length > 0)
                {
                    view.SetParameterValue(parameterValues);
                }
                this.Views.Load(view, ViewDockOptions.Center);
            }
            else
            {
                if (parameterValues != null && parameterValues.Length > 0)
                {
                    view.SetParameterValue(parameterValues);
                }
                view.Focus();
            }

            return(view);
        }
예제 #2
0
        /// <summary>
        /// 跳转至指定分类的插件。
        /// </summary>
        /// <param name="classifyPluginType">分类插件类型声明。</param>
        /// <param name="classifys">分类集合。</param>
        /// <param name="parameterValues">需要为该界面插件设置的参数默认值,如无参数可不设置。</param>
        /// <returns></returns>
        public ClassifyPluginView LoadView(Type classifyPluginType, Classify[] classifys, params ParameterValue[] parameterValues)
        {
            ClassifyPluginType pluginType = base.GetClassifyPluginType(this.CurrentAccount, classifyPluginType, new Type[] { typeof(System.Windows.Forms.Control), typeof(System.Windows.Forms.ToolStripItem) }, classifys);

            if (pluginType != null)
            {
                return(this.LoadView(pluginType, classifys, parameterValues));
            }
            else
            {
                throw new Exception("未发现可用的分类插件“" + classifyPluginType + "”");
            }
        }
예제 #3
0
        private bool GetClassifyMenu(PluginTypeCollection pluginTypes, ToolStripItemCollection menuItems)
        {
            bool bolIsOutMenu = false;

            for (int intIndex = 0; intIndex < pluginTypes.Count; intIndex++)
            {
                ClassifyPluginType pluginType = pluginTypes[intIndex] as ClassifyPluginType;

                if ((pluginType.Type.GetInterface(typeof(IClassifyHtmlPlugin).FullName, true) != null) || (Function.IsInheritableBaseType(pluginType.Type, typeof(System.Windows.Forms.Control))))
                {
                    //HTML、控件
                    ToolStripMenuItem mnuClassifyPlugin = new ToolStripMenuItem();
                    mnuClassifyPlugin.Text  = pluginType.Name;
                    mnuClassifyPlugin.Image = pluginType.Icon16;
                    mnuClassifyPlugin.Tag   = pluginType;
                    if (pluginType.Description != null && pluginType.Description.Length > 0)
                    {
                        mnuClassifyPlugin.ToolTipText = pluginType.Description;
                    }
                    if (pluginType.Icon16 != null)
                    {
                        mnuClassifyPlugin.Image = pluginType.Icon16;
                    }
                    mnuClassifyPlugin.Click += new EventHandler(mnuClassifyPlugin_Click);

                    if (pluginType.Children.Count > 0)
                    {
                        this.GetClassifyMenu(pluginType.Children, mnuClassifyPlugin.DropDownItems);
                    }
                    //mnuClassifyPlugin.MouseEnter += new EventHandler(mnuClassifyPlugin_MouseEnter);
                    menuItems.Add(mnuClassifyPlugin);
                    bolIsOutMenu = true;
                }
                else if (Function.IsInheritableBaseType(pluginType.Type, typeof(System.Windows.Forms.ToolStripItem)))
                {
                    //自定义的菜单项
                    System.Reflection.ConstructorInfo ci = pluginType.Type.GetConstructor(new System.Type[] { });
                    object objInstance = ci.Invoke(new object[] { });

                    IClassifyPlugin plugin            = objInstance as IClassifyPlugin;
                    ToolStripItem   mnuClassifyPlugin = plugin as ToolStripItem;
                    if (pluginType.Icon16 != null)
                    {
                        mnuClassifyPlugin.Image = pluginType.Icon16;
                    }
                    menuItems.Add(mnuClassifyPlugin);

                    plugin.SetClassifys((Classify[])mnuClassifyPlugin.Owner.Tag);
                    if (plugin is IUseAccount)
                    {
                        IUseAccount useAccount = plugin as IUseAccount;
                        useAccount.SetAccount(this.CurrentAccount);
                    }
                    plugin.SetApplication(this);

                    if (mnuClassifyPlugin.Text.Length == 0)
                    {
                        mnuClassifyPlugin.Text = pluginType.Name;
                    }
                    if (pluginType.Description != null && pluginType.Description.Length > 0 && (mnuClassifyPlugin.ToolTipText == null || mnuClassifyPlugin.ToolTipText.Length == 0))
                    {
                        mnuClassifyPlugin.ToolTipText = pluginType.Description;
                    }
                    //tsi.MouseEnter += new EventHandler(mnuClassifyPlugin_MouseEnter);
                    bolIsOutMenu = true;
                }
                else if (pluginType.Name == null)
                {
                    //分隔线
                    if (bolIsOutMenu && pluginType.Children.Count > 0)
                    {
                        menuItems.Add(new ToolStripSeparator());
                    }

                    //分隔线的子插件
                    if (this.GetClassifyMenu(pluginType.Children, menuItems))
                    {
                        bolIsOutMenu = true;
                    }
                }
                else
                {
                    //作为分类处理
                    if (pluginType.Children.Count > 0)
                    {
                        ToolStripMenuItem mnuClassifyPlugin = new ToolStripMenuItem();
                        mnuClassifyPlugin.Text = pluginType.Name;
                        if (pluginType.Description != null && pluginType.Description.Length > 0)
                        {
                            mnuClassifyPlugin.ToolTipText = pluginType.Description;
                        }
                        if (pluginType.Icon16 != null)
                        {
                            mnuClassifyPlugin.Image = pluginType.Icon16;
                        }
                        //mnuClassifyPlugin.MouseEnter += new EventHandler(mnuClassifyPlugin_MouseEnter);

                        this.GetClassifyMenu(pluginType.Children, mnuClassifyPlugin.DropDownItems);
                        menuItems.Add(mnuClassifyPlugin);
                        bolIsOutMenu = true;
                    }
                }
            }
            return(bolIsOutMenu);
        }