public GridFunds(Model model)
        {
            InitializeComponent();
            m_grid.MouseRightButtonUp += DataGrid_.ColumnVisibility;
            DockControl = new DockControl(this, "Funds");

            Model     = model;
            Filter    = new CoinFilter(x => (CoinDataAdapter)x);
            Exchanges = CollectionViewSource.GetDefaultView(model.Exchanges);            // { Filter = x => !(x is CrossExchange) };
            CoinsView = new ListCollectionView(ListAdapter.Create(model.Coins, x => new CoinDataAdapter(this, x), x => x.CoinData))
            {
                Filter = Filter.Predicate
            };
            Funds = new ListCollectionView(model.Funds);

            //Exchanges.MoveCurrentToFirst();
            Exchanges.CurrentChanged += delegate { CoinsView.Refresh(); };
            Filter.PropertyChanged   += delegate { CoinsView.Refresh(); };

            // Commands
            CreateNewFund         = Command.Create(this, CreateNewFundInternal);
            RemoveFund            = Command.Create(this, RemoveFundInternal);
            ResetSort             = Command.Create(this, ResetSortInternal);
            ShowFundAllocationsUI = Command.Create(this, ShowFundAllocationsUIInternal);

            CreateFundColumns();
            DataContext = this;
        }
Beispiel #2
0
        // Notes:
        //  - This grid shows balance and coin information based on averages over
        //    all exchanges, the currently selected exchange, or a specific exchange.
        //  - The underlying Model.Coins collection should be ordered by DisplayOrder
        //  - Binding is tricky:
        //      Option 1: Maintain a mirror of Model.Coins contains wrappers for each CoinData.
        //        Con: needs to mirror in both directions src <-> mirror <-> grid,
        //      Option 2: Bind directly to 'Model.CoinData' and use a Converter to supply the
        //       values that aren't available on 'CoinData'

        public GridCoins(Model model)
        {
            InitializeComponent();
            m_grid.MouseRightButtonUp += DataGrid_.ColumnVisibility;

            Model         = model;
            DockControl   = new DockControl(this, "Coins");
            ExchangeNames = new ListCollectionView(SourceExchangeNames.ToList());
            Filter        = new CoinFilter(x => (CoinDataAdapter)x);
            Coins         = new List <CoinDataAdapter>(model.Coins.Select(x => new CoinDataAdapter(x, this)));
            CoinsView     = new ListCollectionView(Coins);

            // Commands
            AddCoin                = Command.Create(this, AddCoinInternal);
            RemoveCoin             = Command.Create(this, RemoveCoinInternal);
            ResetSort              = Command.Create(this, ResetSortInternal);
            SetBackTestingBalances = Command.Create(this, SetBackTestingBalancesInternal);
            PromptValuationPath    = Command.Create(this, PromptValuationPathInternal);

            m_grid.ContextMenu.Opened += delegate { m_grid.ContextMenu.Items.TidySeparators(); };
            DataContext = this;
        }