private void _A0405_MouseRightButtonDown(object sender, MouseButtonEventArgs e) { double dWidth = _A0405.Width; double dHeight = _A0405.Height; MouseButtonEventArgs mbea = (MouseButtonEventArgs)e; //Get the point on the control where the mouse was clicked Point p = mbea.GetPosition(_A0405); ClickCoordinate cc = new ClickCoordinate(dWidth, dHeight, p); double mouseX = p.X; double halfWidth = cc.XControlHalf; //Get half of the height and width double halfHeight = cc.YControlHalf; //Left if (mouseX < halfWidth) //Check if the control was clicked to the left or the right of Center { if (mouseX < cc.XControlQuarter1) { //Quarter 1 MainWindow.isValve = false; MainWindow.stat_sActiveObjectNo = _A0405.ObjectNumber1; } } //Right else if (mouseX > halfWidth) { if (mouseX > cc.XControlQuarter4) { //Quarter 4 MainWindow.isValve = false; MainWindow.stat_sActiveObjectNo = _A0405.ObjectNumber2; } } }
private void _A0405_MouseDown(object sender, MouseButtonEventArgs e) { MainWindow.isValve = false; double dWidth = _A0405.Width; double dHeight = _A0405.Height; MouseButtonEventArgs mbea = (MouseButtonEventArgs)e; //Get the point on the control where the mouse was clicked Point p = mbea.GetPosition(_A0405); ClickCoordinate cc = new ClickCoordinate(dWidth, dHeight, p); double mouseX = p.X; double halfWidth = cc.XControlHalf; //Get half of the height and width double halfHeight = cc.YControlHalf; //Left if (mouseX < halfWidth) //Check if the control was clicked to the left or the right of Center { if (mouseX > cc.XControlQuarter1) { //Quarter 2 MainWindow.sElementDescription = _A0405.Description_FrequencyConverter1; MainWindow.sElementState = _A0405.Status_FrequencyConverter1; } else { //Quarter 1 MainWindow.sElementDescription = _A0405.Description_Motor1; MainWindow.sElementState = _A0405.Status_Motor1; } } //Right else { if (mouseX < cc.XControlQuarter3) { //Quarter 3 MainWindow.sElementDescription = _A0405.Description_FrequencyConverter2; MainWindow.sElementState = _A0405.Status_FrequencyConverter2; } else { //Quarter 4 MainWindow.sElementDescription = _A0405.Description_Motor2; MainWindow.sElementState = _A0405.Status_Motor2; } } MainWindow.sActiveControlName = "_A0405"; }