public void CellPerformedAction(KNTableView view, KNTableColumn column, KNActionCell cell, int rowIndex)
        {
            if (column.Identifier.Equals("bool")) {
                bools[rowIndex] = (bool)KNCellDependencyProperty.GetObjectValue((DependencyObject)cell);
            }

            if (column.Identifier.Equals("button")) {
                MessageBox.Show("Clicked!");
            }
        }
 public object ObjectForRow(KNTableView table, KNTableColumn column, int rowIndex)
 {
     if (column.Identifier.Equals("image")) {
         return image;
     } else if (column.Identifier.Equals("bool")) {
         return bools[rowIndex];
     } else {
         return elements[rowIndex];
     }
 }
        public MainWindow() {
            InitializeComponent();

            // Load!

            if (KNUserDefaults.StandardUserDefaults().ObjectForKey("Keys") != null) {
                foreach (Dictionary<string, object> dict in (ArrayList)KNUserDefaults.StandardUserDefaults().ObjectForKey("Keys")) {
                    keys.Add(new UpdateSigningKey(dict));
                }
            }

            KNTableView keyTable = new KNTableView();
            keyTable.CornerCell = new KNLeopardCornerCell();
            KNCell cell = new KNTextCell();
            ((KNTextCell)cell).IsEditable = true;
            KNTableColumnDelegate del = null;
            KNHeaderCell header = new KNLeopardStyleHeaderCell("Name", false, true, System.Drawing.StringAlignment.Near);
            KNTableColumn col = new KNTableColumn("name", ref cell, ref header, ref del);
            col.Width = (int)KeyListHost.Width;
            keyTable.AddColumn(col);

            keyTable.TableDelegate = this;
            keyTable.DataSource = this;
            keyTable.AlternatingRowBackgrounds = true;

            keyTable.CellPerformedAction += Action;
            keyTable.SelectionChanged += TableSelectionChanged;

            KeyListHost.Child = keyTable;

            KNLeopardStyleHeaderButton button = new KNLeopardStyleHeaderButton();
            button.Enabled = false;
            ButtonBarHost.Child = button;

            SUUpdater updater = SUUpdater.SharedUpdater();

            this.AddObserverToKeyPathWithOptions(this, "SelectedKey", KNKeyValueObservingOptions.KNKeyValueObservingOptionInitial, null);

        }
 public SortOrder ColumnHeaderClicked(ref KNTableView tableView, ref KNTableColumn column, SortOrder suggestedNewSortOrder) {
     return suggestedNewSortOrder;
 }
 public object ObjectForRow(ref KNTableView tableView, ref KNTableColumn tableColumn, int rowIndex) {
     return ((UpdateSigningKey)keys[rowIndex]).Name;
 }
        public void Action(int row, ref KNTableColumn Column, KNActionCell Cell) {

            ((UpdateSigningKey)keys[row]).Name = (string)Cell.ObjectValue;
            Save();
        }
        public KNTableColumn.SortDirection TableViewWillSortByColumnWithSuggestedSortOrder(KNTableView table, KNTableColumn column, KNTableColumn.SortDirection suggestedNewSortOrder)
        {
            Array.Sort(elements);

            if (suggestedNewSortOrder == KNTableColumn.SortDirection.Descending) {
                Array.Reverse(elements);
            }

            return suggestedNewSortOrder;
        }
        public KNTableView()
        {
            this.Focusable = true;
            this.Focus();
            this.ClipToBounds = true;
            this.SnapsToDevicePixels = true;

            columnStack = new StackPanel();
            columnStack.Orientation = Orientation.Horizontal;
            Canvas.SetZIndex(columnStack, kContentZIndex);
            columnStack.ClipToBounds = true;

            Children.Add(columnStack);

            AllowMultipleSelection = true;

            verticalScrollbar = new ScrollBar();
            horizontalScrollbar = new ScrollBar();

            Canvas.SetZIndex(verticalScrollbar, kOverlayZIndex);
            Canvas.SetZIndex(horizontalScrollbar, kOverlayZIndex);

            verticalScrollbar.ValueChanged += VerticalScrollbarDidScroll;
            horizontalScrollbar.ValueChanged += HorizontalScrollBarDidScroll;

            verticalScrollbar.Width = 18.0;
            horizontalScrollbar.Height = 18.0;
            horizontalScrollbar.Orientation = Orientation.Horizontal;

            Children.Add(verticalScrollbar);
            Children.Add(horizontalScrollbar);

            Canvas.SetBottom(horizontalScrollbar, 0.0);
            Canvas.SetRight(verticalScrollbar, 0.0);

            BackgroundColor = Colors.White;
            SelectedRows = new ArrayList();
            RowHeight = 22.0;
            Columns = new KNTableColumn[] {};
            AlternateRowColor = Color.FromRgb(237, 243, 254);

            HeaderHeight = 24.0;
            RowSelectionStyle = SelectionStyle.WindowsExplorer;

            horizontalScrollbar.SmallChange = RowHeight;

            VerticalScrollBarVisibility = ScrollBarVisibility.Automatic;
            HorizontalScrollBarVisibility = ScrollBarVisibility.Automatic;

            ContentPadding = new Thickness(20.0);

            this.AddObserverToKeyPathWithOptions(this, "HeaderHeight", 0, null);
            this.AddObserverToKeyPathWithOptions(this, "VerticalScrollBarVisibility", 0, null);
            this.AddObserverToKeyPathWithOptions(this, "HorizontalScrollBarVisibility", 0, null);
            this.AddObserverToKeyPathWithOptions(this, "ContentPadding", 0, null);
            this.AddObserverToKeyPathWithOptions(this, "RowHeight", 0, null);
            this.AddObserverToKeyPathWithOptions(this, "SelectedRows", 0, null);

            this.AddObserverToKeyPathWithOptions(this,
                "Columns",
                KNKeyValueObservingOptions.KNKeyValueObservingOptionNew | KNKeyValueObservingOptions.KNKeyValueObservingOptionOld,
                null);
        }
 public int RowCountForColumn(KNTableColumn column)
 {
     if (DataSource != null) {
         return DataSource.NumberOfItemsInTableView(this);
     } else {
         return 0;
     }
 }
