public MainWindow()
 {
     FirstTab = new RibbonTabViewModel
     {
         Text = "First Tab"
     };
     DataContext = this;
     InitializeComponent();
 }
Beispiel #2
0
        /// <summary>
        /// 创建Tab
        /// </summary>
        public static RibbonTabViewModel CreateRibbonTab()
        {
            var tab = new RibbonTabViewModel()
            {
                Name   = "ExampleTab",
                Header = "测试Tab",
            };

            M.RibbonManager.InsertRibbonTab(tab, 1);
            return(tab);
        }
        /// <summary>
        /// 创建Tab
        /// </summary>
        public static RibbonTabViewModel CreateRibbonTab(IApp iApp, string tabName, string header, int index = 0)
        {
            var tab = new RibbonTabViewModel
            {
                Name   = tabName,
                Header = header,
            };

            Mg.Get <IMgRibbon>().InsertRibbonTab(iApp, tab, index);//index为插入的位置
            return(tab);
        }
Beispiel #4
0
        public void Install(IPluginInfo pluginInfo)
        {
            /*******************采用代码方式创建************************/
            //创建RibbonTab标签
            //_tab = RibbonExample.CreateRibbonTab();
            ////创建RibbonGroup 并加入Tab
            //_group = RibbonExample.CreateRibbonGroup();
            //_tab.Groups.Add(_group);
            ////tab.Groups.Insert(0,group);
            ////创建RibbonButton 在上述创建的RibbonGroup中加入RibbonButton
            //_button = RibbonExample.CreateRibbonButton();
            //_button.Click = new RelayCommand(OnClick);//制定button点击的事件
            //_group.Items.Add(_button);

            ////已有的RibbonTab中加入RibbonGroup
            //_existtab = M.RibbonManager.GetRibbonTab("ExampleTab");
            //_existtab.Groups.Add(new RibbonGroupViewModel()
            //{
            //    Name = "ExampleGroup1",
            //    Header = "测试Group1"
            //});//注意如果该Group中没有Item则在界面上不能显示

            ////已有的RibbonGroup中加入RibbonButton
            //_existGroup = M.RibbonManager.GetRibbonGroup("ExampleGroup1");
            //_existGroup.Items.Add(new RibbonButtonViewModel()
            //{
            //    Name = "Name",
            //    Text = "测试Button",
            //    LargeImage = "url",
            //    ButtonSize = ButtonSize.Large,
            //    Click = new RelayCommand(OnClick)
            //});


            /*******************采用Xml方式创建************************/
            M.RibbonManager.InsertRibbonTab(new ViewTabViewModel(), 1);

            //已有的RibbonTab中加入RibbonGroup
            _existtab = M.RibbonManager.GetRibbonTab(LocalConfig.InsertTabName);
            _existtab.Groups.Add(new ViewGroupViewModel());

            //已有的RibbonGroup中加入RibbonButton

            ViewButtonViewModel buttonGroup = new ViewButtonViewModel();

            //注意,如果向已知的RibbonGroup中添加RibbonButton 建议xml配置文件的外层直接加上group标签 如ViewButton.xml
            //通过继承RibbonGroupViewModel 来解析配置文件得到其中的button
            _existGroup = M.RibbonManager.GetRibbonGroup(buttonGroup.Name);
            _existGroup.Items.AddRange(buttonGroup.Items);
        }
