iSpyApplication.Controls.FloorPlanControl.FloorPlanControlClick C# (CSharp) Method

FloorPlanControlClick() private method

private FloorPlanControlClick ( object sender, MouseEventArgs e ) : void
sender object
e MouseEventArgs
return void
        private void FloorPlanControlClick(object sender, MouseEventArgs e)
        {
            var local = new Point(e.X, e.Y);
            double xRat = Convert.ToDouble(Width)/ImageWidth;
            double yRat = Convert.ToDouble(Height)/ImageHeight;
            double hittargetw = 22*xRat;
            double hittargeth = 22*yRat;

            double wrat = Convert.ToDouble(ImageWidth) / 533d;
            double hrat = Convert.ToDouble(ImageHeight) / 400d;

            bool changeHighlight = true;

            if (Highlighted)
            {
                foreach (objectsFloorplanObjectsEntry fpoe in Fpobject.objects.@object)
                {
                    if (((fpoe.x*wrat) - hittargetw)*xRat <= local.X && ((fpoe.x*wrat) + hittargetw)*xRat > local.X &&
                        ((fpoe.y*hrat) - hittargeth)*yRat <= local.Y && ((fpoe.y*hrat) + hittargeth)*yRat > local.Y)
                    {
                        switch (fpoe.type)
                        {
                            case "camera":
                                CameraWindow cw = MainClass.GetCameraWindow(fpoe.id);
                                if (cw != null)
                                {
                                    //cw.Location = new Point(Location.X + e.X, Location.Y + e.Y);
                                    cw.BringToFront();
                                    cw.Focus();
                                }

                                changeHighlight = false;
                                break;
                            case "microphone":
                                VolumeLevel vl = MainClass.GetVolumeLevel(fpoe.id);
                                if (vl != null)
                                {
                                    //vl.Location = new Point(Location.X + e.X, Location.Y + e.Y);
                                    vl.BringToFront();
                                    vl.Focus();
                                }

                                changeHighlight = false;
                                break;
                        }
                        break;
                    }
                }
            }

            if (changeHighlight)
            {
                bool hl = Highlighted;
                MainClass._pnlCameras.ClearHighlights();

                Highlighted = !hl;
            }
            if (Highlighted)
            {
                foreach (objectsFloorplanObjectsEntry fpoe in Fpobject.objects.@object)
                {
                    switch (fpoe.type)
                    {
                        case "camera":
                            CameraWindow cw = MainClass.GetCameraWindow(fpoe.id);
                            if (cw!=null)
                                cw.Highlighted = true;
                            break;
                        case "microphone":
                            VolumeLevel vl = MainClass.GetVolumeLevel(fpoe.id);
                            if (vl!=null)
                                vl.Highlighted = true;

                            break;
                    }
                }
            }

            MainClass.Invalidate(true);
        }