Пример #1
0
        private void LogEvent(string eventName, short sButton, short sShift, double dX, double dY, double dZ, object pWindowDispatch, int lKeyPointType, object pGraphicDispatch)
        {
            if (_mouse == null)
            {
                return;
            }

            List <string> entries = new List <string>();

            Type windowDispatchType  = null;
            Type graphicDispatchType = null;

            if (pWindowDispatch != null)
            {
                windowDispatchType = SolidEdgeCommunity.Runtime.InteropServices.ComObject.GetType(pWindowDispatch);
            }

            if (pGraphicDispatch != null)
            {
                graphicDispatchType = SolidEdgeCommunity.Runtime.InteropServices.ComObject.GetType(pGraphicDispatch);
            }

            entries.Add("MouseDown event");
            entries.Add(String.Format("sButton: '{0}'", (MouseButtons)sButton));
            entries.Add(String.Format("sShift: '{0}'", sShift));
            entries.Add(String.Format("dX: '{0}'", dX));
            entries.Add(String.Format("dY: '{0}'", dY));
            entries.Add(String.Format("dZ: '{0}'", dZ));
            entries.Add(String.Format("pWindowDispatch: '{0}'", windowDispatchType));
            entries.Add(String.Format("lKeyPointType: '{0}'", lKeyPointType));
            entries.Add(String.Format("pGraphicDispatch: '{0}'", graphicDispatchType));

            if (pGraphicDispatch is SolidEdgeFramework.Reference)
            {
                var reference           = (SolidEdgeFramework.Reference)pGraphicDispatch;
                var referenceObject     = reference.Object;
                var referenceObjectType = SolidEdgeCommunity.Runtime.InteropServices.ComObject.GetType(referenceObject);
                entries.Add(String.Format("pGraphicDispatch reference: '{0}'", referenceObjectType));
            }

            int    PointOnGraphicFlag;
            double PointOnGraphic_X;
            double PointOnGraphic_Y;
            double PointOnGraphic_Z;

            // Get the actual point on the graphic element (in database coordinates). Note this is not
            // the same as the input dX, dY, dZ coordinates. Those are either in window coordinates
            // or are the window coordinates transformed to data base coordinates (depends on the
            // value of ScaleMode). That is, the inputs to this routine are NOT the intersection of the
            // bore line and the element.
            _mouse.PointOnGraphic(out PointOnGraphicFlag, out PointOnGraphic_X, out PointOnGraphic_Y, out PointOnGraphic_Z);

            // It would seem that the PointOnGraphicFlag only gets set on MouseDown and stays set until the next MouseDown event.
            if (PointOnGraphicFlag == 1)
            {
                entries.Add(String.Format("PointOnGraphicFlag: '{0}'", PointOnGraphicFlag));
                entries.Add(String.Format("PointOnGraphic_X: '{0}'", PointOnGraphic_X));
                entries.Add(String.Format("PointOnGraphic_Y: '{0}'", PointOnGraphic_Y));
                entries.Add(String.Format("PointOnGraphic_Z: '{0}'", PointOnGraphic_Z));
            }

            entries.Add(String.Empty);

            StringBuilder sb = new StringBuilder();

            foreach (string entry in entries)
            {
                sb.AppendLine(entry);
            }

            outputTextBox.AppendText(sb.ToString());
        }