#region Copyright Syncfusion Inc. 2001 - 2024 // Copyright Syncfusion Inc. 2001 - 2024. All rights reserved. // Use of this code is subject to the terms of our license. // A copy of the current license can be obtained at any time by e-mailing // licensing@syncfusion.com. Any infringement will be prosecuted under // applicable laws. #endregion namespace syncfusion.olapchartdemos.wpf { using System; using System.Collections.Generic; using Syncfusion.Olap.Manager; using Syncfusion.Olap.Reports; using Syncfusion.Windows.Shared; using System.Windows.Media; using System.Reflection; /// /// ViewModel Class /// public class ChartWaterMarkViewModel : NotificationObject, IDisposable { #region Members /// /// Shared connection string. /// public static string ConnectionString; private OlapDataManager olapDataManager; #endregion #region Constructor /// /// Initializes a new instance of the class. /// public ChartWaterMarkViewModel() { ConnectionString = OlapChartModel.Initialize(System.IO.Path.GetFullPath(@"Assets\Config\OLAPSample.config")); olapDataManager = new OlapDataManager(ConnectionString); olapDataManager.SetCurrentReport(SimpleDimensions()); } #endregion #region Properties /// /// Gets or sets the grid data manager. /// /// The grid data manager. public OlapDataManager DataManager { get { return olapDataManager; } set { olapDataManager = value; } } /// /// Gets the color collection. /// /// The color collection. public List ColorCollection { get { List lst = new List(); Type br = typeof(Brushes); foreach (MemberInfo info in br.GetMembers()) { if (info is PropertyInfo) { PropertyInfo pi = info as PropertyInfo; lst.Add(pi.Name); } } return lst; } } #endregion #region Helper Method public void Dispose() { this.Dispose(true); GC.SuppressFinalize(this); } private void Dispose(bool disposing) { if (disposing && this.olapDataManager != null) this.olapDataManager.Dispose(); } private OlapReport SimpleDimensions() { OlapReport olapReport = new OlapReport(); olapReport.CurrentCubeName = "Adventure Works"; DimensionElement dimensionElementColumn = new DimensionElement(); //Specifying the Column Name for the Dimension and measure elements dimensionElementColumn.Name = "Customer"; dimensionElementColumn.AddLevel("Customer Geography", "Country"); MeasureElements measureElementColumn = new MeasureElements(); measureElementColumn.Elements.Add(new MeasureElement { Name = "Internet Sales Amount" }); //Specifying the Row Name for the Dimension element DimensionElement dimensionElementRow = new DimensionElement(); //Specifying the Dimension Name dimensionElementRow.Name = "Date"; dimensionElementRow.AddLevel("Fiscal", "Fiscal Year"); // Adding Column Members olapReport.CategoricalElements.Add(dimensionElementColumn); //Adding Measure Element olapReport.CategoricalElements.Add(measureElementColumn); //Adding Row Members olapReport.SeriesElements.Add(dimensionElementRow); return olapReport; } #endregion } }