Beispiel #1
0
        public SwipeDelete()
        {
            this.SfGrid                     = new SfDataGrid();
            this.viewModel                  = new SwipingViewModel();
            this.SfGrid.ItemsSource         = viewModel.OrdersInfo;
            this.SfGrid.AutoGenerateColumns = false;
            this.SfGrid.ShowRowHeader       = false;
            this.SfGrid.HeaderRowHeight     = 45;
            this.SfGrid.RowHeight           = 45;
            this.SfGrid.ColumnSizer         = ColumnSizer.Star;

            UILabel leftSwipeViewText = new UILabel();

            leftSwipeViewText.Text            = "Deleted";
            leftSwipeViewText.TextColor       = UIColor.White;
            leftSwipeViewText.TextAlignment   = UITextAlignment.Left;
            leftSwipeViewText.BackgroundColor = UIColor.FromRGB(26, 170, 135);


            UILabel leftSwipeViewButton = new UILabel();

            leftSwipeViewButton.UserInteractionEnabled = true;
            leftSwipeViewButton.Text            = "UNDO";
            leftSwipeViewButton.TextColor       = UIColor.White;
            leftSwipeViewButton.Font            = UIFont.BoldSystemFontOfSize(14);
            leftSwipeViewButton.TextAlignment   = UITextAlignment.Right;
            leftSwipeViewButton.BackgroundColor = UIColor.FromRGB(26, 170, 135);
            leftSwipeViewButton.AddGestureRecognizer(new UITapGestureRecognizer(UndoTapped));

            SwipeView leftSwipeView = new SwipeView();

            leftSwipeView.BackgroundColor = UIColor.FromRGB(26, 170, 135);
            leftSwipeView.AddSubview(leftSwipeViewText);
            leftSwipeView.AddSubview(leftSwipeViewButton);

            UILabel rightSwipeViewText = new UILabel();

            rightSwipeViewText.Text            = "Deleted";
            rightSwipeViewText.TextColor       = UIColor.White;
            rightSwipeViewText.TextAlignment   = UITextAlignment.Left;
            rightSwipeViewText.BackgroundColor = UIColor.FromRGB(26, 170, 135);

            UILabel rightSwipeViewButton = new UILabel();

            rightSwipeViewButton.UserInteractionEnabled = true;
            rightSwipeViewButton.Text            = "UNDO";
            rightSwipeViewButton.TextColor       = UIColor.White;
            rightSwipeViewButton.Font            = UIFont.BoldSystemFontOfSize(14);
            rightSwipeViewButton.TextAlignment   = UITextAlignment.Right;
            rightSwipeViewButton.BackgroundColor = UIColor.FromRGB(26, 170, 135);
            rightSwipeViewButton.AddGestureRecognizer(new UITapGestureRecognizer(UndoTapped));

            SwipeView rightSwipeView = new SwipeView();

            rightSwipeView.BackgroundColor = UIColor.FromRGB(26, 170, 135);
            rightSwipeView.AddSubview(rightSwipeViewText);
            rightSwipeView.AddSubview(rightSwipeViewButton);

            this.SfGrid.AllowSwiping   = true;
            this.SfGrid.LeftSwipeView  = leftSwipeView;
            this.SfGrid.RightSwipeView = rightSwipeView;
            this.SfGrid.SwipeEnded    += SfGrid_SwipeEnded;
            this.SfGrid.SwipeStarted  += SfGrid_SwipeStarted;

            GridTextColumn CustomerID = new GridTextColumn();

            CustomerID.MappingName = "CustomerID";
            CustomerID.HeaderText  = "Customer ID";
            GridTextColumn OrderID = new GridTextColumn();

            OrderID.MappingName = "OrderID";
            OrderID.HeaderText  = "Order ID";
            GridTextColumn EmployeeID = new GridTextColumn();

            EmployeeID.MappingName = "EmployeeID";
            EmployeeID.HeaderText  = "Employee ID";
            GridTextColumn Name = new GridTextColumn();

            Name.MappingName = "FirstName";
            Name.HeaderText  = "Name";

            this.SfGrid.Columns.Add(OrderID);
            this.SfGrid.Columns.Add(CustomerID);
            this.SfGrid.Columns.Add(EmployeeID);
            this.SfGrid.Columns.Add(Name);

            this.AddSubview(SfGrid);
        }
