Mini Kabibi Habibi
using System;
using System.Windows.Forms;
using System.Drawing;
using DevExpress.XtraGauges.Base;
using DevExpress.XtraGauges.Core.Model;
using DevExpress.XtraGauges.Core.Primitive;
using DevExpress.XtraGauges.Core.Base;
namespace DevExpress.XtraGauges.Demos {
public partial class InteractionFeature : TutorialControl {
public InteractionFeature() {
InitializeComponent();
}
void gaugeControl1_MouseMove(object sender, MouseEventArgs e) {
CheckCursor(gaugeControl1 as IGaugeContainer, e);
if(e.Button == MouseButtons.Left)
CalculateMouseValue(gaugeControl1 as IGaugeContainer, arcScaleComponent1, e);
}
void gaugeControl2_MouseMove(object sender, MouseEventArgs e) {
CheckCursor(gaugeControl2 as IGaugeContainer, e);
if(e.Button == MouseButtons.Left)
CalculateMouseValue(gaugeControl2 as IGaugeContainer, linearScaleComponent1, e);
}
void gaugeControl1_MouseDown(object sender, MouseEventArgs e) {
CalculateMouseValue(gaugeControl1 as IGaugeContainer, arcScaleComponent1, e);
}
void gaugeControl2_MouseDown(object sender, MouseEventArgs e) {
CalculateMouseValue(gaugeControl2 as IGaugeContainer, linearScaleComponent1, e);
}
void CalculateMouseValue(IGaugeContainer container, IConvertibleScaleEx scale, MouseEventArgs e) {
BasePrimitiveHitInfo hi = container.CalcHitInfo(e.Location);
if(hi.Element != null) {
PointF modelPt = MathHelper.PointToModelPoint(scale as IElement<IRenderableElement>, new PointF(e.X, e.Y));
float percent = scale.PointToPercent(modelPt);
scale.Value = scale.PercentToValue(percent);
}
}
void CheckCursor(IGaugeContainer container, MouseEventArgs e) {
BasePrimitiveHitInfo hi = container.CalcHitInfo(e.Location);
Cursor cursor = (hi.Element != null) ? Cursors.Hand : Cursors.Default;
if(Cursor.Current != cursor) Cursor.Current = cursor;
}
}
}