Exemplo n.º 1
0
        private static void SetVisibility(ActionItem item, BarItem guiItem)
        {
            // todo: reduce near duplicate code in this method.
            RibbonPageGroupItemLinkCollection groupLinkCollection = null;

            if (guiItem.Links.Count > 0)
            {
                groupLinkCollection = guiItem.Links[0].Links as RibbonPageGroupItemLinkCollection;
            }

            if (item.Visible)
            {
                guiItem.Visibility = BarItemVisibility.Always;
                if (groupLinkCollection != null)
                {
                    RibbonPageGroup pg = groupLinkCollection.PageGroup;
                    RibbonPage      p  = pg.Page;

                    foreach (BarItemLink link in groupLinkCollection)
                    {
                        if (link.Item != guiItem)
                        {
                            if (link.Item.Visibility != BarItemVisibility.Always)
                            {
                                return;
                            }
                        }
                    }

                    pg.Visible = true;
                }
            }
            else
            {
                guiItem.Visibility = BarItemVisibility.OnlyInCustomizing;

                if (groupLinkCollection != null)
                {
                    RibbonPageGroup pg = groupLinkCollection.PageGroup;
                    RibbonPage      p  = pg.Page;

                    foreach (BarItemLink link in groupLinkCollection)
                    {
                        if (link.Item != guiItem)
                        {
                            if (link.Item.Visibility == BarItemVisibility.Always)
                            {
                                return;
                            }
                        }
                    }

                    pg.Visible = false;
                }
            }
        }
Exemplo n.º 2
0
        private void btnNapDL_Click(object sender, EventArgs e)
        {
            for (int k = 0; k < this._ribbon.Pages.Count; k++)
            {
                RibbonPageGroupCollection pgColection = this._ribbon.Pages[k].Groups;

                string prID   = this._ribbon.Pages[k].Name; // pgColection[k].Name.ToString();
                string prName = this._ribbon.Pages[k].Text;
                for (int j = 0; j < pgColection.Count; j++)
                {
                    if (pgColection[j].Name.Contains("_ck"))
                    {
                        continue;                                     //bỏ qua những group tên có dạng _ck
                    }
                    RibbonPageGroupItemLinkCollection colection = pgColection[j].ItemLinks;

                    for (int i = 0; i < colection.Count; i++)
                    {
                        if (colection[i].Item.Name.Contains("_ck"))
                        {
                            continue;                                        //bỏ qua những item tên có dạng _ck vì ko có trong bảng danh mục chức năng
                        }
                        ChucNangInfor objChucNang = new ChucNangInfor();
                        objChucNang.ParentId    = prID;
                        objChucNang.ParentName  = prName;
                        objChucNang.MaChucNang  = colection[i].Item.Name;
                        objChucNang.TenChucNang = colection[i].Item.Caption;

                        ChucNangDataProvider.InsertIfNotExist(objChucNang);

                        if (colection[i].Item is BarSubItem)
                        {
                            LinksInfo linksInfo = ((BarSubItem)colection[i].Item).LinksPersistInfo;
                            for (int l = 0; l < linksInfo.Count; l++)
                            {
                                if (linksInfo[l].Item.Name.Contains("_ck"))
                                {
                                    continue;
                                }
                                ChucNangInfor objSubChucNang = new ChucNangInfor();
                                objSubChucNang.ParentId    = objChucNang.MaChucNang;
                                objSubChucNang.ParentName  = objChucNang.TenChucNang;
                                objSubChucNang.MaChucNang  = linksInfo[l].Item.Name;
                                objSubChucNang.TenChucNang = linksInfo[l].Item.Caption;

                                ChucNangDataProvider.InsertIfNotExist(objSubChucNang);
                            }
                        }
                    }
                }
            }
            LoadAllChucNang();
            MessageBox.Show("Nạp dữ liệu thành công!");
        }
Exemplo n.º 3
0
        /// <summary>
        /// Remove item from the standard toolbar or ribbon control
        /// </summary>
        /// <param name="key">
        /// The string itemName to remove from the standard toolbar or ribbon control
        /// </param>
        public override void Remove(string key)
        {
            foreach (BarItem item in this._ribbon.Items)
            {
                if (item.Caption == key)
                {
                    RibbonPageGroupItemLinkCollection groupLinkCollection = item.Links[0].Links as RibbonPageGroupItemLinkCollection;
                    if (groupLinkCollection == null)
                    {
                        // TODO: We don't provide complete support in the situation where there are "menus" embedded in the ribbon.
                        // We should remove the associated Page Group and Page when appropriate.
                        item.Dispose();
                        break;
                    }
                    else
                    {
                        RibbonPageGroup pg = groupLinkCollection.PageGroup;
                        RibbonPage      p  = pg.Page;

                        this._ribbon.Items.Remove(item);

                        // Remove the group when nothing remains in it.
                        if (pg.ItemLinks.Count == 0)
                        {
                            p.Groups.Remove(pg);

                            // If we removed the last group on a tab, remove the tab as well.
                            if (p.Groups.Count == 0)
                            {
                                _ribbon.Pages.Remove(p);
                            }
                        }
                        // remove all sub items?
                        break;
                    }
                }
            }

            base.Remove(key);
        }