Example #1
0
        public void SetPermisonInBarItemLink(string menuname, BarItemLink page, ref bool visibleGroup)
        {
            BarItem barItem = page.Item;

            if (barItem != null)
            {
                if (barItem.Name == menuname)
                {
                    barItem.Visibility = DevExpress.XtraBars.BarItemVisibility.Always;
                    visibleGroup       = true;
                }
                if (barItem.GetType().FullName == "DevExpress.XtraBars.BarSubItem")
                {
                    BarSubItem mBarSubItem = (BarSubItem)barItem;
                    foreach (BarItemLink menuSubLink in mBarSubItem.ItemLinks)
                    {
                        SetPermisonInBarItemLink(menuname, menuSubLink, ref visibleGroup);
                        if (visibleGroup)
                        {
                            barItem.Visibility = DevExpress.XtraBars.BarItemVisibility.Always;
                            break;
                        }
                    }
                }
            }
        }
Example #2
0
        private void load_InitData()
        {
            //TODO:1开启多线程获取数据流
            //ThreadPool.QueueUserWorkItem(o=> { Download.GetInstance().DownloadData(); });
            ThreadPool.QueueUserWorkItem(o => { Server.GetInstance().Start(); });
            //加载菜单栏项目下拉列表和点击事件
            string    sql = "select * from project";
            DataTable dt  = common.MySqlHelper.GetDataSet(sql, null).Tables[0];

            //清空原有子菜单
            barSubItem1.ItemLinks.Clear();
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                BarButtonItem item = new BarButtonItem();
                item.Caption    = dt.Rows[i].ItemArray[1].ToString();
                item.Id         = Convert.ToInt32(dt.Rows[i].ItemArray[0]);
                item.Name       = "itemFaviate" + item.Id;
                item.ItemClick += new DevExpress.XtraBars.ItemClickEventHandler(itemFaviate_ItemClick);
                if (i == 0)
                {
                    BarItemLink itemLink = barSubItem1.AddItem(item);
                    itemLink.BeginGroup = true;
                }
                else
                {
                    barSubItem1.AddItem(item);
                }
            }
        }
Example #3
0
 public static void AddQuickToolBar(System.Collections.IList collection1, System.Collections.IList collection2)
 {
     collection2.Clear();
     foreach (object obj1 in collection1)
     {
         if (!(obj1 is BarItem))
         {
             continue;
         }
         BarItem bi = obj1 as BarItem;
         if (AddInTree.QuickToolbarItem.Contains(bi.Name))
         {
             bool flag = false;
             foreach (object obj2 in collection2)
             {
                 if (!(obj2 is BarItemLink))
                 {
                     continue;
                 }
                 BarItemLink bil = obj2 as BarItemLink;
                 if (bil.Item.Name == bi.Name)
                 {
                     flag = true;
                     break;
                 }
             }
             if (!flag)
             {
                 collection2.Add(obj1);
             }
         }
     }
 }
        /// <summary>
        /// 插入操作按钮,
        /// </summary>
        /// <param name="ReferButtonName">参照按钮</param>
        /// <param name="Before">在操作按钮前插入还是在操作按钮后插入,默认在之前插入True</param>
        /// <param name="btn">按钮类</param>
        /// <param name="Authority">权限值</param>
        /// <param name="AuthorityName">权限名称,如果为空权限名称==按钮显示名称</param>
        /// <returns></returns>
        private BarItem InsertButton(string ReferButtonName, bool Before, RibbonItemButtonBase btn, int Authority, string AuthorityName = null)
        {
            BarItemLink Refer = GetButtonByName(ReferButtonName);

            if (String.IsNullOrEmpty(AuthorityName))
            {
                AuthorityName = btn.Caption;
            }
            BarItemLink bilink = gen.InsertBarItem(btn.name, btn.Caption, btn.LoadImage, Refer, Before);
            BarItem     bi     = bilink.Item;

            _Buttons.AddBtn(bilink);

            //if (btn.Shortcut != null && btn.Shortcut != Keys.None)
            if (btn.Shortcut != Keys.None)
            {
                bi.ItemShortcut = new DevExpress.XtraBars.BarShortcut(btn.Shortcut);
            }
            if (Authority > 0)
            {
                this.AuthorityAdd(bi, Authority, AuthorityName);
            }

            return(bi);
        }
