/// <summary>
 /// Called when [update chart].
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="args">The <see cref="BCSPowerPointAddin.ChartDataEventArgs"/> instance containing the event data.</param>
 public void OnUpdateChart(object sender, ChartDataEventArgs args)
 {
     if (args != null)
     {
         ChartDataObject chartDataObject = args.ChartDataObject;
         UpdateChart(chartDataObject);
     }
 }
        /// <summary>
        /// Gets the chart data object.
        /// </summary>
        /// <param name="entity">The entity.</param>
        /// <returns></returns>
        private ChartDataEventArgs GetChartDataObject(IEntity entity)
        {
            ChartDataObject chartObject = new ChartDataObject();

            chartObject.Data       = EntityDataLookup[entity];
            chartObject.Entity     = ectList.SelectedItem as IEntity;
            chartObject.SeriesName = seriesList.SelectedItem as string;
            chartObject.XValues    = new string[chkCategories.CheckedItems.Count];

            int counter = 0;

            foreach (string item in chkCategories.CheckedItems)
            {
                chartObject.XValues[counter] = item;
                counter++;
            }
            ChartDataEventArgs args = new ChartDataEventArgs();

            args.ChartDataObject = chartObject;
            return(args);
        }
        /// <summary>
        /// Handles the Click event of the btnInsert control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void btnInsert_Click(object sender, EventArgs e)
        {
            String EntityName = ectList.SelectedItem as String;

            if (String.IsNullOrWhiteSpace(EntityName))
            {
                return;
            }
            IEntity Entity = EntityLookup[EntityName];

            if (chkCategories.Items.Count == 0)
            {
                System.Windows.Forms.MessageBox.Show("Select at least one category in the checkbox");
                return;
            }
            ChartDataEventArgs args = GetChartDataObject(Entity);
            //Rasise the event in a thread safe manner
            EventHandler <ChartDataEventArgs> temp = Interlocked.CompareExchange(ref m_InsertChart, null, null);

            if (temp != null)
            {
                temp(this, args);
            }
        }