Exemple #1
0
        private void removeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (listView1.SelectedIndices.Count == 0)
            {
                return;
            }

            OrderContainer.Remove(listView1.SelectedIndices[0]);
            TimerRefresh_Tick(sender, e);
        }
Exemple #2
0
        private async Task <bool> DeleteOrdersAsync(OrderContainer[] Orders)
        {
            bool needWait = false;

            for (int i = Orders.Length - 1; i >= 0; i--)
            {
                if (Orders[i].Algorithm == AlgorithmComboBox.SelectedIndex)
                {
                    if (needWait)
                    {
                        await Task.Delay(1100);
                    }
                    OrderContainer.Remove(i);
                    needWait = true;
                }
            }
            return(true);
        }
Exemple #3
0
        private void FillPanel()
        {
            IDLabel = new Label
            {
                Text     = "# " + order.ID.ToString(),
                Location = new System.Drawing.Point(5, 7),
                AutoSize = true,
            };
            panel.Controls.Add(IDLabel);
            IDLabel.Click += (o, args) =>
            {
                System.Diagnostics.Process.Start("https://www.nicehash.com/order/" + order.ID.ToString());
            };

            var DeleteButton = new Button
            {
                Text      = "X",
                Location  = new System.Drawing.Point(170, 3),
                Width     = 25,
                BackColor = SystemColors.ButtonFace,
            };

            panel.Controls.Add(DeleteButton);
            DeleteButton.Click += (o, args) =>
            {
                OrderContainer.Remove(id);
            };
            DeleteButton.Click += TimerRefresh;

            if (order.OrderStats == null)
            {
                return;
            }

            var LimitTextBox = new TextBox
            {
                Text     = order.Limit.ToString(),
                Location = new System.Drawing.Point(5, 32),
                Width    = 40,
            };

            panel.Controls.Add(LimitTextBox);

            var PriceTextBox = new TextBox
            {
                Text     = order.MaxPrice.ToString("F4"),
                Location = new System.Drawing.Point(50, 32),
                Width    = 50,
            };

            panel.Controls.Add(PriceTextBox);
            PriceTextBox.TextChanged += PriceTextBox_TextChanged;

            if (order.MaxPriceInput != 0)
            {
                PriceTextBox.Text = order.MaxPriceInput.ToString("F4");
            }

            ToolTip currentPriceTooltip = new ToolTip();

            currentPriceTooltip.ToolTipIcon = ToolTipIcon.Info;
            currentPriceTooltip.IsBalloon   = true;
            currentPriceTooltip.ShowAlways  = true;

            currentPriceTooltip.SetToolTip(PriceTextBox, order.MaxPrice.ToString("F4"));

            var AddBitsTextBox = new TextBox
            {
                Text     = "0",
                Location = new System.Drawing.Point(105, 32),
                Width    = 30,
            };

            panel.Controls.Add(AddBitsTextBox);
            AddBitsTextBox.TextChanged += AddBitsTextBox_TextChanged;

            if (order.BitsInput != 0)
            {
                AddBitsTextBox.Text = order.BitsInput.ToString();
            }

            panel.Controls.Add(new Label
            {
                Text     = "Speed: " + order.OrderStats.Speed + " (" + order.OrderStats.Workers + " workers)",
                Location = new System.Drawing.Point(5, 55),
                AutoSize = true,
            });

            panel.Controls.Add(new Label
            {
                Text     = "Availiable BTC: " + order.OrderStats.BTCAvailable,
                Location = new System.Drawing.Point(5, 75),
                AutoSize = true,
            });

            var SetButton = new Button
            {
                Text      = "Set",
                Location  = new System.Drawing.Point(145, 30),
                Width     = 50,
                BackColor = SystemColors.ButtonFace,
            };

            panel.Controls.Add(SetButton);
            SetButton.Click += async(o, args) =>
            {
                await SetValuesAsync();

                TimerRefresh(null, null);
            };
            //SetButton.Click += TimerRefresh;

            async Task <bool> SetValuesAsync()
            {
                int  delayTime = 1900;
                int  i         = 0;
                bool needDelay = false;

                FormPleaseWait pleaseWait = new FormPleaseWait();

                try
                {
                    pleaseWait.StartPosition = FormStartPosition.CenterScreen;
                    pleaseWait.Show();
                }
                catch (Exception ex) { Console.WriteLine(ex); }

                foreach (OrderContainer _order in OrderContainer.GetAll())
                {
                    if (_order.ID == order.ID)
                    {
                        if (_order.Limit != Convert.ToDouble(LimitTextBox.Text))
                        {
                            if (needDelay)
                            {
                                await Task.Delay(delayTime);
                            }
                            OrderContainer.SetLimit(i, Convert.ToDouble(LimitTextBox.Text));
                            APIWrapper.OrderSetLimit(_order.ServiceLocation, _order.Algorithm, _order.ID, Convert.ToDouble(LimitTextBox.Text));
                            needDelay = true;
                        }

                        if (_order.MaxPrice != Convert.ToDouble(PriceTextBox.Text) + Convert.ToDouble(AddBitsTextBox.Text) * 0.0001)
                        {
                            if (needDelay)
                            {
                                await Task.Delay(delayTime);
                            }
                            OrderContainer.SetMaxPrice(i, Convert.ToDouble(PriceTextBox.Text) + Convert.ToDouble(AddBitsTextBox.Text) * 0.0001);
                            APIWrapper.OrderSetPrice(_order.ServiceLocation, _order.Algorithm, _order.ID, Convert.ToDouble(PriceTextBox.Text) + Convert.ToDouble(AddBitsTextBox.Text) * 0.0001);
                            needDelay            = true;
                            _order.MaxPriceInput = _order.MaxPrice;
                            _order.BitsInput     = 0;
                        }

                        if (Sync != -1)
                        {
                            OrderContainer[] Orders = OrderContainer.GetAll();
                            int _i = 0;
                            foreach (OrderContainer _orderSynced in Orders)
                            {
                                if (_orderSynced.ID == Sync)
                                {
                                    if (_orderSynced.Limit != Convert.ToDouble(LimitTextBox.Text))
                                    {
                                        if (needDelay)
                                        {
                                            await Task.Delay(delayTime);
                                        }
                                        OrderContainer.SetLimit(_i, Convert.ToDouble(LimitTextBox.Text));
                                        APIWrapper.OrderSetLimit(_orderSynced.ServiceLocation, _orderSynced.Algorithm, _orderSynced.ID, Convert.ToDouble(LimitTextBox.Text));
                                        needDelay = true;
                                    }

                                    if (_orderSynced.MaxPrice != Convert.ToDouble(PriceTextBox.Text) + Convert.ToDouble(AddBitsTextBox.Text) * 0.0001)
                                    {
                                        if (needDelay)
                                        {
                                            await Task.Delay(delayTime);
                                        }
                                        OrderContainer.SetMaxPrice(_i, Convert.ToDouble(PriceTextBox.Text) + Convert.ToDouble(AddBitsTextBox.Text) * 0.0001);
                                        APIWrapper.OrderSetPrice(_orderSynced.ServiceLocation, _orderSynced.Algorithm, _orderSynced.ID, Convert.ToDouble(PriceTextBox.Text) + Convert.ToDouble(AddBitsTextBox.Text) * 0.0001);
                                        needDelay = true;
                                        _orderSynced.MaxPriceInput = _orderSynced.MaxPrice;
                                        _orderSynced.BitsInput     = 0;
                                    }

                                    break;
                                }
                                _i++;
                            }
                        }
                    }

                    i++;
                }
                try { pleaseWait.Close(); }
                catch (Exception ex) { Console.WriteLine(ex); }

                return(true);
            }

            var RefillButton = new Button
            {
                Text      = "Refill",
                Location  = new System.Drawing.Point(145, 68),
                Width     = 50,
                BackColor = SystemColors.ButtonFace,
            };

            panel.Controls.Add(RefillButton);
            RefillButton.Click += (o, args) =>
            {
                order.OrderStats.Refill(0.005);
            };
            RefillButton.Click += TimerRefresh;
        }
