Example #1
0
        private static bool IsSymbolValid(MaskType mask, string str)
        {
            switch (mask)
            {
                case MaskType.Any:
                    return true;

                case MaskType.Integer:
                    if (str == NumberFormatInfo.CurrentInfo.NegativeSign)
                        return true;
                    break;

                case MaskType.Decimal:
                    if (str == NumberFormatInfo.CurrentInfo.NumberDecimalSeparator ||
                        str == NumberFormatInfo.CurrentInfo.NegativeSign)
                        return true;
                    break;
            }

            if (mask.Equals(MaskType.Integer) || mask.Equals(MaskType.Decimal))
            {
                foreach (char ch in str)
                {
                    if (!Char.IsDigit(ch))
                        return false;
                }

                return true;
            }

            return false;
        }
Example #2
0
		public void Show (Context context, string status = null, int progress = -1, MaskType maskType = MaskType.Black, TimeSpan? timeout = null, Action clickCallback = null, bool centered = true, Action cancelCallback = null)
		{
			if (progress >= 0)
				showProgress (context, progress, status, maskType, timeout, clickCallback, cancelCallback);
			else
				showStatus (context, true, status, maskType, timeout, clickCallback, centered, cancelCallback);
		}
		public virtual IProgressDialog Progress(string title, Action onCancel, string cancelText, bool show, MaskType? maskType) {
			return this.Progress(new ProgressDialogConfig {
                Title = title ?? ProgressDialogConfig.DefaultTitle,
                AutoShow = show,
                CancelText = cancelText ?? ProgressDialogConfig.DefaultCancelText,
				MaskType = maskType ?? ProgressDialogConfig.DefaultMaskType,
                IsDeterministic = true,
                OnCancel = onCancel
            });
        }
Example #4
0
        /// <summary>
        /// Adiciona a máscara escolhida.
        /// </summary>
        /// <param name="Type">Tipo de máscara</param>
        /// <param name="Value">Valor que receberá a máscara.</param>
        /// <returns>Retorna o valor com a máscara escolhida aplicada.</returns>
        public static String AddMask(MaskType Type, String Value)
        {
            if (!string.IsNullOrEmpty(Value))
                switch (Type)
                {
                    case MaskType.CPF:
                        if (Value.Length == 11)
                            Value = string.Format("{0}.{1}.{2}-{3}", Value.Substring(0, 3), Value.Substring(3, 3), Value.Substring(6, 3), Value.Substring(9, 2));
                        break;
                    case MaskType.CNPJ:
                        if (Value.Length == 14)
                            Value = string.Format("{0}.{1}.{2}/{3}-{4}", Value.Substring(0, 2), Value.Substring(2, 3), Value.Substring(5, 3), Value.Substring(8, 4), Value.Substring(12, 2));
                        break;
                }

            return Value;
        }
Example #5
0
        /// <summary>Generates and applies gradient mask to cloned <see cref="System.Drawing.Bitmap"/>.</summary>
        /// <param name="type"><see cref="MaskType"/> specifies which type of mask to generate.</param>
        /// <param name="width">Width or height of gradient rectangle.</param>
        public void ApplyMask(MaskType type, int width = 20)
        {
            // First of all, generating mask
            GenerateMask(type, width);

            // Right after, applying generated mask to bitmap
            for (var x = 0; x < Bitmap.Width; x++) {
                for (var y = 0; y < Bitmap.Height; y++) {

                    // Reading pixels from both, mask and target bitmaps
                    var msk = Mask.GetPixel(x, y);
                    var bmp = Bitmap.GetPixel(x, y);

                    // Calculating alpha-value
                    var alpha = (msk.A * 100) / 255;
                    alpha = (bmp.A * alpha) / 100;
                    alpha = Math.Min(255, Math.Max(0, alpha));

                    // Setting pixel with same colors except alpha
                    Bitmap.SetPixel(x, y, Color.FromArgb(alpha, bmp));

                }
            }
        }
 public static void SetMask(DependencyObject obj, MaskType value)
 {
     obj.SetValue(MaskProperty, value);
 }
Example #7
0
        protected override void Initialize()
        {
            SLText = new Text(GraphicsDevice, Services, SLConfig["content"], "Arial");
            Timer = new SLTimer();
            Timer.Start();
            Input = new SLInput();

            BarPara bpara = BarPara.Default;
            bpara.width = 3.5f;
            bpara.height = 0.7f;
            bpara.BasePara.orientation = 90.0f;
            Bar = new Bar(GraphicsDevice, bpara);

            GratingPara gpara = GratingPara.Default;
            gpara.BasePara.diameter = 2.0f;
            gpara.sf = 0.8f;
            gpara.tf = 3.0f;
            Grating = new Grating(GraphicsDevice, Services, SLConfig["content"], gpara);
            GratingType = Grating.Para.gratingtype;
            GratingShape = Grating.Para.shape;
            GratingMask = Grating.Para.maskpara.masktype;

            Cross = new Primitive(GraphicsDevice, PrimitivePara.Cross(1.0f, Color.Black, Vector3.Zero));

            Bgcolor = Color.DimGray;
            CurrentSti = VSType.Bar;
            HelpText = 0;
        }
Example #8
0
 /// <summary>
 /// Initialize Mask Parameters
 /// </summary>
 /// <param name="basepara"></param>
 /// <param name="masktype"></param>
 public MaskPara(vsBasePara basepara, MaskType masktype)
 {
     basepara.vstype = VSType.Mask;
     this.BasePara = basepara;
     this.masktype = masktype;
 }
