コード例 #1
0
        static void ed_PointMonitor(object sender, PointMonitorEventArgs e)
        {
            string blockInfo = ""; //用于存储块参照的信息:名称和个数
            //获取命令行对象(鼠标监视事件的发起者),用于获取文档对象
            Editor            ed  = (Editor)sender;
            Document          doc = ed.Document;
            InputPointContext ic  = e.Context;

            //获取鼠标停留处的实体
            FullSubentityPath[] paths = e.Context.GetPickedEntities();
            using (Transaction trans = doc.TransactionManager.StartTransaction())
            {
                //如果鼠标停留处有实体
                if (paths.Length > 0)
                {
                    //获取鼠标停留处的实体
                    FullSubentityPath path     = paths[0];
                    BlockReference    blockRef = trans.GetObject(path.GetObjectIds()[0], OpenMode.ForRead) as BlockReference;
                    if (blockRef != null)//如果鼠标停留处为块参照
                    {
                        //获取块参照所属的块表记录并以写的方式打开
                        ObjectId         blockId = blockRef.BlockTableRecord;
                        BlockTableRecord btr     = trans.GetObject(blockId, OpenMode.ForRead) as BlockTableRecord;
                        //获取属于同一块表记录的所有块参照
                        ObjectIdCollection ids = btr.GetBlockReferenceIds(true, false);
                        //若鼠标停留处的块参照的块表记录与上一次的不同
                        Entity ent = null;
                        if (ids.Count >= 0)
                        {
                            ent = trans.GetObject(ids[0], OpenMode.ForRead) as Entity;
                        }

                        if (ent != null && blockName != btr.Name || ent.HighlightState(path) == HighlightStyle.None)
                        {
                            blockName = btr.Name;           //重新设置块表记录名
                            blockIds.UnHighlightEntities(); //取消上一次块表记录的块参照的亮显
                            blockIds.Clear();               //清空块参照ObjectId列表
                            blockIds = ids;                 //设置需要亮显的块参照的ObjectId列表
                            blockIds.HighlightEntities();   //亮显所有同名的块参照
                        }
                        blockInfo += "块名:" + btr.Name + "\n个数:" + blockIds.Count.ToString();
                    }
                }
                trans.Commit();
            }
            if (blockInfo != "")
            {
                e.AppendToolTipText(blockInfo);//在鼠标停留处显示提示信息
            }
        }
コード例 #2
0
        Stream(ArrayList data, InputPointContext inputPtCntxt)
        {
            data.Add(new Snoop.Data.ClassSeparator(typeof(InputPointContext)));

            data.Add(new Snoop.Data.Point3d("Cartesian snapped point", inputPtCntxt.CartesianSnappedPoint));
            data.Add(new Snoop.Data.Point3d("Computed point", inputPtCntxt.ComputedPoint));
            data.Add(new Snoop.Data.Object("Document", inputPtCntxt.Document));
            data.Add(new Snoop.Data.Object("Draw context", inputPtCntxt.DrawContext));
            data.Add(new Snoop.Data.Point3d("Gripped point", inputPtCntxt.GrippedPoint));
            data.Add(new Snoop.Data.String("History", inputPtCntxt.History.ToString()));
            data.Add(new Snoop.Data.Point3d("Last point", inputPtCntxt.LastPoint));
            data.Add(new Snoop.Data.Object("Object snap overrides", inputPtCntxt.ObjectSnapOverrides.ToString()));
            data.Add(new Snoop.Data.Point3d("Object snapped point", inputPtCntxt.ObjectSnappedPoint));
            data.Add(new Snoop.Data.Bool("Point computed", inputPtCntxt.PointComputed));
            data.Add(new Snoop.Data.Point3d("Raw point", inputPtCntxt.RawPoint));
            data.Add(new Snoop.Data.String("Tooltip text", inputPtCntxt.ToolTipText));
        }
