Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="e"></param>
        protected override void OnMouseUp(MouseEventArgs e)
        {
            base.OnMouseUp(e);
            if (_mouse_type == MouseType.DragMap)  //拖动地图 鼠标弹起
            {
            }
            if (_mouse_type == MouseType.DrawDownloadArea)  //绘制下载区域 弹起鼠标
            {
                BDownloadRectangle d = _current_drawing as BDownloadRectangle;
                if (d != null)
                {
                    LatLngPoint left_down = MapHelper.GetLatLngByScreenLocation(new Point(d.LeftTop.X, d.LeftTop.Y + d.Height), _center, _zoom, ClientSize);
                    LatLngPoint right_up  = MapHelper.GetLatLngByScreenLocation(new Point(d.LeftTop.X + d.Width, d.LeftTop.Y), _center, _zoom, ClientSize);

                    using (MapDownloadDialog dlg = new MapDownloadDialog(left_down, right_up))
                    {
                        if (dlg.ShowDialog() == DialogResult.OK)
                        {
                        }

                        _current_drawing = null;
                        Invalidate();
                    }
                }
            }
            _current_cursor_cache = Cursor = Cursors.Arrow;
            _mouse_type           = MouseType.None;
        }
Exemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="e"></param>
        protected override void OnMouseDown(MouseEventArgs e)
        {
            base.OnMouseDown(e);

            //拖拽
            if (e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                // 拖拽地图
                _mouse_type           = MouseType.DragMap;
                _current_cursor_cache = Cursor = Cursors.SizeAll;
                _previous_point_cache = e.Location;

                //拖拽区域
            }

            //绘制区域
            if (e.Button == System.Windows.Forms.MouseButtons.Right)
            {
                _current_drawing = new BDownloadRectangle {
                    LeftTop = e.Location, Width = 0, Height = 0
                };
                _mouse_type           = MouseType.DrawDownloadArea;
                _current_cursor_cache = Cursor = Cursors.Cross;
                _previous_point_cache = e.Location;
            }
        }
Exemplo n.º 3
0
    private void WriteMouseMessage(MouseType type)
    {
        float time = Time.realtimeSinceStartup;

        Vector3 pos = Input.mousePosition;


        if (pos.x < 0 || pos.y < 0)
        {
            return;
        }

        /*
         * float realh = gameView.position.height - 17;
         * float realw = gameView.position.width;
         *
         * float expectw = realh * width / height;
         *
         * float xprecent = pos.x / (float)expectw;
         * float yprecent = pos.y / (float)realh;
         */

        Debug.Log("lucky mouse " + pos);

        float xprecent = pos.x / (float)width;
        float yprecent = pos.y / (float)height;

        string message = time + " " + (int)type + " " + xprecent + " " + yprecent;

        sw.WriteLine(message);
        sw.Flush();
    }
Exemplo n.º 4
0
        public virtual void LoadMouseEvent(MouseButtons button, PointF location, MouseType type)
        {
            PointF pf = location;

            if (IsVector)
            {
                pf = Calculation.GetInvertPos(((IDrawVector)this).Matrix, location);
            }

            switch (type)
            {
            case MouseType.Down:
                OnMouseDown(button, pf.X - Rect.X, pf.Y - Rect.Y);
                break;

            case MouseType.Up:
                OnMouseUp(button, pf.X - Rect.X, pf.Y - Rect.Y);
                break;

            case MouseType.Move:
                OnMouseMove(button, pf.X - Rect.X, pf.Y - Rect.Y);
                break;

            default:
                break;
            }
        }
Exemplo n.º 5
0
    /// <summary>
    /// 處理滑鼠狀態
    /// </summary>
    private void ProcessMouseState()
    {
        switch (this.currentMouseType)
        {
            case MouseType.初始播放引導動畫:
                //播放引導動畫
                PlayHandBoneAnimation.script.animationType = PlayHandBoneAnimation.AnimationType.太陽引導;
                // PlayHintBoneAnimation.script.animationType = PlayHintBoneAnimation.AnimationType.畫布上方太陽;
                this.currentMouseType = MouseType.無狀態;
                break;

            case MouseType.無狀態:
                if (Input.GetKey(KeyCode.Mouse0) || Input.GetKey(KeyCode.Mouse1))
                    this.currentMouseType = MouseType.點擊;
                break;

            case MouseType.點擊:

                if (Physics.Raycast(this.ViewCamera.ScreenToWorldPoint(Input.mousePosition), new Vector3(0, 0, 1), out hit, 200, this.TargetLayer))
                    this.currentMouseType = MouseType.拖曳中;
                else
                    this.currentMouseType = MouseType.無狀態;
                break;

            case MouseType.拖曳中:

                //拖曳後解鎖
                ClickObject.script.isLock = false;

                if (Physics.Raycast(this.ViewCamera.ScreenToWorldPoint(Input.mousePosition), new Vector3(0, 0, 1), out hit, 200, this.TargetLayer))
                {
                    //關閉手指動畫
                    PlayHandBoneAnimation.script.animationType = PlayHandBoneAnimation.AnimationType.空動畫;

                    //物件拖曳範圍 Min~Max
                    this.hit.transform.position = new Vector3(
                       Mathf.Max(Mathf.Min(this.ViewCamera.ScreenToWorldPoint(Input.mousePosition).x, 物件位置Max), 物件位置Min),
                       this.hit.transform.position.y,
                       this.hit.transform.position.z);

                    //土坡物件的淡化漸變 ALPHA 0.5 -> 1.0
                    //最左邊為0.5 最右為1.0 雙倍的與中心點的距離
                    對應土坡圖.GetComponent<SmoothMoves.Sprite>().color = new Color(1, 1, 1, 0.7F + 0.3F * (float)((this.hit.transform.position.x - 物件位置Min) / (dis * 2)));
                    對應土坡圖.GetComponent<SmoothMoves.Sprite>().UpdateArrays();
                    //使狀態更正為已使用 通知下一步按鈕出現
                    對應土坡圖.GetComponent<PictureInfo>().isUsed = true;

                }
                if (!Input.GetKey(KeyCode.Mouse0) && !Input.GetKey(KeyCode.Mouse1))
                    this.currentMouseType = MouseType.無狀態;

                break;

            case MouseType.放開:

                this.currentMouseType = MouseType.無狀態;
                break;
        }
    }
 public MouseAction(UILevelSelectChapterItem component, ulong timeStamp)
 {
     this.targetComponentInfo = component.name;
     // Pos = GameObject.Find("UI Root").transform.TransformPoint(component.transform.localPosition);
     Pos       = component.transform.position;
     TimeStamp = timeStamp;
     mouseType = MouseType.UILevelSelectChapterItem;
 }
Exemplo n.º 7
0
        public static void RemoveInput(int index, Action action, MouseType type)
        {
            switch (type)
            {
            case MouseType.Down:
                obj.LateUpdate += () =>
                {
                    if (obj && obj.inputsMouseDown.ContainsKey(index))
                    {
                        obj.inputsMouseDown[index] -= action;
                        if (obj.inputsMouseDown[index] == null)
                        {
                            obj.inputsMouseDown.Remove(index);
                            if (obj.inputsMouseDown.Count == 0)
                            {
                                GameEvent.RemoveEvent(obj.TOnUpdate_MouseDown, Method.Update);
                            }
                        }
                    }
                };
                break;

            case MouseType.Press:
                obj.LateUpdate += () =>
                {
                    if (obj && obj.inputsMousePress.ContainsKey(index))
                    {
                        obj.inputsMousePress[index] -= action;
                        if (obj.inputsMousePress[index] == null)
                        {
                            obj.inputsMousePress.Remove(index);
                            if (obj.inputsMousePress.Count == 0)
                            {
                                GameEvent.RemoveEvent(obj.TOnUpdate_MousePress, Method.Update);
                            }
                        }
                    }
                };
                break;

            case MouseType.Up:
                obj.LateUpdate += () => {
                    if (obj && obj.inputsMouseUp.ContainsKey(index))
                    {
                        obj.inputsMouseUp[index] -= action;
                        if (obj.inputsMouseUp[index] == null)
                        {
                            obj.inputsMouseUp.Remove(index);
                            if (obj.inputsMouseUp.Count == 0)
                            {
                                GameEvent.RemoveEvent(obj.TOnUpdate_MouseUp, Method.Update);
                            }
                        }
                    }
                };
                break;
            }
        }
 public MouseAction(UIEventListener component, ulong timeStamp)
 {
     this.targetComponentInfo = component.name;
     // Pos = GameObject.Find("UI Root").transform.TransformPoint(component.transform.localPosition);
     Pos = component.transform.position;
     Debug.Log("Construct Listen" + Pos);
     TimeStamp = timeStamp;
     mouseType = MouseType.UIEventListener;
 }
