Пример #1
0
        public FrmRuntime()
        {
            // 加载登陆
            string[] strSplit = { "," };
            string[] strLoginor=ConfigManager.Loginor.Split(strSplit, StringSplitOptions.RemoveEmptyEntries);
            ILogin loginor = ResourceFactory.CreateInstance(strLoginor[0], strLoginor[1]) as Frame.Define.ILogin;
            if (loginor == null)
                loginor = new FrmLogin();

            loginor.Logger = Environment.LogWriter;
            loginor.NhibernateHelper = Environment.NHibernateHelper;
            loginor.AdodbHelper = Environment.AdodbHelper;
            global::Define.IApplication app = Environment.Application;
            if (!loginor.Login(ref app))
            {
                Application.Exit();
                return;
            }
            Environment.Application = app;

            loginor.ShowMessage("正在验证GIS控件权限...");
            string errMsg = null;
            if (!Environment.ResourceManager.LicenseVerify(ref errMsg))
            {
                MessageBox.Show(errMsg);
                Application.Exit();
                return;
            }

            loginor.ShowMessage("正在加载框架界面方案...");
            InitializeComponent();
            this.Text = ConfigManager.AppName;
            this.Icon = ConfigManager.Logo;
            //splitControlMain.PanelVisibility = SplitPanelVisibility.Panel1;

            loginor.ShowMessage("正在创建GIS控件对象...");
            IHooker hooker = Environment.ResourceManager.GetHooker();
            this.m_MainHookPage= this.AddHooker(hooker, enumDockPosition.Center) as XtraTabPage;
            this.Hook = hooker.Hook;
            //Control hookControl = hooker.Control;
            //if (hookControl != null)
            //{
            //    if (hookControl is System.ComponentModel.ISupportInitialize) ((System.ComponentModel.ISupportInitialize)(hookControl)).BeginInit();
            //    //this.splitControlMain.Panel1.Controls.Add(hookControl);
            //    this.tpDefalut.Controls.Add(hookControl);
            //    this.tpDefalut.Text = hooker.Caption;
            //    hookControl.Dock = DockStyle.Fill;
            //    if (hookControl is System.ComponentModel.ISupportInitialize) ((System.ComponentModel.ISupportInitialize)(hookControl)).EndInit();
            //}
            //this.Hook = hooker.Hook;
            //this.m_DictHooker[hooker.ID] = this.tpDefalut;

            loginor.ShowMessage("正在加载插件...");
            IList<Define.ClassInfo> listPlugin = Environment.NHibernateHelper.GetObjectsByCondition<Define.ClassInfo>("from ClassInfo cInfo where cInfo.Type=1");
            foreach (Define.ClassInfo cInfo in listPlugin)
            {
                IPlugin plugin= Utility.ResourceFactory.CreatePlugin(cInfo);
                if (plugin != null)
                {
                    plugin.Logger = Environment.LogWriter;
                    plugin.NhibernateHelper = Environment.NHibernateHelper;
                    plugin.AdodbHelper = Environment.AdodbHelper;
                    plugin.GisWorkspace = Environment.Workspace;
                    plugin.Application = Environment.Application;
                }
            }

            loginor.ShowMessage("正在读取界面配置...");
            IList<RibbonCommandInfo> listCommand = Environment.NHibernateHelper. GetObjectsByCondition<RibbonCommandInfo>("from RibbonCommandInfo rcInfo order by Order asc"); ;

            m_CommandInfoList = new List<RibbonCommandInfo>();
            int count = listCommand.Count;
            for (int i = 0; i < count; i++)
            {
                m_CommandInfoList.Add(listCommand[i]);
            }

            loginor.ShowMessage("正在创建资源...");
            ribbonEngine = new RibbonEngine();
            ribbonEngine.CommandInfoList = m_CommandInfoList;
            ribbonEngine.Ribbon = this.ribbon;
            ribbonEngine.MainMenu = this.mainMenu;
            ribbonEngine.CommandInfoFinder = delegate(string resourceID)
            {
                return m_CommandInfoList.Find(delegate(RibbonCommandInfo cmdInfo) { return cmdInfo.ID == resourceID; });
            };
            ribbonEngine.OnMessage += delegate(string strMsg)
            {
                Utility.Log.AppendMessage(enumLogType.Operate, strMsg);
                loginor.ShowMessage(strMsg);
            };

            //List<ICommand>
                m_CommandList=new List<ICommand>();
            //cmdList.Add(new Commands.CommandLinkage());
            //cmdList.Add(new Utility.EsriCommandProxy(new ESRI.ArcGIS.Controls.ControlsAddDataCommandClass()));
            //cmdEngine.LoadFromCommand(new Commands.CommandLinkage(), "ESRI", "ESRI命令In Frame",null,null);
            //cmdEngine.LoadFromCommand(new Utility.EsriCommandProxy(new ESRI.ArcGIS.Controls.ControlsAddDataCommandClass()), "ESRI", "ESRI命令In Frame",null,null);

            ribbonEngine.Load(ref m_CommandList);

            loginor.ShowMessage("正在绑定资源...");
            //RibbonCommandAdapter
                m_Adapter = new RibbonCommandAdapter(this);
            m_Adapter.OnMessage += delegate(string strMsg)
            {
                this.statusBarMessage.Caption = strMsg;
                Application.DoEvents();
                //frmLogin.SetMessage(strMsg);
            };
            m_Adapter.Adapter(this.ribbon);
            m_Adapter.AddCommands(m_CommandList.ToArray());

            loginor.ShowMessage("正在绘制界面...");
            Thread.Sleep(1000);

            loginor.Dispose();

            //this.dockPanelBottom.Visibility = DockVisibility.Hidden;
            //this.dockPanelLeft.Visibility = DockVisibility.Hidden;
            //this.dockPanelRight.Visibility = DockVisibility.Hidden;
            this.defaultLookAndFeel1.LookAndFeel.SkinName = Properties.Settings.Default.SkinName;
        }
