using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace CubeAnalysis
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();

            // prepare to build view 
            //string connectionString = @"Data Source=http://c1db1.componentone.com/olap/msmdpump.dll;Provider=msolap;Initial Catalog=AdventureWorksDW2012Multidimensional-EE";
            string connectionString = @"Data Source=CRIMSONY;Provider=msolap;Initial Catalog=AdventureWorksDW2014Multidimensional-EE";

            string cubeName = "Adventure Works";
            try
            {
                c1FlexPivotPage1.FlexPivotPanel.ConnectCube(cubeName, connectionString);

                // show some data.
                var fp = c1FlexPivotPage1.FlexPivotEngine;
                fp.BeginUpdate();
                fp.ColumnFields.Add("Color");
                fp.RowFields.Add("Category");
                fp.ValueFields.Add("Order Count");
                fp.EndUpdate();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            c1FlexPivotPage1.FlexPivotEngine.Updated += (s1, e) =>
            {
                progressBar1.Visible = false;
            };

            c1FlexPivotPage1.FlexPivotEngine.UpdateProgressChanged += (s1, e) =>
            {
                progressBar1.Visible = true;
                progressBar1.Value = (int)e.ProgressPercentage;
            };
        }
    }
}
