コード例 #1
0
ファイル: GridView.cs プロジェクト: sami1971/Eto
        void SelectNextViewRow(bool next)
        {
            var increment        = next ? 1 : -1;
            int?modelRowToSelect = null;              // If there are no selected rows, this is the default

            var rows = SelectedRows.ToArray();

            if (DataStoreView != null && rows.Length > 0)
            {
                // Get the last (or first, if moving back) selected view row.
                // This handles multiselection.
                int?currentRowViewIndex = null;
                foreach (var x in rows)
                {
                    var temp = DataStoreView.ModelToView(x);
                    if (temp != null &&
                        (currentRowViewIndex == null || Math.Sign(temp.Value - currentRowViewIndex.Value) == Math.Sign(increment)))
                    {
                        currentRowViewIndex = temp;
                    }
                }

                if (currentRowViewIndex != null)
                {
                    var newRow = currentRowViewIndex.Value + increment;                     // view index
                    if (newRow >= 0 &&
                        DataStore.Count > newRow)
                    {
                        modelRowToSelect = DataStoreView.ViewToModel(newRow);
                    }
                }
            }

            if (modelRowToSelect == null)
            {
                var viewRows = ViewRows.ToArray();
                if (viewRows.Length > 0)
                {
                    modelRowToSelect = next ? viewRows.First() : viewRows.Last();
                }
            }

            if (modelRowToSelect != null)
            {
                UnselectAll();
                SelectRow(modelRowToSelect.Value);
            }
        }
コード例 #2
0
ファイル: GridViewSelection.cs プロジェクト: pcdummy/Eto
        public void UnselectRow(int row)
        {
            ChangeSelection(() => {
                areAllObjectsSelected = false;
                if (selectedRows.Contains(row))
                {
                    selectedRows.Remove(row);
                }

                var viewIndex = DataStoreView.ModelToView(row);
                if (viewIndex != null)                 // can be null if the row is not in the view because it is filtered out
                {
                    Handler.UnselectRow(viewIndex.Value);
                }
            });
        }
コード例 #3
0
ファイル: GridViewSelection.cs プロジェクト: pcdummy/Eto
        /// <summary>
        /// Programmatically selects a row.
        /// </summary>
        public void SelectRow(int row)
        {
            ChangeSelection(() => {
                if (!AllowMultipleSelection)
                {
                    selectedRows.Clear();
                }

                selectedRows.Add(row);
                var viewIndex = DataStoreView.ModelToView(row);
                if (viewIndex != null)
                {
                    if (!AllowMultipleSelection)
                    {
                        Handler.UnselectAll();
                    }
                    Handler.SelectRow(viewIndex.Value);
                }
            });
        }