Пример #2
0
        public FrmRuntime()
        {
            FrmLoging   frmLogin = null;
            bool        flag     = true;
            ThreadStart t        = delegate
            {
                frmLogin = new FrmLoging();
                flag     = false;
                frmLogin.ShowDialog();
            };
            Thread thread = new Thread(t);

            thread.Start();

            while (flag)
            {
                Thread.Sleep(10);
            }

            frmLogin.SetMessage("正在加载框架界面方案...");

            InitializeComponent();

            frmLogin.SetMessage("正在创建三维控件对象...");
            this.Text = ConfigManager.AppName;
            splitControlMain.PanelVisibility = SplitPanelVisibility.Panel1;


            TerraExplorerX.SGWorld61 sgwTopLeft;
            TerraExplorerX.SGWorld61 sgwTopRight;
            TerraExplorerX.SGWorld61 sgwBottomLeft;
            TerraExplorerX.SGWorld61 sgwBottomRight;
            this.uC3DWindow1.CreateHooker(out sgwTopLeft, out sgwTopRight, out sgwBottomLeft, out sgwBottomRight);

            frmLogin.SetMessage("正在创建绑定对象...");
            FrameHook hook = new FrameHook(this, new TerraExplorerX.TerraExplorerClass(), sgwTopLeft, this.axMapControl1.Object as ESRI.ArcGIS.Controls.IMapControl4, this.dockPanelRight);

            // 测试
            // // Dictionary<string, Utility.enumCommandType> d = Utility.CommandFactory.GetCommandClasses(@"C:\Program Files (x86)\ArcGIS\DeveloperKit10.0\DotNet\ESRI.ArcGIS.Controls.dll");
            //  Dictionary<string, enumResourceType> dic = Utility.ResourceFactory.GetResources(@"C:\Program Files (x86)\ArcGIS\DeveloperKit10.0\DotNet\ESRI.ArcGIS.Controls.dll");
            // int count = dic.Count;
            //// List<Utility.RibbonCommandInfo>
            //     infoList = new List<RibbonCommandInfo>();
            // for (int i = 0; i < count; i++)
            // {
            //     RibbonCommandInfo info = new RibbonCommandInfo();

            //     ClassInfo cInfo = new ClassInfo();
            //     cInfo.DllName = "ESRI.ArcGIS.Controls.dll";
            //     cInfo.ClassName = dic.Keys.ElementAt(i);// +", ESRI.ArcGIS.Controls";

            //     info.CommandClass = cInfo;
            //     info.Page = "ESRI";
            //     info.PageGroup = "ESRI命令测试";

            //     infoList.Add(info);
            // }
            IList listPlugin = Environment.NHibernateHelper.GetObjectByCondition("from ClassInfo cInfo where cInfo.Type=1");

            foreach (object cInfo in listPlugin)
            {
                IPlugin plugin = Utility.ResourceFactory.CreatePlugin(cInfo as ClassInfo);
                if (plugin != null)
                {
                    plugin.Logger           = Environment.Logger;
                    plugin.NhibernateHelper = Environment.NHibernateHelper;
                    plugin.SysConnection    = Environment.SysDbConnection;
                    plugin.GisWorkspace     = Environment.Workspace;
                }
            }

            frmLogin.SetMessage("正在读取界面配置...");
            IList listCommand = Environment.NHibernateHelper.GetObjectByCondition("from RibbonCommandInfo rcInfo order by Order asc");;

            infoList = new List <RibbonCommandInfo>();
            int count = listCommand.Count;

            for (int i = 0; i < count; i++)
            {
                infoList.Add(listCommand[i] as RibbonCommandInfo);
            }


            frmLogin.SetMessage("正在创建资源...");
            cmdEngine = new RibbonEngine();
            cmdEngine.CommandInfoList   = infoList;
            cmdEngine.Ribbon            = this.ribbon;
            cmdEngine.OnMessageChanged += delegate(string strMsg)
            {
                Utility.Log.AppendMessage(enumLogType.Operate, strMsg);
                frmLogin.SetMessage(strMsg);
            };

            //List<ICommand>
            cmdList = new List <ICommand>();
            //cmdList.Add(new Commands.CommandLinkage());
            //cmdList.Add(new Utility.EsriCommandProxy(new ESRI.ArcGIS.Controls.ControlsAddDataCommandClass()));
            //cmdEngine.LoadFromCommand(new Commands.CommandLinkage(), "ESRI", "ESRI命令In Frame",null,null);
            //cmdEngine.LoadFromCommand(new Utility.EsriCommandProxy(new ESRI.ArcGIS.Controls.ControlsAddDataCommandClass()), "ESRI", "ESRI命令In Frame",null,null);

            cmdEngine.Load(ref cmdList);


            frmLogin.SetMessage("正在绑定资源...");
            //RibbonCommandAdapter
            cmdAdapter = new RibbonCommandAdapter(hook);
            cmdAdapter.OnMessageChanged += delegate(string strMsg)
            {
                //this.statusBarMessage.Caption = strMsg;
                frmLogin.SetMessage(strMsg);
            };
            cmdAdapter.Adapter(this.ribbon);
            cmdAdapter.AddCommands(cmdList.ToArray());


            axTOCControl1.SetBuddyControl(this.axMapControl1);

            frmLogin.SetMessage("正在绘制界面...");
            Thread.Sleep(1000);

            thread.Abort();
        }
