void PnlPrice_MouseMove(object sender, MouseEventArgs e)
{
mouseXOld = mouseX;
mouseYOld = mouseY;
mouseX = e.X;
mouseY = e.Y;
if (e.Button == MouseButtons.Left)
{
if (mouseX > XRight)
{
if (mouseY > mouseYOld)
VerticalScaleDecrease();
else
VerticalScaleIncrease();
return;
}
else
{
int newScrollValue = scroll.Value;
if (mouseX > mouseXOld)
newScrollValue -= (int)Math.Round(scroll.SmallChange * 0.1 * (100 - barPixels));
else if (mouseX < mouseXOld)
newScrollValue += (int)Math.Round(scroll.SmallChange * 0.1 * (100 - barPixels));
if (newScrollValue < scroll.Minimum)
newScrollValue = scroll.Minimum;
else if (newScrollValue > scroll.Maximum + 1 - scroll.LargeChange)
newScrollValue = scroll.Maximum + 1 - scroll.LargeChange;
scroll.Value = newScrollValue;
}
}
if (isCrossShown)
{
GraphicsPath path = new GraphicsPath(FillMode.Winding);
// Adding the old positions
if (mouseXOld >= XLeft && mouseXOld <= XRight)
{
if (mouseYOld >= YTop && mouseYOld <= YBottom)
{
// Horizontal Line
path.AddRectangle(new Rectangle(0, mouseYOld, pnlPrice.ClientSize.Width, 1));
// PriceBox
path.AddRectangle(new Rectangle(XRight - 1, mouseYOld - font.Height / 2 - 1, szPrice.Width + 2, font.Height + 2));
}
// Vertical Line
path.AddRectangle(new Rectangle(mouseXOld, 0, 1, pnlPrice.ClientSize.Height));
// DateBox
path.AddRectangle(new Rectangle(mouseXOld - szDateL.Width / 2 - 1, YBottomText - 1, szDateL.Width + 2, font.Height + 3));
}
// Adding the new positions
if (mouseX >= XLeft && mouseX <= XRight)
{
if (mouseYOld >= YTop && mouseYOld <= YBottom)
{
// Horizontal Line
path.AddRectangle(new Rectangle(0, mouseY, pnlPrice.ClientSize.Width, 1));
// PriceBox
path.AddRectangle(new Rectangle(XRight - 1, mouseY - font.Height / 2 - 1, szPrice.Width + 2, font.Height + 2));
}
// Vertical Line
path.AddRectangle(new Rectangle(mouseX, 0, 1, pnlPrice.ClientSize.Height));
// DateBox
path.AddRectangle(new Rectangle(mouseX - szDateL.Width / 2 - 1, YBottomText - 1, szDateL.Width + 2, font.Height + 3));
}
pnlPrice.Invalidate(new Region(path));
for (int i = 0; i < indPanels && isIndicatorsShown; i++)
{
GraphicsPath path1 = new GraphicsPath(FillMode.Winding);
if (mouseXOld > XLeft - 1 && mouseXOld < XRight + 1)
path1.AddRectangle(new Rectangle(mouseXOld, 0, 1, pnlInd[i].ClientSize.Height));
if (mouseX > XLeft - 1 && mouseX < XRight + 1)
path1.AddRectangle(new Rectangle(mouseX, 0, 1, pnlInd[i].ClientSize.Height));
pnlInd[i].Invalidate(new Region(path1));
}
if (isBalanceEquityShown)
{
GraphicsPath path1 = new GraphicsPath(FillMode.Winding);
if (mouseXOld > XLeft - 1 && mouseXOld < XRight + 1)
path1.AddRectangle(new Rectangle(mouseXOld, 0, 1, pnlBalanceChart.ClientSize.Height));
if (mouseX > XLeft - 1 && mouseX < XRight + 1)
path1.AddRectangle(new Rectangle(mouseX, 0, 1, pnlBalanceChart.ClientSize.Height));
pnlBalanceChart.Invalidate(new Region(path1));
}
if (isFloatingPLShown)
{
GraphicsPath path1 = new GraphicsPath(FillMode.Winding);
if (mouseXOld > XLeft - 1 && mouseXOld < XRight + 1)
path1.AddRectangle(new Rectangle(mouseXOld, 0, 1, pnlFloatingPLChart.ClientSize.Height));
if (mouseX > XLeft - 1 && mouseX < XRight + 1)
path1.AddRectangle(new Rectangle(mouseX, 0, 1, pnlFloatingPLChart.ClientSize.Height));
pnlFloatingPLChart.Invalidate(new Region(path1));
}
}
// Determines the shown bar.
if (mouseXOld >= XLeft && mouseXOld <= XRight)
{
if (mouseX >= XLeft && mouseX <= XRight)
{ // Moving inside the chart
isMouseInPriceChart = true;
isDrawDinInfo = true;
GenerateDynamicInfo((e.X - XLeft) / barPixels);
}
else
{ // Escaping from the bar area of chart
isMouseInPriceChart = false;
pnlPrice.Cursor = Cursors.Default;
}
}
else if (mouseX >= XLeft && mouseX <= XRight)
{ // Entering into the chart
if (isCrossShown)
pnlPrice.Cursor = Cursors.Cross;
isMouseInPriceChart = true;
isDrawDinInfo = true;
pnlInfo.Invalidate();
GenerateDynamicInfo((e.X - XLeft) / barPixels);
}
return;
}