Example #9
0
		void showImage(Context context, Android.Graphics.Drawables.Drawable image, string status = null, MaskType maskType = MaskType.Black, TimeSpan? timeout = null, Action clickCallback = null, Action cancelCallback = null)
		{
			if (timeout == null)
				timeout = TimeSpan.Zero;

			if (CurrentDialog != null && imageView == null)
				DismissCurrent (context);

			lock (dialogLock)
			{
				if (CurrentDialog == null)
				{
					SetupDialog (context, maskType, cancelCallback, (a, d, m) => {
						var inflater = LayoutInflater.FromContext(context);
						var view = inflater.Inflate(Resource.Layout.loadingimage, null);

						if (clickCallback != null)
							view.Click += (sender, e) => clickCallback();

						imageView = view.FindViewById<ImageView>(Resource.Id.loadingImage);
						statusText = view.FindViewById<TextView>(Resource.Id.textViewStatus);

						if (maskType != MaskType.Black)
							view.SetBackgroundResource(Resource.Drawable.roundedbgdark);

						imageView.SetImageDrawable(image);

						if (statusText != null)
						{
							statusText.Text = status ?? "";
							statusText.Visibility = string.IsNullOrEmpty(status) ? ViewStates.Gone : ViewStates.Visible;
						}

						return view;
					});

					if (timeout > TimeSpan.Zero)
					{
						Task.Factory.StartNew(() => {
							if (!waitDismiss.WaitOne (timeout.Value))
								DismissCurrent (context);
			
						}).ContinueWith(ct => {
							var ex = ct.Exception;

							if (ex != null)
								Android.Util.Log.Error("AndHUD", ex.ToString());
						}, TaskContinuationOptions.OnlyOnFaulted);
					}
				}
				else
				{
					Application.SynchronizationContext.Send(state => {
						imageView.SetImageDrawable(image);
						statusText.Text = status ?? "";
					}, null);
				}
			}
		}
Example #10
0
 public Mask()
 {
     Type = MaskType.Mask17;
 }
Example #11
0
        void showImage(Context context, Android.Graphics.Drawables.Drawable image, string status = null, MaskType maskType = MaskType.Black, TimeSpan?timeout = null, Action clickCallback = null, Action cancelCallback = null)
        {
            if (timeout == null)
            {
                timeout = TimeSpan.Zero;
            }

            if (CurrentDialog != null && imageView == null)
            {
                DismissCurrent(context);
            }

            lock (dialogLock)
            {
                if (CurrentDialog == null)
                {
                    SetupDialog(context, maskType, cancelCallback, (a, d, m) => {
                        var inflater = LayoutInflater.FromContext(context);
                        var view     = inflater.Inflate(Resource.Layout.loadingimage, null);

                        if (clickCallback != null)
                        {
                            view.Click += (sender, e) => clickCallback();
                        }

                        imageView  = view.FindViewById <ImageView>(Resource.Id.loadingImage);
                        statusText = view.FindViewById <TextView>(Resource.Id.textViewStatus);

                        if (maskType != MaskType.Black)
                        {
                            view.SetBackgroundResource(Resource.Drawable.roundedbgdark);
                        }

                        imageView.SetImageDrawable(image);

                        if (statusText != null)
                        {
                            statusText.Text       = status ?? "";
                            statusText.Visibility = string.IsNullOrEmpty(status) ? ViewStates.Gone : ViewStates.Visible;
                        }

                        return(view);
                    });

                    if (timeout > TimeSpan.Zero)
                    {
                        Task.Factory.StartNew(() => {
                            if (!waitDismiss.WaitOne(timeout.Value))
                            {
                                DismissCurrent(context);
                            }
                        }).ContinueWith(ct => {
                            var ex = ct.Exception;

                            if (ex != null)
                            {
                                Android.Util.Log.Error("AndHUD", ex.ToString());
                            }
                        }, TaskContinuationOptions.OnlyOnFaulted);
                    }
                }
                else
                {
                    Application.SynchronizationContext.Send(state => {
                        imageView.SetImageDrawable(image);
                        statusText.Text = status ?? "";
                    }, null);
                }
            }
        }
Example #12
0
 public IProgressDialog LoadingAlert(string title, bool show, MaskType masktype)
 {
     return(UserDialogs.Instance.Loading(title, null, null, show, masktype));
 }
Example #13
0
 public void ShowLoading(string title = DialogConstants.Loading, MaskType type = MaskType.Black)
 => UserDialogs.Instance.ShowLoading(title, type);
Example #14
0
 public override void Toast(string message, int timeoutSeconds, Action onClick, MaskType maskType)
 {
     UIApplication.SharedApplication.InvokeOnMainThread(() => {
         var ms = timeoutSeconds * 1000;
         BTProgressHUD.ShowToast(
             message,
             maskType.ToNative(),
             false,
             ms
         );
     });
 }
Example #15
0
        async void Loading(MaskType maskType) {
            var cancelSrc = new CancellationTokenSource();

			using (var dlg = UserDialogs.Instance.Loading("Loading", maskType: maskType)) {
                dlg.SetCancel(cancelSrc.Cancel);

                try {
                    await Task.Delay(TimeSpan.FromSeconds(5), cancelSrc.Token);
                }
                catch { }
            }
            this.Result(cancelSrc.IsCancellationRequested ? "Loading Cancelled" : "Loading Complete");
        }
Example #16
0
 public void ShowContinuousProgress(string status = null, MaskType maskType = MaskType.None)
 {
     obj.InvokeOnMainThread(() => ShowProgressWorker(0, status, maskType, false, true, null, null, 1000, true));
 }
