private void GridView1_CustomRowCellEdit(object sender, DevExpress.XtraGrid.Views.Grid.CustomRowCellEditEventArgs e) { if (e.Column != this.colSparkline) { return; } Ticker t = (Ticker)this.gvTikers.GetRow(e.RowHandle); if (this.greenSparkline == null) { this.greenSparkline = (RepositoryItemSparklineEdit)e.RepositoryItem.Clone(); this.greenSparkline.View.Color = Exchange.BidColor; this.gcTickers.RepositoryItems.Add(this.greenSparkline); } if (this.redSparkline == null) { this.redSparkline = (RepositoryItemSparklineEdit)e.RepositoryItem.Clone(); this.redSparkline.View.Color = Exchange.AskColor; this.gcTickers.RepositoryItems.Add(this.redSparkline); } if (t.Sparkline.Length < 2) { return; } if (t.Sparkline[t.Sparkline.Length - 1] > t.Sparkline[0]) { e.RepositoryItem = this.greenSparkline; } else { e.RepositoryItem = this.redSparkline; } }
private void Form1_Load(object sender, EventArgs e) { // Fill a grid's data source. this.customersPaymentTableAdapter.Fill(this.contactsDataSet.CustomersPayment); // Create a Sparkline repository item, adjust it and add it to the grid's repository. RepositoryItemSparklineEdit repositoryItemSparklineEdit1 = new RepositoryItemSparklineEdit(); LineSparklineView lineSparklineView1 = repositoryItemSparklineEdit1.View as LineSparklineView; lineSparklineView1.HighlightEndPoint = true; lineSparklineView1.HighlightMaxPoint = true; lineSparklineView1.HighlightMinPoint = true; lineSparklineView1.HighlightStartPoint = true; this.gridControl1.RepositoryItems.Add(repositoryItemSparklineEdit1); // Create an unbound column, adjust it and add it to the grid view. GridColumn colPayments = new GridColumn(); colPayments.Visible = true; colPayments.Caption = "Payments"; colPayments.UnboundType = UnboundColumnType.Object; colPayments.ColumnEdit = repositoryItemSparklineEdit1; colPayments.FieldName = "gridColumn1"; colPayments.MaxWidth = 300; colPayments.MinWidth = 50; colPayments.Width = 255; this.gridView1.Columns.Add(colPayments); // Expand all groups for better initial navigation. this.gridView1.ExpandAllGroups(); }
protected RepositoryItem CreateEditor(object first, StrategyDataItemInfo info) { if (first == null) { return(null); } if (info.FieldName == null) { return(null); } PropertyInfo pi = first.GetType().GetProperty(info.FieldName, BindingFlags.Instance | BindingFlags.Public); if (pi == null) { return(null); } object value = pi.GetValue(first); if (pi.PropertyType == typeof(bool) || value is bool) { RepositoryItemCheckEdit res = new RepositoryItemCheckEdit(); res.CheckBoxOptions.Style = DevExpress.XtraEditors.Controls.CheckBoxStyle.SvgStar2; return(res); } double[] doubleData = null; if (pi.PropertyType == typeof(ResizeableArray <TimeBaseValue>) || value is ResizeableArray <TimeBaseValue> ) { if (value == null) { doubleData = new double[0]; } else { ResizeableArray <TimeBaseValue> data = (ResizeableArray <TimeBaseValue>)value; doubleData = new double[Math.Min(data.Count, 50)]; for (int i = 0; i < doubleData.Length; i++) { doubleData[i] = data[i].Value; } } } if (value is double[] || pi.PropertyType == typeof(double[])) { if (value == null) { doubleData = new double[0]; } else { doubleData = (double[])value; } } if (doubleData != null) { RepositoryItemSparklineEdit res = new RepositoryItemSparklineEdit(); res.View = new AreaSparklineView() { AreaOpacity = 30, HighlightStartPoint = false, HighlightEndPoint = false, HighlightMaxPoint = false, HighlightMinPoint = false, HighlightNegativePoints = false }; return(res); } return(null); }
void StockWorkspacesUC_Load(object sender, EventArgs e) { if (StockMarketView.defaultViewModel == null) { return; } StockMarketView.defaultViewModel.CurrentPriceIndexChanged += defaultViewModel_CurrentPriceIndexChanged; StockMarketView.defaultViewModel.PropertyChanged += defaultViewModel_PropertyChanged; //watchList watchListGridView.OptionsBehavior.AutoPopulateColumns = false; watchListGridView.OptionsBehavior.CacheValuesOnRowUpdating = CacheRowValuesMode.Disabled; watchListGrid.MainView.DataController.AllowIEnumerableDetails = false; watchListGridView.FocusRectStyle = XtraGrid.Views.Grid.DrawFocusRectStyle.None; watchListGrid.DataSource = StockMarketView.defaultViewModel.WatchListBindingData; GridColumn col = watchListGridView.Columns.Add(); col.FieldName = "CompanyName"; col.Caption = "Symbol"; col.Visible = true; col = watchListGridView.Columns.Add(); col.FieldName = "Price"; col.Caption = "Last Price"; //col.ColumnEdit = new ArrowButtonRepositoryItem(); col.DisplayFormat.FormatType = FormatType.Numeric; col.DisplayFormat.FormatString = "c"; col.Visible = true; col = watchListGridView.Columns.Add(); col.FieldName = "Volume"; col.DisplayFormat.FormatType = FormatType.Numeric; col.DisplayFormat.FormatString = "n0"; col.Visible = true; col = watchListGridView.Columns.Add(); col.FieldName = "Volume Dynamics"; RepositoryItemSparklineEdit rise = new RepositoryItemSparklineEdit(); col.ColumnEdit = rise; col.UnboundType = Data.UnboundColumnType.Object; AreaSparklineView view = new AreaSparklineView(); view.HighlightMaxPoint = true; view.HighlightMinPoint = true; rise.View = view; col.Visible = true; col = watchListGridView.Columns.Add(); col.FieldName = "Rise"; col.Name = "Rise"; col.Visible = false; //col = watchListGridView.Columns.Add(); //col.FieldName = "TotalRise"; //col.Name = "TotalRise"; //col.Visible = false; //FormatConditionRuleIconSet val = new FormatConditionIconSetPositiveNegativeTriangles() { RangeDescription = "0, >0" }; //watchListGridView.FormatRules.Add(new GridFormatRule() { Rule = val, Column = watchListGridView.Columns["Rise"], ColumnApplyTo=watchListGridView.Columns[1]}); var rule = watchListGridView.FormatRules.AddIconSetRule(watchListGridView.Columns["Rise"], new FormatConditionIconSetPositiveNegativeTriangles() { RangeDescription = "<0, 0, >0" }); rule.ColumnApplyTo = watchListGridView.Columns[1]; rule.Enabled = true; watchListGridView.BestFitColumns(); watchListGridView.FocusedRowChanged += new XtraGrid.Views.Base.FocusedRowChangedEventHandler(watchListGridView_FocusedRowChanged); //watchListGridView.CustomDrawCell += watchListGridView_CustomDrawCell; watchListGridView.CustomUnboundColumnData += watchListGridView_CustomUnboundColumnData; //chart stockChartUC.stockChart.Series["Price"].DataSource = StockMarketView.defaultViewModel.StockChartBindingData; stockChartUC.stockChart.Series["Price"].ArgumentDataMember = "Date"; stockChartUC.stockChart.Series["Price"].ValueDataMembers.AddRange(new string[] { "Low", "High", "Open", "Close" }); stockChartUC.stockChart.Series["Volume"].DataSource = StockMarketView.defaultViewModel.StockChartBindingData; stockChartUC.stockChart.Series["Volume"].ArgumentDataMember = "Date"; stockChartUC.stockChart.Series["Volume"].ValueDataMembers.AddRange(new string[] { "Volume" }); //volumeChart volumeChart.Series[0].DataSource = StockMarketView.defaultViewModel.VolumeChartBindingData; volumeChart.Series[0].ArgumentDataMember = "CompanyName"; volumeChart.Series[0].ToolTipPointPattern = "Argument: {A}
Value: {V}"; volumeChart.Series[0].ValueDataMembers.AddRange(new string[] { "Volume" }); //transationsGrid transactionGridView.OptionsBehavior.AutoPopulateColumns = false; transactionGrid.DataSource = StockMarketView.defaultViewModel.TransactionGridBindingData; var fceAsk = new FormatConditionRuleExpression() { Expression = "Ask > 0", PredefinedName = "Red Fill" }; transactionGridView.FormatRules.AddRule(new GridFormatRule() { ApplyToRow = true, Rule = fceAsk }); var fceBid = new FormatConditionRuleExpression() { Expression = "Bid > 0", PredefinedName = "Green Fill" }; transactionGridView.FormatRules.AddRule(new GridFormatRule() { ApplyToRow = true, Rule = fceBid }); StockMarketView.defaultViewModel.WatchListChanged += defaultViewModel_WatchListChanged; helpBarItemButton.ImageOptions.SvgImage = SvgResources.GetSvgImage("Help"); bbiSwatches.ImageOptions.SvgImage = SvgResources.GetSvgImage("Swatches"); bsiConnectedStatus.ImageOptions.SvgImage = SvgResources.GetSvgImage("Connected"); }