Ejemplo n.º 1
0
        async void StartProgress(IParameters param)
        {
            switch ((await client.PostContext <Catalog.Privacies>(param)).Item1)
            {
            case 0xCA:
                if (Statistical == null)
                {
                    Statistical = new Controls.Strategics(client, new Disclosure(cookie, 'D'));
                    Controls.Add(Statistical);
                    Statistical.Dock      = DockStyle.Fill;
                    Statistical.SendSize += OnReceiveTheChangedSize;
                }
                Result = DialogResult.Yes;
                break;

            case 0xC8:
                foreach (var url in termsOfUse)
                {
                    Process.Start(url);
                }

                Result = ChooseBox.Show(string.Concat(welcomeTo, (1 + await client.GetContext()).ToString("N0"), theGoblinBat), welcome, agree, fExit);
                break;

            default:
                Result = DialogResult.No;
                break;
            }
            if (Result.Equals(DialogResult.Yes) && IsApplicationAlreadyRunning(param.Security))
            {
                Privacy = new Catalog.Privacies
                {
                    Security = param.Security
                };
                Opacity = 0;
                timer.Start();
            }
            else if (Result.Equals(DialogResult.No))
            {
                strip.ItemClicked -= OnItemClick;
                Dispose();
            }
            else
            {
                Opacity         = 0;
                notifyIcon.Text = text;
                WindowState     = FormWindowState.Minimized;
            }
        }
Ejemplo n.º 2
0
        async void OnReceiveAnalysisData(object sender, SendSecuritiesAPI e)
        {
            if (e.Convey is Tuple <dynamic, Catalog.Statistics> tuple)
            {
                var coin = double.NaN;

                if (string.IsNullOrEmpty(tuple.Item2.Key) == false)
                {
                    switch (tuple.Item1)
                    {
                    case Catalog.TrendFollowingBasicFutures tf:
                        break;

                    case Catalog.TrendsInStockPrices ts:
                        if (tuple.Item2.Base > 0 && (ts.Setting.Equals(Setting.Both) || ts.Setting.Equals(Setting.Reservation)))
                        {
                            coin = await client.PutContext(new StocksStrategics
                            {
                                Code                       = ts.Code,
                                Strategics                 = tuple.Item2.Key,
                                Date                       = tuple.Item2.Date,
                                MaximumInvestment          = (long)tuple.Item2.Base,
                                CumulativeReturn           = tuple.Item2.Cumulative / tuple.Item2.Base,
                                WeightedAverageDailyReturn = tuple.Item2.Statistic / tuple.Item2.Base
                            });
                        }
                        break;

                    case Catalog.ScenarioAccordingToTrend st:
                        if (tuple.Item2.Base > 0)
                        {
                            coin = await client.PutContext(new StocksStrategics
                            {
                                Code                                  = st.Code,
                                Strategics                            = tuple.Item2.Key,
                                Date                                  = tuple.Item2.Date,
                                MaximumInvestment                     = (long)tuple.Item2.Base,
                                CumulativeReturn                      = tuple.Item2.Cumulative / tuple.Item2.Base,
                                WeightedAverageDailyReturn            = tuple.Item2.Statistic / tuple.Item2.Base,
                                DiscrepancyRateFromExpectedStockPrice = tuple.Item2.Price
                            });
                        }
                        break;

                    case Catalog.TrendToCashflow tc:
                        if (tuple.Item2.Base > 0)
                        {
                            coin = await client.PutContext(new StocksStrategics
                            {
                                Code                                  = tc.Code,
                                Strategics                            = tuple.Item2.Key,
                                Date                                  = tuple.Item2.Date,
                                MaximumInvestment                     = (long)tuple.Item2.Base,
                                CumulativeReturn                      = tuple.Item2.Cumulative / tuple.Item2.Base,
                                WeightedAverageDailyReturn            = tuple.Item2.Statistic / tuple.Item2.Base,
                                DiscrepancyRateFromExpectedStockPrice = tuple.Item2.Price
                            });
                        }
                        break;
                    }
                }
                if (double.IsNaN(coin) == false)
                {
                    if (DateTime.Now.DayOfWeek.Equals(DayOfWeek.Sunday) && DateTime.Now.Hour < 3 && (cookie as string).Equals(admin) == false)
                    {
                        ClosingForm = true;
                        backgroundWorker.CancelAsync();

                        if (WindowState.Equals(FormWindowState.Minimized))
                        {
                            WindowState = FormWindowState.Normal;
                        }
                    }
                    var remain = await client.PutContext(new Catalog.Privacies
                    {
                        Security       = Privacy.Security,
                        SecuritiesAPI  = Privacy.SecuritiesAPI,
                        SecurityAPI    = Privacy.SecurityAPI,
                        Account        = Privacy.Account,
                        Commission     = Privacy.Commission,
                        CodeStrategics = Privacy.CodeStrategics,
                        Coin           = coin + GoblinBatClient.Coin
                    });

                    if (remain < 0)
                    {
                        if (ChooseBox.Show(bill, money, charge, fExit).Equals(DialogResult.Yes))
                        {
                        }
                        else
                        {
                            Thread.Sleep((int)Math.Pow(await client.DeleteContext <Catalog.Privacies>(Privacy), charge.Length));
                            ClosingForm        = true;
                            strip.ItemClicked -= OnItemClick;
                            Dispose();
                        }
                    }
                    else
                    {
                        notifyIcon.Text = ConvertTheFare(remain);
                    }
                }
                else
                {
                    SendMessage((tuple.Item1 as IStrategics).Code);
                }
            }
            else if (e.Convey is Tuple <dynamic, double, uint> strategics)
            {
                switch (strategics.Item1)
                {
                case Catalog.TrendsInStockPrices ts:
                    Statistical.SetDataGridView(ts, strategics.Item3, strategics.Item2);
                    return;
                }
            }
        }