Example #5
0
        public string GetToolbarAsString()
        {
            List <string> itemsStrings = new List <string>();

            foreach (BarItemLinkBase itemLinkBase in this.ribbonControl.ToolbarItemLinks)
            {
                BarItemLink itemLink = itemLinkBase as BarItemLink;
                if (itemLink == null)
                {
                    continue;
                }
                string  name       = null;
                string  properties = null;
                BarItem sharedBarItem;
                if (itemLink.Item != null && this.sharedBarItems.TryGetValue(itemLink.Item, out sharedBarItem))
                {
                    properties = barItemEqualityComparer.BarItemToString(sharedBarItem);
                }
                else
                {
                    name = itemLink.BarItemName;
                }
                itemsStrings.Add(ReflectionHelper.CombineStrings(ReflectionHelper.ObjectToString(name), ReflectionHelper.ObjectToString(properties)));
            }
            return(ReflectionHelper.CombineStrings(itemsStrings.ToArray()));
        }
 public void AddBtn(BarItemLink btn)
 {
     if (!buttons.ContainsKey(btn.Item.Name))
     {
         buttons.Add(btn.Item.Name, btn);
     }
 }
Example #7
0
        public void AddDynamicPages_PerformClick()
        {
            BarItem         barItem1, barItem2;
            RibbonPage      page1, page2;
            RibbonPageGroup group1, group2;

            CreateDynamicPage("FirstItem", "1", out barItem1, out page1, out group1);
            CreateDynamicPage("SecondItem", "1", out barItem2, out page2, out group2);
            bool barItem1Clicked = false;
            bool barItem2Clicked = false;

            barItem1.ItemClick += (s, e) => { barItem1Clicked = true; };
            barItem2.ItemClick += (s, e) => { barItem2Clicked = true; };
            BarItemLink barItemLink1 = (BarItemLink)group1.ItemLinks[0];
            BarItemLink barItemLink2 = (BarItemLink)group2.ItemLinks[0];

            Assert.IsNotNull(barItemLink1.Item);
            Assert.AreEqual(barItemLink1.Item, barItemLink2.Item);
            this.ribbonControl.SelectedPage = page1;
            barItemLink1.Item.PerformClick();
            Assert.IsTrue(barItem1Clicked);
            Assert.IsFalse(barItem2Clicked);
            barItem1Clicked = false;
            this.ribbonControl.SelectedPage = page2;
            barItemLink2.Item.PerformClick();
            Assert.IsFalse(barItem1Clicked);
            Assert.IsTrue(barItem2Clicked);
        }
Example #8
0
        /// <summary>
        /// 获取指定名称的上下文菜单
        /// </summary>
        /// <param name="name">上下文菜单名称</param>
        /// <returns>返回正确的上下文菜单,如果不存在指定名称的上下文菜单则返回空的<see cref="PopupMenu"/>对象</returns>
        public object GetContentMenu(string name)
        {
            PopupMenu content = new PopupMenu();

            content.Manager = barManager;
            if (contents.ContainsKey(name))
            {
                AddInTree addInTree = workItem.Services.Get <AddInTree>();
                if (addInTree != null)
                {
                    try
                    {
                        AddInNode addInNode = addInTree.GetChild(name);
                        if (addInNode != null)
                        {
                            addInNode.BuildChildItems(this);
                        }
                    }
                    catch (Exception ex) {
                        throw new UniframeworkException(String.Format("无法创建指定路径 \"{0} \" 的插件单元,{1}", name, ex.Message));
                    }
                }
            }

            if (contents.ContainsKey(name))
            {
                foreach (BarItemLink link in contents[name].ItemLinks)
                {
                    BarItemLink barlink = content.AddItem(link.Item);
                    barlink.BeginGroup = link.BeginGroup;
                }
            }

            return(content);
        }
