Example #1
0
        public void OnSelectionboxListChanged(int Id, int Count)
        {
            //获取当前id代表的选择框(SelectionBox)
            SldSelectionBox sldSelectionBox = GetSelectionBoxById(Id);

            //没有找到匹配的选择框 则返回
            if (sldSelectionBox == null)
            {
                return;
            }

            //当前清楚选择,直接设置为0
            if (Count == 0)
            {
                sldSelectionBox.OnSelectionChanged(Count, null);
                return;
            }

            //获取选择管理器
            var seleMgr = _doc.ISelectionManager;

            //实例化一个选择列表
            List <swSeleTypeObjectPair> selections = new List <swSeleTypeObjectPair>(Count);

            //获取选择,更新列表
            for (int i = 1; i < Count + 1; i++)
            {
                var seleType  = seleMgr.GetSelectedObjectType3(i, sldSelectionBox.Mark);
                var seleObj   = seleMgr.GetSelectedObject6(i, sldSelectionBox.Mark);
                var selePoint = (double[])seleMgr.GetSelectionPoint2(i, sldSelectionBox.Mark);

                //所有从0开始
                var name = sldSelectionBox.SControl.ItemText[(short)(i - 1)];

                //预先选择数量之下
                if (i <= sldSelectionBox.PreSelectionCount &&
                    sldSelectionBox.Selections?.Count > i - 1)
                {
                    //选择的是相同对象,取相同名称
                    if (App.IsSame(seleObj, sldSelectionBox.Selections[i - 1].SelectedObject) == (int)swObjectEquality.swObjectSame)
                    {
                        name = sldSelectionBox.Selections[i - 1].Name;
                    }
                }

                selections.Add(new swSeleTypeObjectPair(i, (swSelectType_e)seleType, sldSelectionBox.Mark, seleObj, name, selePoint));
            }

            sldSelectionBox.OnSelectionChanged(Count, selections);

            //如果是单选框 - 切换到下一个焦点
            if (sldSelectionBox.SingleEntityOnly)
            {
                bool            isCurrent = false;
                SldSelectionBox next      = default;
                foreach (var sldSeleItem in GetSpecControl <SldSelectionBox>())
                {
                    if (isCurrent)
                    {
                        next = sldSeleItem;
                        break;
                    }
                    if (sldSeleItem.ID == sldSelectionBox.ID)
                    {
                        isCurrent = true;
                    }
                }
                //存在下一个选择框且下一个选择框不为0,则切换焦点
                if (next != null &&
                    next.SldControlIsVisible() &&
                    next.AutoMoveFocusToThis)
                {
                    next.SControl.SetSelectionFocus();
                }
            }
        }
Example #2
0
 //向PMPage中注册SelectionBox
 public static void RegisterSelectionBox(SldSelectionBox selectionBox)
 {
     _selectionBoxs.Add(selectionBox);
 }