Exemplo n.º 9
0
        public override void LoadMouseEvent(MouseButtons button, PointF location, MouseType type)
        {
            base.LoadMouseEvent(button, location, type);

            IDrawObj draw = ObjList.LastOrDefault(obj => obj.CanSelect(location));

            if (draw != null)
            {
                ((DrawObj)draw).LoadMouseEvent(button, location, type);
            }
        }
Exemplo n.º 10
0
        private void SwitchButton_MouseUp(object sender, MouseEventArgs e)
        {
            this.mouseType = MouseType.Up;
            this.DrawImage();
            this.IsOpen = !this.IsOpen;
            EventHandler expr_25 = this.SwitchChanged;

            if (expr_25 != null)
            {
                expr_25(this, e);
            }
        }
Exemplo n.º 11
0
    private void WriteTouchMessage(MouseType type, int num = 0)
    {
        Vector2 pos = Input.GetTouch(num).position;

        float time     = Time.realtimeSinceStartup;
        float xprecent = pos.x / (float)width;
        float yprecent = pos.y / (float)height;

        string message = time + " " + (int)type + " " + xprecent + " " + yprecent;

        sw.WriteLine(message);
        sw.Flush();
    }
Exemplo n.º 12
0
        public static void AddInput(int index, Action action, MouseType type)
        {
            switch (type)
            {
            case MouseType.Down:
                if (Obj.inputsMouseDown.ContainsKey(index))
                {
                    obj.inputsMouseDown[index] += action;
                }
                else
                {
                    if (obj.inputsMouseDown.Count == 0)
                    {
                        GameEvent.AddEvent(obj.TOnUpdate_MouseDown, Method.Update);
                    }
                    obj.inputsMouseDown.Add(index, action);
                }
                break;

            case MouseType.Press:
                if (Obj.inputsMousePress.ContainsKey(index))
                {
                    obj.inputsMousePress[index] += action;
                }
                else
                {
                    if (obj.inputsMousePress.Count == 0)
                    {
                        GameEvent.AddEvent(obj.TOnUpdate_MousePress, Method.Update);
                    }
                    obj.inputsMousePress.Add(index, action);
                }
                break;

            case MouseType.Up:
                if (Obj.inputsMouseUp.ContainsKey(index))
                {
                    obj.inputsMouseUp[index] += action;
                }
                else
                {
                    if (obj.inputsMouseUp.Count == 0)
                    {
                        GameEvent.AddEvent(obj.TOnUpdate_MouseUp, Method.Update);
                    }
                    obj.inputsMouseUp.Add(index, action);
                }
                break;
            }
        }
Exemplo n.º 13
0
    public MouseExecution(int type, string[] commandsData, DesktopManager desktop) : base()
    {
        this.type    = (MouseType)type;
        this.desktop = desktop;

        if (commandsData.Length > 0)
        {
            _ = int.TryParse(commandsData[0], out data0);
            if (commandsData.Length > 1)
            {
                _ = int.TryParse(commandsData[1], out data1);
            }
        }
    }
Exemplo n.º 14
0
        //钩子子程:就是钩子所要做的事情 
        private static int MouseHookProc(int nCode, Int32 wParam, IntPtr lParam)
        {
            if (nCode >= 0)
            {
                MSG       m    = (MSG)Marshal.PtrToStructure(lParam, typeof(MSG));//鼠标 
                MouseType type = MouseType.Move;
                switch (wParam)
                {
                case WM_MOUSEMOVE:
                    type = MouseType.Move;
                    break;

                case WM_LBUTTONDOWN:
                    type = MouseType.LeftDown;
                    break;

                case WM_RBUTTONDOWN:
                    type = MouseType.RightDown;
                    break;

                case WM_MBUTTONDOWN:
                    type = MouseType.MiddleDown;
                    break;

                case WM_LBUTTONUP:
                    type = MouseType.LeftUp;
                    break;

                case WM_RBUTTONUP:
                    type = MouseType.RightUp;
                    break;

                case WM_MBUTTONUP:
                    type = MouseType.MiddleUp;
                    break;

                case WM_MOUSEWHEEL:
                    type = MouseType.Wheel;
                    break;

                default:
                    break;
                }

                MouseEventHandler?.Invoke(type);

                return(0);//如果返回1,则结束消息,这个消息到此为止,不再传递。如果返回0或调用CallNextHookEx函数则消息出了这个钩子继续往下传递,也就是传给消息真正的接受者 
            }
            return(CallNextHookEx(hMouseHook, nCode, wParam, lParam));
        }
Exemplo n.º 15
0
        public TSIDockContainer(string name, string text, DevComponents.AdvTree.AdvTree tree, System.Windows.Forms.PropertyGrid propGrid)
        {
            cmdManager       = new CommandManager();
            selectedDDSIndex = -1;
            TSItree          = tree;
            propertyGrid     = propGrid;
            this.Name        = name;
            this.Text        = text;
            //
            // renderPanel
            //
            renderControl            = new RenderControl();
            renderControl.Location   = new System.Drawing.Point(3, 1);
            renderControl.Dock       = DockStyle.Fill;
            renderControl.Name       = "renderControl";
            renderControl.Size       = new System.Drawing.Size(657, 423);
            renderControl.TabIndex   = 0;
            renderControl.MouseMove += new MouseEventHandler(MouseMove);
            renderControl.MouseUp   += new MouseEventHandler(MouseUp);
            renderControl.MouseDown += new MouseEventHandler(MouseDown);

            codePanelDockContainer = new DevComponents.DotNetBar.PanelDockContainer();
            //
            // codePanelDockContainer
            //
            codePanelDockContainer.Controls.Add(renderControl);
            codePanelDockContainer.Location        = new System.Drawing.Point(3, 28);
            codePanelDockContainer.Dock            = DockStyle.Fill;
            codePanelDockContainer.Name            = "codePanelDockContainer";
            codePanelDockContainer.Size            = new System.Drawing.Size(663, 427);
            codePanelDockContainer.Style.Alignment = System.Drawing.StringAlignment.Center;
            codePanelDockContainer.Style.BackColor1.ColorSchemePart  = DevComponents.DotNetBar.eColorSchemePart.BarBackground;
            codePanelDockContainer.Style.BackColor2.ColorSchemePart  = DevComponents.DotNetBar.eColorSchemePart.BarBackground2;
            codePanelDockContainer.Style.BorderColor.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.BarDockedBorder;
            codePanelDockContainer.Style.ForeColor.ColorSchemePart   = DevComponents.DotNetBar.eColorSchemePart.ItemText;
            codePanelDockContainer.Style.GradientAngle = 90;
            codePanelDockContainer.TabIndex            = 0;
            this.Control = codePanelDockContainer;

            //mouse position render
            font         = this.renderControl.Content.Load <SpriteFont>("Arial");
            positionText = new Text(this.renderControl.GraphicsDevice);
            positionText.Set(0 + "," + 0, new Vector2(0, 0), font, Color.Red);
            renderControl.AddText(positionText);
            mouseType = MouseType.MOUSE_POINT;

            renderControl.AddAera(aera);
            renderControl.AddSprite(dds);
        }