Beispiel #2
0
        public override Android.Views.View GetSampleContent(Android.Content.Context context)
        {
            parentLayout = new FrameLayout(context);

            optionHeading         = new TextView(context);
            optionHeading.Gravity = GravityFlags.CenterHorizontal;
            body       = new LinearLayout(context);
            optionView = new LinearLayout(context);
            optionView.SetBackgroundColor(Color.Gray);
            editor = new LinearLayout(context);
            bottom = new LinearLayout(context);

            bodyRow1             = new LinearLayout(context);
            bodyRow1.Orientation = Android.Widget.Orientation.Horizontal;
            bodyRow1.SetGravity(GravityFlags.CenterHorizontal);
            bodyRow2             = new LinearLayout(context);
            bodyRow2.Orientation = Android.Widget.Orientation.Horizontal;
            bodyRow2.SetGravity(GravityFlags.CenterHorizontal);
            bodyRow3             = new LinearLayout(context);
            bodyRow3.Orientation = Android.Widget.Orientation.Horizontal;
            bodyRow3.SetGravity(GravityFlags.CenterHorizontal);
            bodyRow4             = new LinearLayout(context);
            bodyRow4.Orientation = Android.Widget.Orientation.Horizontal;
            bodyRow4.SetGravity(GravityFlags.CenterHorizontal);


            col1      = new TextView(context);
            col1.Text = "Order ID";
            col2      = new TextView(context);
            col2.Text = "Customer ID";
            col3      = new TextView(context);
            col3.Text = "Employee ID";
            col4      = new TextView(context);
            col4.Text = "Name";

            orderIDText         = new EditText(context);
            orderIDText.Gravity = GravityFlags.Start;
            customerIDText      = new EditText(context);
            employeeIDText      = new EditText(context);
            nameText            = new EditText(context);

            save          = new Button(context);
            save.Click   += save_Click;
            cancel        = new Button(context);
            cancel.Click += cancel_Click;

            editView = new LinearLayout(context);
            editView.TextAlignment = TextAlignment.Center;
            editView.Orientation   = Android.Widget.Orientation.Horizontal;
            editView.Click        += editView_Click;

            deleteView = new LinearLayout(context);
            deleteView.TextAlignment = TextAlignment.Center;
            deleteView.Orientation   = Android.Widget.Orientation.Horizontal;
            deleteView.Click        += swipeViewImage_Click;

            ImageView editImage = new ImageView(context);

            editImage.SetImageResource(Resource.Drawable.Edit);
            editImage.SetBackgroundColor(Color.ParseColor("#42A5F5"));
            // editImage.SetPadding((int)(16 * Resources.System.DisplayMetrics.Density), 0, (int)(16 * Resources.System.DisplayMetrics.Density), 0);

            TextView edit = new TextView(context);

            edit.Text          = "EDIT";
            edit.TextAlignment = TextAlignment.Center;
            edit.SetTextColor(Color.White);
            edit.SetPadding((int)(16 * Resources.System.DisplayMetrics.Density), (int)(10 * Resources.System.DisplayMetrics.Density), (int)(10 * Resources.System.DisplayMetrics.Density), 0);
            edit.SetBackgroundColor(Color.ParseColor("#42A5F5"));

            ImageView deleteImage = new ImageView(context);

            deleteImage.SetImageResource(Resource.Drawable.Delete);
            deleteImage.SetBackgroundColor(Color.ParseColor("#EF5350"));
            // deleteImage.SetPadding((int)(16 * Resources.System.DisplayMetrics.Density), 0, (int)(16 * Resources.System.DisplayMetrics.Density), 0);

            TextView delete = new TextView(context);

            delete.Text          = "DELETE";
            delete.TextAlignment = TextAlignment.Center;
            delete.SetPadding((int)(14 * Resources.System.DisplayMetrics.Density), (int)(10 * Resources.System.DisplayMetrics.Density), (int)(10 * Resources.System.DisplayMetrics.Density), 0);
            delete.SetTextColor(Color.White);
            delete.SetBackgroundColor(Color.ParseColor("#EF5350"));

            viewModel = new SwipingViewModel();
            viewModel.SetRowstoGenerate(100);

            sfGrid = new SfDataGrid(context);
            sfGrid.AutoGenerateColumns = false;
            sfGrid.ItemsSource         = (viewModel.OrdersInfo);
            sfGrid.AllowSwiping        = true;
            sfGrid.ColumnSizer         = ColumnSizer.Star;

            DisplayMetrics metrics = context.Resources.DisplayMetrics;
            int            width   = metrics.WidthPixels;

            sfGrid.MaxSwipeOffset = (int)(100 * metrics.Density);
            leftSwipeView         = new SwipeView(context);
            rightSwipeView        = new SwipeView(context);

            editView.AddView(editImage, (int)(30 * Resources.System.DisplayMetrics.Density), (int)sfGrid.RowHeight);
            editView.AddView(edit, sfGrid.MaxSwipeOffset - 30, (int)sfGrid.RowHeight);

            deleteView.AddView(deleteImage, (int)(30 * Resources.System.DisplayMetrics.Density), (int)sfGrid.RowHeight);
            deleteView.AddView(delete, sfGrid.MaxSwipeOffset - 30, (int)sfGrid.RowHeight);

            leftSwipeView.AddView(editView, sfGrid.MaxSwipeOffset, (int)sfGrid.RowHeight);
            rightSwipeView.AddView(deleteView, sfGrid.MaxSwipeOffset, (int)sfGrid.RowHeight);

            sfGrid.LeftSwipeView  = leftSwipeView;
            sfGrid.RightSwipeView = rightSwipeView;
            sfGrid.SwipeEnded    += sfGrid_SwipeEnded;
            sfGrid.SwipeStarted  += sfGrid_SwipeStarted;

            GridTextColumn CustomerID = new GridTextColumn();

            CustomerID.MappingName = "CustomerID";
            CustomerID.HeaderText  = "Customer ID";
            GridTextColumn OrderID = new GridTextColumn();

            OrderID.MappingName      = "OrderID";
            OrderID.HeaderText       = "Order ID";
            OrderID.TextMargin       = new Thickness(16, 0, 0, 0);
            OrderID.HeaderTextMargin = new Thickness(16, 0, 0, 0);

            GridTextColumn EmployeeID = new GridTextColumn();

            EmployeeID.MappingName = "EmployeeID";
            EmployeeID.HeaderText  = "Employee ID";
            GridTextColumn Name = new GridTextColumn();

            Name.MappingName = "FirstName";
            Name.HeaderText  = "Name";

            sfGrid.Columns.Add(OrderID);
            sfGrid.Columns.Add(CustomerID);
            sfGrid.Columns.Add(EmployeeID);
            sfGrid.Columns.Add(Name);
            sfGrid.VerticalOverScrollMode = VerticalOverScrollMode.None;
            parentLayout.AddView(sfGrid);

            editor.SetBackgroundColor(Color.White);
            editor.Orientation = Android.Widget.Orientation.Vertical;
            optionHeading.Text = "EDIT DETAILS";
            optionHeading.SetTypeface(null, TypefaceStyle.Bold);
            optionHeading.Gravity = GravityFlags.Center;

            bodyRow1.AddView(col1, (int)(100 * sfGrid.Resources.DisplayMetrics.Density), (int)(50 * sfGrid.Resources.DisplayMetrics.Density));
            bodyRow1.AddView(orderIDText, (int)(100 * sfGrid.Resources.DisplayMetrics.Density), ViewGroup.LayoutParams.WrapContent);
            bodyRow2.AddView(col2, (int)(100 * sfGrid.Resources.DisplayMetrics.Density), (int)(50 * sfGrid.Resources.DisplayMetrics.Density));
            bodyRow2.AddView(customerIDText, (int)(100 * sfGrid.Resources.DisplayMetrics.Density), ViewGroup.LayoutParams.WrapContent);
            bodyRow3.AddView(col3, (int)(100 * sfGrid.Resources.DisplayMetrics.Density), (int)(50 * sfGrid.Resources.DisplayMetrics.Density));
            bodyRow3.AddView(employeeIDText, (int)(100 * sfGrid.Resources.DisplayMetrics.Density), ViewGroup.LayoutParams.WrapContent);
            bodyRow4.AddView(col4, (int)(100 * sfGrid.Resources.DisplayMetrics.Density), (int)(50 * sfGrid.Resources.DisplayMetrics.Density));
            bodyRow4.AddView(nameText, (int)(100 * sfGrid.Resources.DisplayMetrics.Density), ViewGroup.LayoutParams.WrapContent);

            body.Orientation = Android.Widget.Orientation.Vertical;
            body.SetGravity(GravityFlags.CenterHorizontal);
            body.AddView(bodyRow1);
            body.AddView(bodyRow2);
            body.AddView(bodyRow3);
            body.AddView(bodyRow4);

            save.Text          = "Save";
            cancel.Text        = "Cancel";
            bottom.Orientation = Android.Widget.Orientation.Horizontal;
            bottom.AddView(save);
            bottom.AddView(cancel);
            bottom.SetGravity(GravityFlags.Center);

            editor.AddView(optionHeading);
            editor.AddView(body);
            editor.AddView(bottom);
            optionView.AddView(editor, ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent);
            if (parentLayout.ChildCount == 1)
            {
                parentLayout.AddView(optionView, 1);
            }
            parentLayout.GetChildAt(0).Visibility = ViewStates.Visible;
            parentLayout.GetChildAt(1).Visibility = ViewStates.Invisible;
            return(parentLayout);
        }