Example #9
0
        void popupControl_MouseMove(object sender, MouseEventArgs e)
        {
            if (editorShown)
            {
                editorShown = false;
                return;
            }
            BarItemLink highlightedLink = (sender as PopupMenuBarControl).GetLinkByPoint(Cursor.Position);

            if (highlightedLink != null)
            {
                if (highlightedLink.Item != searchBarItem)
                {
                    foreach (BarEditItemLink item in searchBarItem.Links)
                    {
                        if (item.ActiveEditor != null)
                        {
                            item.CloseEditor();
                            item.PostEditor();
                            break;
                        }
                    }
                }
            }
        }
Example #10
0
 public void AddItem(string cmdName, string parentName, bool isGroup)
 {
     if (!string.IsNullOrEmpty(parentName))
     {
         BarItemLink oldLink = popupMenu1.ItemLinks.FirstOrDefault(c => c.Item.Name == parentName);
         if (oldLink != null && oldLink.Item is BarSubItem)
         {
             BarSubItem subItem = oldLink.Item as BarSubItem;
             BarItem    find    = _context.RibbonMenu.SubItems.FindItem(cmdName);
             if (find == null)
             {
                 return;
             }
             find.Enabled = ((YutaiCommand)find.Tag).Enabled;
             BarItemLink link = subItem.ItemLinks.Add(find);
             link.BeginGroup = isGroup;
         }
     }
     else
     {
         BarItem find = _context.RibbonMenu.SubItems.FindItem(cmdName);
         if (find == null)
         {
             return;
         }
         find.Enabled = ((YutaiCommand)find.Tag).Enabled;
         BarItemLink link = popupMenu1.ItemLinks.Add(find);
         link.BeginGroup = isGroup;
     }
 }
Example #11
0
        private BarItemLink CreateNormalLink(MenuItemDescriptor item,
                                             IBarItemFinder finder,
                                             PopupMenu popupMenu,
                                             string moduleID)
        {
            BarItem barItem    = null;
            string  cmdId      = string.Empty;
            bool    beginGroup = false;

            cmdId = item.Codon.Properties["cmdId"];
            if (!string.IsNullOrEmpty(item.Codon.Properties["beginGroup"]))
            {
                beginGroup = bool.Parse(item.Codon.Properties["beginGroup"]);
            }

            barItem = finder.GetBarItem(cmdId);
            if (barItem == null)
            {
                throw new Exception("Context menu invalid:" + cmdId + " in " + moduleID);
            }
            BarItemLink link = popupMenu.ItemLinks.Add(barItem);

            link.BeginGroup = beginGroup;
            return(link);
        }
Example #12
0
        void ShowItemSuperTip(BarItemLink item)
        {
            var args = new ToolTipControllerShowEventArgs {
                ToolTipType = ToolTipType.SuperTip,
                SuperTip    = new SuperToolTip()
            };

            foreach (var choiceActionItem in _newObjectAction.Items)
            {
                var formatTestAction = EasyTestTagHelper.FormatTestAction(_newObjectAction.Caption + '.' + choiceActionItem.GetItemPath());
                if (formatTestAction == item.Item.Tag as string)
                {
                    var data = choiceActionItem.Data;
                    if (data != null)
                    {
                        var newObjectActionTooltip =
                            ((IModelClassNewObjectActionTooltip)
                             _newObjectAction.Application.Model.BOModel.GetClass((Type)data)).NewObjectActionTooltip;
                        if (!string.IsNullOrEmpty(newObjectActionTooltip))
                        {
                            args.SuperTip.Items.Add(newObjectActionTooltip);
                            ToolTipController.DefaultController.ShowHint(args);
                        }
                    }
                }
            }
        }
        public void refreshProducts()
        {
            Bar         bar1 = new Bar();
            BarItemLink link = bar1.AddItem(btnRefresh);

            btnRefresh_ItemClick(new object(), new ItemClickEventArgs(btnRefresh, link));
        }
