iSpyApplication.Controls.VolumeLevel.OnMouseDown C# (CSharp) Method

OnMouseDown() protected method

protected OnMouseDown ( MouseEventArgs e ) : void
e MouseEventArgs
return void
        protected override void OnMouseDown(MouseEventArgs e)
        {
            base.OnMouseDown(e);
            Select();
            IntPtr hwnd = Handle;
            if ((ResizeParent) && (Parent != null) && (Parent.IsHandleCreated))
            {
                hwnd = Parent.Handle;
            }
            if (e.Button == MouseButtons.Left)
            {
                MousePos mousePos = GetMousePos(e.Location);

                if (mousePos == MousePos.NoWhere)
                {
                    if (MainForm.Conf.ShowOverlayControls)
                    {
                        int bpi = GetButtonIndexByLocation(e.Location);
                        switch (bpi)
                        {
                            case -999:
                                var layoutPanel = (LayoutPanel)Parent;
                                layoutPanel?.ISpyControlDown(new Point(this.Left + e.X, this.Top + e.Y));
                                break;
                            case 0:
                                if (IsEnabled)
                                {
                                    Disable();
                                }
                                else
                                {
                                    Enable();
                                }
                                break;
                            case 1:
                                if (IsEnabled)
                                {
                                    RecordSwitch(!(Recording || ForcedRecording));
                                }
                                break;
                            case 2:
                                if (Helper.HasFeature(Enums.Features.Edit))
                                {
                                    MainClass.EditMicrophone(Micobject);
                                }
                                break;
                            case 3:
                                if (Helper.HasFeature(Enums.Features.Access_Media))
                                {
                                    string url = MainForm.Webpage;
                                    if (WsWrapper.WebsiteLive && MainForm.Conf.ServicesEnabled)
                                    {
                                        MainForm.OpenUrl(url);
                                    }
                                    else
                                        MainClass.Connect(url, false);
                                }
                                break;
                            case 4:
                                if (IsEnabled)
                                {
                                    Listen();
                                }
                                break;
                        }
                    }
                    return;
                }
                if (CameraControl!=null ||  MainForm.LockLayout) return;
                switch (mousePos)
                {
                    case MousePos.Right:
                        {
                            NativeCalls.ReleaseCapture(hwnd);
                            NativeCalls.SendMessage(hwnd, NativeCalls.WmSyscommand, NativeCalls.ScDragsizeE, IntPtr.Zero);
                        }
                        break;
                    case MousePos.Bottom:
                        {
                            NativeCalls.ReleaseCapture(hwnd);
                            NativeCalls.SendMessage(hwnd, NativeCalls.WmSyscommand, NativeCalls.ScDragsizeS, IntPtr.Zero);
                        }
                        break;
                    case MousePos.BottomRight:
                        {
                            NativeCalls.ReleaseCapture(hwnd);
                            NativeCalls.SendMessage(hwnd, NativeCalls.WmSyscommand, NativeCalls.ScDragsizeSe,
                                                    IntPtr.Zero);
                        }
                        break;
                    default:
                        Cursor = Cursors.Hand;
                        break;

                }
            }
        }