Example #17
0
 /// <summary> Unpause all CoRoutines with given CoMask. </summary>
 public static void UnpauseCoRoutines(uint coMask, MaskType maskType)
 {
     OrderToCoRoutinesViaCoMask?.Invoke(CallbackOrder.Unpause, coMask, maskType);
 }
Example #18
0
        protected async override Task OnFirstAfterRenderAsync()
        {
            await JSRunner.InitializeTextEdit(ElementId, ElementRef, MaskType.ToMaskTypeString(), EditMask);

            await base.OnFirstAfterRenderAsync();
        }
Example #19
0
 public void ShowToast(Context context, string status, MaskType maskType = MaskType.Black, TimeSpan?timeout = null, bool centered = true, Action clickCallback = null, Action cancelCallback = null)
 {
     showStatus(context, false, status, maskType, timeout, clickCallback, centered, cancelCallback);
 }
        private static string ValidateValue(MaskType mask, string value, double min, double max)
        {
            if (string.IsNullOrEmpty(value))
                return string.Empty;

            value = value.Trim();
            switch (mask) {
                case MaskType.Integer:
                    try {
                        Convert.ToInt64(value);
                        return value;
                    }
                    catch {
                    }
                    return string.Empty;

                case MaskType.Decimal:
                    try {
                        Convert.ToDouble(value);

                        return value;
                    }
                    catch {
                    }
                    return string.Empty;
            }

            return value;
        }
Example #21
0
 public void ShowImage(Context context, int drawableResourceId, string status = null, MaskType maskType = MaskType.Black, TimeSpan?timeout = null, Action clickCallback = null, Action cancelCallback = null)
 {
     showImage(context, GetDrawable(context, drawableResourceId), status, maskType, timeout, clickCallback, cancelCallback);
 }
Example #22
0
        public void InitBothMode( )
        {
            this.Properties.NullValuePrompt = DummyText;
            this.Properties.AllowNullInput  = DevExpress.Utils.DefaultBoolean.True;

            if (this.Anchor == AnchorStyles.None)
            {
                this.Anchor = AnchorStyles.Left | AnchorStyles.Top;
            }



            if (!String.IsNullOrWhiteSpace(EditMask.ToString()) && !String.IsNullOrWhiteSpace(MaskType.ToString()))
            {
                this.Properties.Mask.UseMaskAsDisplayFormat = true;
            }

            this.Properties.NullValuePromptShowForEmptyValue = true;

            if (this.RightToLeft == System.Windows.Forms.RightToLeft.Yes)
            {
                this.Properties.Appearance.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Far;
            }

            this.Properties.Buttons[1].Visible = false;
        }
 static ProgressDialogConfig() {
     DefaultTitle = "Loading";
     DefaultCancelText = "Cancel";
     DefaultMaskType = MaskType.Black;
 }
Example #24
0
		public void ShowImage(Context context, int drawableResourceId, string status = null, MaskType maskType = MaskType.Black, TimeSpan? timeout = null, Action clickCallback = null, Action cancelCallback = null)
		{
			showImage (context, context.Resources.GetDrawable(drawableResourceId), status, maskType, timeout, clickCallback, cancelCallback);
		}
Example #25
0
 public void ShowContinuousProgressTest(string status = null, MaskType maskType = MaskType.None, double timeoutMs = 1000)
 {
     obj.InvokeOnMainThread(() => ShowProgressWorker(0, status, maskType, false, ToastPosition.Center, null, null, timeoutMs, true));
 }
Example #26
0
 public static void Show(string status = null, float progress = -1, MaskType maskType = MaskType.None)
 {
     obj.InvokeOnMainThread (() => SharedView.ShowProgressWorker (progress, status, maskType));
 }
Example #27
0
		public void ShowToast(Context context, string status, MaskType maskType = MaskType.Black, TimeSpan? timeout = null, bool centered = true, Action clickCallback = null, Action cancelCallback = null)
		{
			showStatus (context, false, status, maskType, timeout, clickCallback, centered, cancelCallback);
		}
Example #28
0
 public void ShowToast(string status, MaskType maskType = MaskType.None, ToastPosition toastPosition = ToastPosition.Center, double timeoutMs = 1000)
 {
     obj.InvokeOnMainThread(() => ShowProgressWorker(status: status, textOnly: true, toastPosition: toastPosition, timeoutMs: timeoutMs, maskType: maskType));
 }
