Esempio n. 1
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            DataSourceKeywordGroups = new DataSourceTableViewKeywordGroups();
            foreach (string kwd in OpenLibrary.KeywordGroupsFormatted)
            {
                DataSourceKeywordGroups.Keywords.Add(
                    new DataSourceTableViewKeywordGroupKeyword
                {
                    GroupName = kwd,
                    IsNew     = false,
                    IsDeleted = false
                }
                    );
            }

            TableViewKeywordGroups.DataSource = DataSourceKeywordGroups;
            TableViewKeywordGroups.Delegate   = new DelegateTableViewKeywordGroups(DataSourceKeywordGroups);

            TableViewKeywordGroups.OnDeletePressed += (sender, e) =>
            {
                if (e.SelectedRow != -1)
                {
                    if (DataSourceKeywordGroups.Keywords[e.SelectedRow].IsDeleted)
                    {
                        DataSourceKeywordGroups.Keywords[e.SelectedRow].IsDeleted = false;
                        TableViewKeywordGroups.ReloadData();
                    }
                    else
                    {
                        var alert = new NSAlert
                        {
                            AlertStyle      = NSAlertStyle.Warning,
                            MessageText     = "Are you sure you wish to delete the selected keyword group?",
                            InformativeText = "This will not delete the keyword group from the sources in the library.",
                        };
                        alert.AddButton("Yes");
                        alert.AddButton("No");

                        var choice = alert.RunModal();

                        if (choice == 1000)
                        {
                            DataSourceKeywordGroups.Keywords[e.SelectedRow].IsDeleted = true;
                            TableViewKeywordGroups.ReloadData();
                        }
                    }
                }
            };
        }
 public DelegateTableViewKeywordGroups(DataSourceTableViewKeywordGroups dataSource)
 {
     _dataSource = dataSource;
 }