Ejemplo n.º 3
0
        protected override void WndProc(ref Message m)
        {
            Point vPoint = new Point(MousePosition.X - Left, MousePosition.Y - Top);

            switch (m.Msg)
            {
            case 0x0084:
                base.WndProc(ref m);
                if (rect1.Contains(vPoint))
                {
                    if (Cursor != Cursors.Hand)
                    {
                        Cursor = Cursors.Hand;
                    }
                    return;
                }
                if (rect2.Contains(vPoint))
                {
                    if (Cursor != Cursors.Hand)
                    {
                        Cursor = Cursors.Hand;
                    }
                    return;
                }
                if (Cursor != Cursors.Default)
                {
                    Cursor = Cursors.Default;
                }
                break;

            case 0x0201:
                if (rect1.Contains(vPoint))
                {
                    index = 1;
                    return;
                }
                if (rect2.Contains(vPoint))
                {
                    index = 2;
                    return;
                }
                index    = -1;
                m.Msg    = 0x00A1;
                m.WParam = new IntPtr(2);
                base.WndProc(ref m);
                break;

            case 0x202:

                if (index == 1 && rect1.Contains(vPoint))
                {
                    ChooseBox chooseBox = new ChooseBox(this, true, TDictionary.BaseDict, 50, 10, false);
                    chooseBox.Location = new Point(Left + rect1.X, Top + rect1.Y + rect1.Height);
                    chooseBox.Show();
                }
                if (index == 2 && rect2.Contains(vPoint))
                {
                    Dictionary <string, string> d = TDictionary.langDic[tranApiVaule];
                    if (d.ContainsKey("自动检测"))
                    {
                        d.Remove("自动检测");
                    }
                    ChooseBox chooseBox = new ChooseBox(this, false, d, 70, 10, false);
                    chooseBox.Location = new Point(Left + rect2.X, Top + rect2.Y + rect2.Height);
                    chooseBox.Show();
                }
                base.WndProc(ref m);
                break;

            default:
                base.WndProc(ref m);
                break;
            }
        }
Ejemplo n.º 4
0
 static DialogResult GetResult(string choose, string name) => ChooseBox.Show(choose, name, Enum.GetName(typeof(SecuritiesCOM), SecuritiesCOM.OpenAPI), Enum.GetName(typeof(SecuritiesCOM), SecuritiesCOM.XingAPI));