protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.View> e) { base.OnElementChanged(e); if (Control == null) { // Instantiate the native control and assign it to the Control property with // the SetNativeControl method progressView = new RadialProgressView(getLabelText, RadialProgressViewStyle.Small); SetNativeControl(progressView); } if (e.OldElement != null) { // Unsubscribe from event handlers and cleanup any resources progressView.LabelTextDelegate = null; progressView.Dispose(); progressView = null; formsControl = null; } if (e.NewElement != null) { // Configure the control and subscribe to event handlers formsControl = e.NewElement as ProgressView; var percentValue = formsControl.PercentComplete / 100.0f; progressView.LabelTextDelegate = (arg) => formsControl.LabelText; progressView.Value = percentValue; progressView.Center = new PointF((float)formsControl.Bounds.Center.X, (float)formsControl.Bounds.Center.Y - 100); if (formsControl.LabelStyle.ToLower().Equals("failure")) { progressView.ProgressColor = formsControl.FailureProgressColor.ToUIColor(); RadialProgressLayer.BackCircleBackgroundColor = formsControl.FailureBackgroundColor.ToCGColor(); progressView.InitSubviews(); } else if (formsControl.LabelStyle.ToLower().Equals("complete")) { progressView.ProgressColor = formsControl.SuccessProgressColor.ToUIColor(); RadialProgressLayer.BackCircleBackgroundColor = formsControl.SuccessBackgroundColor.ToCGColor(); progressView.InitSubviews(); } else { progressView.ProgressColor = RadialProgressLayer.DefaultFillColor; RadialProgressLayer.BackCircleBackgroundColor = RadialProgressLayer.DefaultBackgroundColor; progressView.InitSubviews(); } } }
protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.View> e) { base.OnElementChanged(e); if (Control == null) { progressView = new RadialProgressView(Context, labelTextFunc: getLabelText, progressType: RadialProgressViewStyle.Small); progressView.SetPadding(20, 20, 20, 20); SetNativeControl(progressView); } if (e.OldElement != null) { // Unsubscribe from event handlers and cleanup any resources progressView.LabelTextDelegate = null; progressView.Dispose(); progressView = null; formsControl = null; } if (e.NewElement != null) { // Configure the control and subscribe to event handlers formsControl = e.NewElement as ProgressView; var percentValue = formsControl.PercentComplete / 100.0f; if (formsControl.LabelStyle.ToLower().Equals("failure")) { progressView.ProgressColor = formsControl.FailureProgressColor.ToAndroid(); RadialProgressView.CircleBackgroundColor = formsControl.FailureBackgroundColor.ToAndroid(); progressView.InitPaints(); } else if (formsControl.LabelStyle.ToLower().Equals("complete")) { progressView.ProgressColor = formsControl.SuccessProgressColor.ToAndroid(); RadialProgressView.CircleBackgroundColor = formsControl.SuccessBackgroundColor.ToAndroid(); progressView.InitPaints(); } else { progressView.ProgressColor = RadialProgressView.DefaultColor; RadialProgressView.CircleBackgroundColor = RadialProgressView.DefaultCircleBackgroundColor; progressView.InitPaints(); } progressView.Value = percentValue; } }
protected override void Dispose(bool disposing) { if (disposing) { if (_innerView != null) { _innerView.Dispose(); _innerView = null; } if (_jobName != null) { _jobName.Dispose(); _jobName = null; } if (_companyName != null) { _companyName.Dispose(); _companyName = null; } if (_officeLocation != null) { _officeLocation.Dispose(); _officeLocation = null; } if (_dueDateView != null) { _dueDateView.Dispose(); _dueDateView = null; } if (_jobStatusView != null) { _jobStatusView.Dispose(); _jobStatusView = null; } if (_rightDueDateDivider != null) { _rightDueDateDivider.Dispose(); _rightDueDateDivider = null; } if (_lightsContainerView != null) { _lightsContainerView.Dispose(); _lightsContainerView = null; } if (_greenLightView != null) { _greenLightView.Dispose(); _greenLightView = null; } if (_yellowLightView != null) { _yellowLightView.Dispose(); _yellowLightView = null; } if (_redLightView != null) { _redLightView.Dispose(); _redLightView = null; } if (_tasksInProgressView != null) { _tasksInProgressView.Dispose(); _tasksInProgressView = null; } if (_tasksInProgressSeperatorView != null) { _tasksInProgressSeperatorView.Dispose(); _tasksInProgressSeperatorView = null; } if (_tasksInReviewView != null) { _tasksInReviewView.Dispose(); _tasksInReviewView = null; } if (_tasksInReviewSeperatorView != null) { _tasksInReviewSeperatorView.Dispose(); _tasksInReviewSeperatorView = null; } if (_tasksForReviewView != null) { _tasksForReviewView.Dispose(); _tasksForReviewView = null; } if (_tasksForReviewSeperatorView != null) { _tasksForReviewSeperatorView.Dispose(); _tasksForReviewSeperatorView = null; } if (_tasksToDoView != null) { _tasksToDoView.Dispose(); _tasksToDoView = null; } if (_tasksInProgressHeader != null) { _tasksInProgressHeader.Dispose(); _tasksInProgressHeader = null; } if (_tasksInReviewHeader != null) { _tasksInReviewHeader.Dispose(); _tasksInReviewHeader = null; } if (_tasksForReviewHeader != null) { _tasksForReviewHeader.Dispose(); _tasksForReviewHeader = null; } if (_tasksToDoHeader != null) { _tasksToDoHeader.Dispose(); _tasksToDoHeader = null; } if (_tasksInProgress != null) { _tasksInProgress.Dispose(); _tasksInProgress = null; } if (_tasksInReview != null) { _tasksInReview.Dispose(); _tasksInReview = null; } if (_tasksForReview != null) { _tasksForReview.Dispose(); _tasksForReview = null; } if (_tasksToDo != null) { _tasksToDo.Dispose(); _tasksToDo = null; } if (_topDivider != null) { _topDivider.Dispose(); _topDivider = null; } if (_middleDivider != null) { _middleDivider.Dispose(); _middleDivider = null; } if (_bottomDivider != null) { _bottomDivider.Dispose(); _bottomDivider = null; } if (_percentPrepView != null) { _percentPrepView.Dispose(); _percentPrepView = null; } if (_percentWorkView != null) { _percentWorkView.Dispose(); _percentWorkView = null; } if (_percentDeliveryView != null) { _percentDeliveryView.Dispose(); _percentDeliveryView = null; } if (_percentPrepHeader != null) { _percentPrepHeader.Dispose(); _percentPrepHeader = null; } if (_percentWorkHeader != null) { _percentWorkHeader.Dispose(); _percentWorkHeader = null; } if (_percentDeliveryHeader != null) { _percentDeliveryHeader.Dispose(); _percentDeliveryHeader = null; } if (_percentPrepRadialView != null) { _percentPrepRadialView.Dispose(); _percentPrepRadialView = null; } if (_percentWorkRadialView != null) { _percentWorkRadialView.Dispose(); _percentWorkRadialView = null; } if (_percentDeliveryRadialView != null) { _percentDeliveryRadialView.Dispose(); _percentDeliveryRadialView = null; } } base.Dispose(disposing); }