Exemplo n.º 1
0
 public void ReloadTable()
 {
     DataSource = new TableDataSource(ListOfSpectra);
     for (int i = 0; i <= ListOfSpectra.Count; i++)
     {
         SpectraListTable.DataSource = DataSource;
         SpectraListTable.Delegate   = new TableDelegate(DataSource);
     }
 }
Exemplo n.º 2
0
        partial void AddButton(NSObject sender)
        {
            var dlg = NSOpenPanel.OpenPanel;

            dlg.CanChooseFiles       = true;
            dlg.CanChooseDirectories = false;
            dlg.AllowedFileTypes     = new string[] { "dat", "txt" };
            if (dlg.RunModal() == 1)
            {
                var url = dlg.Urls[0];

                //  MainClass.listOfSpectra.Add(new Spectrum(url.Path));
                ListOfSpectra.Add(new Spectrum(url.Path));
                DataSource = new TableDataSource(ListOfSpectra);

                SpectraListTable.DataSource = DataSource;
                SpectraListTable.Delegate   = new TableDelegate(DataSource);
            }
        }
Exemplo n.º 3
0
        // It works with Segue Instance.
        public override void PrepareForSegue(NSStoryboardSegue segue, NSObject sender)
        {
            base.PrepareForSegue(segue, sender);

            switch (segue.Identifier)
            {
            case "RenameSheetSegue":
                var sheet = segue.DestinationController as SheetViewController;
                int k;

                if (SpectraListTable.IsRowSelected(SpectraListTable.SelectedRow))
                {
                    k             = (int)SpectraListTable.SelectedRow;
                    sheet.NewName = ListOfSpectra[k].Name;
                }

                sheet.SheetAccepted += (s, e) =>
                {
                    if (SpectraListTable.IsRowSelected(SpectraListTable.SelectedRow))
                    {
                        k = (int)SpectraListTable.SelectedRow;
                        ListOfSpectra[k].Name = sheet.NewName;

                        DataSource = new TableDataSource(ListOfSpectra);

                        for (int i = 0; i <= ListOfSpectra.Count; i++)
                        {
                            SpectraListTable.DataSource = DataSource;
                            SpectraListTable.Delegate   = new TableDelegate(DataSource);
                        }
                    }
                };
                sheet.Presentor = this;
                break;

            case "TrimSegue":
                var trimSheet = segue.DestinationController as TrimDialogController;
                int l         = (int)SpectraListTable.SelectedRow;

                trimSheet.SheetAccepted += (s, e) =>
                {
                    if (SpectraListTable.IsRowSelected(SpectraListTable.SelectedRow))
                    {
                        double l1 = Convert.ToDouble(trimSheet.Lamda1);
                        double l2 = Convert.ToDouble(trimSheet.Lamda2);
                        ListOfSpectra.Add(ListOfSpectra[l].Trimmed(l1, l2));

                        ReloadTable();
                    }
                };

                trimSheet.Presentor = this;
                break;

            case "MathSegue":
                var      mathSheet = segue.DestinationController as CustomDialogController;
                string[] mas       = new string[ListOfSpectra.Count];
                for (int i = 0; i < ListOfSpectra.Count; i++)
                {
                    mas[i] = ListOfSpectra[i].Name;
                }

                // Fill List
                mathSheet.BoxSpectraList = new List <string>(mas);
                mathSheet.SheetAccepted += (s, e) =>
                {
                    Spectrum sp1 = ListOfSpectra[mathSheet.Index1];
                    Spectrum sp2 = ListOfSpectra[mathSheet.Index2];
                    switch (mathSheet.RadioId)
                    {
                    case "PlusId":

                        ListOfSpectra.Add(sp1 + sp2);
                        break;

                    case "MinusId":
                        ListOfSpectra.Add(sp1 - sp2);
                        break;

                    case "MultiplyId":
                        ListOfSpectra.Add(sp1 * sp2);
                        break;

                    case "DivisionId":
                        ListOfSpectra.Add(sp1 / sp2);
                        break;
                    }
                    ReloadTable();
                };
                mathSheet.Presentor = this;
                SpectraListTable.ReloadData();
                break;

            case "PlotSegue":
                var dlg = segue.DestinationController as PlotWindowController;
                // Console.WriteLine(indexies.Count.ToString() + "======================");
                if (SpectraListTable.IsRowSelected(SpectraListTable.SelectedRow))
                {
                    k = (int)SpectraListTable.SelectedRow;
                    if (indexies.Count > 0)
                    {
                        int c = 0;
                        for (int i = 0; i < indexies.Count; i++)
                        {
                            if (indexies[i] == k)
                            {
                                c++;
                            }
                        }
                        if (c == 0)
                        {
                            indexies.Add(k);
                        }
                    }
                    else
                    {
                        indexies.Add(k);
                    }



                    for (int j = 0; j < indexies.Count; j++)
                    {
                        Console.WriteLine("===" + indexies[j].ToString() + "===");
                        dlg.ListOfSpectra.Add(ListOfSpectra[indexies[j]]);
                    }
                    //dlg.ListOfSpectra.Add(ListOfSpectra[k]);
                }

                dlg.DialogAccepted += (s, e) =>
                {
                    DismissController(dlg);
                };
                dlg.DialogCanceled += (s, e) =>
                {
                    indexies.Clear();
                    DismissController(dlg);
                };
                dlg.Presentor = this;
                break;
            }
        }
Exemplo n.º 4
0
 public TableDelegate(TableDataSource dataSource)
 {
     this.DataSource = dataSource;
 }