Example #29
0
        /*
        void ShowProgressWorker(string cancelCaption, Delegate cancelCallback, float progress = -1, string status = null, MaskType maskType = MaskType.None){
            CancelHudButton.SetTitle(cancelCaption, UIControlState.Normal);
            CancelHudButton.TouchUpInside += delegate {
                BTProgressHUD.Dismiss();
                if(cancelCallback != null){
                    cancelCallback.DynamicInvoke(null);
                }
            };
            UpdatePosition();
            ShowProgressWorker(progress, status, maskType);
        }
        */
        void ShowProgressWorker(float progress = -1, string status = null, MaskType maskType = MaskType.None, bool textOnly = false, bool showToastCentered = true, string cancelCaption = null, Action cancelCallback = null)
        {
            if (OverlayView.Superview == null)
                UIApplication.SharedApplication.KeyWindow.AddSubview (OverlayView);

            if (Superview == null)
                OverlayView.AddSubview (this);

            _fadeoutTimer = null;
            ImageView.Hidden = true;
            _maskType = maskType;
            _progress = progress;

            StringLabel.Text = status;

            if(!string.IsNullOrEmpty(cancelCaption)){
                CancelHudButton.SetTitle(cancelCaption, UIControlState.Normal);
                CancelHudButton.TouchUpInside += delegate {
                    BTProgressHUD.Dismiss();
                    if(cancelCallback != null){
                        obj.InvokeOnMainThread (() => cancelCallback.DynamicInvoke(null));
                        //cancelCallback.DynamicInvoke(null);
                    }
                };
            }

            UpdatePosition (textOnly);

            if(progress >= 0)
            {
                ImageView.Image = null;
                ImageView.Hidden = false;
                SpinnerView.StopAnimating();
                RingLayer.StrokeEnd = progress;
            } else if (textOnly)
            {
                CancelRingLayerAnimation();
                SpinnerView.StopAnimating();
            } else
            {
                CancelRingLayerAnimation();
                SpinnerView.StartAnimating();
            }

            if(maskType != MaskType.None) {
                OverlayView.UserInteractionEnabled = true;
                //AccessibilityLabel = status;
                //IsAccessibilityElement = true;
            }
            else {
                OverlayView.UserInteractionEnabled = true;
                //hudView.IsAccessibilityElement = true;
            }

            OverlayView.Hidden = false;
            this.showToastCentered = showToastCentered;
            PositionHUD (null);

            if (Alpha != 1)
            {
                RegisterNotifications ();
                HudView.Transform.Scale (1.3f, 1.3f);

                UIView.Animate (0.15f, 0,
                                UIViewAnimationOptions.AllowUserInteraction | UIViewAnimationOptions.CurveEaseOut | UIViewAnimationOptions.BeginFromCurrentState,
                                delegate {
                    HudView.Transform.Scale ((float)1 / 1.3f, (float)1f / 1.3f);
                    Alpha = 1;
                }, delegate {
                    //UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification, string);

                    if (textOnly) StartDismissTimer(new TimeSpan(0,0,1));
                });

                SetNeedsDisplay();
            }
        }
Example #30
0
        void ShowProgressWorker(float progress = -1, string status = null, MaskType maskType = MaskType.None, bool textOnly = false,
                                ToastPosition toastPosition = ToastPosition.Center, string cancelCaption = null, Action cancelCallback  = null,
                                double timeoutMs            = 1000, bool showContinuousProgress = false, UIImage displayContinuousImage = null)
        {
            if (OverlayView.Superview == null)
            {
                var windows = UIApplication.SharedApplication.Windows;
                Array.Reverse(windows);
                foreach (UIWindow window in windows)
                {
                    if (window.WindowLevel == UIWindowLevel.Normal && !window.Hidden)
                    {
                        window.AddSubview(OverlayView);
                        break;
                    }
                }
            }


            if (Superview == null)
            {
                OverlayView.AddSubview(this);
            }

            _fadeoutTimer    = null;
            ImageView.Hidden = true;
            _maskType        = maskType;
            _progress        = progress;

            StringLabel.Text = status;

            if (!string.IsNullOrEmpty(cancelCaption))
            {
                CancelHudButton.SetTitle(cancelCaption, UIControlState.Normal);
                CancelHudButton.TouchUpInside += delegate
                {
                    Dismiss();
                    if (cancelCallback != null)
                    {
                        obj.InvokeOnMainThread(() => cancelCallback.DynamicInvoke(null));
                        //cancelCallback.DynamicInvoke(null);
                    }
                };
            }

            UpdatePosition(textOnly);

            if (showContinuousProgress)
            {
                if (displayContinuousImage != null)
                {
                    _displayContinuousImage = true;
                    ImageView.Image         = displayContinuousImage;
                    ImageView.Hidden        = false;
                }

                RingLayer.StrokeEnd = 0.0f;
                StartProgressTimer(TimeSpan.FromMilliseconds(Ring.ProgressUpdateInterval));
            }
            else
            {
                if (progress >= 0)
                {
                    ImageView.Image  = null;
                    ImageView.Hidden = false;

                    SpinnerView.StopAnimating();
                    RingLayer.StrokeEnd = progress;
                }
                else if (textOnly)
                {
                    CancelRingLayerAnimation();
                    SpinnerView.StopAnimating();
                }
                else
                {
                    CancelRingLayerAnimation();
                    SpinnerView.StartAnimating();
                }
            }

            bool cancelButtonVisible = _cancelHud != null && _cancelHud.IsDescendantOfView(_hudView);

            // intercept user interaction with the underlying view
            if (maskType != MaskType.None || cancelButtonVisible)
            {
                OverlayView.UserInteractionEnabled = true;
                //AccessibilityLabel = status;
                //IsAccessibilityElement = true;
            }
            else
            {
                OverlayView.UserInteractionEnabled = false;
                //hudView.IsAccessibilityElement = true;
            }

            OverlayView.Hidden = false;
            this.toastPosition = toastPosition;
            PositionHUD(null);


            if (Alpha != 1)
            {
                RegisterNotifications();
                HudView.Transform.Scale(1.3f, 1.3f);

                if (isClear)
                {
                    Alpha         = 1f;
                    HudView.Alpha = 0f;
                }

                UIView.Animate(0.15f, 0,
                               UIViewAnimationOptions.AllowUserInteraction | UIViewAnimationOptions.CurveEaseOut | UIViewAnimationOptions.BeginFromCurrentState,
                               delegate
                {
                    HudView.Transform.Scale((float)1 / 1.3f, (float)1f / 1.3f);
                    if (isClear)
                    {
                        HudView.Alpha = 1f;
                    }
                    else
                    {
                        Alpha = 1f;
                    }
                }, delegate
                {
                    //UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification, string);

                    if (textOnly)
                    {
                        StartDismissTimer(TimeSpan.FromMilliseconds(timeoutMs));
                    }
                });

                SetNeedsDisplay();
            }
        }