Пример #3
0
        public FrmRuntime()
        {
            // 加载登陆
            string[] strSplit   = { "," };
            string[] strLoginor = ConfigManager.Loginor.Split(strSplit, StringSplitOptions.RemoveEmptyEntries);
            ILogin   loginor    = ResourceFactory.CreateInstance(strLoginor[0], strLoginor[1]) as Frame.Define.ILogin;

            if (loginor == null)
            {
                loginor = new FrmLogin();
            }

            loginor.Logger           = Environment.LogWriter;
            loginor.NhibernateHelper = Environment.NHibernateHelper;
            loginor.AdodbHelper      = Environment.AdodbHelper;
            global::Define.IApplication app = Environment.Application;
            if (!loginor.Login(ref app))
            {
                Application.Exit();
                return;
            }
            Environment.Application = app;

            loginor.ShowMessage("正在验证GIS控件权限...");
            string errMsg = null;

            if (!Environment.ResourceManager.LicenseVerify(ref errMsg))
            {
                MessageBox.Show(errMsg);
                Application.Exit();
                return;
            }


            loginor.ShowMessage("正在加载框架界面方案...");
            InitializeComponent();
            this.Text = ConfigManager.AppName;
            this.Icon = ConfigManager.Logo;
            //splitControlMain.PanelVisibility = SplitPanelVisibility.Panel1;


            loginor.ShowMessage("正在创建GIS控件对象...");
            IHooker hooker = Environment.ResourceManager.GetHooker();

            this.m_MainHookPage = this.AddHooker(hooker, enumDockPosition.Center) as XtraTabPage;
            this.Hook           = hooker.Hook;
            //Control hookControl = hooker.Control;
            //if (hookControl != null)
            //{
            //    if (hookControl is System.ComponentModel.ISupportInitialize) ((System.ComponentModel.ISupportInitialize)(hookControl)).BeginInit();
            //    //this.splitControlMain.Panel1.Controls.Add(hookControl);
            //    this.tpDefalut.Controls.Add(hookControl);
            //    this.tpDefalut.Text = hooker.Caption;
            //    hookControl.Dock = DockStyle.Fill;
            //    if (hookControl is System.ComponentModel.ISupportInitialize) ((System.ComponentModel.ISupportInitialize)(hookControl)).EndInit();
            //}
            //this.Hook = hooker.Hook;
            //this.m_DictHooker[hooker.ID] = this.tpDefalut;

            loginor.ShowMessage("正在加载插件...");
            IList <Define.ClassInfo> listPlugin = Environment.NHibernateHelper.GetObjectsByCondition <Define.ClassInfo>("from ClassInfo cInfo where cInfo.Type=1");

            foreach (Define.ClassInfo cInfo in listPlugin)
            {
                IPlugin plugin = Utility.ResourceFactory.CreatePlugin(cInfo);
                if (plugin != null)
                {
                    plugin.Logger           = Environment.LogWriter;
                    plugin.NhibernateHelper = Environment.NHibernateHelper;
                    plugin.AdodbHelper      = Environment.AdodbHelper;
                    plugin.GisWorkspace     = Environment.Workspace;
                    plugin.Application      = Environment.Application;
                }
            }

            loginor.ShowMessage("正在读取界面配置...");
            IList <RibbonCommandInfo> listCommand = Environment.NHibernateHelper.GetObjectsByCondition <RibbonCommandInfo>("from RibbonCommandInfo rcInfo order by Order asc");;

            m_CommandInfoList = new List <RibbonCommandInfo>();
            int count = listCommand.Count;

            for (int i = 0; i < count; i++)
            {
                m_CommandInfoList.Add(listCommand[i]);
            }


            loginor.ShowMessage("正在创建资源...");
            ribbonEngine = new RibbonEngine();
            ribbonEngine.CommandInfoList   = m_CommandInfoList;
            ribbonEngine.Ribbon            = this.ribbon;
            ribbonEngine.MainMenu          = this.mainMenu;
            ribbonEngine.CommandInfoFinder = delegate(string resourceID)
            {
                return(m_CommandInfoList.Find(delegate(RibbonCommandInfo cmdInfo) { return cmdInfo.ID == resourceID; }));
            };
            ribbonEngine.OnMessage += delegate(string strMsg)
            {
                Utility.Log.AppendMessage(enumLogType.Operate, strMsg);
                loginor.ShowMessage(strMsg);
            };

            //List<ICommand>
            m_CommandList = new List <ICommand>();
            //cmdList.Add(new Commands.CommandLinkage());
            //cmdList.Add(new Utility.EsriCommandProxy(new ESRI.ArcGIS.Controls.ControlsAddDataCommandClass()));
            //cmdEngine.LoadFromCommand(new Commands.CommandLinkage(), "ESRI", "ESRI命令In Frame",null,null);
            //cmdEngine.LoadFromCommand(new Utility.EsriCommandProxy(new ESRI.ArcGIS.Controls.ControlsAddDataCommandClass()), "ESRI", "ESRI命令In Frame",null,null);

            ribbonEngine.Load(ref m_CommandList);


            loginor.ShowMessage("正在绑定资源...");
            //RibbonCommandAdapter
            m_Adapter            = new RibbonCommandAdapter(this);
            m_Adapter.OnMessage += delegate(string strMsg)
            {
                this.statusBarMessage.Caption = strMsg;
                Application.DoEvents();
                //frmLogin.SetMessage(strMsg);
            };
            m_Adapter.Adapter(this.ribbon);
            m_Adapter.AddCommands(m_CommandList.ToArray());

            loginor.ShowMessage("正在绘制界面...");
            Thread.Sleep(1000);

            loginor.Dispose();

            //this.dockPanelBottom.Visibility = DockVisibility.Hidden;
            //this.dockPanelLeft.Visibility = DockVisibility.Hidden;
            //this.dockPanelRight.Visibility = DockVisibility.Hidden;
            this.defaultLookAndFeel1.LookAndFeel.SkinName = Properties.Settings.Default.SkinName;
        }
