Mini Kabibi Habibi
using System;
using System.Collections.Generic;
using System.Data;
using DevExpress.Sparkline;
using DevExpress.XtraGrid.Views.Base;
namespace DevExpress.XtraGrid.Demos {
public partial class Sparklines : TutorialControl {
const int januaryIndex = 3;
const int decemberIndex = 14;
public Sparklines() {
InitializeComponent();
TutorialInfo.WhatsThisCodeFile = "CS\\GridMainDemo\\Modules\\Sparklines.cs";
TutorialInfo.WhatsThisXMLFile = "DevExpress.XtraGrid.Demos.CodeInfo.Sparklines.xml";
gridControl.ForceInitialize();
cheHighlightMaxPoint.Checked = repositoryItemSparklineEdit1.View.HighlightMaxPoint;
cheHighlightMinPoint.Checked = repositoryItemSparklineEdit1.View.HighlightMaxPoint;
cheHighlightStartPoint.Checked = repositoryItemSparklineEdit1.View.HighlightMaxPoint;
cheHighlightEndPoint.Checked = repositoryItemSparklineEdit1.View.HighlightMaxPoint;
UpdateColors();
UpdateMaxColorEnabled();
UpdateMinColorEnabled();
UpdateStartColorEnabled();
UpdateEndColorEnabled();
InitCustomersPaymentData(dsContacts1);
InitializeViewCombobox();
}
void InitializeViewCombobox() {
foreach (SparklineViewType view in Enum.GetValues(typeof(SparklineViewType)))
cbeView.Properties.Items.Add(view);
cbeView.SelectedItem = repositoryItemSparklineEdit1.View.Type;
}
void Sparklines_Load(object sender, System.EventArgs e) {
gridControl.ForceInitialize();
gridView.ExpandAllGroups();
}
//<cbeView>
void cbeView_SelectedIndexChanged(object sender, EventArgs e) {
if (repositoryItemSparklineEdit1.View.Type != (SparklineViewType)cbeView.SelectedItem)
repositoryItemSparklineEdit1.View = SparklineViewBase.CreateView((SparklineViewType)cbeView.SelectedItem);
}
//</cbeView>
//<cheHighlightMaxPoint>
void cheHighlightMaxPoint_CheckedChanged(object sender, EventArgs e) {
repositoryItemSparklineEdit1.View.HighlightMaxPoint = cheHighlightMaxPoint.Checked;
UpdateMaxColorEnabled();
}
//</cheHighlightMaxPoint>
//<cheHighlightMinPoint>
void cheHighlightMinPoint_CheckedChanged(object sender, EventArgs e) {
repositoryItemSparklineEdit1.View.HighlightMinPoint = cheHighlightMinPoint.Checked;
UpdateMinColorEnabled();
}
//</cheHighlightMinPoint>
//<cheHighlightStartPoint>
void cheHighlightStartPoint_CheckedChanged(object sender, EventArgs e) {
repositoryItemSparklineEdit1.View.HighlightStartPoint = cheHighlightStartPoint.Checked;
UpdateStartColorEnabled();
}
//</cheHighlightStartPoint>
//<cheHighlightEndPoint>
void cheHighlightEndPoint_CheckedChanged(object sender, EventArgs e) {
repositoryItemSparklineEdit1.View.HighlightEndPoint = cheHighlightEndPoint.Checked;
UpdateEndColorEnabled();
}
//</cheHighlightEndPoint>
void UpdateMaxColorEnabled() {
ceMax.Enabled = cheHighlightMaxPoint.Checked;
}
void UpdateMinColorEnabled() {
ceMin.Enabled = cheHighlightMinPoint.Checked;
}
void UpdateStartColorEnabled() {
ceStart.Enabled = cheHighlightStartPoint.Checked;
}
void UpdateEndColorEnabled() {
ceEnd.Enabled = cheHighlightEndPoint.Checked;
}
//<ceStart>
void ceStart_EditValueChanged(object sender, EventArgs e) {
repositoryItemSparklineEdit1.View.StartPointColor = ceStart.Color;
}
//</ceStart>
//<ceMin>
void ceMin_EditValueChanged(object sender, EventArgs e) {
repositoryItemSparklineEdit1.View.MinPointColor = ceMin.Color;
}
//</ceMin>
//<ceEnd>
void ceEnd_EditValueChanged(object sender, EventArgs e) {
repositoryItemSparklineEdit1.View.EndPointColor = ceEnd.Color;
}
//</ceEnd>
//<ceMax>
void ceMax_EditValueChanged(object sender, EventArgs e) {
repositoryItemSparklineEdit1.View.MaxPointColor = ceMax.Color;
}
//</ceMax>
//<ceColor>
void ceColor_EditValueChanged(object sender, EventArgs e) {
repositoryItemSparklineEdit1.View.Color = ceColor.Color;
}
//</ceColor>
void UpdateColors() {
ceMax.Color = repositoryItemSparklineEdit1.View.ActualMaxPointColor;
ceMin.Color = repositoryItemSparklineEdit1.View.ActualMinPointColor;
ceStart.Color = repositoryItemSparklineEdit1.View.ActualStartPointColor;
ceEnd.Color = repositoryItemSparklineEdit1.View.ActualEndPointColor;
ceColor.Color = repositoryItemSparklineEdit1.View.ActualColor;
}
protected override void OnStyleChanged() {
base.OnStyleChanged();
UpdateColors();
}
//<gridControl>
void gridView_CustomUnboundColumnData(object sender, CustomColumnDataEventArgs e) {
if (e.IsGetData) {
List<double> values = new List<double>();
DataRowView row = (DataRowView)e.Row;
for (int i = januaryIndex; i <= decemberIndex; i++)
values.Add((double)row.Row.ItemArray[i]);
e.Value = values;
}
}
//</gridControl>
}
}