Example #1
0
        void OnWorkspaceRequestClose(object sender, EventArgs e)
        {
            ShearGridViewModel workspace = sender as ShearGridViewModel;

            workspace.Dispose();
            this.ShearCollection.Remove(workspace);
        }
Example #2
0
 void ShearCollection_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
 {
     if (e.OldItems == null)
     {
         return;
     }
     foreach (object item in e.OldItems)
     {
         ShearGridViewModel sgvm = (ShearGridViewModel)item;
         AlphaRemoved(sgvm.GridCollection);
     }
 }
        private void dg1_AutoGeneratingColumn(object sender, DataGridAutoGeneratingColumnEventArgs e)
        {
            DataGrid           dgc  = (DataGrid)sender;
            UserControl        uc   = (UserControl)this.FindName("UC");
            ShearGridViewModel sgvm = (ShearGridViewModel)uc.DataContext;
            IAxis axis  = sgvm.GridCollection.Yaxis;
            int   index = int.Parse(e.PropertyName.ToString());


            // Create a new template column.
            BindableDataTemplateColumn templateColumn = new BindableDataTemplateColumn();

            templateColumn.ColumnName   = e.PropertyName;
            templateColumn.CellTemplate = (DataTemplate)Resources["DecimalConvert"];
            templateColumn.Header       = axis.AxisValues[index];
            // ...
            // Replace the auto-generated column with the templateColumn.
            e.Column = templateColumn;
        }
Example #4
0
        void RunShear()
        {
            BackgroundWorker worker = new BackgroundWorker();

            try
            {
                worker.RunWorkerCompleted += delegate(object sender, RunWorkerCompletedEventArgs e)
                {
                };
                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];


                        IAxis Xaxis = GetAxis(_xShearAxis, _xBinWidth);
                        IAxis Yaxis = GetAxis(_yShearAxis, _yBinWidth);

                        AlphaFactory afactory = new AlphaFactory();
                        Alpha        alpha    = (Alpha)afactory.CreateAlpha(DownloadedData[0], _alphaFilter, upperws, lowerws, Xaxis, Yaxis);

                        alpha.AlphaUpdated += new Alpha.AlphaUpdatedEventHandler(UpdatedAlphaCollection);
                        alpha.SourceDataSet = this.DisplayName;

                        ColumnCollection.AlphaCollection.Add(alpha);
                        alpha.CalculateAlpha();

                        string xBin = string.Empty;
                        string yBin = string.Empty;

                        if (Xaxis.AxisType == AxisType.WD)
                        {
                            var wdaxis = (WindDirectionAxis)Xaxis;
                            xBin = " " + wdaxis.BinWidth.ToString() + " deg";
                        }
                        if (Xaxis.AxisType == AxisType.WS)
                        {
                            var wsaxis = (WindSpeedAxis)Xaxis;
                            xBin = " " + wsaxis.BinWidth.ToString() + " m/s";
                        }
                        if (Yaxis.AxisType == AxisType.WD)
                        {
                            var wdaxis = (WindDirectionAxis)Yaxis;
                            yBin = " " + wdaxis.BinWidth.ToString() + " deg";
                        }
                        if (Yaxis.AxisType == AxisType.WS)
                        {
                            var wsaxis = (WindSpeedAxis)Yaxis;
                            yBin = " " + wsaxis.BinWidth.ToString() + " m/s";
                        }

                        AllShearViewModel asvm = new AllShearViewModel();
                        string            filter;
                        if (_alphaFilter == AlphaFilterMethod.Coincident)
                        {
                            filter = "CDNT";
                        }
                        else
                        {
                            filter = "NCDNT";
                        }

                        string             gridname = alpha.SourceDataSet + "_" + filter + "_" + Xaxis.AxisType + xBin + " by " + Yaxis.AxisType + yBin;
                        ShearGridViewModel sgvm     = new ShearGridViewModel(alpha, gridname);

                        if (ShearGridCollection == null)
                        {
                            ShearGridCollection = new AllShearViewModel();
                        }

                        if (ShearGridCollection.ShearCollection.Count == 0)
                        {
                            asvm.ShearCollection.Add(sgvm);
                        }



                        UpdatedAlphaCollection(alpha);
                        alpha.AlphaUpdated -= UpdatedAlphaCollection;
                        this.Dispatcher.Invoke(DispatcherPriority.Render, new Action
                                               (
                                                   delegate()
                        {
                            if (ShearGridCollection.ShearCollection.Count == 0)
                            {
                                ShearGridCollection = asvm;
                            }
                            else
                            {
                                ShearGridCollection.ShearCollection.Add(sgvm);
                            }
                        }));
                        //add sheargridviewmodels to allsheargridviewmodel


                        IsProcessing = false;
                    }
                    catch (ApplicationException e)
                    {
                        MessageBox.Show(e.Message);
                    }
                    finally
                    {
                        IsProcessing = false;
                    }
                };
                worker.RunWorkerAsync();
            }
            catch (Exception e)
            {
                throw;
            }
        }