Exemplo n.º 1
0
 private void AutoCadMessageHandler(object sender, PreTranslateMessageEventArgs e)
 {
     if (e.Message.message == (int)WndMsg.WM_KEYDOWN)
     {
         if ((int)e.Message.wParam == (int)WndKey.VK_F1)
         {
             // F1 pressed
             if (_currentTooltip != null && _currentTooltip.Length > 8 && _currentTooltip.StartsWith("https://modplus.org/"))
             {
                 // Another implementation could be to look up the help topic in an index file matching it to URLs.
                 _dropNextHelpCall = true; // Even though we don't forward this F1 keypress, AutoCAD sends a message to itself to open the AutoCAD help file
                 object nomutt = AcApp.GetSystemVariable("NOMUTT");
                 string cmd    = $"._BROWSER {_currentTooltip} _NOMUTT {nomutt} ";
                 AcApp.SetSystemVariable("NOMUTT", 1);
                 AcApp.DocumentManager.MdiActiveDocument.SendStringToExecute(cmd, true, false, false);
                 e.Handled = true;
             }
         }
     }
     else if (e.Message.message == (int)WndMsg.WM_ACAD_HELP && _dropNextHelpCall)
     {
         // Seems this is the message AutoCAD generates itself to open the help file. Drop this if help was called from a ribbon tooltip.
         _dropNextHelpCall = false; // Reset state of help calls
         e.Handled         = true;  // Stop this message from being passed on to AutoCAD
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// 消息分发前事件  监听滚轮事件
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void Application_PreTranslateMessage(object sender, PreTranslateMessageEventArgs e)
 {
     if ((e.Message.message == 522 && e.Message.wParam != IntPtr.Zero))//WM_MOUSEWHEEL
     {
         _zoom_wheel   = int.Parse(Autodesk.AutoCAD.ApplicationServices.Application.GetSystemVariable("ZOOMWHEEL").ToString());
         _center_point = (Point3d)Autodesk.AutoCAD.ApplicationServices.Application.GetSystemVariable("VIEWCTR");    //视口中心点
         _screenSize   = (Point2d)Autodesk.AutoCAD.ApplicationServices.Application.GetSystemVariable("SCREENSIZE"); //视口大小,像素级别
         if (0 == _zoom_wheel)
         {
             if (0 == e.Message.wParam.ToString().CompareTo("4287102976"))
             {
                 //后滚 缩小
                 zoomLevel(false);
             }
             if (0 == e.Message.wParam.ToString().CompareTo("7864320"))
             {
                 //前滚 放大
                 zoomLevel(true);
             }
         }
         else if (1 == _zoom_wheel)
         {
             if (0 == e.Message.wParam.ToString().CompareTo("4287102976"))
             {
                 //前滚 缩小
                 zoomLevel(false);
             }
             if (0 == e.Message.wParam.ToString().CompareTo("7864320"))
             {
                 //后滚 放大
                 zoomLevel(true);
             }
         }
     }
 }
Exemplo n.º 3
0
        private static void Application_PreTranslateMessage(object sender, PreTranslateMessageEventArgs e)
        {
            var wp = e.Message.wParam.ToInt64();

            //if (wp != 0 && wp != 2 && wp != 47806 && wp != 16385 && wp != 1)
            //{
            //    Application.DocumentManager.MdiActiveDocument.Editor.WriteLine(wp);
            //}

            if (e.Message.message == WmRbuttondown && (wp != 6 && wp != MkShift))
            {
                e.Handled = true;
            }
            if (e.Message.message == WmRbuttonup && wp != MkShift)
            {
                Application.PreTranslateMessage -= Application_PreTranslateMessage;
                e.Handled = true;
                Application.DocumentManager.MdiActiveDocument.SendCancel();
            }

            if (e.Message.message == WmKeydown && wp == VkReturn)
            {
                Application.PreTranslateMessage -= Application_PreTranslateMessage;
                e.Handled = true;
                Application.DocumentManager.MdiActiveDocument.SendCancel();
            }
        }
Exemplo n.º 4
0
        public static void Application_PreTranslateMessage(object sender, PreTranslateMessageEventArgs e)
        {
            try
            {
                if (acadApp.DocumentManager.MdiActiveDocument != null)
                {
                    var ed = acadApp.DocumentManager.MdiActiveDocument.Editor;
                    switch (e.Message.message)
                    {
                    case WM_SYSKEYDOWN:
                        if (e.Message.wParam.ToInt32() == 65)
                        {
                            ObjectContextMenu.AddOrRefreshConnectCtr(true);
                        }
                        else if (e.Message.wParam.ToInt32() == 88)
                        {
                            ObjectContextMenu.ShowBulkChange();
                        }
                        else if (e.Message.wParam.ToInt32() == 81)
                        {
                            PublicMethod.Instance.SendCommend("pan\n");
                        }
                        break;

                    case WM_MOUSEWHEEL:
                        //System.Windows.Forms.MessageBox.Show("你在CAD操作中转动滚轮了!");
                        showmap();
                        break;

                    case WM_MOUSEMOVE:
                        // System.Windows.Forms.MessageBox.Show("你在CAD操作中移动鼠标了!");
                        break;

                    case WM_LBUTTONDOWN:
                        //System.Windows.Forms.MessageBox.Show("你在CAD操作中按下左键了!");
                        point = ed.PointToWorld(new Point(e.Message.pt_x, e.Message.pt_y));
                        var leftbuttondown = new FixEntityArgs {
                            Position = point
                        };
                        if (LeftButtonDownEventHander != null)
                        {
                            LeftButtonDownEventHander(new object(), leftbuttondown);
                        }
                        break;

                    case WM_LBUTTONUP:
                        //System.Windows.Forms.MessageBox.Show("你在CAD操作中弹起左键了!");
                        if (bpan)
                        {
                            showmap();
                        }
                        break;

                    case WM_MBUTTONUP:
                        //System.Windows.Forms.MessageBox.Show("你在CAD操作中弹起中键了!");
                        showmap();
                        break;
                    }
                }
            }
            catch (System.Exception ex)
            {
                //LogManager.Instance.Error(ex);
            }
        }
Exemplo n.º 5
0
        private static void Application_PreTranslateMessage(object sender, PreTranslateMessageEventArgs e)
        {
            var wp = e.Message.wParam.ToInt64();
            //if (wp != 0 && wp != 2 && wp != 47806 && wp != 16385 && wp != 1)
            //{
            //    Application.DocumentManager.MdiActiveDocument.Editor.WriteLine(wp);
            //}

            if (e.Message.message == WmRbuttondown && (wp != 6 && wp != MkShift))
            {
                e.Handled = true;
            }
            if (e.Message.message == WmRbuttonup && wp != MkShift)
            {
                Application.PreTranslateMessage -= Application_PreTranslateMessage;
                e.Handled = true;
                Application.DocumentManager.MdiActiveDocument.SendCancel();
            }

            if (e.Message.message == WmKeydown && wp == VkReturn)
            {
                Application.PreTranslateMessage -= Application_PreTranslateMessage;
                e.Handled = true;
                Application.DocumentManager.MdiActiveDocument.SendCancel();
            }
        }
 private void Application_PreTranslateMessage(object sender, PreTranslateMessageEventArgs e)
 {
     throw new NotImplementedException();
 }