Exemplo n.º 16
0
        /************************************************************************/
        /* SendMouse - Payload format                                           */
        /* %c - flags                                                           */
        /*    - 0x01 absolute position                                          */
        /* %i - mousex (0-65535 => maps to screen width)                        */
        /* %i - mousey (0-65535 => maps to screen height)                       */
        /************************************************************************/
        public bool SendMouse(ushort x, ushort y, MouseType mType)
        {
            if (!Connected)
            {
                return(false);
            }
            var payload = new byte[9];
            var offset  = 0;

            payload[offset++] = (byte)mType;
            payload[offset++] = (byte)((x & 0xff00) >> 8);
            payload[offset++] = (byte)(x & 0x00ff);
            payload[offset++] = (byte)((y & 0xff00) >> 8);
            payload[offset]   = (byte)(y & 0x00ff);

            return(Send(PacketType.PtMouse, payload));
        }
Exemplo n.º 17
0
        public Mouse(int dpi, string manufacturer, string model, double price, MouseType type)
        {
            try
            {
                if (dpi <= 0)
                {
                    throw new ArgumentException("Mouse cannot have a DPI less or equal to 0. Entered value: " + dpi.ToString());
                }

                if (string.IsNullOrEmpty(manufacturer) || string.IsNullOrWhiteSpace(manufacturer))
                {
                    throw new ArgumentNullException(manufacturer);
                }

                if (string.IsNullOrEmpty(model) || string.IsNullOrWhiteSpace(model))
                {
                    throw new ArgumentNullException(model);
                }

                if (price <= 0)
                {
                    throw new ArgumentException("Price cannot be less or equal to 0. Entered value: " + price.ToString());
                }

                _dpi          = dpi;
                _id           = IDGenerator.NextID();
                _manufacturer = manufacturer;
                _model        = model;
                _price        = price;
                _type         = type.ToString();

                AddToWarehouse(1);
            }
            catch (ArgumentNullException exception)
            {
                throw exception;
            }
            catch (ArgumentException exception)
            {
                throw exception;
            }
            catch (Exception exception)
            {
                throw exception;
            }
        }
Exemplo n.º 18
0
 /// <summary>
 /// 构造器
 /// </summary>
 public SwitchButton()
 {
     this.InitializeComponent();
     this.anim          = new Animation(60);
     this._textDir      = TextDirect.Right;
     this.TextOpen      = "开";
     this.TextClose     = "关";
     this._isOpen       = true;
     this._isClose      = true;
     this.mouseType     = MouseType.Leave;
     this.pbFore.Parent = this.pbBack;
     this.pbFore.BringToFront();
     ControlSet.ThemeStyleChanged += delegate(object sender, EventArgs e)
     {
         this.DrawImage();
     };
     ControlSet.ThemeColorChanged += delegate(object sender, EventArgs e)
     {
         this.DrawImage();
     };
 }
Exemplo n.º 19
0
        private void LoadMouseEvent(MouseButtons button, PointF location, MouseType type)
        {
            IDrawObj draw = Objs.LastOrDefault(obj => obj.CanSelect(location));

            if (_mouseMovingObj != draw)
            {
                if (_mouseMovingObj != null)
                {
                    _mouseMovingObj.LoadMouseLeaveEvent();
                }
                _mouseMovingObj = draw;
                if (_mouseMovingObj != null)
                {
                    _mouseMovingObj.LoadMouseEnterEvent();
                }
            }

            if (_mouseMovingObj != null)
            {
                _mouseMovingObj.LoadMouseEvent(button, location, type);
            }
        }
Exemplo n.º 20
0
 public void RunAway()
 {
     if (isPlayer)
     {
         if (Checkpoint.lastCheckpoint)
         {
             Checkpoint.lastCheckpoint.Reburn(GetComponentInParent <GrowInNumbers>());
         }
         else
         {
             SceneManager.LoadScene(1);
         }
     }
     else
     {
         GetComponent <Collider2D>().enabled = false;
         mouseType = MouseType.runningAway;
         isAlly    = false;
         isEnemy   = false;
         transform.SetParent(null);
         targetPointToRunAway = transform.position + transform.up * 99999f;//Vector3.ProjectOnPlane(Random.onUnitSphere, Vector3.forward).normalized * 9999f;
     }
 }
