Exemplo n.º 1
0
        private static void OnRightClick(DataGrid grid, object sender, SelectedCellsChangedEventArgs e)
        {
            var data = ((DataUnit)(grid.SelectedCells[0].Item));

            if (data == null)
            {
                return;
            }
            var index = ((BDataGridTextColumn)grid.SelectedCells[0].Column).index;

            grid.ContextMenu.Items.Clear();
            {//复制
                var menuItem = new MenuItem();
                menuItem.Header = "复制到剪贴板";
                menuItem.Click += (object newSender, RoutedEventArgs newE) =>
                {
                    Clipboard.SetText(data.dataInfo[index]);
                };
                grid.ContextMenu.Items.Add(menuItem);
            }
            if (index != VIEW_DATA.VALUE.ToInt())
            {
                return;
            }

            var retList = SearchManager.Instance.RawSearch(data.dataInfo[index]);

            foreach (var it in retList)
            {
                var tempIt   = it;
                var menuItem = new MenuItem();
                menuItem.Header = tempIt.header;
                menuItem.Click += (object newSender, RoutedEventArgs newE) =>
                {
                    MainWindow.tabCtrl.AddItem(UCTabItemWithClose.NewItem(tempIt));
                };
                grid.ContextMenu.Items.Add(menuItem);
            }
        }
Exemplo n.º 2
0
        public void OnMuluItemSelected(object sender, RoutedEventArgs e)
        {
            var tree = (BTreeView)(sender);

            AddItem(UCTabItemWithClose.NewItem(tree.data));
        }
Exemplo n.º 3
0
        public void RebuildItems()
        {
            if (m_Parent.Items.Count <= 0 || allTabls.Count <= 0 || leftIndex < 0)
            {
                return;
            }

            var tabMaxWidth = win.TabContent.ActualWidth;

            if (tabMaxWidth <= 10)
            {
                return;
            }
            var criticalCount = (int)((tabMaxWidth - MainConfig.Instance.tableItemExtraWidth) / MainConfig.Instance.tableItemWidth);

            if (allTabls.Count > criticalCount)
            {
                if (SWITCH_COUNT <= 0)
                {
                    m_Parent.Items.Add(UCTabItemWithClose.NewItem(null, TAB_ITEM.LEFT_ARROW));
                    m_Parent.Items.Add(UCTabItemWithClose.NewItem(null, TAB_ITEM.RIGHT_ARROW));
                    SWITCH_COUNT = 2;
                }
            }
            else
            {
                if (SWITCH_COUNT > 0)
                {
                    m_Parent.Items.RemoveAt(m_Parent.Items.Count - 1);
                    m_Parent.Items.RemoveAt(m_Parent.Items.Count - 1);
                    SWITCH_COUNT = 0;
                }
            }

            criticalCount = (int)(tabMaxWidth - MainConfig.Instance.tableArrowItemWidth * SWITCH_COUNT - MainConfig.Instance.tableItemExtraWidth) / MainConfig.Instance.tableItemWidth;
            if (criticalCount <= 0)
            {
                criticalCount = 1;
            }

            var curTabIndex = tabSelectIndex;

            if (curTabIndex < 0)
            {
                curTabIndex = 0;
            }
            if (curTabIndex < leftIndex)
            {
                for (int i = leftIndex - 1; i >= curTabIndex; i--)
                {
                    m_Parent.Items.Insert(0, allTabls[i]);
                }
                leftIndex = curTabIndex;
            }
            if (curTabIndex >= rightIndex)
            {
                for (int i = rightIndex; i <= curTabIndex; ++i)
                {
                    m_Parent.Items.Insert(m_Parent.Items.Count - SWITCH_COUNT, allTabls[i]);
                }
                rightIndex = curTabIndex + 1;
            }

            if (m_Parent.Items.Count - SWITCH_COUNT > criticalCount)
            {
                var removeCount = m_Parent.Items.Count - criticalCount - SWITCH_COUNT;

                var leftAdd  = Math.Min(removeCount, curTabIndex - leftIndex);
                var rightDec = removeCount - leftAdd;
                for (int i = 0; i < leftAdd; ++i)
                {
                    m_Parent.Items.RemoveAt(0);
                }
                for (int i = 0; i < rightDec; ++i)
                {
                    m_Parent.Items.RemoveAt(m_Parent.Items.Count - SWITCH_COUNT - 1);
                }
                leftIndex  += leftAdd;
                rightIndex -= rightDec;
            }
            else
            {
                var maxRemoveCount = criticalCount + SWITCH_COUNT - m_Parent.Items.Count;
                var leftDec        = Math.Min(maxRemoveCount, leftIndex);
                var rightAdd       = Math.Min(maxRemoveCount - leftDec, allTabls.Count - rightIndex);
                for (int i = leftIndex - 1; i >= leftIndex - leftDec; --i)
                {
                    m_Parent.Items.Insert(0, allTabls[i]);
                }
                for (int i = rightIndex; i < rightIndex + rightAdd; ++i)
                {
                    m_Parent.Items.Insert(m_Parent.Items.Count - SWITCH_COUNT, allTabls[i]);
                }
                leftIndex  -= leftDec;
                rightIndex += rightAdd;
            }
            tabSelectIndex = curTabIndex;
            AjustTabSelect();
        }