Example #31
0
 void Grating_Type()
 {
     if (Input.IsKeyPressed(Keys.Space))
     {
         GratingType += 1;
         if ((int)GratingType > 2) GratingType = 0;
         Grating.SetGratingType(GratingType);
     }
     if (Input.IsKeyPressed(Keys.E))
     {
         if (GratingShape == Shape.Quadrate )
         {
             GratingShape = Shape.Circle;
         }
         else
         {
             GratingShape = Shape.Quadrate;
         }
         Grating.SetShape(GratingShape);
     }
     if (Input.IsKeyPressed(Keys.M))
     {
         GratingMask += 1;
         if ((int)GratingMask > 1) GratingMask = 0;
         Grating.SetMask(GratingMask);
     }
     if (Input.IsKeyDown(Keys.T))
     {
         Grating.SetGaussianSigma(Grating.Para.maskpara.BasePara.diameter * 1.01f);
     }
     if (Input.IsKeyDown(Keys.Y))
     {
         Grating.SetGaussianSigma(Grating.Para.maskpara.BasePara.diameter * 0.99f);
     }
 }
Example #32
0
 public void Show(string status = null, float progress = -1, MaskType maskType = MaskType.None, double timeoutMs = 1000)
 {
     obj.InvokeOnMainThread(() => ShowProgressWorker(progress, status, maskType, timeoutMs: timeoutMs));
 }
Example #33
0
 public ClosingFilter(MaskType maskType)
     : base(maskType)
 {
 }
Example #34
0
 public static void Show(string message, int progress = -1, MaskType maskType = MaskType.Black)
 {
     AndHUD.Shared.Show(HUD.MyActivity, message, progress, (AndroidHUD.MaskType)maskType);
 }
Example #35
0
 void onmasktype(MaskType t)
 {
     renderer.material.SetInt("_masktype", (int)t);
     MaskType = t;
 }
Example #36
0
 public static void ShowToast(string message, MaskType maskType, bool showToastCentered = true, double timeoutMs = 1000)
 {
     AndHUD.Shared.ShowToast(HUD.MyActivity, message, (AndroidHUD.MaskType)maskType, TimeSpan.FromSeconds(timeoutMs / 1000), showToastCentered);
 }
Example #37
0
 protected void ShowLoading(MaskType maskType = MaskType.Black) => UserDialogs.ShowLoading("Loading...", maskType);
 /// <summary>
 /// Sets the mask
 /// </summary>
 /// <param name="obj">The object</param>
 /// <param name="value">The value</param>
 public static void SetMask(DependencyObject obj, MaskType value)
 {
     obj.SetValue(MaskProperty, value);
 }
Example #39
0
        void showStatus(Context context, bool spinner, string status = null, MaskType maskType = MaskType.Black, TimeSpan?timeout = null, Action clickCallback = null, bool centered = true, Action cancelCallback = null)
        {
            if (timeout == null)
            {
                timeout = TimeSpan.Zero;
            }

            if (CurrentDialog != null && statusObj == null)
            {
                DismissCurrent(context);
            }

            lock (dialogLock)
            {
                if (CurrentDialog == null)
                {
                    SetupDialog(context, maskType, cancelCallback, (a, d, m) => {
                        View view;

                        view = LayoutInflater.From(context).Inflate(Resource.Layout.loading, null);

                        if (clickCallback != null)
                        {
                            view.Click += (sender, e) => clickCallback();
                        }

                        statusObj = new object();

                        statusText = view.FindViewById <TextView>(Resource.Id.textViewStatus);

                        if (!spinner)
                        {
                            view.FindViewById <ProgressBar>(Resource.Id.loadingProgressBar).Visibility = ViewStates.Gone;
                        }

                        if (maskType != MaskType.Black)
                        {
                            view.SetBackgroundResource(Resource.Drawable.roundedbgdark);
                        }

                        if (statusText != null)
                        {
                            statusText.Text       = status ?? "";
                            statusText.Visibility = string.IsNullOrEmpty(status) ? ViewStates.Gone : ViewStates.Visible;
                        }

                        if (!centered)
                        {
                            d.Window.SetGravity(GravityFlags.Bottom);
                            var p = d.Window.Attributes;

                            p.Y = DpToPx(context, 22);

                            d.Window.Attributes = p;
                        }

                        return(view);
                    });

                    if (timeout > TimeSpan.Zero)
                    {
                        Task.Factory.StartNew(() => {
                            if (!waitDismiss.WaitOne(timeout.Value))
                            {
                                DismissCurrent(context);
                            }
                        }).ContinueWith(ct => {
                            var ex = ct.Exception;

                            if (ex != null)
                            {
                                Android.Util.Log.Error("AndHUD", ex.ToString());
                            }
                        }, TaskContinuationOptions.OnlyOnFaulted);
                    }
                }
                else
                {
                    Application.SynchronizationContext.Send(state => {
                        if (statusText != null)
                        {
                            statusText.Text = status ?? "";
                        }
                    }, null);
                }
            }
        }
        private static string ValidateValue(MaskType mask, string value)
        {
            if (string.IsNullOrEmpty(value))
            {
                return string.Empty;
            }

            value = value.Trim();
            switch (mask)
            {
                case MaskType.Integer:
                    try
                    {
                        Convert.ToInt64(value, CultureInfo.CurrentCulture);
                        return value;
                    }
                    catch (FormatException)
                    {
                        return string.Empty;
                    }
                    catch (OverflowException)
                    {
                        return string.Empty;
                    }

                case MaskType.Decimal:
                    try
                    {
                        Convert.ToDouble(value, CultureInfo.CurrentCulture);

                        return value;
                    }
                    catch (FormatException)
                    {
                        return string.Empty;
                    }
                    catch (OverflowException)
                    {
                        return string.Empty;
                    }
            }

            return value;
        }
