Пример #1
0
        /// <summary>
        /// Shows a popup form at bottom right side of screen
        /// </summary>
        /// <param name="head">Title text</param>
        /// <param name="body">Body text</param>
        private void DoPopup(Config.ConfirmationClass CC)
        {
            /*Find a good position on screen*/
            Rectangle workingArea = Screen.GetWorkingArea(this);
            Point     cPoint      = new Point(workingArea.Right - 290, workingArea.Bottom - 110 - (popupForms.Count * 110));

            /*Show form and add to list*/
            PopupForm popupForm = new PopupForm(CC.conf.Description, CC.conf.ID, CC.account.AccountName, cPoint);

            popupForms.Add(popupForm);
            popupForm.Show();
        }
Пример #2
0
        /// <summary>
        /// Searches for new trade confirmations
        /// </summary>
        private void confirmTimer_Tick(object sender, EventArgs e)
        {
            Task.Run(() =>
            {
                for (int i = 0; i < accountList.Count; i++)
                {
                    try
                    {
                        /*Fetch all confirmations pending for current account*/
                        Confirmation[] conftemp = LoadConfirmations(accountList[i]);
                        if (conftemp.Length > 0)
                        {
                            foreach (Confirmation conf in conftemp)
                            {
                                /*Go through all and set some cool info in new class...*/
                                Config.ConfirmationClass CC = new Config.ConfirmationClass()
                                {
                                    account   = accountList[i],
                                    conf      = conf,
                                    tradeid   = conf.ID,
                                    displayed = false
                                };

                                if (!confirmationList.Any(o => o.tradeid == CC.tradeid))
                                {
                                    confirmationList.Add(CC);
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        //Value cannot be null for FetchConformations
                        Debug.WriteLine(ex.ToString());
                    }
                }

                /*Go through all confirmations pending and see if we should make a popup about the trade*/
                lock (confirmationList)
                {
                    foreach (Config.ConfirmationClass CC in confirmationList)
                    {
                        /*Have to make an additional check here because user might accept from ConfirmForm*/
                        if (confirmForm.completedTrades.Contains(CC.conf.ID))
                        {
                            CC.done = true;
                        }

                        if (!CC.displayed)
                        {
                            CC.displayed = true;

                            /*Invoke because yolo*/
                            Invoke(new Action(() =>
                            {
                                DoPopup(CC);
                                notifyPlayer.Play();
                            }));
                        }
                    }
                }
            });

            confirmForm.RefreshList(confirmationList);
        }
Пример #3
0
        /// <summary>
        /// Searches for new trade confirmations
        /// </summary>
        private void confirmTimer_Tick(object sender, EventArgs e)
        {
            Task.Run(() =>
            {
                for(int i = 0; i < accountList.Count; i++)
                {
                    try
                    {
                        /*Fetch all confirmations pending for current account*/
                        Confirmation[] conftemp = LoadConfirmations(accountList[i]);
                        if (conftemp.Length > 0)
                        {
                            foreach (Confirmation conf in conftemp)
                            {
                                /*Go through all and set some cool info in new class...*/
                                Config.ConfirmationClass CC = new Config.ConfirmationClass()
                                {
                                    account = accountList[i],
                                    conf = conf,
                                    tradeid = conf.ID,
                                    displayed = false
                                };

                                if (!confirmationList.Any(o => o.tradeid == CC.tradeid))
                                {
                                    confirmationList.Add(CC);
                                }
                            }
                        }
                    }
                    catch(Exception ex)
                    {
                        //Value cannot be null for FetchConformations
                        Debug.WriteLine(ex.ToString());
                    }
                }

                /*Go through all confirmations pending and see if we should make a popup about the trade*/
                lock (confirmationList)
                {
                    foreach (Config.ConfirmationClass CC in confirmationList)
                    {
                        /*Have to make an additional check here because user might accept from ConfirmForm*/
                        if (confirmForm.completedTrades.Contains(CC.conf.ID))
                            CC.done = true;

                        if (!CC.displayed)
                        {
                            CC.displayed = true;

                            /*Invoke because yolo*/
                            Invoke(new Action(() =>
                            {
                                DoPopup(CC);
                                notifyPlayer.Play();

                            }));
                        }
                    }
                }
            });

            confirmForm.RefreshList(confirmationList);
        }