using BinanceExchange.API.Models.WebSocket;
using System.Diagnostics;
using System.Runtime.InteropServices;
using Telegram.Bot;
using Telegram.Bot.Exceptions;
using Telegram.Bot.Polling;
using Telegram.Bot.Types;
using Telegram.Bot.Types.Enums;
using Message = Telegram.Bot.Types.Message;

namespace SignalsTest
{
    public partial class Form1 : Form
    {
        [DllImport("kernel32.dll", SetLastError = true)]
        [return: MarshalAs(UnmanagedType.Bool)]
        static extern bool AllocConsole();
        public Form1()
        {
            InitializeComponent();
            AllocConsole();
        }

        private void Form1_LoadAsync(object sender, EventArgs e)
        {
            Log("Initiating messiah");
            Messenger.instance.SendMessage("Bot Rebooted");
            Log("Done");
            Log("Initiating coin watch for BTCUSDT");
            CoinWatch btcWatch = new CoinWatch("BTCUSDT");
            btcWatch.PriceUpdated += BtcWatch_OnPriceUpdate;
        }

        private void BtcWatch_OnPriceUpdate(Object? sender,BinanceTradeData data)
        {
            this.Invoke(() => { listBox1.Items.Add(data.BestAskPrice + " : " + data.EventTime); });
        }

        void Log(string message)
        {
            listBox1.Items.Add(message);
        }



        private void button1_Click(object sender, EventArgs e)
        {
        }
    }
}