Exemple #10
0
 public object ObjectForRow(int row, KNTableColumn column)
 {
     if (DataSource != null) {
         return DataSource.ObjectForRow(this, column, row);
     } else {
         return null;
     }
 }
Exemple #11
0
        public void HeaderWasClicked(KNTableColumn column)
        {
            if (Delegate != null) {

                KNTableColumn.SortDirection newDirection = KNTableColumn.SortDirection.Ascending;

                foreach (KNTableColumn aColumn in Columns) {

                    if (aColumn.SortingPriority == KNTableColumn.SortPriority.Primary) {
                        aColumn.SortingPriority = KNTableColumn.SortPriority.Secondary;

                        if (aColumn == column) {
                            // Flip direction

                            if (aColumn.SortingDirection == KNTableColumn.SortDirection.Ascending) {
                                newDirection = KNTableColumn.SortDirection.Descending;
                            } else {
                                newDirection = KNTableColumn.SortDirection.Ascending;
                            }

                        } else {
                            newDirection = aColumn.SortingDirection;
                        }
                    } else {
                        aColumn.SortingPriority = KNTableColumn.SortPriority.NotUsed;
                    }

                }

                newDirection = Delegate.TableViewWillSortByColumnWithSuggestedSortOrder(this, column, newDirection);

                column.SortingDirection = newDirection;
                column.SortingPriority = KNTableColumn.SortPriority.Primary;

                ReloadData();

            }
        }
Exemple #12
0
 public void ActionCellPerformedAction(KNActionCell cell, KNTableColumn column)
 {
     if (DataSource != null) {
         DataSource.CellPerformedAction(this, column, cell, column.RowForCell(cell));
         ReloadData();
     }
 }