Esempio n. 1
0
        public MainWindow()
        {
            InitializeComponent();
            try
            {
                ProfileMngr = new ProfileManager();
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, ex.Source, MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.Exit();
            }

            ErrorStatus = new StatusClass();
            refcontrol  = new Control();
            refcontrol.CreateControl();

            //Bindings

            StatusLabel.DataBindings.Add(new Binding("Text", ErrorStatus, "STATUS"));
            OrdersView.DataSource    = OrderList;
            UsersComboBox.DataSource = ProfileMngr.UserNames;

            UsersComboBox.SelectedIndex = -1;

            //Initialize List for the ListView

            OrderList             = new BindingList <Order>();
            OrdersView.DataSource = OrderList;

            if (!fMonoFramework)
            {
                //Creation of context menu of NotifyIcon

                NotifyMenu = new System.Windows.Forms.ContextMenu();
                NotifyMenu.MenuItems.Add("Restore", MenuItem_Restore);
                NotifyMenu.MenuItems.Add("Exit", MenuItem_Exit);

                //Initializing for the NotifyIcon

                AppNotifyIcon                = new System.Windows.Forms.NotifyIcon();
                AppNotifyIcon.Icon           = System.Drawing.Icon.FromHandle(Properties.Resources.logo.GetHicon());
                AppNotifyIcon.Visible        = true;
                AppNotifyIcon.DoubleClick   += OnDoubleClickNotify;
                AppNotifyIcon.ContextMenu    = NotifyMenu;
                AppNotifyIcon.BalloonTipText = "BitFresh is minimized to system tray";
                AppNotifyIcon.Text           = "BitFresh";
            }

            //Add Icon to Window
            this.Icon = System.Drawing.Icon.FromHandle(Properties.Resources.logo.GetHicon());

            //Create configuration object
            PrfWindow  = new ProfileWindow(ConnectButton, confBtn, ProfManagerButton, ProfileMngr);
            confWindow = new Configure(ConnectButton, confBtn, ProfManagerButton);
            passWindow = new PasswordInput();
        }
Esempio n. 2
0
        private void disconnectingTask(StatusClass _ErrorStatus)
        {
            refcontrol.BeginInvoke((MethodInvoker) delegate()
            {
                this.ConnectButton.Text = "Disconnecting";
            });

            Manager.Dispose();

            refcontrol.BeginInvoke((MethodInvoker) delegate()
            {
                ConnectButton.Enabled     = true;
                this.ConnectButton.Text   = "Connect";
                ProfManagerButton.Enabled = true;
                UsersComboBox.Enabled     = true;
                _ErrorStatus.STATUS       = "Waiting...";
                this.confBtn.Enabled      = true;
            });
        }
Esempio n. 3
0
        private void UpdateGUI(StatusClass _ErrorStatus)
        {
            List <string> tempIDs  = new List <string>();
            List <Order>  tempData = new List <Order>();

            bool fonlyOnce = true;

            while (!Manager.fStop)
            {
                if (Manager.Bridge.fFailedConection)
                {
                    Manager.fStop = true;

                    refcontrol.BeginInvoke((MethodInvoker) delegate()
                    {
                        ShowConnectionError();
                    });
                }

                if (!Manager.Bridge.fConnected)
                {
                    System.Threading.Thread.Sleep(500);
                    continue;
                }

                if (fonlyOnce)
                {
                    if (Manager.bkp.ordersToRestore())
                    {
                        refcontrol.BeginInvoke((MethodInvoker) delegate()
                        {
                            AskForBackup();
                        });
                    }
                    else
                    {
                        Manager.startTasks();
                    }
                    fonlyOnce = false;
                }

                tempData = OrderList.Where(el => !(Manager.Bridge.OnHoldOrders.Exists(x => x.OrderUuid == el.ID) || Manager.Bridge.ActiveOrders.Exists(x => x.OrderUuid == el.ID))).ToList();

                if (tempData.Any())
                {
                    foreach (Order it in tempData)
                    {
                        refcontrol.BeginInvoke((MethodInvoker) delegate()
                        {
                            OrderList.Remove(it);
                        });
                    }
                }

                tempData = OrderList.Where(el => Manager.Bridge.OnHoldOrders.Exists(x => x.OrderUuid == el.ID) || Manager.Bridge.ActiveOrders.Exists(x => x.OrderUuid == el.ID)).ToList();

                if (tempData.Any())
                {
                    foreach (Order it in tempData)
                    {
                        int index = OrderList.IndexOf(it);
                        OrderList[index].STATUS   = ErrorStatus.getStatusByOrder(it.ID);
                        OrderList[index].TIMELEFT = (DateTime.UtcNow - it.CREATED).ToString(@"dd\.hh\:mm\:ss");
                    }
                }

                foreach (Order it in OrderList)
                {
                    tempIDs.Add(it.ID);
                }

                foreach (BittrexSharp.Domain.OpenOrder it in Manager.Bridge.OnHoldOrders)
                {
                    if (tempIDs.Contains(it.OrderUuid))
                    {
                        continue;
                    }
                    refcontrol.BeginInvoke((MethodInvoker) delegate()
                    {
                        OrderList.Add(new Order(it.OrderUuid, it.Exchange, it.QuantityRemaining, it.OrderType, ErrorStatus.getStatusByOrder(it.OrderUuid), it.Opened, (DateTime.UtcNow - it.Opened).ToString(@"dd\.hh\:mm\:ss")));
                    });
                }

                foreach (BittrexSharp.Domain.OpenOrder it in Manager.Bridge.ActiveOrders)
                {
                    if (tempIDs.Contains(it.OrderUuid))
                    {
                        continue;
                    }

                    refcontrol.BeginInvoke((MethodInvoker) delegate()
                    {
                        if (!Manager.Bridge.OnHoldOrders.Exists(x => x.OrderUuid == it.OrderUuid))
                        {
                            OrderList.Add(new Order(it.OrderUuid, it.Exchange, it.QuantityRemaining, it.OrderType, ErrorStatus.getStatusByOrder(it.OrderUuid), it.Opened, (DateTime.UtcNow - it.Opened).ToString(@"dd\.hh\:mm\:ss")));
                        }
                    });
                }

                tempIDs.Clear();
                System.Threading.Thread.Sleep(Constants.second);
            }

            refcontrol.BeginInvoke((MethodInvoker) delegate()
            {
                OrderList.Clear();
            });
        }