Example #14
0
 private void ActionControlsSiteController_CustomizeActionControl(object sender, ActionControlEventArgs e)
 {
     if ((Frame.Template is RibbonForm) && needWordWrapActionsId.Contains(e.ActionControl.ActionId) && (e.ActionControl.NativeControl is BarButtonItem))
     {
         BarItemLink barItemLink = GetBarItemLinkForBarItem((IActionControlsSite)Frame.Template, (BarItem)e.ActionControl.NativeControl);
         if ((barItemLink != null) && (!barItemLink.IsLinkInMenu))
         {
             barItemLink.UserCaption = barItemLink.Item.Caption.Replace(' ', '\n');
         }
     }
     if (beginGroupActionsId.Contains(e.ActionControl.ActionId) && (e.ActionControl.NativeControl is BarItem))
     {
         BarItemLink barItemLink = GetBarItemLinkForBarItem((IActionControlsSite)Frame.Template, (BarItem)e.ActionControl.NativeControl);
         if (barItemLink != null)
         {
             barItemLink.BeginGroup = true;
         }
     }
     if (e.ActionControl.ActionId == "FindBySubjectAction")
     {
         BarEditItem barEditItem = e.ActionControl.NativeControl as BarEditItem;
         if (barEditItem != null)
         {
             RepositoryItemButtonEdit edit = barEditItem.Edit as RepositoryItemButtonEdit;
             if (edit != null)
             {
                 EditorButton executeButton = edit.Buttons.FirstOrDefault(x => (string)x.Tag == "ExecuteButton");
                 if (executeButton != null)
                 {
                     executeButton.Kind = ButtonPredefines.Search;
                 }
             }
         }
     }
 }
 protected override void OnClick(BarItemLink link)
 {
     if (RichEditControl != null)
     {
         RichEditControl.CreateCommand(RichEditCommandId.ShowInsertMergeFieldForm).Execute();
     }
 }
Example #16
0
            /// <summary>
            /// Get the page index for the page specified within the current collection
            /// </summary>
            public int GetItemIndex(RibbonPage page, BarItemLink barItem)
            {
                int rtv = 0;

                int count = 0;

                foreach (mgDevX_RibbonControlBarItem item in this)
                {
                    if (item.Page == page)
                    {
                        if (item.BarItemLink == barItem)
                        {
                            rtv = item.PageIndex;
                            break;
                        }
                        else
                        {
                            count++;
                        }
                    }
                }
                if (count > 0)
                {
                    rtv = count;
                }

                return(rtv);
            }
Example #17
0
        private Rectangle GetLinksScreenRect(BarItemLink link)
        {
            PropertyInfo info = typeof(BarItemLink).GetProperty("BarControl", BindingFlags.Instance | BindingFlags.NonPublic);
            Control      c    = (Control)info.GetValue(link, null);

            return(c.RectangleToScreen(link.Bounds));
        }
Example #18
0
        void richEditControl1_HoverMenuShowing(object sender, HoverMenuShowingEventArgs e)
        {
            // Remove DecreaseIndent and IncreaseIndent command menu items.
            for (int i = 0; i < e.Menu.ItemsCount; i++)
            {
                BarItemLink       bLink = (BarItemLink)e.Menu.ItemLinks[i];
                RichEditUICommand cmd   = (RichEditUICommand)bLink.Item.Command;
                if (cmd.CommandId == RichEditCommandId.DecreaseIndent ||
                    cmd.CommandId == RichEditCommandId.IncreaseIndent)
                {
                    e.Menu.ItemLinks.Remove(bLink);
                }
            }
            // Add a separator.
            BarItemLinkSeparator itemSep = new BarItemLinkSeparator();

            e.Menu.ItemLinks.Add(itemSep);
            // Create a new menu item and add it to the hover menu.
            RichEditMenuItem item1 = new RichEditMenuItem();

            item1.Content = "Replace Emoticon with Smiley";
            MySmileyCommand cmd_toAdd = new MySmileyCommand(richEditControl1);

            item1.Command = cmd_toAdd;
            item1.Glyph   = cmd_toAdd.Glyph;
            e.Menu.ItemLinks.Add(item1);
        }
