Example #1
0
        private void Initialize (Context ctx)
        {
            var dm = ctx.Resources.DisplayMetrics;
            var inflater = LayoutInflater.FromContext (ctx);

            overlayInset = (int)TypedValue.ApplyDimension (ComplexUnitType.Dip, 45, dm);

            backgroundView = new SliceView (ctx) {
                StartAngle = 0,
                EndAngle = 360,
                Color = emptyPieColor,
            };
            AddView (backgroundView);

            loadingOverlayView = inflater.Inflate (Resource.Layout.PieChartLoading, this, false);
            AddView (loadingOverlayView);

            emptyOverlayView = inflater.Inflate (Resource.Layout.PieChartEmpty, this, false);
            emptyOverlayView.Visibility = ViewStates.Gone;
            AddView (emptyOverlayView);

            statsOverlayView = inflater.Inflate (Resource.Layout.PieChartStats, this, false);
            statsOverlayView.Visibility = ViewStates.Gone;
            AddView (statsOverlayView);

            statsTimeTextView = statsOverlayView.FindViewById<TextView> (Resource.Id.TimeTextView);
            statsMoneyTextView = statsOverlayView.FindViewById<TextView> (Resource.Id.MoneyTextView);

            Click += delegate {
                // Deselect slices on click. The Clickable property is set to true only when a slice is selected.
                ActiveSlice = -1;
            };
            Clickable = false;
        }
Example #2
0
        private void Initialize(Context ctx)
        {
            var dm       = ctx.Resources.DisplayMetrics;
            var inflater = LayoutInflater.FromContext(ctx);

            overlayInset = (int)TypedValue.ApplyDimension(ComplexUnitType.Dip, 45, dm);

            backgroundView = new SliceView(ctx)
            {
                StartAngle = 0,
                EndAngle   = 360,
                Color      = emptyPieColor,
            };
            AddView(backgroundView);

            loadingOverlayView = inflater.Inflate(Resource.Layout.PieChartLoading, this, false);
            AddView(loadingOverlayView);

            emptyOverlayView            = inflater.Inflate(Resource.Layout.PieChartEmpty, this, false);
            emptyOverlayView.Visibility = ViewStates.Gone;
            AddView(emptyOverlayView);

            statsOverlayView            = inflater.Inflate(Resource.Layout.PieChartStats, this, false);
            statsOverlayView.Visibility = ViewStates.Gone;
            AddView(statsOverlayView);

            statsTimeTextView  = statsOverlayView.FindViewById <TextView> (Resource.Id.TimeTextView);
            statsMoneyTextView = statsOverlayView.FindViewById <TextView> (Resource.Id.MoneyTextView);

            Click += delegate {
                // Deselect slices on click. The Clickable property is set to true only when a slice is selected.
                ActiveSlice = -1;
            };
            Clickable = false;
        }
Example #3
0
        private void ResetSlices(int neededSlices)
        {
            var existingSlices = slices.Count;
            var totalRows      = (int)Math.Max(existingSlices, neededSlices);
            var expandSlices   = neededSlices > existingSlices;
            var contractSlices = existingSlices > neededSlices;

            if (expandSlices)
            {
                for (var i = existingSlices; i < totalRows; i++)
                {
                    // Create new row
                    var slice = new SliceView(Context);
                    slice.Click += OnSliceClicked;
                    slices.Add(slice);

                    // Add new slice views
                    AddView(slice, 1 + i);
                }
            }
            else if (contractSlices)
            {
                // Remove unused rows and views
                var sliceCount = existingSlices - neededSlices;
                for (var i = neededSlices; i < existingSlices; i++)
                {
                    var slice = slices [0];
                    slice.Click -= OnSliceClicked;
                }
                slices.RemoveRange(neededSlices, sliceCount);

                var startIndex = 1 + neededSlices;
                var viewCount  = sliceCount;
                RemoveViews(startIndex, viewCount);
            }
        }
Example #4
0
        private void ResetSlices (int neededSlices)
        {
            var existingSlices = slices.Count;
            var totalRows = (int)Math.Max (existingSlices, neededSlices);
            var expandSlices = neededSlices > existingSlices;
            var contractSlices = existingSlices > neededSlices;

            if (expandSlices) {
                for (var i = existingSlices; i < totalRows; i++) {
                    // Create new row
                    var slice = new SliceView (Context);
                    slice.Click += OnSliceClicked;
                    slices.Add (slice);

                    // Add new slice views
                    AddView (slice, 1 + i);
                }
            } else if (contractSlices) {
                // Remove unused rows and views
                var sliceCount = existingSlices - neededSlices;
                for (var i = neededSlices; i < existingSlices; i++) {
                    var slice = slices [0];
                    slice.Click -= OnSliceClicked;
                }
                slices.RemoveRange (neededSlices, sliceCount);

                var startIndex = 1 + neededSlices;
                var viewCount = sliceCount;
                RemoveViews (startIndex, viewCount);
            }
        }