U8 内嵌.Net UserControl,winform挂菜单

目录

1.创建类库

创建类库命名:UFIDA.U8.Portal.+自定义名称...

2.项目引用U8安装路径dll:

F: U8SOFT\Interop\Interop.U8Login.dll //设置嵌入互操作类型为false

F: U8SOFT\Interop\Interop.UFPortalProxylnterface.dll

F: U8SOFT\Portal \UFIDA.U8.Portal.Common.dll

F: U8SOFT\Portal\UFIDA.U8.Portal.Framework.dll

F: U8SOFT\Portal \UFIDA.U8.Portal.Proxy.dll

F: U8SOFT\Framework\UFSoft.U8.Framework.Login.Ul.dl

3.新建类MyLoginable 继承 NetLoginable:

csharp 复制代码
using UFIDA.U8.Portal.Proxy.editors;
using UFIDA.U8.Portal.Proxy.supports;

namespace UFIDA.U8.Portal.Produce.Print
{
    public class MyLoginable : NetLoginable
    {
        public override object CallFunction(string cMenuId, string cMenuName, string cAuthId, string cCmdLine)
        {
            INetUserControl mycontrol = new MyNetUserControl();
            mycontrol.Title = "生产计划核销物料";
            base.ShowEmbedControl(mycontrol, cMenuId, true);
            return null;
        }
        public override bool SubSysLogin()
        {
            GlobalParameters.gLoginable = this;
            return base.SubSysLogin();
        }

        public override bool SubSysLogOff()
        {
            return base.SubSysLogOff();
        }

        public static class GlobalParameters
        {
            private static MyLoginable _myLoginable = null;
            public static MyLoginable gLoginable
            {
                get
                {
                    return _myLoginable;
                }
                set
                {
                    _myLoginable = value;
                }
            }
        }

    }
}

4.新建类 MyNetUserControl 实现接口 INetUserControl:

csharp 复制代码
using System.Windows.Forms;
using UFIDA.U8.Portal.Framework.Actions;
using UFIDA.U8.Portal.Framework.MainFrames;
using UFIDA.U8.Portal.Produce.Print.Utility;
using UFIDA.U8.Portal.Proxy.Actions;
using UFIDA.U8.Portal.Proxy.editors;
using UFSoft.U8.Framework.Login.UI;

namespace UFIDA.U8.Portal.Produce.Print
{
    public class MyNetUserControl : INetUserControl
    {
        #region INetUserControl 成员
        UserControlSummaryPrint  summaryPrint = null;
        private IEditorInput _editInput = null;
        private IEditorPart _editPart = null;
        private string _title;

        /// <summary>
        /// EditorInput
        /// </summary>
        public IEditorInput EditorInput
        {
            get
            {
                return _editInput;
            }
            set
            {
                _editInput = value;
            }
        }

        /// <summary>
        /// EditorPart
        /// </summary>
        public IEditorPart EditorPart
        {
            get
            {
                return _editPart;
            }
            set
            {
                _editPart = value;
            }
        }

        /// <summary>
        /// 页签标题
        /// </summary>
        public string Title
        {
            get
            {
                return this._title;
            }
            set
            {
                this._title = value;
            }
        }
        public bool CloseEvent()
        {
            //throw new Exception("The method or operation is not implemented.");
            return true;
        }

        public Control CreateControl(clsLogin login, string MenuID, string Paramters)
        {
            DBConfig.connStr = login.GetLoginInfo().ConnString.Substring(18).Replace("Provider=SQLOLEDB;", string.Empty);
            // objConnection = "Data Source=yuyang;Initial Catalog=UFDATA_888_2006;User ID=sa;Password=123";
            DBConfig.operDate = login.GetLoginInfo().operDate;
            DBConfig.UserName = login.GetLoginInfo().UserName;
            DBConfig.UserId = login.GetLoginInfo().UserId;
            DBConfig.AccID = login.GetLoginInfo().AccID;
            DBConfig.AppServer = login.GetLoginInfo().AppServer;
            DBConfig.AccName = login.GetLoginInfo().AccName;
            DBConfig.iYear = login.GetLoginInfo().iYear;
            DBConfig.iBeginYear = login.GetLoginInfo().iBeginYear;
            //构造U8登陆对象
            U8Login.clsLogin u8login = new U8Login.clsLoginClass();
            if (login != null)
            {
                u8login.ConstructLogin(login.userToken);
                string taskId = login.GetTaskID("DP");
                u8login.set_TaskId(ref taskId);
            }

            summaryPrint = new UserControlSummaryPrint();
            summaryPrint.Name = "生产计划核销物料";
            return summaryPrint;
        }

        public NetAction[] CreateToolbar(clsLogin login)
        {
            IActionDelegate nsd = new NetSampleDelegate();
            //string skey = "mynewcontrol";
            //NetAction ac = new NetAction("sss", nsd);
            NetAction[] aclist;
            aclist = new NetAction[0];
            //ac.Text = "Sample Button 2";
            //ac.Tag = summaryPrint;
            //aclist[0] = ac;
            return aclist;

            // throw new Exception("The method or operation is not implemented.");
        }


        #endregion

    }
}

5.新建类 NetSampleDelegate 实现上面的CreateToolbar方法

csharp 复制代码
using UFIDA.U8.Portal.Common.Core;
using UFIDA.U8.Portal.Framework.Actions;

namespace UFIDA.U8.Portal.Produce.Print
{
    public class NetSampleDelegate : IActionDelegate
    {
        public void Run(IAction action)
        {
            //throw new NotImplementedException();
        }

        public void SelectionChanged(IAction action, ISelection selection)
        {
            //throw new NotImplementedException();
        }
    }
}

6.新建你的用户控件

7.最后一步到UAP挂接菜单,到U8上就看到了

相关推荐
小码编匠8 小时前
一款 C# 编写的神经网络计算图框架
后端·神经网络·c#
Envyᥫᩣ11 小时前
C#语言:从入门到精通
开发语言·c#
IT技术分享社区17 小时前
C#实战:使用腾讯云识别服务轻松提取火车票信息
开发语言·c#·云计算·腾讯云·共识算法
羊小猪~~18 小时前
数据结构C语言描述2(图文结合)--有头单链表,无头单链表(两种方法),链表反转、有序链表构建、排序等操作,考研可看
c语言·数据结构·c++·考研·算法·链表·visual studio
WineMonk18 小时前
.NET WPF CommunityToolkit.Mvvm框架
.net·wpf·mvvm
界面开发小八哥18 小时前
界面控件DevExpress WPF中文教程:Data Grid——卡片视图设置
.net·wpf·界面控件·devexpress·ui开发
△曉風殘月〆1 天前
WPF MVVM入门系列教程(二、依赖属性)
c#·wpf·mvvm
逐·風1 天前
unity关于自定义渲染、内存管理、性能调优、复杂物理模拟、并行计算以及插件开发
前端·unity·c#