Ejemplo n.º 1
0
        public void ShowHistory(bool transient, string currency = null, int?left = null, int?top = null)
        {
            var form = new History
            {
                Currency     = currency,
                Width        = Constants.HistoryWidth,
                Height       = Constants.HistoryHeight,
                Left         = left ?? Screen.PrimaryScreen.WorkingArea.Width - Constants.HistoryWidth,
                Top          = top ?? Screen.PrimaryScreen.WorkingArea.Height - Constants.HistoryHeight,
                HistoryChart =
                {
                    Title          = currency?.ToUpperInvariant() ?? "Total",
                    CurrencySymbol = AppSettings.Instance.FiatCurrencySymbol
                },
                Text               = currency,
                FormMoved          = FormMoved,
                CloseEventReceived = FormClosed
            };

            form.Closed += FormOnClosed;

            _forms.Add(form);

            form.Show(transient);

            form.Activate();

            if (!transient)
            {
                form.TopMost = AppSettings.Instance.AlwaysOnTop;

                if (!string.IsNullOrWhiteSpace(currency))
                {
                    form.HistoryChart.BarColour = _colours[_colourIndex];

                    _colourIndex++;

                    if (_colourIndex >= _colours.Length)
                    {
                        _colourIndex = 0;
                    }
                }
            }

            var high = currency == null
                           ? AppSettings.Instance.BalanceHigh
                           : _historyManager.GetHigh(currency);

            var low = currency == null
                          ? AppSettings.Instance.BalanceLow
                          : _historyManager.GetLow(currency);

            form.HistoryChart.UpdateData(_historyManager.GetHistory(currency), LocaliseTime(_historyManager.GetHistoryTime()), _historyManager.GetExchangeRate(currency), _historyManager.GetHolding(currency), GetHoldingPercent(currency), high, low);
        }