Exemple #4
0
        private void TimerRefresh_Tick(object sender, EventArgs e)
        {
            if (!APIWrapper.ValidAuthorization)
            {
                return;
            }

            int tempTick = ++Tick;

            OrderContainer[] Orders = OrderContainer.GetAll();
            int Selected            = -1;

            if (listView1.SelectedIndices.Count > 0)
            {
                Selected = listView1.SelectedIndices[0];
            }
            listView1.Items.Clear();
            for (int i = 0; i < Orders.Length; i++)
            {
                int          Algorithm = Orders[i].Algorithm;
                ListViewItem LVI       = new ListViewItem(APIWrapper.SERVICE_NAME[Orders[i].ServiceLocation]);
                LVI.SubItems.Add(APIWrapper.ALGORITHM_NAME[Algorithm]);
                if (Orders[i].OrderStats != null)
                {
                    if (tempTick % 120 == 0)
                    {
                        if ((Orders[i].OrderStats.Price > 1.025 * Orders[i].MaxPrice) && (Orders[i].OrderStats.Speed > 0))
                        {
                            OrderContainer copy = new OrderContainer(Orders[i]);
                            OrderContainer.Remove(i);
                            OrderContainer.Add(copy.ServiceLocation, copy.Algorithm, copy.MaxPrice, copy.Limit, copy.PoolData, copy.ID, copy.StartingPrice, copy.StartingAmount, copy.HandlerDLL);
                            Console.WriteLine("Order recreated");
                        }
                    }
                    else
                    {
                        LVI.SubItems.Add("#" + Orders[i].OrderStats.ID.ToString());
                        string PriceText = Orders[i].OrderStats.Price.ToString("F4") + " (" + Orders[i].MaxPrice.ToString("F4") + ")";
                        PriceText += " BTC/" + APIWrapper.SPEED_TEXT[Algorithm] + "/Day";
                        LVI.SubItems.Add(PriceText);
                        LVI.SubItems.Add(Orders[i].OrderStats.BTCAvailable.ToString("F8"));
                        LVI.SubItems.Add(Orders[i].OrderStats.Workers.ToString());
                        string SpeedText = (Orders[i].OrderStats.Speed * APIWrapper.ALGORITHM_MULTIPLIER[Algorithm]).ToString("F4") + " (" + Orders[i].Limit.ToString("F2") + ") " + APIWrapper.SPEED_TEXT[Algorithm] + "/s";
                        LVI.SubItems.Add(SpeedText);
                        if (!Orders[i].OrderStats.Alive)
                        {
                            LVI.BackColor = Color.PaleVioletRed;
                        }
                        else
                        {
                            LVI.BackColor = Color.LightGreen;
                        }
                        LVI.SubItems.Add("View competing orders");
                    }
                }

                if (Selected >= 0 && Selected == i)
                {
                    LVI.Selected = true;
                }

                listView1.Items.Add(LVI);
            }
        }