Exemplo n.º 1
0
        void RunShear()
        {
            BackgroundWorker worker = new BackgroundWorker();

            try
            {
                worker.RunWorkerCompleted += delegate(object sender, RunWorkerCompletedEventArgs e)
                {
                    MessageBox.Show("Done with Alpha");
                };
                worker.DoWork += delegate(object s, DoWorkEventArgs args)
                {
                    try
                    {
                        IsProcessing = true;

                        int upperCompidx = ColumnCollection.UpperWSComp(DataSetStartDate);
                        int lowerCompidx = ColumnCollection.LowerWSComp(DataSetStartDate);

                        ISessionColumn upperws = ColumnCollection[upperCompidx];
                        ISessionColumn lowerws = ColumnCollection[lowerCompidx];

                        AxisFactory factory = new AxisFactory();

                        IAxis Yaxis = factory.CreateAxis(AxisType.Hour);
                        Yaxis.SessionColIndex = ColumnCollection.DateIndex;

                        IAxis Xaxis = factory.CreateAxis(AxisType.Month);
                        Xaxis.SessionColIndex = ColumnCollection.DateIndex;

                        AlphaFactory afactory = new AlphaFactory();
                        ColumnCollection.AlphaCollection.Add(afactory.CreateAlpha(DownloadedData [0], upperws, lowerws, Xaxis, Yaxis));
                        ColumnCollection.AlphaCollection.ToList().ForEach(c => c.CalculateAlpha());

                        ObservableCollection <ShearGridViewModel> thisShearCollection = new ObservableCollection <ShearGridViewModel>();

                        foreach (Alpha a in ColumnCollection.AlphaCollection)
                        {
                            int i = 1;
                            thisShearCollection.Add(new ShearGridViewModel(a, Xaxis.AxisType + " by " + Yaxis.AxisType));
                            i++;
                        }

                        //add sheargridviewmodels to allsheargridviewmodel
                        ShearGridCollection = new AllShearViewModel(thisShearCollection);

                        IsProcessing = false;
                    }
                    finally
                    {
                        IsProcessing = false;
                    }
                };
                worker.RunWorkerAsync();
            }
            catch (Exception e)
            {
                throw;
            }
        }
Exemplo n.º 2
0
        IAxis GetAxis(AxisType type, double binwidth)
        {
            AxisFactory factory = new AxisFactory();

            switch (type)
            {
            case AxisType.Month:
            {
                IAxis axis = factory.CreateAxis(AxisType.Month);
                axis.SessionColIndex = ColumnCollection.DateIndex;
                return(axis);
            }

            case AxisType.Hour:
            {
                IAxis axis = factory.CreateAxis(AxisType.Hour);
                axis.SessionColIndex = ColumnCollection.DateIndex;
                return(axis);
            }

            case AxisType.WD:
            {
                IAxis axis = factory.CreateAxis(binwidth);
                axis.SessionColIndex = ColumnCollection.WDComp(ColumnCollection.DataSetStart);
                return(axis);
            }

            case AxisType.WS:
            {
                int   i    = ColumnCollection.UpperWSComp(ColumnCollection.DataSetStart);
                IAxis axis = factory.CreateAxis(binwidth, ColumnCollection.Data.AsDataView(), i);
                axis.SessionColIndex = i;
                return(axis);
            }

            default:
                return(null);
            }
        }