Beispiel #1
0
        private async void LoadData()
        {
            var cv = new C1DataCollection <Customer>(Customer.GetCustomerList(100));
            await cv.SortAsync(new SortDescription("FirstName", SortDirection.Ascending), new SortDescription("LastName", SortDirection.Descending));

            grid.ItemsSource = cv;
        }
Beispiel #2
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            // Perform any additional setup after loading the view, typically from a nib.

            sunburst = new C1Sunburst();

            sunburst.Binding            = "Value";
            sunburst.BindingName        = "Year,Quarter,Month";
            sunburst.ToolTipContent     = "{}{name}\n{y}";
            sunburst.DataLabel.Position = PieLabelPosition.Center;
            sunburst.DataLabel.Content  = "{}{name}";
            this.Add(sunburst);

            cv = new SunburstViewModel().View;
            cv.GroupChanged += View_GroupChanged;
            cv.SortChanged  += Cv_SortChanged;

            //Sort cannot work synchronize with group in current DataCollection
            SortDescription yearSortDescription    = new SortDescription("Year", SortDirection.Ascending);
            SortDescription quarterSortDescription = new SortDescription("Quarter", SortDirection.Ascending);
            SortDescription monthSortDescription   = new SortDescription("MonthValue", SortDirection.Ascending);

            SortDescription[] sortDescriptions = new SortDescription[] { yearSortDescription, quarterSortDescription, monthSortDescription };
            cv.SortAsync(sortDescriptions);
        }
 async void OnSortClicked(object sender, EventArgs e)
 {
     if (_dataCollection != null)
     {
         var direction = GetCurrentSortDirection();
         await _dataCollection.SortAsync(x => x.Title, direction == SortDirection.Ascending?SortDirection.Descending : SortDirection.Ascending);
     }
 }
Beispiel #4
0
 private async void sortButton_Click(object sender, EventArgs e)
 {
     if (_dataCollection != null)
     {
         var direction = GetCurrentSortDirection();
         await _dataCollection.SortAsync(x => x.FirstName, direction == SortDirection.Ascending?SortDirection.Descending : SortDirection.Ascending);
     }
 }
        private async void LoadData()
        {
            var cv = new C1DataCollection <Customer>(Customer.GetCustomerList(100));
            await cv.SortAsync(new SortDescription("FirstName", SortDirection.Ascending), new SortDescription("LastName", SortDirection.Descending));

            grid.ItemsSource = cv;
            grid.SortAscendingIconTemplate = new C1IconTemplate(() => new C1BitmapIcon(this.ApplicationContext)
            {
                Source = BitmapFactory.DecodeResource(this.Resources, Resource.Drawable.arrow_up)
            });
        }
        private async void LoadData()
        {
            var dataCollection = new C1DataCollection <Customer>(Customer.GetCustomerList(100));
            await dataCollection.SortAsync(new SortDescription("FirstName", SortDirection.Ascending), new SortDescription("LastName", SortDirection.Descending));

            Grid.ItemsSource = dataCollection;
            Grid.SortAscendingIconTemplate = new C1IconTemplate(() => new C1BitmapIcon()
            {
                Source = UIImage.FromBundle("arrow_up")
            });
        }
Beispiel #7
0
        private async Task ToggleSort(IMenuItem item)
        {
            if (_dataCollection != null)
            {
                var direction = GetCurrentSortDirection();
                item.SetEnabled(false);
                var newDirection = direction == SortDirection.Ascending ? SortDirection.Descending : SortDirection.Ascending;
                await _dataCollection.SortAsync(x => x.Title, newDirection);

                item.SetEnabled(true);
                InvalidateOptionsMenu();
            }
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_getting_started);
            var toolbar = FindViewById <Toolbar>(Resource.Id.toolbar);

            SetSupportActionBar(toolbar);
            SupportActionBar.Title = GetString(Resource.String.group_collection);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            SupportActionBar.SetHomeButtonEnabled(true);

            sunburst = (C1Sunburst)FindViewById(Resource.Id.sunburst);

            sunburst.Binding            = "Value";
            sunburst.BindingName        = "Year,Quarter,Month";
            sunburst.ToolTipContent     = "{}{name}\n{y}";
            sunburst.DataLabel.Position = PieLabelPosition.Center;
            sunburst.DataLabel.Content  = "{}{name}";

            //LinearLayout layout = new LinearLayout(this);
            //LinearLayout.LayoutParams param = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MatchParent, LinearLayout.LayoutParams.MatchParent);
            //layout.AddView(sunburst, param);


            cv = new SunburstViewModel().View;
            cv.GroupChanged += View_GroupChanged;
            cv.SortChanged  += Cv_SortChanged;

            //Sort cannot work synchronize with group in current DataCollection
            SortDescription yearSortDescription    = new SortDescription("Year", SortDirection.Ascending);
            SortDescription quarterSortDescription = new SortDescription("Quarter", SortDirection.Ascending);
            SortDescription monthSortDescription   = new SortDescription("MonthValue", SortDirection.Ascending);

            SortDescription[] sortDescriptions = new SortDescription[] { yearSortDescription, quarterSortDescription, monthSortDescription };
            cv.SortAsync(sortDescriptions);
            //SetContentView(layout);
        }