Example #41
0
 public void ShowErrorWithStatus(Context context, string status, MaskType maskType = MaskType.Black, TimeSpan?timeout = null, Action clickCallback = null, Action cancelCallback = null)
 {
     showImage(context, GetDrawable(context, Resource.Drawable.ic_errorstatus), status, maskType, timeout, clickCallback, cancelCallback);
 }
Example #42
0
 public void ShowLoading(MaskType maskType)
 {
 }
Example #43
0
 public void ShowImage(Context context, Android.Graphics.Drawables.Drawable drawable, string status = null, MaskType maskType = MaskType.Black, TimeSpan?timeout = null, Action clickCallback = null, Action cancelCallback = null)
 {
     showImage(context, drawable, status, maskType, timeout, clickCallback, cancelCallback);
 }
Example #44
0
 public void Show(string status = null, float progress = -1, MaskType maskType = MaskType.None, double timeoutMs = 1000)
 {
     obj.InvokeOnMainThread (() => ShowProgressWorker (progress, status, maskType, timeoutMs: timeoutMs));
 }
Example #45
0
        /// <inheritdoc/>
        protected async override Task OnFirstAfterRenderAsync()
        {
            await JSModule.Initialize(ElementRef, ElementId, MaskType.ToMaskTypeString(), EditMask);

            await base.OnFirstAfterRenderAsync();
        }
Example #46
0
 public void ShowContinuousProgressTest(string status = null, MaskType maskType = MaskType.None, double timeoutMs = 1000)
 {
     obj.InvokeOnMainThread (() => ShowProgressWorker (0, status, maskType, false, ToastPosition.Center, null, null, timeoutMs, true));
 }
 public ProgressDialogConfig SetMaskType(MaskType maskType) {
     this.MaskType = maskType;
     return this;
 }
Example #48
0
 public void ShowToast(string status, MaskType maskType = MaskType.None, ToastPosition toastPosition = ToastPosition.Center, double timeoutMs = 1000)
 {
     obj.InvokeOnMainThread (() => ShowProgressWorker (status: status, textOnly: true, toastPosition: toastPosition, timeoutMs: timeoutMs, maskType: maskType));
 }
Example #49
0
		void SetupDialog(Context context, MaskType maskType, Action cancelCallback, Func<Context, Dialog, MaskType, View> customSetup)
		{
			Application.SynchronizationContext.Send(state => {

				CurrentDialog = new Dialog(context);

				CurrentDialog.RequestWindowFeature((int)WindowFeatures.NoTitle);

				if (maskType != MaskType.Black)
					CurrentDialog.Window.ClearFlags(WindowManagerFlags.DimBehind);

				if (maskType == MaskType.None)
					CurrentDialog.Window.SetFlags(WindowManagerFlags.NotTouchModal, WindowManagerFlags.NotTouchModal);

				CurrentDialog.Window.SetBackgroundDrawable(new Android.Graphics.Drawables.ColorDrawable(Android.Graphics.Color.Transparent));

				var customView = customSetup(context, CurrentDialog, maskType);

				CurrentDialog.SetContentView (customView);

				CurrentDialog.SetCancelable (cancelCallback != null);	
				if (cancelCallback != null)
					CurrentDialog.CancelEvent += (sender, e) => cancelCallback();

				CurrentDialog.Show ();

			}, null);
		}
