예제 #1
0
        public void PreSelect(PtSelectContext sltCtx)
        {
            #if DEBUG// Test Performance
            DateTime StartTime = DateTime.Now;
            Console.WriteLine("Start time -" + StartTime.ToString());
            #endif// End Test

            PtApp.ActiveView.Select(sltCtx);

            #if DEBUG// Test Performance
            DateTime EndTime = DateTime.Now;
            Console.WriteLine("End time -" + EndTime.ToString());
            TimeSpan Span = EndTime - StartTime;
            Console.WriteLine("Use time -" + Span.ToString());
            #endif // End Test

            FRList<Selection> Selections =
                sltCtx.CurrentSelectionSet.Selections;
            if (!Selections.Empty())
            {
                //PtApp.ActiveView.UpdateView();

                Debug.WriteLine("Preselect successfully.");
            }
        }
예제 #2
0
 public void CreateSelection(PtSelectContext SltCtx, DisplayItem SelectedItem)
 {
     Debug.Assert(SltCtx != null && SelectedItem != null);
     if (SltCtx.CurrentSelectionSet != null && SelectedItem != null)
     {
         m_SelectTolerance = SltCtx.SelectTolerance;
         Selection Slt = GetSelection();
         Slt.SetManipulator(GetManipulator(SelectedItem));
         SltCtx.CurrentSelectionSet.AddSelection(Slt);
     }
 }
예제 #3
0
        public static SnapContext InitalizeSnapContextFromPreSelection(GePoint mousePoint)
        {
            Debug.Assert(mousePoint != null);

            SnapContext snapCtx = new SnapContext(PtApp.ActiveDocument.Database);

            PtSelectContext sltCtx = new PtSelectContext();
            sltCtx.WorldPoint = mousePoint;

            SelectionSet tempSet =
                PtApp.ActiveView.SelectionMgr.CreateSelectionSet("SnapTemporarySet");
            tempSet.Clear();
            sltCtx.CurrentSelectionSet = tempSet;

            PtApp.ActiveView.Select(sltCtx);

            // Set selection set.
            SelectionSet PreSet = PtApp.ActiveView.SelectionMgr.GetPreviewSelectionSet();
            PreSet.Clear();

            if (!tempSet.Empty())
            {
                foreach (Selection selection in tempSet.Selections)
                {
                    SymbolConstraint instance = selection.GetInstance();
                    Debug.Assert(instance != null);

                    SymbolGeometryConstraint constr = instance.GetGeometryConstraint(
                        mousePoint, snapCtx.SnapTolerance);
                    if (constr != null)
                    {
                        // We just highlight the snapped nodes.
                        snapCtx.CandidateProxies.Add(constr);
                        PreSet.AddSelection(selection);
                    }
                }
            }

            PtApp.ActiveView.UpdateView();

            return snapCtx;
        }
예제 #4
0
        public void Select(PtSelectContext sltCtx)
        {
            PtDocument doc = PtApp.GetActiveDocument();
            FRList<GraphicNode> NodeList = doc.GetGraphicNodes();

            // Find
            foreach (GraphicNode NodeItem in NodeList)
            {
                sltCtx.ResetSelectionFlag();
                NodeItem.Qualify(sltCtx);

                if (!sltCtx.CurrentSelectionSet.Empty() && !sltCtx.MultiSelect)
                    break;
            }
        }
예제 #5
0
        // For selecting
        public void Qualify(PtSelectContext selectCtx)
        {
            Debug.Assert(selectCtx != null);
            if (null == selectCtx) return;

            if (!m_CanBeSelected) return;

            SelectionCreator Creator = GetCreator();
            if (null == Creator) return;

            if (m_ItemList != null)
            {
                m_ItemList.Qualify(selectCtx, null);

                //SelectionCreator Creator = selectCtx.Creator;
                if (selectCtx.IsHitted && selectCtx.CurrentSelectionSet != null)
                {

                    Creator.CreateSelection(selectCtx, selectCtx.GetHittedItem());
                }
            }
        }
예제 #6
0
        protected override EventResult OnMouseMove(EventContext Context)
        {
            // Drag and translation the view.
            if(true == m_IsMiddleButtonDown)
            {
                PtApp.GetActiveView().GetTranslationManipulator().Drag(Context);
                SetCursorShape(PtApp.GetActiveView().GetTranslationManipulator().GetCursorShape());
                return EventResult.eContinue;
            }

            if (true == m_bIsDragging)
            {
                SelectionSet SelectedSet = PtApp.ActiveView.SelectionMgr.GetSelectedSelectionSet();

                // We just support drag a selection
                FRList<Selection> Selections = SelectedSet.Selections;
                if (Selections.Count == 1)
                {
                    if (Selections[0].GetManipulator() != null)
                    {
                        Selections[0].GetManipulator().Drag(Context);
                        SetCursorShape(Selections[0].GetManipulator().GetCursorShape());
                    }
                }
            }
            else
            {
                // We do preselect when the mouse move but not drag.
                PtApp.GetActiveView().UpdateView();

                GePoint mousPoint = Context.MouseWorldPoint;
                PtSelectContext sltCtx = new PtSelectContext();
                sltCtx.WorldPoint = mousPoint;

                // Set selection set.
                SelectionSet PreSet = PtApp.ActiveView.SelectionMgr.GetPreviewSelectionSet();
                PreSet.Clear();
                sltCtx.CurrentSelectionSet = PreSet;

                PreSelect(sltCtx);

                //bool bAfterSelect = PreSet.Empty();

                //// We just update the preview when need.
                //if (!bAfterSelect)
                //    PtApp.ActiveView.UpdateView();

                // We just support drag a selection
                FRList<Selection> Selections = PreSet.Selections;
                if (Selections.Count == 1)
                {
                    if (Selections[0].GetManipulator() != null)
                    {
                        SetCursorShape(Selections[0].GetManipulator().GetCursorShape());
                    }
                    else
                    {
                        SetCursorShape("SelectArrow.cur");
                    }
                }
                else
                {
                    SetCursorShape("SelectArrow.cur");
                }
            }

            return EventResult.eContinue;
        }