internal static Retrieve GetInstance(string key, string code) { if (retrieve == null) { Code = code; retrieve = new Retrieve(key, code); } else if (Code.Equals(code) == false) { Code = code; retrieve = new Retrieve(key, code); } return(retrieve); }
void OnReceiveNotifyIcon(object sender, NotifyIconText e) { switch (e.NotifyIcon.GetType().Name) { case dic: var temp = (Dictionary <int, string>)e.NotifyIcon; if (temp.TryGetValue(0, out string code)) { notifyIcon.Text = checkDataBase; Open.StartProgress(3605); notifyIcon.Text = secret.GetIdentify(); return; } var first = temp.First(); notifyIcon.Text = string.Concat(DateTime.Now.ToShortTimeString(), " Remains_", first.Key, " Code_", first.Value); return; case sb: strip.ItemClicked += OnItemClick; BeginInvoke(new Action(() => { if (Quotes == null) { Quotes = new QuotesControl(); panel.Controls.Add(Quotes); Open.SendQuotes += Quotes.OnReceiveQuotes; Quotes.Dock = DockStyle.Fill; } if (Account == null) { Account = new AccountControl(); panel.Controls.Add(Account); Account.Dock = DockStyle.Fill; Open.SendDeposit += Account.OnReceiveDeposit; } if (Balance == null) { Balance = new BalanceControl(); panel.Controls.Add(Balance); Balance.Dock = DockStyle.Fill; Open.SendBalance += Balance.OnReceiveBalance; } if (Statistical == null) { Statistical = new StatisticalAnalysis(); panel.Controls.Add(Statistical); Statistical.Dock = DockStyle.Fill; } var chart = Retrieve.GetInstance(KeyDecoder.GetWindowsProductKeyFromRegistry(), Open.Code).Chart; var check = e.NotifyIcon.ToString().Split((char)59); Acc = new string[check.Length - 3]; Server = check[check.Length - 1].Equals(secret.Mock); if (Server ? false : new VerifyIdentity().Identify(check[check.Length - 3], check[check.Length - 2]) == false) { TimerBox.Show(new Secret(check[check.Length - 2]).Identify, secret.GoblinBat, MessageBoxButtons.OK, MessageBoxIcon.Warning, 3750); Dispose(); return; } for (int i = 0; i < check.Length - 3; i++) { Acc[i] = check[i]; } new Task(() => { var specify = new Specify { Account = Acc, Assets = 17500000, Code = Open.Code, Strategy = "TF", Time = 30, Short = 4, Long = 60 }; new Strategy.OpenAPI.Trading(Open, specify, new Strategy.OpenAPI.Quotes(specify, Open), chart); }).Start(); new Task(() => { var liquidate = new Specify { Account = Acc, Assets = 17500000, Code = Open.Code, Strategy = "WU", Time = 15, Short = 4, Long = 60 }; new Strategy.OpenAPI.Trading(Open, liquidate, new Strategy.OpenAPI.Quotes(liquidate, Open), chart); }).Start(); new Task(() => new Strategy.OpenAPI.Trading(Open, new Specify { Account = Acc, Assets = 17500000, Code = Open.Code, Strategy = "DL", Time = 1440, Short = 4, Long = 60, Reaction = 531 }, chart)).Start(); Open.SendState += Quotes.OnReceiveState; Open.SendTrend += Quotes.OnReceiveTrend; Retrieve.Dispose(); })); return; case str: BeginInvoke(new Action(() => Quotes.OnReceiveOrderMsg(e.NotifyIcon.ToString()))); return; case bt: if (Array.Exists(XingConnect, o => o.Equals(initial))) { BeginInvoke(new Action(() => { Xing = XingAPI.ConnectAPI.GetInstance(initial.Equals(trading) ? Strategy.Retrieve.Code : Open.Code, Strategy.Retrieve.Date); Xing.Send += OnReceiveNotifyIcon; notifyIcon.Text = string.Concat("Trading Code_", initial.Equals(trading) ? Strategy.Retrieve.Code : Open.Code); OnEventConnect(); OnClickMinimized = quo; Application.DoEvents(); })); } else { Account.Show(); Open.SendDeposit -= Account.OnReceiveDeposit; Account.Hide(); Balance.Show(); Open.SendBalance -= Balance.OnReceiveBalance; Balance.Hide(); Open.SendState -= Quotes.OnReceiveState; Open.SendTrend -= Quotes.OnReceiveTrend; } return; case int32: if ((int)e.NotifyIcon < 0) { if (Temporary != null && initial.Equals(collecting)) { Temporary.SetStorage(Open.Code); } Process.Start("shutdown.exe", "-r"); Dispose(); } else { foreach (var ctor in Xing.querys) { switch (ctor.GetType().Name) { case cfobq10500: case ccebq10500: ((IEvents <Deposit>)ctor).Send -= Account.OnReceiveDeposit; ((IMessage <NotifyIconText>)ctor).SendMessage -= OnReceiveNotifyIcon; Account.Hide(); break; case t0441: case cceaq50600: ((IEvents <Balance>)ctor).Send -= Balance.OnReceiveBalance; ((IMessage <NotifyIconText>)ctor).SendMessage -= OnReceiveNotifyIcon; Balance.Hide(); break; } } Statistical.Hide(); return; } break; case cha: switch ((char)e.NotifyIcon) { case (char)69: new ExceptionMessage(e.NotifyIcon.ToString()); Dispose(); return; case (char)41: if (initial.Equals(trading)) { Xing.OnReceiveBalance = false; Process.Start("shutdown.exe", "-r"); Dispose(); } break; case (char)21: if (initial.Equals(trading)) { Xing.OnReceiveBalance = true; } break; default: return; } break; case boolean: break; } }