Example #50
0
        void ShowProgressWorker(float progress = -1, string status = null, MaskType maskType = MaskType.None, bool textOnly = false, 
		                         ToastPosition toastPosition = ToastPosition.Center, string cancelCaption = null, Action cancelCallback = null, 
		                         double timeoutMs = 1000, bool showContinuousProgress = false, UIImage displayContinuousImage = null)
        {
            Ring.ResetStyle(IsiOS7ForLookAndFeel, (IsiOS7ForLookAndFeel ? TintColor : UIColor.White));

            if (OverlayView.Superview == null) {
                var windows = UIApplication.SharedApplication.Windows;
                Array.Reverse (windows);
                foreach (UIWindow window in windows) {
                    if (window.WindowLevel == UIWindowLevel.Normal && !window.Hidden) {
                        window.AddSubview (OverlayView);
                        break;
                    }
                }
            }

            if (Superview == null)
                OverlayView.AddSubview (this);

            _fadeoutTimer = null;
            ImageView.Hidden = true;
            _maskType = maskType;
            _progress = progress;

            StringLabel.Text = status;

            if (!string.IsNullOrEmpty (cancelCaption)) {
                CancelHudButton.SetTitle (cancelCaption, UIControlState.Normal);
                CancelHudButton.TouchUpInside += delegate {
                    Dismiss ();
                    if (cancelCallback != null) {
                        obj.InvokeOnMainThread (() => cancelCallback.DynamicInvoke (null));
                        //cancelCallback.DynamicInvoke(null);
                    }
                };
            }

            UpdatePosition (textOnly);

            if (showContinuousProgress) {
                if (displayContinuousImage != null) {
                    _displayContinuousImage = true;
                    ImageView.Image = displayContinuousImage;
                    ImageView.Hidden = false;
                }

                RingLayer.StrokeEnd = 0.0f;
                StartProgressTimer (TimeSpan.FromMilliseconds (Ring.ProgressUpdateInterval));
            } else {
                if (progress >= 0) {
                    ImageView.Image = null;
                    ImageView.Hidden = false;

                    SpinnerView.StopAnimating ();
                    RingLayer.StrokeEnd = progress;
                } else if (textOnly) {
                    CancelRingLayerAnimation ();
                    SpinnerView.StopAnimating ();
                } else {
                    CancelRingLayerAnimation ();
                    SpinnerView.StartAnimating ();
                }
            }

            bool cancelButtonVisible = _cancelHud != null && _cancelHud.IsDescendantOfView (_hudView);

            // intercept user interaction with the underlying view
            if (maskType != MaskType.None || cancelButtonVisible) {
                OverlayView.UserInteractionEnabled = true;
                //AccessibilityLabel = status;
                //IsAccessibilityElement = true;
            } else {
                OverlayView.UserInteractionEnabled = false;
                //hudView.IsAccessibilityElement = true;
            }

            OverlayView.Hidden = false;
            this.toastPosition = toastPosition;
            PositionHUD (null);

            if (Alpha != 1) {
                RegisterNotifications ();
                HudView.Transform.Scale (1.3f, 1.3f);

                if (isClear) {
                    Alpha = 1f;
                    HudView.Alpha = 0f;
                }

                UIView.Animate (0.15f, 0,
                    UIViewAnimationOptions.AllowUserInteraction | UIViewAnimationOptions.CurveEaseOut | UIViewAnimationOptions.BeginFromCurrentState,
                    delegate {
                        HudView.Transform.Scale ((float)1 / 1.3f, (float)1f / 1.3f);
                        if (isClear) {
                            HudView.Alpha = 1f;
                        } else {
                            Alpha = 1f;
                        }
                    }, delegate {
                    //UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification, string);

                    if (textOnly)
                        StartDismissTimer (TimeSpan.FromMilliseconds (timeoutMs));
                });

                SetNeedsDisplay ();
            }
        }
Example #51
0
		public void ShowErrorWithStatus(Context context, string status, MaskType maskType = MaskType.Black, TimeSpan? timeout = null, Action clickCallback = null, Action cancelCallback = null)
		{
			showImage (context, context.Resources.GetDrawable (Resource.Drawable.ic_errorstatus), status, maskType, timeout, clickCallback, cancelCallback);
		}
Example #52
0
        /*
         * void ShowProgressWorker(string cancelCaption, Delegate cancelCallback, float progress = -1, string status = null, MaskType maskType = MaskType.None){
         *      CancelHudButton.SetTitle(cancelCaption, UIControlState.Normal);
         *      CancelHudButton.TouchUpInside += delegate {
         *              BTProgressHUD.Dismiss();
         *              if(cancelCallback != null){
         *                      cancelCallback.DynamicInvoke(null);
         *              }
         *      };
         *      UpdatePosition();
         *      ShowProgressWorker(progress, status, maskType);
         * }
         */
        void ShowProgressWorker(float progress         = -1, string status = null, MaskType maskType = MaskType.None, bool textOnly = false,
                                bool showToastCentered = true, string cancelCaption = null, Action cancelCallback = null, double timeoutMs = 1000)
        {
            if (OverlayView.Superview == null)
            {
                UIApplication.SharedApplication.KeyWindow.AddSubview(OverlayView);
            }

            if (Superview == null)
            {
                OverlayView.AddSubview(this);
            }

            _fadeoutTimer    = null;
            ImageView.Hidden = true;
            _maskType        = maskType;
            _progress        = progress;

            StringLabel.Text = status;

            if (!string.IsNullOrEmpty(cancelCaption))
            {
                CancelHudButton.SetTitle(cancelCaption, UIControlState.Normal);
                CancelHudButton.TouchUpInside += delegate {
                    BTProgressHUD.Dismiss();
                    if (cancelCallback != null)
                    {
                        obj.InvokeOnMainThread(() => cancelCallback.DynamicInvoke(null));
                        //cancelCallback.DynamicInvoke(null);
                    }
                };
            }

            UpdatePosition(textOnly);

            if (progress >= 0)
            {
                ImageView.Image  = null;
                ImageView.Hidden = false;
                SpinnerView.StopAnimating();
                RingLayer.StrokeEnd = progress;
            }
            else if (textOnly)
            {
                CancelRingLayerAnimation();
                SpinnerView.StopAnimating();
            }
            else
            {
                CancelRingLayerAnimation();
                SpinnerView.StartAnimating();
            }

            if (maskType != MaskType.None)
            {
                OverlayView.UserInteractionEnabled = true;
                this.SetAccessibilityName(status);
                this.SetIsAccessibilityElement(true);
            }
            else
            {
                OverlayView.UserInteractionEnabled = true;
                this.SetIsAccessibilityElement(true);
            }

            OverlayView.Hidden     = false;
            this.showToastCentered = showToastCentered;
            PositionHUD(null);


            if (Alpha != 1)
            {
                RegisterNotifications();
                HudView.Transform.Scale(1.3f, 1.3f);

                UIView.Animate(0.15f, 0,
                               UIViewAnimationOptions.AllowUserInteraction | UIViewAnimationOptions.CurveEaseOut | UIViewAnimationOptions.BeginFromCurrentState,
                               delegate {
                    HudView.Transform.Scale((float)1 / 1.3f, (float)1f / 1.3f);
                    Alpha = 1;
                }, delegate {
                    // UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification, string);
                    if (textOnly)
                    {
                        StartDismissTimer(TimeSpan.FromMilliseconds(timeoutMs));
                    }
                });

                SetNeedsDisplay();
            }
        }