Example #19
0
 private void ClearResource(BarSubItem parentItem, BarItem item, BarItemLink link, BarItemInvoker invoker, IdentKey key, int lastValidIndex)
 {
     LastIndex = lastValidIndex;
     try { _Commands.Remove(key); }
     catch { }
     try { if (invoker != null)
           {
               invoker.Dispose();
           }
     }
     catch { }
     try
     {
         if (link != null)
         {
             if (parentItem == null)
             {
                 _rootBar.ItemLinks.Remove(link);
             }
             else
             {
                 parentItem.ItemLinks.Remove(link);
             }
         }
     }
     catch { }
     try { if (item != null)
           {
               _barManager.Items.Remove(item);
           }
     }
     catch { }
 }
        private void frmPermission_Load(object sender, EventArgs e)
        {
            Bar         bar1 = new Bar();
            BarItemLink link = bar1.AddItem(btnRefresh);

            btnRefresh_ItemClick(sender, new DevExpress.XtraBars.ItemClickEventArgs(btnRefresh, link));
        }
Example #21
0
 protected override void OnClick(BarItemLink link)
 {
     base.OnClick(link);
     if (this.codon != null)
     {
         ICommand command = this.Command;
         if (command != null)
         {
             if (command.CheckPermission())
             {
                 if (this.Checked)
                 {
                     command.Run(this, null);
                     string functionInfo = this.Command.CommandID;
                     if (this.Command.CommandName != null && this.Command.CommandName != "")
                     {
                         functionInfo = StringParser.Parse(this.Command.CommandName);
                     }
                     LoggingService.Info("Function " + functionInfo + " run.");
                     return;
                 }
                 command.RestoreEnv();
                 return;
             }
             else
             {
                 XtraMessageBox.Show(StringParser.Parse("${res:ModeNoAuth}"), StringParser.Parse("${res:View_Prompt}"));
             }
         }
     }
 }
Example #22
0
 protected override void OnClick(BarItemLink link)
 {
     base.OnClick(link);
     if (this.dockPanel != null)
     {
         this.dockPanel.Visibility = DockVisibility.AutoHide;
     }
 }
Example #23
0
 protected override void ItemClicked(BarItemLink barItemLink)
 {
     base.ItemClicked(barItemLink);
     if (IsItemClickEnable && IsConfirmed())
     {
         Action.Checked = !Action.Checked;
     }
 }
 private void ProcessSeperator(BarItemLink barItemLink)
 {
     if (_nextItemBeginsGroup)
     {
         barItemLink.BeginGroup = _nextItemBeginsGroup;
         _nextItemBeginsGroup   = false;
     }
 }
Example #25
0
 public mgDevX_RibbonControlBarItem(RibbonPage page,
                                    RibbonPageGroup group,
                                    BarItemLink barItemLink)
 {
     _page        = page;
     _pageGroup   = group;
     _barItemLink = barItemLink;
 }
Example #26
0
        private void ShowItemSuperTip(BarItemLink item)
        {
            ToolTipControllerShowEventArgs args = new ToolTipControllerShowEventArgs();

            args.ToolTipType = ToolTipType.SuperTip;
            args.SuperTip    = new SuperToolTip();
            args.SuperTip.Items.Add(item.Item.Hint);
            ToolTipController.DefaultController.ShowHint(args);
        }
        /// <summary>
        /// 设置按钮可用状态
        /// </summary>
        /// <param name="btnName"></param>
        /// <param name="sEnabled"></param>
        protected void SetButtonEnabled(string btnName, bool sEnabled)
        {
            BarItemLink bi = _Buttons.GetButtonByName(btnName);

            if (bi != null)
            {
                bi.Item.Enabled = sEnabled;
            }
        }
        /// <summary>
        /// 设置按钮可见状态
        /// </summary>
        /// <param name="btnName"></param>
        /// <param name="sEnabled"></param>
        protected void SetButtonVisible(string btnName, bool sVisible)
        {
            BarItemLink bi = _Buttons.GetButtonByName(btnName);

            if (bi != null)
            {
                bi.Item.Visibility = sVisible == true ? BarItemVisibility.Always : BarItemVisibility.Never;
            }
        }
