本文整理汇总了C#中MaskType类的典型用法代码示例。如果您正苦于以下问题:C# MaskType类的具体用法?C# MaskType怎么用?C# MaskType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MaskType类属于命名空间,在下文中一共展示了MaskType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsSymbolValid
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;
}
示例2: Show
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);
}
示例3: Progress
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
});
}
示例4: AddMask
/// <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;
}
示例5: ApplyMask
/// <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));
}
}
}
示例6: ShowProgressWorker
/*
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();
}
}
示例7: Show
public static void Show(string status = null, float progress = -1, MaskType maskType = MaskType.None)
{
obj.InvokeOnMainThread (() => SharedView.ShowProgressWorker (progress, status, maskType));
}
示例8: ShowToast
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);
}
示例9: ShowImage
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);
}
示例10: showImage
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);
}
}
}
示例11: SetMask
/// <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);
}
示例12: ValidateValue
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;
}
示例13: Toast
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
);
});
}
示例14: Loading
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");
}
示例15: MaskPara
/// <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;
}