Пример #4
0
        private void InitRibbon()
        {
            IList <RibbonCommandInfo> listCommand = m_HibernateHelper.GetObjectsByCondition <RibbonCommandInfo>("from RibbonCommandInfo rcInfo order by Order asc");//from RibbonCommandInfo rcInfo order by Page,PageGroup asc");
            int count = listCommand.Count;

            //m_CommandList = new List<RibbonCommandInfo>();
            //for (int i = 0; i < count; i++)
            //{
            //    m_CommandList.Add(listCommand[i] as RibbonCommandInfo);
            //}
            m_CommandList = listCommand as List <RibbonCommandInfo>;

            // 工具栏预览
            this.applicationMenu1.ItemLinks.Clear();
            this.ribbonControl1.Items.Clear();
            this.ribbonControl1.Pages.Clear();
            this.ribbonControl1.StatusBar.ItemLinks.Clear();
            this.ribbonControl1.PageHeaderItemLinks.Clear();
            this.ribbonControl1.Toolbar.ItemLinks.Clear();
            ribbonControl1.Pages.Clear();
            RibbonEngine ribbonEngine = new RibbonEngine();

            ribbonEngine.CommandInfoList   = m_CommandList;
            ribbonEngine.Ribbon            = this.ribbonControl1;
            ribbonEngine.MainMenu          = applicationMenu1;
            ribbonEngine.CommandInfoFinder = delegate(string resourceID)
            {
                return(m_CommandList.Find(delegate(RibbonCommandInfo cmdInfo) { return cmdInfo.ID == resourceID; }));
            };
            List <ICommand> cmdList = new List <ICommand>();

            ribbonEngine.Load(ref cmdList);


            // 树
            tlRibbon.Nodes.Clear();
            string strPage  = null;
            string strGroup = null;
            Dictionary <string, TreeListNode> dicNode = new Dictionary <string, TreeListNode>();
            TreeListNode nodePage   = null;
            TreeListNode nodeGroup  = null;
            TreeListNode nodeParent = null;
            int          pageOrder  = 1;
            int          groupOrder = 1;
            int          cmdOrder   = 1;

            for (int i = 0; i < count; i++)
            {
                RibbonCommandInfo cmdInfo = m_CommandList[i];
                //if (cmdInfo.Type != enumCommandType.Normal)
                //    continue;
                if (cmdInfo.Parent != null)
                {
                    // 必须排好序才能这么来
                    nodeParent = dicNode[cmdInfo.Parent.ID];
                }
                else
                {
                    if (strPage != cmdInfo.Page)
                    {
                        strPage   = cmdInfo.Page;
                        nodePage  = tlRibbon.AppendNode(new object[] { strPage, null, null, pageOrder++ }, null);
                        pageOrder = 1;
                    }

                    if (strGroup != cmdInfo.PageGroup)
                    {
                        strGroup  = cmdInfo.PageGroup;
                        nodeGroup = tlRibbon.AppendNode(new object[] { strGroup, null, null, groupOrder++ }, nodePage);
                        cmdOrder  = 1;
                    }
                    nodeParent = nodeGroup;
                }

                TreeListNode nodeCommand = tlRibbon.AppendNode(new object[] { cmdInfo.Caption, cmdInfo.Icon, cmdInfo.CommandClass, cmdOrder++, m_TypeNames[(int)cmdInfo.Type] }, nodeParent);
                nodeCommand.Tag = cmdInfo;

                dicNode.Add(cmdInfo.ID, nodeCommand);
            }
        }
