Example #1
0
 /// <summary>
 /// 登记模块,创建新的模块实例
 /// </summary>
 /// <param name="Info"></param>
 /// <param name="Parameters"></param>
 /// <returns></returns>
 public IModule CheckinModule(ModuleInfo Info, params object[] Parameters)
 {
     if (Info != null)
     {
         IModule result = Lemon.GetInstance <IModule>(Info.AssemblyPath, Info.FullClassName, Parameters);
         if (result != null)
         {
             result.ModuleName = Info.FullClassName;
             result.MainForm   = Lemon.GetMainForm();
             result.Initialize();
             Lemon.SendMsgDebug("运行插件:" + Info.FullClassName);
             this.moduleList.Add(result);
             return(result);
         }
         else
         {
             Lemon.SendMsgError("运行插件失败:" + Info.FullClassName);
             return(null);
         }
     }
     else
     {
         Lemon.SendMsgError("没找到插件信息,无法提示插件详细信息");
         return(null);
     }
 }
Example #2
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            StartUp startup = Lemon.GetInstance <StartUp>(typeof(StartUp));

            Application.Run(startup);
        }
Example #3
0
        /// <summary>
        /// 加载菜单
        /// </summary>
        protected virtual void LoadMenu()
        {
            IEventBinder     binder  = Lemon.GetInstance <EventBinderToModule>(typeof(EventBinderToModule), new object[] { this });
            IMenuItemFactory itemfac = this.Envir.BllConfig.GetConfig <ILemonEnvironment>().MenuItemFactory;

            itemfac.Eventbinder = binder;
            itemfac.Mainform    = this;
            //itemfac.Regidit(this);
            MenuFactory menuFac = new MenuFactory(this, itemfac);

            menuFac.SetMenuStrip();
            Thread      newThrd   = null;
            ThreadStart thrdStart = delegate { AddMenuControl(menuFac); };

            newThrd = new Thread(thrdStart);
            newThrd.IsBackground = true;
            newThrd.Start();
        }
Example #4
0
        /// <summary>
        /// 创建动作
        /// </summary>
        /// <param name="ActionName">动作名称</param>
        /// <param name="Type">动作类型</param>
        /// <param name="InvokeObject">调用的对象</param>
        /// <param name="InvokeProcessor">对象处理者委托</param>
        /// <param name="Performer">注销动作时的回调函数</param>
        /// <returns></returns>
        public bool CreateAction(string ActionName, ActionType Type, object InvokeObject, Delegate InvokeProcessor, ActionPerformer Performer = null)
        {
            bool    iscmp     = false;
            IAction newAction = new Action(InvokeObject, ActionName, Type, InvokeProcessor, Performer);
            //查找是否已经存在上下文
            var f = this.contexts.Find(delegate(IActionContext ac) { return(ac.ContextProcessType == Lemon.GetObjType(InvokeObject)); });

            if (f == null)
            {
                //不存在则创建新的
                if (this.contexttemplates.Count > 0)
                {
                    //创建新的上下文
                    IActionContext newAc = Lemon.GetInstance <IActionContext>(Lemon.GetObjType(this.MatcherContextTemplate(newAction)));
                    newAc.ContextProcessType = Lemon.GetObjType(InvokeObject);
                    f = newAc;
                    //加入上下文实例的集合
                    this.contexts.Add(f);
                }
            }
            if (f != null)
            {
                //判断是否是单一动作
                if (newAction.Type == Lemonade.Frame.Running.ActionType.Single)
                {
                    this.Remove(newAction.InvokeObject, newAction.ActionName, ActionType.Single);
                }
                else
                {
                    f.RemoveAction(newAction);
                }
                f.AddAction(newAction);
                iscmp = true;
            }

            return(iscmp);
        }