Beispiel #3
0
        private void CreateDataGrid()
        {
            deleteView = new LinearLayout(cont);
            deleteView.TextAlignment = TextAlignment.Center;
            deleteView.Orientation   = Android.Widget.Orientation.Horizontal;
            deleteView.Click        += swipeViewImage_Click;

            ImageView deleteImage = new ImageView(cont);

            deleteImage.SetImageResource(Resource.Drawable.Delete);
            deleteImage.SetBackgroundColor(Color.ParseColor("#EF5350"));

            TextView delete = new TextView(cont);

            delete.Text          = "DELETE";
            delete.TextAlignment = TextAlignment.Center;
            delete.SetPadding((int)(16 * density), (int)(10 * density), (int)(10 * density), 0);
            delete.SetTextColor(Color.White);
            delete.SetBackgroundColor(Color.ParseColor("#EF5350"));

            viewModel = new SwipingViewModel();
            viewModel.SetRowstoGenerate(100);

            sfGrid = new SfDataGrid(cont);
            sfGrid.AutoGenerateColumns = false;
            sfGrid.ItemsSource         = (viewModel.OrdersInfo);
            sfGrid.AllowSwiping        = true;
            sfGrid.AllowSorting        = true;
            sfGrid.AllowResizingColumn = true;
            sfGrid.AllowDraggingRow    = true;
            sfGrid.ColumnSizer         = ColumnSizer.Star;
            sfGrid.GridLoaded         += SfGrid_GridLoaded;
            sfGrid.SwipeEnded         += SfGrid_SwipeEnded;

            int width = cont.Resources.DisplayMetrics.WidthPixels;

            sfGrid.MaxSwipeOffset = (int)(120 * density);
            leftSwipeView         = new SwipeView(cont);

            deleteView.AddView(deleteImage, (int)(30 * density), (int)sfGrid.RowHeight);
            deleteView.AddView(delete, sfGrid.MaxSwipeOffset - 30, (int)sfGrid.RowHeight);

            leftSwipeView.AddView(deleteView, sfGrid.MaxSwipeOffset, (int)sfGrid.RowHeight);

            sfGrid.LeftSwipeView = leftSwipeView;

            GridTextColumn CustomerID = new GridTextColumn();

            CustomerID.MappingName = "CustomerID";
            CustomerID.HeaderText  = "Customer ID";
            GridTextColumn OrderID = new GridTextColumn();

            OrderID.MappingName      = "OrderID";
            OrderID.HeaderText       = "Order ID";
            OrderID.TextMargin       = new Thickness(16, 0, 0, 0);
            OrderID.HeaderTextMargin = new Thickness(16, 0, 0, 0);

            GridTextColumn EmployeeID = new GridTextColumn();

            EmployeeID.MappingName = "EmployeeID";
            EmployeeID.HeaderText  = "Employee ID";
            GridTextColumn Name = new GridTextColumn();

            Name.MappingName = "FirstName";
            Name.HeaderText  = "Name";

            sfGrid.Columns.Add(OrderID);
            sfGrid.Columns.Add(CustomerID);
            sfGrid.Columns.Add(EmployeeID);
            sfGrid.Columns.Add(Name);
            sfGrid.VerticalOverScrollMode = VerticalOverScrollMode.None;
        }
