Esempio n. 1
0
 public void RemoveWatchlistItem(ArbitrageItemControl control)
 {
     if (flowLayoutPanel.InvokeRequired)
     {
         RemoveWatchlistItemCallback d = new RemoveWatchlistItemCallback(RemoveWatchlistItem);
         flowLayoutPanel.Invoke(d, new object[] { control });
     }
     else
     {
         flowLayoutPanel.Controls.Remove(control);
         UpdateUI();
     }
 }
Esempio n. 2
0
        public void UpdateUI(bool resize = false)
        {
            if (flowLayoutPanel.InvokeRequired)
            {
                UpdateUICallback d = new UpdateUICallback(UpdateUI);
                flowLayoutPanel.Invoke(d, new object[] { resize });
            }
            else
            {
                try
                {
                    //LogManager.AddDebugMessage(Name, "UpdateUI", "1 colcount=" + listView.OLVGroups. .CollapsedGroups.Count());
                    //grouper.GroupTitle = ExchangeManager.coinBalanceList.Select(s => s.Symbol).Distinct().Count() + " Coins";
                    foreach (Control control in flowLayoutPanel.Controls)
                    {
                        if (control is ArbitrageItemControl)
                        {
                            ArbitrageItemControl item = control as ArbitrageItemControl;
                            item.UpdateUI(resize);
                        }
                    }

                    if (ArbitragePreferences.CurrentWatchList.Contains('|'))
                    {
                        string[] data   = ArbitragePreferences.CurrentWatchList.Split('|');
                        string   name   = data[0];
                        string   preset = data[1];
                        toolStripLabel_totals.Text = GetPresetWatchlistTotals(name, preset);
                    }
                    else
                    {
                        toolStripLabel_totals.Text = "NO";
                    }

                    toolStripLabel_lastUpdate.Text = "Last Update : " + DateTime.Now;

                    if (resize)
                    {
                        ResizeUI();
                    }
                }
                catch (Exception ex)
                {
                    LogManager.AddLogMessage(Name, "UpdateUI", ex.Message, LogManager.LogMessageType.EXCEPTION);
                }
            }
        }
Esempio n. 3
0
        public void SetWatchlist(bool resize = false, bool clear = false)
        {
            if (flowLayoutPanel.InvokeRequired)
            {
                SetWatchlistCallback d = new SetWatchlistCallback(SetWatchlist);
                flowLayoutPanel.Invoke(d, new object[] { resize, clear });
            }
            else
            {
                if (clear)
                {
                    flowLayoutPanel.Controls.Clear();
                }

                /*
                 * if (ArbitragePreferences.CurrentWatchList.Contains('|'))
                 * {
                 *  string[] data = ArbitragePreferences.CurrentWatchList.Split('|');
                 *  string name = data[0];
                 *  string preset = data[1];
                 *  toolStripLabel_totals.Text = GetPresetWatchlistTotals(name, preset);
                 * }
                 * else
                 * {
                 *  toolStripLabel_totals.Text = "NO";
                 * }
                 */
                WatchList = ArbitragePreferences.GetCurrentWatchList();
                SetOptionsMenu();

                foreach (ExchangeTicker ticker in WatchList.Items.OrderByDescending(item => item.last))
                {
                    //LogManager.AddLogMessage(Name, "SetWatchlist", "ticker=" + ticker.symbol + " | " + ticker.market + " | " + ticker.last, LogManager.LogMessageType.DEBUG);
                    Control[] ctrls = flowLayoutPanel.Controls.Find(ticker.symbol, false);

                    if (ctrls.Length > 0)
                    {
                        // UPDATE
                        ArbitrageItemControl control = ctrls[0] as ArbitrageItemControl;
                        //control.UpdateUI();
                        //control.SetData(ticker.symbol, PreferenceManager.ArbitragePreferences.market);
                        if (ticker.symbol != "BTC")
                        {
                            control.SetData(ticker.symbol, ArbitragePreferences.market);
                        }
                        else
                        {
                            control.SetData(ticker.symbol, "USD");
                        }
                    }
                    else
                    {
                        // ADD
                        ArbitrageItemControl control = new ArbitrageItemControl()
                        {
                            Name = ticker.symbol, manager = this
                        };
                        if (ticker.symbol != "BTC")
                        {
                            control.SetData(ticker.symbol, ArbitragePreferences.market);
                        }
                        else
                        {
                            control.SetData(ticker.symbol, "USD");
                        }
                        //PreferenceManager.SetControlTheme(control, PreferenceManager.preferences.Theme, ParentForm);
                        flowLayoutPanel.Controls.Add(control);
                        //LogManager.AddLogMessage(Name, "SetWatchlist", "ticker=" + ticker.symbol + " | " + ticker.market + " | " + ticker.last, LogManager.LogMessageType.DEBUG);
                    }
                }
                UpdateUI(resize);
            }
        }