Exemplo n.º 21
0
    private void Start()
    {
        // 文件读写
        sr = FileManager.GetStreamReader((FileManager.GetFilePath("Input.rec")));
        Debug.Log("lucky start play input");
        if (sr == null)
        {
            return;
        }

        cursor = DebugControl.instance.cursor;

        // 获得gameView窗口
        System.Type T = System.Type.GetType("UnityEditor.GameView,UnityEditor");
        gameView = UnityEditor.EditorWindow.GetWindow(T, true, "Game") as UnityEditor.EditorWindow;

        // 获得gameView中渲染窗口的分辨率
        var prop       = gameView.GetType().GetProperty("currentGameViewSize", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
        var gvsize     = prop.GetValue(gameView, new object[0] {
        });
        var gvSizeType = gvsize.GetType();

        resh = (int)gvSizeType.GetProperty("height", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance).GetValue(gvsize, new object[0] {
        });
        resw = (int)gvSizeType.GetProperty("width", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance).GetValue(gvsize, new object[0] {
        });

        if ((line = sr.ReadLine()) != null)
        {
            string[] ss = line.Split(' ');
            time = Convert.ToSingle(ss[0]);
            type = (MouseType)Convert.ToInt32(ss[1]);
            xpre = Convert.ToSingle(ss[2]);
            ypre = Convert.ToSingle(ss[3]);
        }
    }
Exemplo n.º 22
0
        public int MCount(MouseType key)
        {
            int code = (int)key;
            if (code >= mkeys.Length)
                return 0;

            return mcount[code];
        }
Exemplo n.º 23
0
 public void SetMouseType(MouseType mType)
 {
 }
Exemplo n.º 24
0
        public static void MakeMouseEvent(MouseEventType metype, MouseType mtype, System.Drawing.Point p)
        {
            if (metype == MouseEventType.MOVE)
            {
                SetCursorPos(p.X, p.Y);
                return;
            }

            switch (mtype)
            {
            case MouseType.LEFT:
            {
                SetCursorPos(p.X, p.Y);
                switch (metype)
                {
                case MouseEventType.DOWN:
                    mouse_event(LBDOWN, 0, 0, 0, 0);
                    break;

                case MouseEventType.UP:
                    mouse_event(LBUP, 0, 0, 0, 0);
                    break;

                case MouseEventType.CLICK:
                    mouse_event(LBDOWN, 0, 0, 0, 0);
                    mouse_event(LBUP, 0, 0, 0, 0);
                    break;

                default:
                    break;
                }
                break;
            }

            case MouseType.RIGHT:
            {
                SetCursorPos(p.X, p.Y);
                switch (metype)
                {
                case MouseEventType.DOWN:
                    mouse_event(RBDOWN, 0, 0, 0, 0);
                    break;

                case MouseEventType.UP:
                    mouse_event(RBUP, 0, 0, 0, 0);
                    break;

                case MouseEventType.CLICK:
                    mouse_event(RBDOWN, 0, 0, 0, 0);
                    mouse_event(RBUP, 0, 0, 0, 0);
                    break;

                default:
                    break;
                }
                break;
            }

            case MouseType.WHEEL:
            {
                switch (metype)
                {
                case MouseEventType.DOWN:
                    SetCursorPos(p.X, p.Y);
                    mouse_event(MBDOWN, 0, 0, 0, 0);
                    break;

                case MouseEventType.UP:
                    SetCursorPos(p.X, p.Y);
                    mouse_event(MBUP, 0, 0, 0, 0);
                    break;

                case MouseEventType.CLICK:
                    SetCursorPos(p.X, p.Y);
                    mouse_event(MBDOWN, 0, 0, 0, 0);
                    mouse_event(MBUP, 0, 0, 0, 0);
                    break;

                case MouseEventType.SCROLLDOWN:
                    mouse_event(WHEEL, 0, 0, -10, 0);
                    break;

                case MouseEventType.SCROLLUP:
                    mouse_event(WHEEL, 0, 0, 10, 0);
                    break;
                }
                break;
            }
            }
        }
Exemplo n.º 25
0
        /************************************************************************/
        /* SendMouse - Payload format                                           */
        /* %c - flags                                                           */
        /*    - 0x01 absolute position                                          */
        /* %i - mousex (0-65535 => maps to screen width)                        */
        /* %i - mousey (0-65535 => maps to screen height)                       */
        /************************************************************************/
        public bool SendMouse(ushort x, ushort y, MouseType mType)
        {
            if (!Connected)
                return false;
            var payload = new byte[9];
            var offset = 0;
            payload[offset++] = (byte)mType;
            payload[offset++] = (byte)((x & 0xff00) >> 8);
            payload[offset++] = (byte)(x & 0x00ff);
            payload[offset++] = (byte)((y & 0xff00) >> 8);
            payload[offset] = (byte)(y & 0x00ff);

            return Send(PacketType.PtMouse, payload);
        }
Exemplo n.º 26
0
 public bool MReleaseTrg(MouseType key)
 {
     return (!MPress(key, true) && MPress(key, false));
 }
Exemplo n.º 27
0
        private bool MPress(MouseType key, bool current)
        {
            int code = (int)key;
            if (code >= mkeys.Length)
                return false;

            if (current)
                return mkeys[code];
            else
                return mback[code];
        }
Exemplo n.º 28
0
 private void SwitchButton_MouseLeave(object sender, EventArgs e)
 {
     this.mouseType = MouseType.Leave;
     this.DrawImage();
 }
Exemplo n.º 29
0
 private void m_ButtonFloor_Click(object sender, EventArgs e)
 {
     this.m_MouseType = MouseType.Floor;
 }
Exemplo n.º 30
0
 private void SwitchButton_MouseDown(object sender, MouseEventArgs e)
 {
     this.mouseType = MouseType.Down;
     this.DrawImage();
 }
Exemplo n.º 31
0
 private void SwitchButton_MouseEnter(object sender, EventArgs e)
 {
     this.mouseType = MouseType.Enter;
     this.DrawImage();
 }
Exemplo n.º 32
0
 private void m_ButtonAddBox_Click(object sender, EventArgs e)
 {
     this.m_MouseType = MouseType.Box;
 }
Exemplo n.º 33
0
 public MouseEvent(uint elapsed, Point point, MouseType mType, MouseEventType eType) : base(EventType.MOUSEEVENT, elapsed)
 {
     this.Point = point;
     this.MouseType = mType;
     this.MouseEventType = eType;
 }
Exemplo n.º 34
0
 /// <summary>
 /// 鼠标在地图上弹起
 /// </summary>
 /// <param name="e"></param>
 protected override void OnMouseUp(MouseEventArgs e)
 {
     base.OnMouseUp(e);
     if (_mouse_type == MouseType.DragMap)  //拖动地图 鼠标弹起
     {
         _mouse_type = MouseType.None;
         _current_cursor_cache = Cursor = Cursors.Arrow;
     }
     else if (_mouse_type == MouseType.DragScreenshotArea)  //拖拽截图矩形
     {
         _mouse_type = MouseType.None;
         _current_cursor_cache = Cursor = Cursors.Arrow;
     }
     else if (_mouse_type == MouseType.DrawCircle && _current_drawing as BCircle != null)  //绘制椭圆鼠标弹起
     {
         _mouse_type = MouseType.None;
         _current_cursor_cache = Cursor = Cursors.Arrow;
         _drawingObjects.Add(_drawingObjects.Count + 1, _current_drawing);
         _current_drawing = null;
     }
     else if (_mouse_type == MouseType.DrawRectange && _current_drawing as BRectangle != null)  //绘制矩形鼠标弹起
     {
         _mouse_type = MouseType.None;
         _current_cursor_cache = Cursor = Cursors.Arrow;
         _drawingObjects.Add(_drawingObjects.Count + 1, _current_drawing);
         _current_drawing = null;
     }
     else if (_mouse_type == MouseType.DrawScreenshotArea && _current_drawing as BScreenShotRectangle != null)  //绘制截图矩形鼠标弹起
     {
         _current_cursor_cache = Cursor = Cursors.Arrow;
         _mouse_type = MouseType.None;
         BScreenShotRectangle r = _current_drawing as BScreenShotRectangle;
         _bScreenshotMenu.Location = new Point(r.LeftTop.X + r.Width - _bScreenshotMenu.Width, r.LeftTop.Y + r.Height + 4);
         _bScreenshotMenu.Visible = true;
     }
     else if (_mouse_type == MouseType.DrawBound && _b_bound != null) //矩形搜索
     {
         _current_cursor_cache = Cursor = Cursors.Arrow;
         _mouse_type = MouseType.None;
         Point p1 = MapHelper.GetScreenLocationByLatLng(_b_bound.LeftTop, _center, _zoom, ClientSize);
         Point p2 = MapHelper.GetScreenLocationByLatLng(_b_bound.RightBottom, _center, _zoom, ClientSize);
         Point p = p1.Y > p2.Y ? p1 : p2;
         _bQuickSearchControl.Location = new Point(p.X - _bQuickSearchControl.Width, p.Y + 2);
         _bQuickSearchControl.Visible = true;
     }
     else if (_mouse_type == MouseType.DrawMarker) //添加标记点
     {
         if (_current_selected_marker != null)
         {
             _mouse_type = MouseType.None;
         }
     }
     Invalidate();
 }
Exemplo n.º 35
0
 public bool MPress(MouseType key)
 {
     return MPress(key, true);
 }
Exemplo n.º 36
0
 private void m_ButtonAddMan_Click(object sender, EventArgs e)
 {
     this.m_MouseType = MouseType.Man;
 }
Exemplo n.º 37
0
 public bool MPressTrg(MouseType key)
 {
     return (MPress(key, true) && !MPress(key, false));
 }
Exemplo n.º 38
0
    /// <summary>
    /// 處理滑鼠狀態
    /// </summary>
    private void ProcessMouseState()
    {
        switch (this.currentMouseType)
        {
            case MouseType.初始播放引導動畫:
                    //播放引導動畫
                    PlayHandBoneAnimation.script.animationType = PlayHandBoneAnimation.AnimationType.太陽引導;
                   // PlayHintBoneAnimation.script.animationType = PlayHintBoneAnimation.AnimationType.畫布上方太陽;
                this.currentMouseType = MouseType.無狀態;
                break;

            case MouseType.無狀態:
                if (Input.GetKey(KeyCode.Mouse0) || Input.GetKey(KeyCode.Mouse1))
                    this.currentMouseType = MouseType.點擊;
                break;

            case MouseType.點擊:

                if (Physics.Raycast(this.ViewCamera.ScreenToWorldPoint(Input.mousePosition), new Vector3(0, 0, 1), out hit, 200, this.TargetLayer))
                    this.currentMouseType = MouseType.拖曳中;
                else
                    this.currentMouseType = MouseType.無狀態;
                break;

            case MouseType.拖曳中:

                if (Physics.Raycast(this.ViewCamera.ScreenToWorldPoint(Input.mousePosition), new Vector3(0, 0, 1), out hit, 200, this.TargetLayer))
                {
                    //通知"下一步"按鈕 可以出現
                    NextButtonController.isCheck4 = true;
                    //關閉手指動畫
                    PlayHandBoneAnimation.script.animationType = PlayHandBoneAnimation.AnimationType.空動畫;

                    //物件拖曳範圍 Min~Max
                    this.hit.transform.position = new Vector3(
                       Mathf.Max(Mathf.Min(this.ViewCamera.ScreenToWorldPoint(Input.mousePosition).x, 物件位置Max), 物件位置Min),
                       this.hit.transform.position.y,
                       this.hit.transform.position.z);

                    //物件的影子倍率與位置
                    foreach (GameObject gameObject in State.script.影子)
                    {
                        if (gameObject.activeInHierarchy)
                        {
                            gameObject.transform.localScale = new Vector3(
                                Mathf.Lerp(影子Scale倍率_Min, 影子Scale倍率_Max, Mathf.Abs(this.hit.transform.position.x - 物件中心點Center) / dis),
                                gameObject.transform.localScale.y,
                                gameObject.transform.localScale.z);

                            gameObject.transform.localPosition = new Vector3(
                                    Mathf.Lerp(
                                    影子Position位置偏移_Max,
                                    影子Position位置偏移_Min,
                                     (((this.hit.transform.position.x - 物件中心點Center) / dis) + 1) / 2F
                                    ),
                                gameObject.transform.localPosition.y,
                                gameObject.transform.localPosition.z);
                        }
                    }

                }
                if (!Input.GetKey(KeyCode.Mouse0) && !Input.GetKey(KeyCode.Mouse1))
                    this.currentMouseType = MouseType.無狀態;

                break;

            case MouseType.放開:

                this.currentMouseType = MouseType.無狀態;
                break;
        }
    }
Exemplo n.º 39
0
        public void SetMKey(MouseType key, bool press)
        {
            int code = (int)key;
            if (code >= mkeys.Length)
                return;

            mkeys[code] = press;
        }
Exemplo n.º 40
0
    /// <summary>
    /// 處理滑鼠狀態
    /// </summary>
    private void ProcessMouseState()
    {
        switch (this.currentMouseType)
        {
            case MouseType.初始播放引導動畫:

                if (ClickObject.script.HintAnimationisInit)
                {
                    //播放引導動畫
                    if (GameManager.script.CurrentDrawStage == GameManager.DrawStage.明暗 || GameManager.script.CurrentDrawStage == GameManager.DrawStage.設色)
                        PlayHandBoneAnimation.script.animationType = PlayHandBoneAnimation.AnimationType.指向引導_馬樹類;
                    if (GameManager.script.CurrentDrawStage == GameManager.DrawStage.淡化)
                        PlayHandBoneAnimation.script.animationType = PlayHandBoneAnimation.AnimationType.指向引導_光源土坡類;
                    //PlayHintBoneAnimation.script.animationType = PlayHintBoneAnimation.AnimationType.畫布閃爍圖片;
                }

                this.currentMouseType = MouseType.無狀態;
                break;

            case MouseType.無狀態:
                if (Input.GetKey(KeyCode.Mouse0) || Input.GetKey(KeyCode.Mouse1))
                    this.currentMouseType = MouseType.點擊;
                break;

            case MouseType.點擊:
                if (!Input.GetKey(KeyCode.Mouse0) && !Input.GetKey(KeyCode.Mouse1))
                    this.currentMouseType = MouseType.放開;
                break;

            case MouseType.放開:

                //多重物件偵測 偵測目標物件是否閃爍 若無則可以獲取
                hits = Physics.RaycastAll(this.ViewCamera.ScreenToWorldPoint(Input.mousePosition), new Vector3(0, 0, 1), 200, this.TargetLayer);
                if (hits.Length > 0)
                {
                    foreach (RaycastHit hit in hits)
                    {
                        if (hit.transform.gameObject.GetComponent<PictureInfo>().isBlink)
                        {
                            //改變動畫 - > 操作區潑墨
                            if (ClickObject.script.HintAnimationisInit)
                            {
                                if (GameManager.script.CurrentDrawStage == GameManager.DrawStage.淡化)
                                    PlayHandBoneAnimation.script.animationType = PlayHandBoneAnimation.AnimationType.指向引導_光源操作區潑墨;
                                else
                                    PlayHandBoneAnimation.script.animationType = PlayHandBoneAnimation.AnimationType.指向引導_操作區潑墨;
                                //PlayHintBoneAnimation.script.animationType = PlayHintBoneAnimation.AnimationType.操作閃爍潑墨;
                            }

                            innerHit = hit;
                            //如果切換圖片後 再解除Lock 才能賦予新的Target

                            //【明暗】與【淡化】部分 鎖定被選定的物件;沒變化前不解鎖
                            if (GameManager.script.CurrentDrawStage == GameManager.DrawStage.明暗 ||
                                GameManager.script.CurrentDrawStage == GameManager.DrawStage.淡化 ||
                                GameManager.script.CurrentDrawStage == GameManager.DrawStage.設色)
                            {
                                if (!this.isLock)
                                {
                                    isLock = true;
                                    ClearControlArea();//清空操作區
                                    this.Target = innerHit.transform.gameObject;
                                }
                            }
                            //【設色】部分 不上鎖
                            //else
                            //{
                            //    if (Target)
                            //    {
                            //        this.Target.GetComponent<PictureInfo>().isBlink = true;
                            //        ClearControlArea(); //清空操作區
                            //        this.Target = innerHit.transform.gameObject; // 給予新的Target
                            //    }

                            //}

                            //停止閃爍 並將顏色還原
                            this.Target.GetComponent<PictureInfo>().isBlink = false;

                            this.Target.GetComponent<SmoothMoves.Sprite>().SetColor(new Color(1, 1, 1, 1));

                            //開啟各階段程式
                            if (this.Target.GetComponent<Step2>()) this.Target.GetComponent<Step2>().enabled = GameManager.script.CurrentDrawStage == GameManager.DrawStage.明暗 ? true : false;
                            if (this.Target.GetComponent<Step3>()) this.Target.GetComponent<Step3>().enabled = GameManager.script.CurrentDrawStage == GameManager.DrawStage.設色 ? true : false;
                            if (this.Target.GetComponent<Step4>()) this.Target.GetComponent<Step4>().enabled = GameManager.script.CurrentDrawStage == GameManager.DrawStage.淡化 ? true : false;
                            if (this.Target.GetComponent<Step4_V2>()) this.Target.GetComponent<Step4_V2>().enabled = GameManager.script.CurrentDrawStage == GameManager.DrawStage.淡化 ? true : false;

                            //在設色階段中 將操作區的改變動畫片段
                            //if (GameManager.script.CurrentDrawStage == GameManager.DrawStage.設色)
                            //{
                            //    SetColorBoneAnimation.script.pictureType =
                            //        this.Target.GetComponent<Step3>().pictureType;
                            //}
                            //break;
                        }

                    }
                }

                this.currentMouseType = MouseType.無狀態;
                break;
        }
    }
Exemplo n.º 41
0
 public static void MakeMouseEvent(MouseEventType metype, MouseType mtype, System.Drawing.Point p)
 {
     if(metype == MouseEventType.MOVE)
     {
         SetCursorPos(p.X, p.Y);
         return;
     }
     
     switch(mtype)
     {
         case MouseType.LEFT:
             {
                 SetCursorPos(p.X, p.Y);
                 switch(metype)
                 {
                     case MouseEventType.DOWN:
                         mouse_event(LBDOWN, 0, 0, 0, 0);
                         break;
                     case MouseEventType.UP:
                         mouse_event(LBUP, 0, 0, 0, 0);
                         break;
                     case MouseEventType.CLICK:
                         mouse_event(LBDOWN, 0, 0, 0, 0);
                         mouse_event(LBUP, 0, 0, 0, 0);
                         break;
                     default:
                         break;
                 }
                 break;
             }
         case MouseType.RIGHT:
             {
                 SetCursorPos(p.X, p.Y);
                 switch (metype)
                 {
                     case MouseEventType.DOWN:
                         mouse_event(RBDOWN, 0, 0, 0, 0);
                         break;
                     case MouseEventType.UP:
                         mouse_event(RBUP, 0, 0, 0, 0);
                         break;
                     case MouseEventType.CLICK:
                         mouse_event(RBDOWN, 0, 0, 0, 0);
                         mouse_event(RBUP, 0, 0, 0, 0);
                         break;
                     default:
                         break;
                 }
                 break;
             }
         case MouseType.WHEEL:
             {
                 switch (metype)
                 {
                     case MouseEventType.DOWN:
                         SetCursorPos(p.X, p.Y);
                         mouse_event(MBDOWN, 0, 0, 0, 0);
                         break;
                     case MouseEventType.UP:
                         SetCursorPos(p.X, p.Y);
                         mouse_event(MBUP, 0, 0, 0, 0);
                         break;
                     case MouseEventType.CLICK:
                         SetCursorPos(p.X, p.Y);
                         mouse_event(MBDOWN, 0, 0, 0, 0);
                         mouse_event(MBUP, 0, 0, 0, 0);
                         break;
                     case MouseEventType.SCROLLDOWN:
                         mouse_event(WHEEL, 0, 0, -10, 0);
                         break;
                     case MouseEventType.SCROLLUP:
                         mouse_event(WHEEL, 0, 0, 10, 0);
                         break;
                 }
                 break;
             }
     }
 }
Exemplo n.º 42
0
    /// <summary>
    /// 處理滑鼠狀態
    /// </summary>
    private void ProcessMouseState()
    {
        switch (this.currentMouseType)
        {
            case MouseType.初始播放引導動畫:
                //播放引導動畫
                PlayHandBoneAnimation.script.animationType = PlayHandBoneAnimation.AnimationType.拖曳引導;
                //PlayHintBoneAnimation.script.animationType = PlayHintBoneAnimation.AnimationType.拖曳操作畫布;
                this.currentMouseType = MouseType.無狀態;
                break;

            case MouseType.無狀態:
                if (Input.GetKey(KeyCode.Mouse0) || Input.GetKey(KeyCode.Mouse1))
                    this.currentMouseType = MouseType.點擊;
                break;

            case MouseType.點擊:

                if (Physics.Raycast(this.ViewCamera.ScreenToWorldPoint(Input.mousePosition), new Vector3(0, 0, 1), out this.hit, 100, this.TargetLayer))
                {
                    this.clickTime += Time.deltaTime;
                    if (this.clickTime > this.clickTime_threshold)
                    {
                        this.Target = this.hit.transform.gameObject;
                        this.clickTime = 0;

                        if (!this.Target.GetComponent<PictureInfo>().CanMove)
                        {
                            this.currentMouseType = MouseType.無狀態;
                            return;
                        }

                        if(!this.GetComponent<iTween>())
                        iTween.ValueTo(this.gameObject, iTween.Hash(
                               "name", "PickObject",
                               "from", 1,
                               "to", 0.5F,
                               "onupdate", "changePictureAlpha",
                               "loopType", "pingPong",
                               "time", 1
                               ));

                        this.currentPictureType = this.Target.GetComponent<PictureInfo>().Type;
                        this.currentMouseType = MouseType.拖曳中;
                    }
                    //取消手指動畫
                    PlayHandBoneAnimation.script.animationType = PlayHandBoneAnimation.AnimationType.空動畫;
                }

                break;

            case MouseType.拖曳中:
                if (this.currentPictureType == PictureInfo.PictureType.馬 || this.currentPictureType == PictureInfo.PictureType.樹 || this.currentPictureType == PictureInfo.PictureType.未分類)
                {
                    //將中心點修正
                    float offsetY = this.Target.GetComponent<SmoothMoves.Sprite>().size.y * this.Target.transform.localScale.y * 0.5f;

                    this.Target.transform.position = new Vector3(this.ViewCamera.ScreenToWorldPoint(Input.mousePosition).x,
                        this.ViewCamera.ScreenToWorldPoint(Input.mousePosition).y - offsetY, this.Target.transform.position.z);
                }
                else if (this.currentPictureType == PictureInfo.PictureType.土坡)
                {
                    this.Target.transform.position = new Vector3(this.ViewCamera.ScreenToWorldPoint(Input.mousePosition).x,
                        this.ViewCamera.ScreenToWorldPoint(Input.mousePosition).y, this.Target.transform.position.z);
                }

                this.Target.GetComponent<PictureInfo>().ChangeScaleDepth();

                if (!Input.GetKey(KeyCode.Mouse0) && !Input.GetKey(KeyCode.Mouse1))
                    this.currentMouseType = MouseType.放開;

                break;

            case MouseType.放開:
                //iTween.StopByName("PickObject");

                this.Target.GetComponent<SmoothMoves.Sprite>().SetColor(new Color(1, 1, 1, 1));

                if (this.currentPictureType == PictureInfo.PictureType.馬 || this.currentPictureType == PictureInfo.PictureType.樹 || this.currentPictureType == PictureInfo.PictureType.未分類)
                    this.馬樹範圍提示物件.GetComponent<SmoothMoves.Sprite>().SetColor(new Color(1, 1, 1, 0));
                else if (this.currentPictureType == PictureInfo.PictureType.土坡)
                    this.土坡範圍提示物件.GetComponent<SmoothMoves.Sprite>().SetColor(new Color(1, 1, 1, 0));

                bool isContain = false;
                if (this.currentPictureType == PictureInfo.PictureType.馬 || this.currentPictureType == PictureInfo.PictureType.樹 || this.currentPictureType == PictureInfo.PictureType.未分類)
                {
                    foreach (var area in GameManager.script.馬樹放置範圍清單)
                    {
                        if (area.isContainArea(this.Target.transform.position))
                        {
                            isContain = true;
                            this.Target.GetComponent<PictureInfo>().isUsed = true;
                            break;
                        }
                    }
                }
                else if (this.currentPictureType == PictureInfo.PictureType.土坡)
                {
                    if (GameManager.script.土坡放置範圍.isContainArea(this.Target.transform.position))
                    {
                        isContain = true;

                        PictureInfo script = this.Target.GetComponent<PictureInfo>();
                        script.CanMove = false;
                        script.isUsed = true;

                        this.Target.transform.localPosition = new Vector3(0, 0, script.MaxDepth);
                    }
                }

                if (!isContain & this.currentPictureType != PictureInfo.PictureType.未定義)
                    this.Target.GetComponent<PictureInfo>().BacktoOriginPosition();

                this.currentPictureType = PictureInfo.PictureType.未定義;
                this.currentMouseType = MouseType.無狀態;

                break;
        }
    }
Exemplo n.º 43
0
        /// <summary>
        /// 鼠标在地图上按下
        /// </summary>
        /// <param name="e"></param>
        protected override void OnMouseDown(MouseEventArgs e)
        {
            base.OnMouseDown(e);
            if (e.Button == System.Windows.Forms.MouseButtons.Left) //左键
            {
                //检查设置鼠标工作方式
                if (new Rectangle(Width - 384 + 26 * 8, 10, 26, 26).Contains(PointToClient(Cursor.Position))) //鼠标定位
                {
                    _cursor_located = !_cursor_located;
                    Invalidate();
                    return;
                }
                else if (new Rectangle(Width - 384 + 26 * 7, 10, 26, 26).Contains(PointToClient(Cursor.Position))) //绘制多边形
                {
                    if (_mouse_type == MouseType.DrawPolygon)
                    {
                        _mouse_type = MouseType.None;
                        _current_cursor_cache = Cursor = Cursors.Arrow;
                    }
                    else
                    {
                        _mouse_type = MouseType.DrawPolygon;
                        _current_cursor_cache = Cursor = Cursors.Cross;  //特定光标
                        _current_drawing = null;
                        _bScreenshotMenu.Visible = false;
                    }
                    Invalidate();
                    return;
                }
                else if (new Rectangle(Width - 384 + 26 * 6, 10, 26, 26).Contains(PointToClient(Cursor.Position))) //绘制直线
                {
                    if (_mouse_type == MouseType.DrawLine)
                    {
                        _mouse_type = MouseType.None;
                        _current_cursor_cache = Cursor = Cursors.Arrow;
                    }
                    else
                    {
                        _mouse_type = MouseType.DrawLine;
                        _current_cursor_cache = Cursor = Cursors.Cross;  //特定光标
                        _current_drawing = null;
                        _bScreenshotMenu.Visible = false;
                    }
                    Invalidate();
                    return;
                }
                else if (new Rectangle(Width - 384 + 26 * 5, 10, 26, 26).Contains(PointToClient(Cursor.Position))) //绘制椭圆
                {
                    if (_mouse_type == MouseType.DrawCircle)
                    {
                        _mouse_type = MouseType.None;
                        _current_cursor_cache = Cursor = Cursors.Arrow;
                    }
                    else
                    {
                        _mouse_type = MouseType.DrawCircle;
                        _current_cursor_cache = Cursor = Cursors.Cross;  //特定光标
                        _current_drawing = null;
                        _bScreenshotMenu.Visible = false;
                    }
                    Invalidate();
                    return;
                }
                else if (new Rectangle(Width - 384 + 26 * 4, 10, 26, 26).Contains(PointToClient(Cursor.Position))) //绘制矩形
                {
                    if (_mouse_type == MouseType.DrawRectange)
                    {
                        _mouse_type = MouseType.None;
                        _current_cursor_cache = Cursor = Cursors.Arrow;
                    }
                    else
                    {
                        _mouse_type = MouseType.DrawRectange;
                        _current_cursor_cache = Cursor = Cursors.Cross;  //特定光标
                        _current_drawing = null;
                        _bScreenshotMenu.Visible = false;
                    }
                    Invalidate();
                    return;
                }
                else if (new Rectangle(Width - 384 + 26 * 3, 10, 26, 26).Contains(PointToClient(Cursor.Position))) //添加标记点
                {
                    if (_mouse_type == MouseType.DrawMarker)
                    {
                        _mouse_type = MouseType.None;
                        _current_cursor_cache = Cursor = Cursors.Arrow;
                    }
                    else
                    {
                        _mouse_type = MouseType.DrawMarker;
                        _current_drawing = null;
                        _bScreenshotMenu.Visible = false;
                    }
                    Invalidate();
                    return;
                }
                else if (new Rectangle(Width - 384 + 26 * 2, 10, 26, 26).Contains(PointToClient(Cursor.Position))) //截图
                {
                    if (_current_drawing as BScreenShotRectangle == null)
                    {
                        if (_mouse_type == MouseType.DrawScreenshotArea)
                        {
                            _mouse_type = MouseType.None;
                            _current_cursor_cache = Cursor = Cursors.Arrow;
                        }
                        else
                        {
                            _mouse_type = MouseType.DrawScreenshotArea;
                            _current_cursor_cache = Cursor = Cursors.Cross;  //特定光标
                        }
                        Invalidate();
                    }
                    return;
                }
                else if (new Rectangle(Width - 384 + 26 * 1, 10, 26, 26).Contains(PointToClient(Cursor.Position))) //测量距离
                {
                    if (_b_distance == null)
                    {
                        if (_mouse_type == MouseType.DrawDistance)
                        {
                            _mouse_type = MouseType.None;
                            _current_cursor_cache = Cursor = Cursors.Arrow;
                        }
                        else
                        {
                            _mouse_type = MouseType.DrawDistance;
                            _current_cursor_cache = Cursor = Cursors.Cross;  //特定光标
                            _current_drawing = null;
                            _bScreenshotMenu.Visible = false;
                        }
                        Invalidate();
                    }
                    else
                    {
                        _b_distance = null;
                    }
                    return;
                }
                else if (new Rectangle(Width - 384, 10, 26, 26).Contains(PointToClient(Cursor.Position))) //矩形区域搜索
                {
                    if (_b_bound == null)
                    {
                        if (_mouse_type == MouseType.DrawBound)
                        {
                            _mouse_type = MouseType.None;
                            _current_cursor_cache = Cursor = Cursors.Arrow;
                        }
                        else
                        {
                            _mouse_type = MouseType.DrawBound;
                            _current_cursor_cache = Cursor = Cursors.Cross;  //特定光标
                            _current_drawing = null;
                            _bScreenshotMenu.Visible = false;
                        }
                        Invalidate();
                    }
                    else
                    {
                        _b_bound = null;
                        _bQuickSearchControl.Visible = false;
                    }
                    return;
                }
                if (new Rectangle(10, 10, 90, 25).Contains(e.Location))  //打开城市切换窗体
                {
                    if (_bCityControl.Visible)
                    {
                        _bCityControl.Visible = false;
                    }
                    else
                    {
                        _bCityControl.Location = new Point(10, 38);
                        _bCityControl.Visible = true;
                        _bCityControl.CurrentCity = _currentCity;
                    }
                    Invalidate();
                    return;
                }
                else if (new Rectangle(Width - 124, 10, 52, 52).Contains(e.Location)) //打开地图加载模式窗体
                {
                    if (_bLoadMapModeControl.Visible)
                    {
                        _bLoadMapModeControl.Visible = false;
                    }
                    else
                    {
                        _bLoadMapModeControl.Location = new Point(Width - 124 + 52 - _bLoadMapModeControl.Width, 10 + 55);
                        _bLoadMapModeControl.LoadMode = _loadmode;
                        _bLoadMapModeControl.Visible = true;
                    }
                    Invalidate();
                    return;
                }
                else if (new Rectangle(Width - 62, 10, 52, 52).Contains(e.Location)) //切换地图模式
                {
                    if (_mode == MapMode.Normal)
                    {
                        if (_chkShowRoadNet.Checked)
                        {
                            Mode = MapMode.Sate_RoadNet;
                        }
                        else
                        {
                            Mode = MapMode.Satellite;
                        }
                        _chkShowRoadNet.Location = new Point(Width - 62, 65);
                        _chkShowRoadNet.Visible = true;
                    }
                    else
                    {
                        Mode = MapMode.Normal;
                        _chkShowRoadNet.Visible = false;
                    }
                    return;
                }


                if (_mouse_type == MouseType.None)  //拖拽地图
                {
                    //判断是否拖拽其他物体 地图优先级最低
                    if (_current_drawing as BScreenShotRectangle != null)  //拖拽截图矩形
                    {
                        if ((_current_drawing as BScreenShotRectangle).Rect.Contains(e.Location))
                        {
                            _mouse_type = MouseType.DragScreenshotArea;
                            _current_cursor_cache = Cursor = Cursors.SizeAll;
                            _previous_point_cache = e.Location;
                            return;
                        }
                    }
                    if (_theStrangePoint != null && _theStrangePoint.Rect.Contains(e.Location)) //是否点击未知点
                    {
                        _current_selected_point = _theStrangePoint;
                        Point point = MapHelper.GetScreenLocationByLatLng(_current_selected_point.Location, _center, _zoom, ClientSize);
                        //信息显示控件
                        _bPointTipControl.BPoint = _current_selected_point;
                        _bPointTipControl.Location = new Point(point.X - _bPointTipControl.Width / 3 + 35, point.Y - _bPointTipControl.Height - _current_selected_point.Rect.Height);
                        _bPointTipControl.Visible = true;
                        return;
                    }
                    if (_theRouteStart !=null && _theRouteStart.Rect.Contains(e.Location)) //是否点击路线起点
                    {
                        _current_selected_point = _theRouteStart;
                        Point point = MapHelper.GetScreenLocationByLatLng(_current_selected_point.Location, _center, _zoom, ClientSize);
                        //信息显示控件
                        _bPointTipControl.BPoint = _current_selected_point;
                        _bPointTipControl.Location = new Point(point.X - _bPointTipControl.Width / 3 + 35, point.Y - _bPointTipControl.Height - _current_selected_point.Rect.Height);
                        _bPointTipControl.Visible = true;                     
                        return;
                    }
                    if (_theRouteEnd != null && _theRouteEnd.Rect.Contains(e.Location)) //是否点击路线终点
                    {
                        _current_selected_point = _theRouteEnd;
                        Point point = MapHelper.GetScreenLocationByLatLng(_current_selected_point.Location, _center, _zoom, ClientSize);
                        //信息显示控件
                        _bPointTipControl.BPoint = _current_selected_point;
                        _bPointTipControl.Location = new Point(point.X - _bPointTipControl.Width / 3 + 35, point.Y - _bPointTipControl.Height - _current_selected_point.Rect.Height);
                        _bPointTipControl.Visible = true;
                        return;
                    }
                    foreach (KeyValuePair<string,BPOI> p in _pois) //是否点击POI点
                    {
                        if (p.Value.Rect.Contains(e.Location))
                        {
                            _current_selected_poi = p.Value;
                            //显示信息控件
                            p.Value.Selected = true;
                            Point point = MapHelper.GetScreenLocationByLatLng(p.Value.Location, _center, _zoom, ClientSize);
                            _bPOITipControl.POI = _current_selected_poi;
                            _bPOITipControl.Location = new Point(point.X - _bPOITipControl.Width / 3 + 35, point.Y - _bPOITipControl.Height - _current_selected_poi.Rect.Height - 5);
                            _bPOITipControl.Visible = true;

                            foreach (KeyValuePair<string, BPOI> pp in _pois)
                            {
                                if (pp.Value != p.Value)
                                {
                                    pp.Value.Selected = false;
                                }
                            }
                            Invalidate();
                            //通知BPlacesBoard  同步选择
                            if (BPlacesBoard != null)
                            {
                                BPlacesBoard.SelectPlace(p.Value);
                            }
                            return;
                        }
                    }
                    foreach (KeyValuePair<string, BMarker> p in _markers) //是否点击标记点
                    {
                        if (p.Value.Rect.Contains(e.Location))
                        {
                            _current_selected_marker = p.Value;
                            //显示标记信息控件
                            Point point = MapHelper.GetScreenLocationByLatLng(p.Value.Location, _center, _zoom, ClientSize);
                            _bMarkerTipControl.Deleted = false;
                            _bMarkerTipControl.Edited = false;
                            _bMarkerTipControl.Marker = _current_selected_marker;
                            _bMarkerTipControl.Location = new Point(point.X - _bMarkerTipControl.Width / 3 + 37, point.Y - _bMarkerTipControl.Height - p.Value.Rect.Height);
                            _bMarkerTipControl.Visible = true;
                            return;
                        }
                    }
                    _bCityControl.Visible = false;
                    _bLoadMapModeControl.Visible = false;
                    _mouse_type = MouseType.DragMap;
                    _current_cursor_cache = Cursor = Cursors.SizeAll;
                    _previous_point_cache = e.Location;
                }
                else if (_mouse_type == MouseType.DrawCircle)  //绘制椭圆
                {
                    LatLngPoint theCenter = MapHelper.GetLatLngByScreenLocation(e.Location, _center, _zoom, ClientSize);
                    _current_drawing = new BCircle { Center = theCenter, RightBottom = theCenter };
                }
                else if (_mouse_type == MouseType.DrawRectange) //绘制矩形
                {
                    LatLngPoint leftTop = MapHelper.GetLatLngByScreenLocation(e.Location, _center, _zoom, ClientSize);
                    _current_drawing = new BRectangle { LeftTop = leftTop, RightBottom = leftTop };
                }
                else if (_mouse_type == MouseType.DrawLine)  //绘制直线
                {
                    LatLngPoint p = MapHelper.GetLatLngByScreenLocation(e.Location, _center, _zoom, ClientSize);
                    if (_current_drawing == null)
                    {
                        _current_drawing = new BLine { Points = new List<LatLngPoint> { p, p } };
                    }
                    (_current_drawing as BLine).Points.Add(p);
                }
                else if (_mouse_type == MouseType.DrawPolygon)  //绘制多边形
                {
                    LatLngPoint p = MapHelper.GetLatLngByScreenLocation(e.Location, _center, _zoom, ClientSize);
                    if (_current_drawing == null)
                    {
                        _current_drawing = new BPolygon { Points = new List<LatLngPoint> { p, p } };
                    }
                    (_current_drawing as BPolygon).Points.Add(p);
                }
                else if (_mouse_type == MouseType.DrawScreenshotArea)  //绘制截图区域
                {
                    _current_drawing = new BScreenShotRectangle { LeftTop = e.Location, Width = 0, Height = 0 };
                }
                else if (_mouse_type == MouseType.DrawBound)  //矩形搜索开始
                {
                    LatLngPoint leftTop = MapHelper.GetLatLngByScreenLocation(e.Location, _center, _zoom, ClientSize);
                    _b_bound = new BBound { LeftTop = leftTop, RightBottom = leftTop };
                }
                else if (_mouse_type == MouseType.DrawDistance) //距离测量
                {
                    LatLngPoint p = MapHelper.GetLatLngByScreenLocation(e.Location, _center, _zoom, ClientSize);
                    if (_b_distance == null)
                    {
                        _b_distance = new BDistance { Points = new List<LatLngPoint> { p, p } };
                    }
                    _b_distance.Points.Add(p);
                }
                else if (_mouse_type == MouseType.DrawMarker) //添加标记
                {
                    LatLngPoint p = MapHelper.GetLatLngByScreenLocation(e.Location, _center, _zoom, ClientSize);
                    ((Action)delegate()
                    {
                        GeocodingService gs = new GeocodingService();
                        JObject place = gs.DeGeocoding(p.Lat + "," + p.Lng);
                        if (place != null)
                        {
                            this.Invoke((Action)delegate()
                            {
                                BMarker marker = new BMarker { Index = _markers.Count, Location = p, Name = (string)place["result"]["formatted_address"], Remarks = "我的备注", Selected = false, Address = (string)place["result"]["formatted_address"] };
                                _markers.Add(marker.Index.ToString(), marker);
                                _bMarkerEditorControl.Saved = false;
                                _bMarkerEditorControl.Marker = marker;
                                _bMarkerEditorControl.Location = new Point(e.Location.X - _bMarkerEditorControl.Width / 3 + 37, e.Location.Y - _bMarkerEditorControl.Height - 22);
                                _bMarkerEditorControl.Visible = true;
                                _current_selected_marker = marker;
                            });
                        }
                    }).BeginInvoke(null, null);
                }
            }
            if (e.Button == System.Windows.Forms.MouseButtons.Right)  //右键弹菜单
            {
                _right_mouse_point_cache = e.Location;
                cm_popup.Show(PointToScreen(e.Location));
            }
        }
Exemplo n.º 44
0
 // Start is called before the first frame update
 void Start()
 {
     this.MouseType = MouseType.Null;
 }
Exemplo n.º 45
0
 /// <summary>
 /// 鼠标双击
 /// </summary>
 /// <param name="e"></param>
 protected override void OnMouseDoubleClick(MouseEventArgs e)
 {
     base.OnMouseDoubleClick(e);
     if (_mouse_type == MouseType.DrawLine)  //绘制线条结束
     {
         _mouse_type = MouseType.None;
         _current_cursor_cache = Cursor = Cursors.Arrow;
         _drawingObjects.Add(_drawingObjects.Count + 1, _current_drawing);
         _current_drawing = null;
     }
     else if (_mouse_type == MouseType.DrawPolygon) //绘制多边形结束
     {
         _mouse_type = MouseType.None;
         _current_cursor_cache = Cursor = Cursors.Arrow;
         _drawingObjects.Add(_drawingObjects.Count + 1, _current_drawing);
         _current_drawing = null;
     }
     else if (_mouse_type == MouseType.DrawDistance) //测量距离
     {
         _mouse_type = MouseType.None;
         _current_cursor_cache = Cursor = Cursors.Arrow;
     }
     Invalidate();
 }
Exemplo n.º 46
0
 public void SetMouseType(MouseType mType)
 {
     mouseType = mType;
 }