Example #53
0
		public void ShowImage(Context context, Android.Graphics.Drawables.Drawable drawable, string status = null, MaskType maskType = MaskType.Black, TimeSpan? timeout = null, Action clickCallback = null, Action cancelCallback = null)
		{
			showImage (context, drawable, status, maskType, timeout, clickCallback, cancelCallback);
		}
Example #54
0
 public static void Show(string status = null, float progress = -1, MaskType maskType = MaskType.None)
 {
     obj.InvokeOnMainThread(() => SharedView.ShowProgressWorker(progress, status, maskType));
 }
Example #55
0
		void showStatus (Context context, bool spinner, string status = null, MaskType maskType = MaskType.Black, TimeSpan? timeout = null, Action clickCallback = null, bool centered = true, Action cancelCallback = null)
		{
			if (timeout == null)
				timeout = TimeSpan.Zero;

			DismissCurrent (context);

			if (CurrentDialog != null && statusObj == null)
				DismissCurrent (context);

			lock (dialogLock)
			{
				if (CurrentDialog == null)
				{
					SetupDialog (context, maskType, cancelCallback, (a, d, m) => {
						View view;

						view = LayoutInflater.From (context).Inflate (Resource.Layout.loading, null);

						if (clickCallback != null)
							view.Click += (sender, e) => clickCallback();

						statusObj = new object();

						statusText = view.FindViewById<TextView>(Resource.Id.textViewStatus);

                        var progressBar = view.FindViewById<ProgressBar>(Resource.Id.loadingProgressBar);
						if (!spinner)
                            progressBar.Visibility = ViewStates.Gone;
                        else if (SystemColor!=null)                            
                            progressBar.IndeterminateDrawable.SetColorFilter(SystemColor.Value, PorterDuff.Mode.SrcIn);

						if (maskType != MaskType.Black)
							view.SetBackgroundResource(Resource.Drawable.roundedbgdark);

						if (statusText != null)
						{
							statusText.Text = status ?? "";
							statusText.Visibility = string.IsNullOrEmpty(status) ? ViewStates.Gone : ViewStates.Visible;
						}

						if (!centered)
						{
							d.Window.SetGravity (GravityFlags.Bottom);
							var p = d.Window.Attributes;

							p.Y = DpToPx (context, 22);

							d.Window.Attributes = p;
						}
							
						return view;
					});

					if (timeout > TimeSpan.Zero)
					{
						Task.Factory.StartNew(() => {
							if (!waitDismiss.WaitOne (timeout.Value))
								DismissCurrent (context);

						}).ContinueWith(ct => {
							var ex = ct.Exception;

							if (ex != null)
								Android.Util.Log.Error("AndHUD", ex.ToString());
						}, TaskContinuationOptions.OnlyOnFaulted);
					}
				}
				else
				{

					Application.SynchronizationContext.Send(state => {
						if (statusText != null)
							statusText.Text = status ?? "";
					}, null);
				}
			}
		}
Example #56
0
 public static void Show(string cancelCaption, Action cancelCallback, string status = null, float progress = -1, MaskType maskType = MaskType.None)
 {
     // Making cancelCaption optional hides the method via the overload
     if (string.IsNullOrEmpty(cancelCaption))
     {
         cancelCaption = "Cancel";
     }
     obj.InvokeOnMainThread(() => SharedView.ShowProgressWorker(progress, status, maskType, cancelCaption: cancelCaption, cancelCallback: cancelCallback));
 }
Example #57
0
 public static void Show(string cancelCaption, Action cancelCallback, string status = null, float progress = -1, MaskType maskType = MaskType.None)
 {
     // Making cancelCaption optional hides the method via the overload
     if(string.IsNullOrEmpty(cancelCaption)){
         cancelCaption = "Cancel";
     }
     obj.InvokeOnMainThread (() => SharedView.ShowProgressWorker (progress, status, maskType, cancelCaption: cancelCaption, cancelCallback: cancelCallback));
 }
Example #58
0
 static ProgressDialogConfig()
 {
     DefaultTitle      = "Loading";
     DefaultCancelText = "Cancel";
     DefaultMaskType   = MaskType.Black;
 }
        public Image<Bgr, byte> GetHighBoostFilteredImage(Image<Bgr, byte> sourceImage, float allFactor, MaskType type)
        {
            Image<Bgr, byte> returnImage = new Image<Bgr, byte>(sourceImage.Width, sourceImage.Height);
            float[,] firstTypeMatrix = new float[3, 3]
            {
                {0, -1, 0},
                { -1, allFactor + 4, -1},
                { 0, -1, 0}
            };
            float[,] secondTypeMatrix = new float[3, 3]
            {
                {-1, -1, -1},
                { -1, allFactor + 8, -1},
                {-1, -1, -1}
            };

            ConvolutionKernelF matrix = null;
            switch (type)
            {
                case MaskType.Type1:
                    matrix = new ConvolutionKernelF(firstTypeMatrix);
                    break;
                case MaskType.Type2:
                    matrix = new ConvolutionKernelF(secondTypeMatrix);
                    break;
            }

            CvInvoke.Filter2D(sourceImage, returnImage, matrix, new Point(0, 0));

            return returnImage;
        }
Example #60
0
 public ProgressDialogConfig SetMaskType(MaskType maskType)
 {
     this.MaskType = maskType;
     return(this);
 }