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上就看到了

相关推荐
程序leo源3 小时前
C语言:操作符详解1
android·java·c语言·c++·青少年编程·c#
yngsqq6 小时前
c#注册机制作(根据机器码生成注册码和注册文件)
c#
雯0609~7 小时前
c#:winform调用bartender实现打印(学习整理笔记)
开发语言·c#
股票GPT分析9 小时前
《Python 股票交易分析:开启智能投资新时代》(二)
大数据·服务器·python·c#·fastapi
j178050569069 小时前
C#学习笔记——窗口停靠控件WeifenLuo.WinFormsUI.Docking使用-腾讯云开发者社区-腾讯云
开发语言·c#
界面开发小八哥9 小时前
界面控件DevExpress WinForms v24.2新功能预览 - 人工智能(AI)
人工智能·.net·界面控件·devexpress·ui开发
离歌漠13 小时前
C#调用C++ DLL方法之C++/CLI(托管C++)
c++·c#·clr
sukalot13 小时前
windows C#-异步返回类型(下)
windows·c#
飞人博尔特的摄影师13 小时前
WPF绑定Bind方法合集,实时更新
visualstudio·c#·wpf·xaml·maui·xamarin·技巧
冷眼Σ(-᷅_-᷄๑)15 小时前
WPF异步UI交互功能的实现方法
c#·wpf