コード例 #3
0
        CollectEvent(object sender, CollectorEventArgs e)
        {
            // cast the sender object to the SnoopCollector we are expecting
            Collector snoopCollector = sender as Collector;

            if (snoopCollector == null)
            {
                Debug.Assert(false);    // why did someone else send us the message?
                return;
            }

            // see if it is a type we are responsible for
            Editor editor = e.ObjToSnoop as Editor;

            if (editor != null)
            {
                Stream(snoopCollector.Data(), editor);
                return;
            }

            PromptOptions promptOpts = e.ObjToSnoop as PromptOptions;

            if (promptOpts != null)
            {
                Stream(snoopCollector.Data(), promptOpts);
                return;
            }

            PromptStringOptionsEventArgs promptStringArgs = e.ObjToSnoop as PromptStringOptionsEventArgs;

            if (promptStringArgs != null)
            {
                Stream(snoopCollector.Data(), promptStringArgs);
                return;
            }

            PromptSelectionOptionsEventArgs promptSelectionArgs = e.ObjToSnoop as PromptSelectionOptionsEventArgs;

            if (promptSelectionArgs != null)
            {
                Stream(snoopCollector.Data(), promptSelectionArgs);
                return;
            }

            PromptSelectionOptions promptSelectionOpts = e.ObjToSnoop as PromptSelectionOptions;

            if (promptSelectionOpts != null)
            {
                Stream(snoopCollector.Data(), promptSelectionOpts);
                return;
            }

            PromptPointOptionsEventArgs promptPointArgs = e.ObjToSnoop as PromptPointOptionsEventArgs;

            if (promptPointArgs != null)
            {
                Stream(snoopCollector.Data(), promptPointArgs);
                return;
            }

            PromptNestedEntityResultEventArgs promptNestResultArgs = e.ObjToSnoop as PromptNestedEntityResultEventArgs;

            if (promptNestResultArgs != null)
            {
                Stream(snoopCollector.Data(), promptNestResultArgs);
                return;
            }

            PromptResult promptResult = e.ObjToSnoop as PromptResult;

            if (promptResult != null)
            {
                Stream(snoopCollector.Data(), promptResult);
                return;
            }

            PromptKeywordOptionsEventArgs promptKeywordArgs = e.ObjToSnoop as PromptKeywordOptionsEventArgs;

            if (promptKeywordArgs != null)
            {
                Stream(snoopCollector.Data(), promptKeywordArgs);
                return;
            }

            PromptIntegerOptionsEventArgs promptIntArgs = e.ObjToSnoop as PromptIntegerOptionsEventArgs;

            if (promptIntArgs != null)
            {
                Stream(snoopCollector.Data(), promptIntArgs);
                return;
            }

            PromptEntityOptionsEventArgs promptEntArgs = e.ObjToSnoop as PromptEntityOptionsEventArgs;

            if (promptEntArgs != null)
            {
                Stream(snoopCollector.Data(), promptEntArgs);
                return;
            }

            PromptDoubleOptionsEventArgs promptDoubleArgs = e.ObjToSnoop as PromptDoubleOptionsEventArgs;

            if (promptDoubleArgs != null)
            {
                Stream(snoopCollector.Data(), promptDoubleArgs);
                return;
            }

            PromptSelectionResult prSelRes = e.ObjToSnoop as PromptSelectionResult;

            if (prSelRes != null)
            {
                Stream(snoopCollector.Data(), prSelRes);
                return;
            }

            SelectionSet selSet = e.ObjToSnoop as SelectionSet;

            if (selSet != null)
            {
                Stream(snoopCollector.Data(), selSet);
                return;
            }

            SelectedObject selObj = e.ObjToSnoop as SelectedObject;

            if (selObj != null)
            {
                Stream(snoopCollector.Data(), selObj);
                return;
            }

            SelectedSubObject selSubObj = e.ObjToSnoop as SelectedSubObject;

            if (selSubObj != null)
            {
                Stream(snoopCollector.Data(), selSubObj);
                return;
            }

            SelectionDetails selDetails = e.ObjToSnoop as SelectionDetails;

            if (selDetails != null)
            {
                Stream(snoopCollector.Data(), selDetails);
                return;
            }

            SelectionRemovedEventArgs selRemovedArgs = e.ObjToSnoop as SelectionRemovedEventArgs;

            if (selRemovedArgs != null)
            {
                Stream(snoopCollector.Data(), selRemovedArgs);
                return;
            }

            SelectionAddedEventArgs selAddedArgs = e.ObjToSnoop as SelectionAddedEventArgs;

            if (selAddedArgs != null)
            {
                Stream(snoopCollector.Data(), selAddedArgs);
                return;
            }

            DraggingEndedEventArgs dragEndArgs = e.ObjToSnoop as DraggingEndedEventArgs;

            if (dragEndArgs != null)
            {
                Stream(snoopCollector.Data(), dragEndArgs);
                return;
            }

            InputPointContext inputPtCntxt = e.ObjToSnoop as InputPointContext;

            if (inputPtCntxt != null)
            {
                Stream(snoopCollector.Data(), inputPtCntxt);
                return;
            }

            Keyword keyword = e.ObjToSnoop as Keyword;

            if (keyword != null)
            {
                Stream(snoopCollector.Data(), keyword);
                return;
            }

            PointFilterEventArgs ptFilterEventArgs = e.ObjToSnoop as PointFilterEventArgs;

            if (ptFilterEventArgs != null)
            {
                Stream(snoopCollector.Data(), ptFilterEventArgs);
                return;
            }

            PointFilterResult ptFilterRes = e.ObjToSnoop as PointFilterResult;

            if (ptFilterRes != null)
            {
                Stream(snoopCollector.Data(), ptFilterRes);
                return;
            }

            PointMonitorEventArgs ptMonitorArgs = e.ObjToSnoop as PointMonitorEventArgs;

            if (ptMonitorArgs != null)
            {
                Stream(snoopCollector.Data(), ptMonitorArgs);
                return;
            }

            PromptAngleOptionsEventArgs promptAngleOptsArgs = e.ObjToSnoop as PromptAngleOptionsEventArgs;

            if (promptAngleOptsArgs != null)
            {
                Stream(snoopCollector.Data(), promptAngleOptsArgs);
                return;
            }

            PromptDistanceOptionsEventArgs promptDistanceOptsArgs = e.ObjToSnoop as PromptDistanceOptionsEventArgs;

            if (promptDistanceOptsArgs != null)
            {
                Stream(snoopCollector.Data(), promptDistanceOptsArgs);
                return;
            }

            PromptDoubleResultEventArgs promptDoubleResArgs = e.ObjToSnoop as PromptDoubleResultEventArgs;

            if (promptDoubleResArgs != null)
            {
                Stream(snoopCollector.Data(), promptDoubleResArgs);
                return;
            }

            PromptFileOptions promptFileOpts = e.ObjToSnoop as PromptFileOptions;

            if (promptFileOpts != null)
            {
                Stream(snoopCollector.Data(), promptFileOpts);
                return;
            }

            PromptForEntityEndingEventArgs promptForEntEndArgs = e.ObjToSnoop as PromptForEntityEndingEventArgs;

            if (promptForEntEndArgs != null)
            {
                Stream(snoopCollector.Data(), promptForEntEndArgs);
                return;
            }

            PromptForSelectionEndingEventArgs promptForSelEndArgs = e.ObjToSnoop as PromptForSelectionEndingEventArgs;

            if (promptForSelEndArgs != null)
            {
                Stream(snoopCollector.Data(), promptForSelEndArgs);
                return;
            }

            PromptNestedEntityOptions promptNestEntOpts = e.ObjToSnoop as PromptNestedEntityOptions;

            if (promptNestEntOpts != null)
            {
                Stream(snoopCollector.Data(), promptNestEntOpts);
                return;
            }

            PromptNestedEntityOptionsEventArgs promptNestEntOptsArgs = e.ObjToSnoop as PromptNestedEntityOptionsEventArgs;

            if (promptNestEntOptsArgs != null)
            {
                Stream(snoopCollector.Data(), promptNestEntOptsArgs);
                return;
            }

            PromptSelectionResultEventArgs promptSelResArgs = e.ObjToSnoop as PromptSelectionResultEventArgs;

            if (promptSelResArgs != null)
            {
                Stream(snoopCollector.Data(), promptSelResArgs);
                return;
            }

            // ValueTypes we have to treat a bit different
            if (e.ObjToSnoop is PickPointDescriptor)
            {
                Stream(snoopCollector.Data(), (PickPointDescriptor)e.ObjToSnoop);
                return;
            }
        }