Fixed issue #5: Color representation. MQL uses different color representation than C# System.Drawing.Color (Thanks Tr4Dr).

This commit is contained in:
DW
2016-05-13 11:53:28 +03:00
parent 05d762977b
commit 13c3ce1445
2 changed files with 20 additions and 4 deletions
+2 -2
View File
@@ -10,12 +10,12 @@ namespace MtApi
{
public static Color ConvertFromMtColor(int color)
{
return Color.FromArgb(color);
return Color.FromArgb((byte)(color), (byte)(color >> 8), (byte)(color >> 16));
}
public static int ConvertToMtColor(Color color)
{
return color == Color.Empty ? 0xffffff : (color.ToArgb() & 0xffffff);
return color == Color.Empty ? 0xffffff : (Color.FromArgb(color.B, color.G, color.R).ToArgb() & 0xffffff);
}
}
}
+18 -2
View File
@@ -980,6 +980,7 @@ namespace TestApiClientUI
AddToLog(string.Format("Delete order result: {0}, ticket = {1}", deleted, ticket));
}
//OrderModify
private async void button22_Click(object sender, EventArgs e)
{
var ticket = int.Parse(textBoxIndexTicket.Text);
@@ -995,12 +996,26 @@ namespace TestApiClientUI
var expiration = DateTime.MinValue;
var modified = await Execute(() => _apiClient.OrderModify(ticket, price, stoploss, takeprofit, expiration));
Color color = new Color();
switch (comboBoxOrderColor.SelectedIndex)
{
case 0:
color = Color.Green;
break;
case 1:
color = Color.Blue;
break;
case 2:
color = Color.Red;
break;
}
var modified = await Execute(() => _apiClient.OrderModify(ticket, price, stoploss, takeprofit, expiration, color));
AddToLog(string.Format("Modify order result: {0}, ticket = {1}", modified, ticket));
}
//iCustom
//iCustom (ZigZag)
private async void iCustomBtn_Click(object sender, EventArgs e)
{
string symbol = "EURUSD";
@@ -1013,6 +1028,7 @@ namespace TestApiClientUI
AddToLog(string.Format("ICustom result: {0}", retVal));
}
//iCustom (Parabolic)
private async void button23_Click(object sender, EventArgs e)
{
string symbol = "EURUSD";