Example #5
0
 /// <summary>
 /// 实例化并注册对象
 /// </summary>
 public virtual void Regedit()
 {
     this.systemFrm  = Lemon.GetInstance <ILoadSystem>(typeof(FrmMain));
     this.displayFrm = Lemon.GetInstance <ILoadDisplay>(typeof(Frm_Welcome), this);
     this.systemFrm.Regidit(this.displayFrm);
 }
Example #6
0
        /// <summary>
        /// 数据转换到控件
        /// </summary>
        protected ToolsBarSetting DataConvterCtrl(ToolsBarData BarData)
        {
            string          pathbase = Lemon.GetCSFRootDirectory();
            ToolsBarSetting result   = new ToolsBarSetting();

            //工具栏
            foreach (TBar tbar in BarData.Bars)
            {
                ToolsBar newBar = new ToolsBar();
                newBar.ParentFormName = tbar.ParentFormName;
                newBar.ToolsBarCode   = tbar.ToolsBarCode;
                newBar.ToolsBarName   = tbar.ToolsBarName;
                result.Bars.Add(newBar);
            }
            //按钮
            foreach (TButton tbtn in BarData.Buttons)
            {
                ToolsButton newBtn = new ToolsButton();
                newBtn.AssemblyPath  = pathbase + tbtn.Assembly;
                newBtn.FullClassName = tbtn.FullClassName;
                newBtn.GroupName     = tbtn.GroupName;
                newBtn.ItemImage     = pathbase + tbtn.ItemImage;
                newBtn.ItemIndex     = tbtn.ItemIndex;
                newBtn.Title         = tbtn.Title;
                newBtn.ToolsBarCode  = tbtn.ToolsBarCode;
                IControlToolsButton elm = Lemon.GetInstance <IControlToolsButton>(newBtn.AssemblyPath, newBtn.FullClassName);
                if (elm != null)
                {
                    newBtn.UIElement = elm;
                    result.Buttons.Add(newBtn);
                }
                else
                {
                    Lemon.SendMsgDebug("配置的工具栏按钮" + newBtn.ToolsBarCode + "没有实现IUIElement接口");
                }
            }
            //下拉框
            foreach (TComboBox tcb in BarData.ComboBoxs)
            {
                ToolsComboBox newCb = new ToolsComboBox();
                newCb.GroupName    = tcb.GroupName;
                newCb.ItemIndex    = tcb.ItemIndex;
                newCb.ToolsBarCode = tcb.ToolsBarCode;
                IControlToolsComoBoxItem cbelm = Lemon.GetInstance <IControlToolsComoBoxItem>(tcb.Assembly, tcb.FullClassName);
                if (cbelm != null)
                {
                    newCb.UIElement = cbelm;
                }
                else
                {
                    Lemon.SendMsgDebug("配置的工具栏下拉框" + newCb.ToolsBarCode + "没有实现IUIElement接口");
                }
                foreach (TComboBoxItem ti in tcb.Items)
                {
                    ToolsComboBoxItem newItem = new ToolsComboBoxItem();
                    ti.Assembly      = pathbase + ti.Assembly;
                    newItem.ItemData = ti;
                    IControlToolsComoBoxItem elm = Lemon.GetInstance <IControlToolsComoBoxItem>(ti.Assembly, ti.FullClassName);
                    if (elm != null)
                    {
                        newItem.UIElement = elm;
                        newCb.Items.Add(newItem);
                    }
                    else
                    {
                        Lemon.SendMsgDebug("配置的工具栏下拉框的选项" + ti.Title + "没有实现IUIElement接口");
                    }
                }
                result.ComboBoxs.Add(newCb);
            }
            //分栏
            foreach (TSeparator tsep in BarData.Separator)
            {
                ToolsSeparator newSep = new ToolsSeparator();
                newSep.GroupName    = tsep.GroupName;
                newSep.ItemIndex    = tsep.ItemIndex;
                newSep.ToolsBarCode = tsep.ToolsBarCode;
                result.Separator.Add(newSep);
            }
            return(result);
        }