Beispiel #9
0
        private async void PopulateEditGrid()
        {
            // create the data
            var data = new C1DataCollection <Customer>(Customer.GetCustomerList(100));
            await data.SortAsync("Name");

            grid.ItemsSource    = data;
            grid.MinColumnWidth = 85;

            //// hide read-only "Country" column
            //var col = grid.Columns["Country"];
            //col.IsVisible = false;
            GridColumn col;

            //// map countryID column so it shows country names instead of their IDs
            //Dictionary<int, string> dct = new Dictionary<int, string>();
            //foreach (var country in Customer.GetCountries())
            //{
            //    dct[country.Key] = country.Value;
            //}
            //col = grid.Columns["CountryId"];
            //col.DataMap = new GridDataMap { ItemsSource = dct, SelectedValuePath = "Key", DisplayMemberPath = "Value" };
            //col.HorizontalAlignment = HorizontalAlignment.Left;
            //col.Width = new GridLength(120);

            // provide auto-complete lists for first and last name columns
            col         = grid.Columns["FirstName"];
            col.DataMap = new GridDataMap {
                ItemsSource = Customer.GetFirstNames()
            };
            col         = grid.Columns["LastName"];
            col.DataMap = new GridDataMap {
                ItemsSource = Customer.GetLastNames()
            };

            //grid.Columns.Move(grid.Columns["Name"].Index, 1);
        }
        public static C1DataCollection <Item> CreateGroupDataCollection()
        {
            var data     = new List <Item>();
            var quarters = new string[] { "Q1", "Q2", "Q3", "Q4" };
            var months   = new[]
            {
                new { Name = "Jan", Value = 1 },
                new { Name = "Feb", Value = 2 },
                new { Name = "Mar", Value = 3 },
                new { Name = "Apr", Value = 4 },
                new { Name = "May", Value = 5 },
                new { Name = "June", Value = 6 },
                new { Name = "Jul", Value = 7 },
                new { Name = "Aug", Value = 8 },
                new { Name = "Sep", Value = 9 },
                new { Name = "Oct", Value = 10 },
                new { Name = "Nov", Value = 11 },
                new { Name = "Dec", Value = 12 }
            };
            var year = DateTime.Now.Year;
            int yearLen, i, len = 100;
            var years = new List <int>();

            yearLen = 3;

            for (i = yearLen; i > 0; i--)
            {
                years.Add(year - i);
            }

            int y, q, m;

            for (i = 0; i < len; i++)
            {
                y = (int)Math.Floor(Instance.rnd.NextDouble() * yearLen);
                q = (int)Math.Floor(Instance.rnd.NextDouble() * 4);
                m = (int)Math.Floor(Instance.rnd.NextDouble() * 3);

                data.Add(new Item()
                {
                    Year       = years[y],
                    Quarter    = quarters[q],
                    MonthName  = months[q].Name,
                    MonthValue = months[q].Value,
                    Value      = Math.Round(Instance.rnd.NextDouble() * 100)
                });
            }
            var cv = new C1DataCollection <Item>(data);

            //Sort cannot work synchronize with group in current DataCollection
            SortDescription yearSortDescription    = new SortDescription("Year", SortDirection.Ascending);
            SortDescription quarterSortDescription = new SortDescription("Quarter", SortDirection.Ascending);
            SortDescription monthSortDescription   = new SortDescription("MonthValue", SortDirection.Ascending);

            SortDescription[] sortDescriptions = new SortDescription[] { yearSortDescription, quarterSortDescription, monthSortDescription };
            cv.SortAsync(sortDescriptions);

            GroupDescription yearGroupDescription    = new GroupDescription("Year");
            GroupDescription quarterGroupDescription = new GroupDescription("Quarter");
            GroupDescription monthGroupDescription   = new GroupDescription("MonthName");

            GroupDescription[] groupDescriptions = new GroupDescription[] { yearGroupDescription, quarterGroupDescription, monthGroupDescription };
            //   cv.GroupAsync(groupDescriptions);

            return(cv);
        }