Beispiel #5
0
        protected override async Task OnStartupAsync()
        {
            /*******************采用代码方式创建************************/
            //创建RibbonTab标签
            _tab = RibbonExample.CreateRibbonTab(this, "CodeCreateTab", "代码Tab");
            //创建RibbonGroup 并加入Tab
            _groupOne = RibbonExample.CreateRibbonGroup("CodeCreateGroupOne", "代码Group");
            _tab.Groups.Add(_groupOne);//_tab.Groups.Insert(0,_group);
            //创建RibbonButton 在上述创建的RibbonGroup中加入RibbonButton
            _buttonOne       = RibbonExample.CreateRibbonButton(this, "CodeCreateButton", "代码Button", ShowWindow);
            _buttonOne.Click = new RelayCommand(ShowWindow);//button点击的事件
            _groupOne.Items.Add(_buttonOne);
            //已有的RibbonTab中加入新的RibbonGroup
            var existTab = Mg.Get <IMgRibbon>().GetRibbonTab(_tab.Name);//传入已存在的tabName

            _groupTwo = RibbonExample.CreateRibbonGroup("CodeCreateGroupTwo", "向已有Tab加入的Group");
            existTab.Groups.Add(_groupTwo);                                       //注意如果该Group中没有Item则在界面上不能显示
            //已有的RibbonGroup中加入新的RibbonButton
            var existGroup = Mg.Get <IMgRibbon>().GetRibbonGroup(_groupTwo.Name); //传入已存在的groupName

            _buttonTwo = RibbonExample.CreateRibbonButton(this, "CodeCreateButtonTwo", "向已有Group加入的Button", ShowWindow);
            existGroup.Items.Add(_buttonTwo);

            /*******************采用Xml方式创建************************/
            Mg.Get <IMgRibbon>().InsertRibbonTab(this, new ViewTabViewModel(), 1);
            //已有的RibbonTab中加入RibbonGroup
            _xmlTab   = Mg.Get <IMgRibbon>().GetRibbonTab(LocalConfig.InsertTabName);//可以通过将一些已存在的TabName存在_config.xml里
            _xmlGroup = new ViewGroupViewModel();
            _xmlTab.Groups.Add(_xmlGroup);
            //已有的RibbonGroup中加入RibbonButton
            _xmlGroupTwo = new ViewButtonViewModel();
            //注意:ViewButtonViewModel并不是继承RibbonButtonViewModel,因为RibbonButtonViewModel不支持直接解析XML文件里的<Button>标签
            //因此只能通过外层加上<Group>标签,通过继承RibbonGroupViewModel去解析XML,然后得到Group里的Button组
            _xmlGroup = Mg.Get <IMgRibbon>().GetRibbonGroup(_xmlGroup.Name);
            _xmlGroup.Items.AddRange(_xmlGroupTwo.Items);

            /*******************采用Xml方式展示所有的Ribbon菜单基本控件************************/
            Mg.Get <IMgRibbon>().InsertRibbonTab(this, new RibbonTypeTabViewModel(), 2);
            //插入返回页的项
            Mg.Get <IMgRibbon>().InsertBackstageItem(this, new RibbonBackstageItemViewModel
            {
                Header       = "新添加的项",
                Content      = new FirstViewModel(),
                IsSelectable = true,
            });
            await Task.Yield();
        }
        /// <summary>
        /// Add a button to the ribbon
        /// </summary>
        /// <param name="tab">Tab header</param>
        /// <param name="tabId">Tab id</param>
        /// <param name="group">Group header</param>
        /// <param name="button">Button</param>
        public void AddRibbonButton(string tab, string tabId, string group, RibbonButtonViewModel button)
        {
            if (!_tabs.Any(x => x.Header == tab))
            {
                _tabs.Add(new RibbonTabViewModel(tab, tabId));
            }

            RibbonTabViewModel tabvm = _tabs.First(x => x.Header == tab);

            if (!tabvm.Groups.Any(x => x.Header == group))
            {
                tabvm.Groups.Add(new RibbonGroupViewModel(group));
            }

            RibbonGroupViewModel groupVM = tabvm.Groups.First(x => x.Header == group);

            groupVM.Buttons.Add(button);
        }
        protected override async Task OnStartupAsync()
        {
            //获取RibbonTab
            _projectTab = Mg.Get <IMgRibbon>().GetRibbonTab(LocalConfig.InsertTabName);
            if (_projectTab != null)
            {
                _groupVm = new PostilGroupViewModel();
                _projectTab.Groups.Add(_groupVm);
            }
            else
            {
                Mg.Get <IMgLog>().Warn($"没有找到名称为{LocalConfig.InsertTabName}的RibbonTab!批注管理应用无法插入相关Ribbon菜单!");
            }
            await DataApi.CreateIndexAsync(Hubs.Postil.T, new[] { Hubs.Postil.ProjectId });

            await DataApi.CreateIndexAsync(Hubs.Tag.T, new[] { Hubs.Postil.ProjectId });

            await Task.Yield();
        }
 public void Init()
 {
     _axisGroupVm = new AxisGroupViewModel();
     //初始化集合
     _axisPaneVmsDic = new Dictionary <string, DockingPaneViewModel>();
     //插入Ribbon菜单
     _mgntTabVm = M.RibbonManager.GetRibbonTab(LocalConfig.InsertTabName);
     if (_mgntTabVm != null)
     {
         _mgntTabVm.Groups.Add(_axisGroupVm);
     }
     else
     {
         LoggerHelper.Debug($"未找到名称为{LocalConfig.InsertTabName}的RibbonTab,无法插入轴线管理相关的Ribbon菜单!");
     }
     //插件设置界面......
     //注册相关命令
     M.CommandManager.Register(new CommandInfo("AxisManagement", _axisGroupVm.AxisManagement));
     //注册右键菜单......
 }