Beispiel #4
0
        public override Android.Views.View GetSampleContent(Android.Content.Context context)
        {
            FrameLayout frame = new FrameLayout(context);

            linear = new LinearLayout(context);
            linear.LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent);
            linear.Orientation      = Orientation.Horizontal;

            TextView swipeViewUndo = new TextView(context);

            swipeViewUndo.Text = "UNDO";
            swipeViewUndo.SetTypeface(swipeViewUndo.Typeface, TypefaceStyle.Bold);
            swipeViewUndo.Gravity = GravityFlags.Center;
            swipeViewUndo.SetTextColor(Color.White);
            swipeViewUndo.SetBackgroundColor(Color.ParseColor("#1AAA87"));
            swipeViewUndo.Click += swipeViewUndo_Click;

            TextView swipeViewText = new TextView(context);

            swipeViewText.SetPadding((int)(25 * context.Resources.DisplayMetrics.Density), 0, 0, 0);
            swipeViewText.Text    = "Deleted";
            swipeViewText.Gravity = GravityFlags.CenterVertical | GravityFlags.Left;
            swipeViewText.SetTextColor(Color.White);
            swipeViewText.SetBackgroundColor(Color.ParseColor("#1AAA87"));
            linear.SetBackgroundColor(Color.ParseColor("#1AAA87"));

            viewModel = new SwipingViewModel();
            viewModel.SetRowstoGenerate(100);

            sfGrid = new SfDataGrid(context);
            sfGrid.AutoGenerateColumns = false;
            sfGrid.ItemsSource         = (viewModel.OrdersInfo);
            sfGrid.AllowSwiping        = true;
            sfGrid.ColumnSizer         = ColumnSizer.Star;

            DisplayMetrics metrics = context.Resources.DisplayMetrics;
            int            width   = metrics.WidthPixels;

            sfGrid.MaxSwipeOffset = width;
            swipe = new SwipeView(context);
            var undoWidth = (int)(100 * context.Resources.DisplayMetrics.Density);

            linear.AddView(swipeViewText, (sfGrid.MaxSwipeOffset - undoWidth), (int)sfGrid.RowHeight);
            linear.AddView(swipeViewUndo, undoWidth, (int)sfGrid.RowHeight);
            swipe.SetBackgroundColor(Color.ParseColor("#1AAA87"));
            swipe.AddView(linear);
            sfGrid.LeftSwipeView  = swipe;
            sfGrid.RightSwipeView = swipe;
            sfGrid.SwipeEnded    += sfGrid_SwipeEnded;
            sfGrid.SwipeStarted  += sfGrid_SwipeStarted;

            GridTextColumn CustomerID = new GridTextColumn();

            CustomerID.MappingName = "CustomerID";
            CustomerID.HeaderText  = "Customer ID";
            GridTextColumn OrderID = new GridTextColumn();

            OrderID.MappingName = "OrderID";
            OrderID.HeaderText  = "Order ID";
            GridTextColumn EmployeeID = new GridTextColumn();

            EmployeeID.MappingName = "EmployeeID";
            EmployeeID.HeaderText  = "Employee ID";
            GridTextColumn Name = new GridTextColumn();

            Name.MappingName = "FirstName";
            Name.HeaderText  = "Name";

            sfGrid.Columns.Add(OrderID);
            sfGrid.Columns.Add(CustomerID);
            sfGrid.Columns.Add(EmployeeID);
            sfGrid.Columns.Add(Name);
            frame.AddView(sfGrid);
            return(frame);
        }