Пример #5
0
        public FrmRuntime()
        {
            FrmLoging frmLogin = null;
            bool flag = true;
            ThreadStart t = delegate
            {
                frmLogin= new FrmLoging();
                flag = false;
                frmLogin.ShowDialog();
            };
            Thread thread = new Thread(t);
            thread.Start();

            while (flag)
            {
                Thread.Sleep(10);
            }

            frmLogin.SetMessage("正在加载框架界面方案...");

            InitializeComponent();

            frmLogin.SetMessage("正在创建三维控件对象...");
            this.Text = ConfigManager.AppName;
            splitControlMain.PanelVisibility = SplitPanelVisibility.Panel1;

            TerraExplorerX.SGWorld61 sgwTopLeft;
            TerraExplorerX.SGWorld61 sgwTopRight;
            TerraExplorerX.SGWorld61 sgwBottomLeft;
            TerraExplorerX.SGWorld61 sgwBottomRight;
            this.uC3DWindow1.CreateHooker(out sgwTopLeft, out sgwTopRight, out sgwBottomLeft, out sgwBottomRight);

            frmLogin.SetMessage("正在创建绑定对象...");
            FrameHook hook = new FrameHook(this, new TerraExplorerX.TerraExplorerClass(), sgwTopLeft, this.axMapControl1.Object as ESRI.ArcGIS.Controls.IMapControl4, this.dockPanelRight);

            // 测试
               // // Dictionary<string, Utility.enumCommandType> d = Utility.CommandFactory.GetCommandClasses(@"C:\Program Files (x86)\ArcGIS\DeveloperKit10.0\DotNet\ESRI.ArcGIS.Controls.dll");
               //  Dictionary<string, enumResourceType> dic = Utility.ResourceFactory.GetResources(@"C:\Program Files (x86)\ArcGIS\DeveloperKit10.0\DotNet\ESRI.ArcGIS.Controls.dll");
               // int count = dic.Count;
               //// List<Utility.RibbonCommandInfo>
               //     infoList = new List<RibbonCommandInfo>();
               // for (int i = 0; i < count; i++)
               // {
               //     RibbonCommandInfo info = new RibbonCommandInfo();

               //     ClassInfo cInfo = new ClassInfo();
               //     cInfo.DllName = "ESRI.ArcGIS.Controls.dll";
               //     cInfo.ClassName = dic.Keys.ElementAt(i);// +", ESRI.ArcGIS.Controls";

               //     info.CommandClass = cInfo;
               //     info.Page = "ESRI";
               //     info.PageGroup = "ESRI命令测试";

               //     infoList.Add(info);
               // }
            IList listPlugin = Environment.NHibernateHelper.GetObjectByCondition("from ClassInfo cInfo where cInfo.Type=1");
            foreach (object cInfo in listPlugin)
            {
                IPlugin plugin= Utility.ResourceFactory.CreatePlugin(cInfo as ClassInfo);
                if (plugin != null)
                {
                    plugin.Logger = Environment.Logger;
                    plugin.NhibernateHelper = Environment.NHibernateHelper;
                    plugin.SysConnection = Environment.SysDbConnection;
                    plugin.GisWorkspace = Environment.Workspace;
                }
            }

            frmLogin.SetMessage("正在读取界面配置...");
            IList listCommand = Environment.NHibernateHelper. GetObjectByCondition("from RibbonCommandInfo rcInfo order by Order asc"); ;

            infoList = new List<RibbonCommandInfo>();
            int count = listCommand.Count;
            for (int i = 0; i < count; i++)
            {
                infoList.Add(listCommand[i] as RibbonCommandInfo);
            }

            frmLogin.SetMessage("正在创建资源...");
            cmdEngine = new RibbonEngine();
            cmdEngine.CommandInfoList = infoList;
            cmdEngine.Ribbon = this.ribbon;
            cmdEngine.OnMessageChanged += delegate(string strMsg)
            {
                Utility.Log.AppendMessage(enumLogType.Operate, strMsg);
                frmLogin.SetMessage(strMsg);
            };

            //List<ICommand>
                cmdList=new List<ICommand>();
            //cmdList.Add(new Commands.CommandLinkage());
            //cmdList.Add(new Utility.EsriCommandProxy(new ESRI.ArcGIS.Controls.ControlsAddDataCommandClass()));
            //cmdEngine.LoadFromCommand(new Commands.CommandLinkage(), "ESRI", "ESRI命令In Frame",null,null);
            //cmdEngine.LoadFromCommand(new Utility.EsriCommandProxy(new ESRI.ArcGIS.Controls.ControlsAddDataCommandClass()), "ESRI", "ESRI命令In Frame",null,null);

            cmdEngine.Load(ref cmdList);

            frmLogin.SetMessage("正在绑定资源...");
            //RibbonCommandAdapter
                cmdAdapter = new RibbonCommandAdapter(hook);
            cmdAdapter.OnMessageChanged += delegate(string strMsg)
            {
                //this.statusBarMessage.Caption = strMsg;
                frmLogin.SetMessage(strMsg);
            };
            cmdAdapter.Adapter(this.ribbon);
            cmdAdapter.AddCommands(cmdList.ToArray());

            axTOCControl1.SetBuddyControl(this.axMapControl1);

            frmLogin.SetMessage("正在绘制界面...");
            Thread.Sleep(1000);

            thread.Abort();
        }