Example #29
0
 public void CreateToolBarButton(string name, EventHandler eventHandler, Image image, int linkIndex, bool isBeginGroup)
 {
     try
     {
         BarLargeButtonItem barLargeButtonItem;
         if (!this._toolbarList.Contains(name))
         {
             this._toolbarList.Add(name);
             linkIndex         += 4;
             barLargeButtonItem = new BarLargeButtonItem(this.barManager, name)
             {
                 CaptionAlignment = BarItemCaptionAlignment.Right,
                 Name             = string.Format("temp_{0}", name)
             };
             if (image != null)
             {
                 barLargeButtonItem.LargeGlyph = image;
                 barLargeButtonItem.Glyph      = image;
             }
             barLargeButtonItem.ItemClick += delegate(object sender, ItemClickEventArgs e) {
                 if (eventHandler != null)
                 {
                     eventHandler(barLargeButtonItem.Caption, e);
                 }
             };
             if (this.bar_toolBar.ItemLinks.Count <= linkIndex)
             {
                 BarItemLink link = this.bar_toolBar.AddItem(barLargeButtonItem);
                 if (isBeginGroup)
                 {
                     link.BeginGroup = true;
                 }
             }
             else
             {
                 BarItemLink beforeLink = this.bar_toolBar.ItemLinks[linkIndex];
                 if (beforeLink == null)
                 {
                     this.bar_toolBar.AddItem(barLargeButtonItem);
                 }
                 else
                 {
                     this.bar_toolBar.InsertItem(beforeLink, barLargeButtonItem);
                 }
                 if (isBeginGroup)
                 {
                     beforeLink.BeginGroup = true;
                 }
             }
         }
     }
     catch (Exception exception)
     {
         MessageBox.Show("创建工具条异常:" + exception.Message);
     }
 }
Example #30
0
        private void ReorderItems(RibbonControl ribbonControl, BarItemLink targetLink)
        {
            int targetIndex = ribbonControl.Toolbar.ItemLinks.IndexOf(targetLink);
            int destIndex   = ribbonControl.Toolbar.ItemLinks.IndexOf(link);

            ribbonControl.Toolbar.ItemLinks.Insert(link, targetLink.Item);
            ribbonControl.Toolbar.ItemLinks.Insert(targetLink, link.Item);
            ribbonControl.Toolbar.ItemLinks.Remove(targetLink);
            ribbonControl.Toolbar.ItemLinks.Remove(link);
        }
Example #31
0
 public MainForm()
 {
     InitializeComponent();
     flashingButton = wbUpdateDirty.Links[0];
 }
 void OnHighlightedLinkChanged(object sender, HighlightedLinkChangedEventArgs e) {
     if (e.Link != null && e.Link.IsLinkInMenu)
         TooltipItem = e.Link;
     else
         TooltipItem = null;
 }
 void ShowItemSuperTip(BarItemLink item) {
     var args = new ToolTipControllerShowEventArgs{
         ToolTipType = ToolTipType.SuperTip,
         SuperTip = new SuperToolTip()
     };
     foreach (var choiceActionItem in _newObjectAction.Items) {
         var formatTestAction = EasyTestTagHelper.FormatTestAction(_newObjectAction.Caption + '.' + choiceActionItem.GetItemPath());
         if (formatTestAction==item.Item.Tag as string) {
             var data = choiceActionItem.Data;
             if (data!=null) {
                 var newObjectActionTooltip =
                     ((IModelClassNewObjectActionTooltip)
                      _newObjectAction.Application.Model.BOModel.GetClass((Type) data)).NewObjectActionTooltip;
                 if (!string.IsNullOrEmpty(newObjectActionTooltip)) {
                     args.SuperTip.Items.Add(newObjectActionTooltip);
                     ToolTipController.DefaultController.ShowHint(args);
                 }
             }
         }
     }
     
 }
 protected override void OnClick(BarItemLink link)
 {
     if(ActAsCheck && ButtonStyle != BarButtonStyle.Check)
         Toggle();
     base.OnClick(link);
 }
 public BarCheckAndDropDownButtonLinkViewInfo(BarDrawParameters parameters, BarItemLink link)
     : base(parameters, link)
 {
 }