public Chart CreateChart(ChartInformation ci)
        {
            m_chart = new Chart();

            m_chart.ToolBarEnabled = true;
            m_chart.ZoomingEnabled = true;
            m_chart.ZoomingMode = ZoomingMode.MouseDragAndWheel;

            m_chart.BorderThickness = ci.m_BorderThickness;
            m_chart.Theme = ci.m_Theme;
            m_chart.View3D = ci.m_View3D;

            Axis m_axisX = new Axis();
            m_axisX.Title = ci.m_axisXTitle;
            m_chart.AxesX.Add(m_axisX);

            Axis m_asixY = new Axis();
            m_asixY.Title = ci.m_axisYTitle;
            m_asixY.Enabled = true;
            m_asixY.StartFromZero = true;
            m_asixY.AxisType = AxisTypes.Primary;
            //m_asixY.AxisMaximum = ci.m_axisYMaximum;
            //m_asixY.Interval = ci.m_axisYInterval;
            m_chart.AxesY.Add(m_asixY);
            for (int i = 0; i < ci.dsc.Count; i++)
            {
                DataSeries ds = new DataSeries();
                ds.LegendText = ci.dsc[i].LegendText;
                ds.RenderAs = ci.dsc[i].RenderAs;
                ds.AxisYType = ci.dsc[i].AxisYType;
                ds.DataPoints = new DataPointCollection(ci.dsc[i].DataPoints);
                m_chart.Series.Add(ds);
            }
            m_chart.Rendered += new EventHandler(chart_Rendered);
            //Add click event to legend.
            SetLegendwithClickHandler();
            return m_chart;
        }
        private void bgw_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            this.pb_1.Value = 100;
            this.tb_progress.Text = "Done!";
            this.button2.IsEnabled = true;
            System.Windows.MessageBox.Show("Computational Time:  " + timeusing);

            //show the line chart
            if(clusterlist!=null)
            {
                ArrayList values1 = clusterlist.GetObjValList();
                ArrayList values2 = clusterlist.GetObj_Vari_ValList();
                if(values1!=null&&values2!=null){
                    ChartHelper ch = new ChartHelper();
                    ChartInformation ci = new ChartInformation();
                    ci.ImportLineData(values1,values2);
                    Chart m_chart = ch.CreateChart(ci);
                    WindowResultLineChart m_window = new WindowResultLineChart(m_chart);
                    m_window.Show();

                    //this.Dispatcher.BeginInvoke(new Action(() =>
                    //{
                    //    int Height = (int)m_chart.ActualHeight;
                    //    int Width = (int)m_chart.ActualWidth;
                    //    RenderTargetBitmap bmp = new RenderTargetBitmap(Width, Height, 96, 96, PixelFormats.Pbgra32);
                    //    bmp.Render(m_chart);
                    //    string file = outputpath+"\\a.jpg";
                    //    BitmapEncoder encoder;
                    //    encoder = new JpegBitmapEncoder();
                    //    encoder.Frames.Add(BitmapFrame.Create(bmp));
                    //    using (Stream stm = File.Create(file))
                    //    {
                    //        encoder.Save(stm);
                    //    }
                    //}), System.Windows.Threading.DispatcherPriority.Render);
                }
            }
        }