コード例 #1
0
        public PageHistory(FlowEditor data, params string[] stockNames)
        {
            this.Content = new ScrollView
            {
                Content         = table,
                Orientation     = ScrollOrientation.Both,
                BackgroundColor = Format.BackgroundColor,
            };
            for (int i = 0; i < 6; i++)
            {
                table.ColumnDefinitions.Add(new ColumnDefinition {
                    Width = GridLength.Auto
                });
            }

            AddRow("Date", "Stock", "Shares", "Flow", "Price", "Comment");
            foreach (Label header in table.Children)
            {
                header.FontAttributes = FontAttributes.Bold;
            }

            foreach (var row in data.GetFlowDetailsOrdered(stockNames, DateTime.MinValue, DateTime.Now))
            {
                AddRow(row);
            }
        }
コード例 #2
0
        public FormHistory(FlowEditor model, IEnumerable <string> stocks, DateTime dateFrom, DateTime dateTo)
        {
            Debug.Assert(model != null && stocks != null);
            this.model = model;

            var portfolio = stocks.ToArray();

            Debug.Assert(portfolio.Length > 0);
            deleteCheckCache = new HashSet <string>(portfolio.Length);

            InitializeComponent();

            /* We use these events just to control what menu options are available
             * or grayed out upon right-click, depending on the selection.
             * In the chronological order they are triggered: */
            table.MouseDown     += Table_MouseDown;
            table.CellMouseDown += Table_CellMouseDown;

            mnuDelete.Click += DoDelete;
            mnuExport.Click += DoExport;
            mnuImport.Click += DoImport;

            colShares.DefaultCellStyle.Alignment        =
                colFlow.DefaultCellStyle.Alignment      =
                    colPrice.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;

            colFlow.DefaultCellStyle.Format      =
                colPrice.DefaultCellStyle.Format = "C2";

            var rowData = model.GetFlowDetailsOrdered(portfolio, dateFrom, dateTo);

            rowsOrdered = new DataGridViewRow[rowData.Count];
            for (int idata = 0; idata < rowData.Count; ++idata)
            {
                var r    = rowData[idata];
                var igui =
                    table.Rows.Add(r.Date, r.StockName, r.Shares, r.Flow, r.PriceAvg, r.Comment);
                (rowsOrdered[idata] = table.Rows[igui])
                .Tag = r.Id;
            }
            Debug.Assert(rowsOrdered.Length == table.Rows.Count);

            headers = (
                from c in DataColumns
                select table.Columns[c].HeaderText
                ).ToArray();
        }
コード例 #3
0
        public FormHistoryFilter(FlowEditor model,
                                 IEnumerable <string> portfolio,
                                 IEnumerable <bool> selected)
        {
            Debug.Assert(model != null);
            this.model = model;

            InitializeComponent();

            listStocks.Items.AddRange(portfolio.ToArray());
            if (selected == null)
            {
                SelectAll();
            }
            else
            {
                int i = 0;
                foreach (bool select in selected.Take(listStocks.Items.Count))
                {
                    listStocks.SetSelected(i++, select);
                }
            }

            pickDateFrom.Value = pickDateFrom.MinDate;

            KeyPreview = true;
            KeyDown   += Form_KeyDown;
            Shown     += (e, a) => btnOK.Focus();        // listStocks interferes with keyboard handling when it's in focus

            // Arbitrary "from", but make both same kind (local):
            pickDateFrom.Value = new DateTime(2000, 1, 1, 0, 0, 0, DateTimeKind.Local);
            pickDateTo.Value   = DateTime.Now.Date;

            RestrictDate(pickDateFrom);
            RestrictDate(pickDateTo);
            pickDateFrom.ValueChanged += (s, e) => RestrictDate(pickDateFrom);
            pickDateTo.ValueChanged   += (s, e) => RestrictDate(pickDateTo);

            btnOK.Click += Launch;
        }