Пример #6
0
        private void InitRibbon()
        {
            IList<RibbonCommandInfo> listCommand = m_HibernateHelper.GetObjectsByCondition<RibbonCommandInfo>("from RibbonCommandInfo rcInfo order by Order asc");//from RibbonCommandInfo rcInfo order by Page,PageGroup asc");
            int count = listCommand.Count;

            //m_CommandList = new List<RibbonCommandInfo>();
            //for (int i = 0; i < count; i++)
            //{
            //    m_CommandList.Add(listCommand[i] as RibbonCommandInfo);
            //}
            m_CommandList = listCommand as List<RibbonCommandInfo>;

            // 工具栏预览
            this.applicationMenu1.ItemLinks.Clear();
            this.ribbonControl1.Items.Clear();
            this.ribbonControl1.Pages.Clear();
            this.ribbonControl1.StatusBar.ItemLinks.Clear();
            this.ribbonControl1.PageHeaderItemLinks.Clear();
            this.ribbonControl1.Toolbar.ItemLinks.Clear();
            ribbonControl1.Pages.Clear();
            RibbonEngine ribbonEngine = new RibbonEngine();
            ribbonEngine.CommandInfoList = m_CommandList;
            ribbonEngine.Ribbon = this.ribbonControl1;
            ribbonEngine.MainMenu = applicationMenu1;
            ribbonEngine.CommandInfoFinder=delegate(string resourceID)
            {
                return m_CommandList.Find(delegate(RibbonCommandInfo cmdInfo) { return cmdInfo.ID == resourceID; });
            };
            List<ICommand > cmdList=new List<ICommand>();

            ribbonEngine.Load(ref cmdList);

            // 树
            tlRibbon.Nodes.Clear();
            string strPage = null;
            string strGroup = null;
            Dictionary<string, TreeListNode> dicNode = new Dictionary<string, TreeListNode>();
            TreeListNode nodePage = null;
            TreeListNode nodeGroup = null;
            TreeListNode nodeParent = null;
            int pageOrder = 1;
            int groupOrder = 1;
            int cmdOrder = 1;
            for(int i=0;i<count;i++)
            {
                RibbonCommandInfo cmdInfo = m_CommandList[i];
                //if (cmdInfo.Type != enumCommandType.Normal)
                //    continue;
                if (cmdInfo.Parent != null)
                {
                    // 必须排好序才能这么来
                    nodeParent = dicNode[cmdInfo.Parent.ID];
                }
                else
                {
                    if (strPage != cmdInfo.Page)
                    {
                        strPage = cmdInfo.Page;
                        nodePage = tlRibbon.AppendNode(new object[] { strPage, null, null, pageOrder++ }, null);
                        pageOrder = 1;
                    }

                    if (strGroup != cmdInfo.PageGroup)
                    {
                        strGroup = cmdInfo.PageGroup;
                        nodeGroup = tlRibbon.AppendNode(new object[] { strGroup, null, null, groupOrder++ }, nodePage);
                        cmdOrder = 1;
                    }
                    nodeParent = nodeGroup;
                }

                TreeListNode nodeCommand = tlRibbon.AppendNode(new object[] { cmdInfo.Caption, cmdInfo.Icon, cmdInfo.CommandClass, cmdOrder++, m_TypeNames[(int)cmdInfo.Type] }, nodeParent);
                nodeCommand.Tag = cmdInfo;

                dicNode.Add(cmdInfo.ID, nodeCommand);
            }
        }