private void ApplySharedStyles(XEntry element) { this.Control.Hint = element.Placeholder; //// Cursor Color (this is not bindable property. Is only internally changed). //IntPtr IntPtrtextViewClass = JNIEnv.FindClass(typeof(TextView)); //IntPtr mCursorDrawableResProperty = // JNIEnv.GetFieldID(IntPtrtextViewClass, "mCursorDrawableRes", "I"); //// replace 0 with a Resource.Drawable.my_cursor //JNIEnv.SetField(Control.Handle, mCursorDrawableResProperty, 0); // Text alignment. if (element.HorizontalTextAlignment == Xamarin.Forms.TextAlignment.Center) { Control.Gravity = Android.Views.GravityFlags.CenterHorizontal; } else if (element.HorizontalTextAlignment == Xamarin.Forms.TextAlignment.Start) { Control.Gravity = Android.Views.GravityFlags.Start; } else if (element.HorizontalTextAlignment == Xamarin.Forms.TextAlignment.End) { Control.Gravity = Android.Views.GravityFlags.End; } }
/// <summary> /// Closes the current ZIP entry and positions the stream for writing /// the next entry. </summary> /// <exception cref="ZipException"> if a ZIP format error has occurred </exception> /// <exception cref="IOException"> if an I/O error has occurred </exception> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public void closeEntry() throws java.io.IOException public virtual void CloseEntry() { EnsureOpen(); if (Current != null) { ZipEntry e = Current.Entry; switch (e.Method_Renamed) { case DEFLATED: Def.Finish(); while (!Def.Finished()) { Deflate(); } if ((e.Flag & 8) == 0) { // verify size, compressed size, and crc-32 settings if (e.Size_Renamed != Def.BytesRead) { throw new ZipException("invalid entry size (expected " + e.Size_Renamed + " but got " + Def.BytesRead + " bytes)"); } if (e.Csize != Def.BytesWritten) { throw new ZipException("invalid entry compressed size (expected " + e.Csize + " but got " + Def.BytesWritten + " bytes)"); } if (e.Crc_Renamed != Crc.Value) { throw new ZipException("invalid entry CRC-32 (expected 0x" + e.Crc_Renamed.ToString("x") + " but got 0x" + Crc.Value.ToString("x") + ")"); } } else { e.Size_Renamed = Def.BytesRead; e.Csize = Def.BytesWritten; e.Crc_Renamed = Crc.Value; WriteEXT(e); } Def.Reset(); Written += e.Csize; break; case STORED: // we already know that both e.size and e.csize are the same if (e.Size_Renamed != Written - Locoff) { throw new ZipException("invalid entry size (expected " + e.Size_Renamed + " but got " + (Written - Locoff) + " bytes)"); } if (e.Crc_Renamed != Crc.Value) { throw new ZipException("invalid entry crc-32 (expected 0x" + e.Crc_Renamed.ToString("x") + " but got 0x" + Crc.Value.ToString("x") + ")"); } break; default: throw new ZipException("invalid compression method"); } Crc.Reset(); Current = null; } }
private void SetReturnType(XEntry view) { if (view.ReturnType.HasValue) { switch (view.ReturnType.Value) { case ReturnType.Go: Control.ImeOptions = ImeAction.Go; Control.SetImeActionLabel("Go", ImeAction.Go); break; case ReturnType.Next: Control.ImeOptions = ImeAction.Next; Control.SetImeActionLabel("Next", ImeAction.Next); break; case ReturnType.Search: Control.ImeOptions = ImeAction.Search; Control.SetImeActionLabel("Search", ImeAction.Search); break; case ReturnType.Send: Control.ImeOptions = ImeAction.Send; Control.SetImeActionLabel("Send", ImeAction.Send); break; default: Control.SetImeActionLabel("Done", ImeAction.Done); break; } } }
private void SetMaxLength(XEntry view) { Control.ShouldChangeCharacters = (textField, range, replacementString) => { var newLength = textField.Text.Length + replacementString.Length - range.Length; return(newLength <= view.MaxLength); }; }
void setBackgroundDrawable(XEntry view) { GradientDrawable gd = new GradientDrawable(); gd.SetColor(view.BackgroundColor.ToAndroid()); //gd.SetCornerRadius(10); gd.SetStroke(2, view.BottomBorderColor.ToAndroid()); Control.SetBackground(gd); }
/// <summary> /// /// </summary> /// <param name="entry"></param> /// <param name="cacheInScene"></param> /// <param name="cacheAllTime"></param> private void SetupBundleCacheType(XEntry entry, List <string> cacheInScene, List <string> cacheAllTime) { if (cacheInScene.Contains(entry.name)) { entry.cacheType = XCacheType.InScene; } else if (cacheAllTime.Contains(entry.name)) { entry.cacheType = XCacheType.AllTime; } }
private void ApplyStylesAndBehaviorsFromBoxStyle(XEntry element) { // Internal Padding Control.SetPadding(element.InternalPadding, Control.PaddingTop, Control.PaddingRight, Control.PaddingBottom); // Applying initial styles. SetUnfocusedBoxStyles(element); element.Unfocused += (sender, evt) => { SetUnfocusedBoxStyles(element); }; element.Focused += (sender, evt) => { SetFocusedBoxStyles(element); }; }
private void SetBorder(XEntry view) { if (!view.HasBorder) { Control.SetBackgroundColor(global::Android.Graphics.Color.Transparent); } else { //Control.SetBackgroundColor(view.BottomBorderColor.ToAndroid()); setBackgroundDrawable(view); } }
protected override void OnElementChanged(ElementChangedEventArgs <Entry> e) { base.OnElementChanged(e); _view = (XEntry)Element; _isPassword = _view.IsPassword; if (Control != null) { Control.SetIncludeFontPadding(false); if (e.NewElement != null && e.NewElement.IsPassword) { Control.SetTypeface(Typeface.Default, TypefaceStyle.Normal); Control.TransformationMethod = new PasswordTransformationMethod(); } } SetBorder(_view); SetMaxLength(_view); SetReturnType(_view); // Editor Action is called when the return button is pressed Control.EditorAction += Control_EditorAction; if (_view.DisableAutocapitalize) { Control.SetRawInputType(Control.InputType |= InputTypes.TextVariationEmailAddress); } if (_view.Autocorrect.HasValue) { Control.SetRawInputType(Control.InputType |= InputTypes.TextFlagNoSuggestions); } if (_view.IsPassword) { Control.SetRawInputType(InputTypes.TextFlagNoSuggestions | InputTypes.TextVariationVisiblePassword); } _view.ToggleIsPassword += ToggleIsPassword; if (_view.FontFamily == "monospace") { Control.Typeface = Typeface.Monospace; } if (_view.HideCursor) { Control.SetCursorVisible(false); } }
/// <summary> /// /// </summary> /// <param name="entry"></param> /// <param name="packageCatrgory1"></param> /// <param name="packageCatrgory2"></param> /// <param name="packageCatrgory3"></param> private void SetupBundlePackageType(XEntry entry, List <string> packageCatrgory1, List <string> packageCatrgory2, List <string> packageCatrgory3) { if (packageCatrgory1.Contains(entry.name)) { entry.packType = XPackType.P1; } else if (packageCatrgory2.Contains(entry.name)) { entry.packType = XPackType.P2; } else if (packageCatrgory3.Contains(entry.name)) { entry.packType = XPackType.P3; } }
private void ApplyStylesAndBehaviorsFromStandardMode(XEntry element) { // Internal Padding. if (element.InternalPadding != default(int)) { var internalPaddingInPx = ConvertToPx(element.InternalPadding); Control.SetPadding(internalPaddingInPx, internalPaddingInPx, internalPaddingInPx, internalPaddingInPx); } // Border color. ChangeColor(element.BorderColor.ToAndroid()); // Border color focused and unfocused. element.Unfocused += (sender, evt) => { ChangeColor(element.BorderColor.ToAndroid()); }; element.Focused += (sender, evt) => { ChangeColor(element.BorderColorFocused.ToAndroid()); }; }
private void SetUnfocusedBoxStyles(XEntry element) { if (Control != null) { var gradientDrawable = new GradientDrawable(); // Border Radius. var borderRadiusPx = ConvertToPx(Convert.ToInt32(element.BoxBorderRadius)); gradientDrawable.SetCornerRadius(borderRadiusPx); // Border Color. var edgeSizePx = ConvertToPx(element.BoxEdgeSize); gradientDrawable.SetStroke(edgeSizePx, element.BorderColor.ToAndroid()); Control.SetBackground(gradientDrawable); } }
/// <summary> /// Add the specified entry. /// </summary> /// <param name="entry">Entry.</param> public void Add(XEntry entry) { switch (entry.Type()) { case XEntryType.Pack: packs.Add(entry.name, entry as XPack); break; case XEntryType.File: files.Add(entry.name, entry as XFile); break; case XEntryType.Scene: scenes.Add(entry.name, entry as XScene); break; } }
/// <summary> /// Remove the specified entry. /// </summary> /// <param name="entry">Entry.</param> public void Remove(XEntry entry) { switch (entry.Type()) { case XEntryType.Pack: packs.Remove(entry.name); break; case XEntryType.File: files.Remove(entry.name); break; case XEntryType.Scene: scenes.Remove(entry.name); break; } }
protected override void OnElementChanged(ElementChangedEventArgs <Entry> e) { base.OnElementChanged(e); if (Control == null || e.NewElement == null) { return; } XEntry element = (XEntry)e.NewElement; ApplySharedStyles(element); if (!element.BoxStyleEnabled && Control != null) { ApplyStylesAndBehaviorsFromStandardMode(element); } else if (element.BoxStyleEnabled && Control != null) { ApplyStylesAndBehaviorsFromBoxStyle(element); } }
private void SetBorder(XEntry view) { if (view.HasOnlyBottomBorder) { var borderLayer = new CALayer(); borderLayer.MasksToBounds = true; borderLayer.Frame = new CGRect(0f, Frame.Height / 2, Frame.Width * 2, 1f); borderLayer.BorderColor = view.BottomBorderColor.ToCGColor(); borderLayer.BorderWidth = 1f; Control.Layer.AddSublayer(borderLayer); Control.BorderStyle = UITextBorderStyle.None; } else if (view.HasBorder) { Control.BorderStyle = UITextBorderStyle.RoundedRect; } else { Control.BorderStyle = UITextBorderStyle.None; } }
/* * Write central directory (CEN) header for specified entry. * REMIND: add support for file attributes */ //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: private void writeCEN(XEntry xentry) throws java.io.IOException private void WriteCEN(XEntry xentry) { ZipEntry e = xentry.Entry; int flag = e.Flag; int version = Version(e); long csize = e.Csize; long size = e.Size_Renamed; long offset = xentry.Offset; int elenZIP64 = 0; bool hasZip64 = false; if (e.Csize >= ZIP64_MAGICVAL) { csize = ZIP64_MAGICVAL; elenZIP64 += 8; // csize(8) hasZip64 = true; } if (e.Size_Renamed >= ZIP64_MAGICVAL) { size = ZIP64_MAGICVAL; // size(8) elenZIP64 += 8; hasZip64 = true; } if (xentry.Offset >= ZIP64_MAGICVAL) { offset = ZIP64_MAGICVAL; elenZIP64 += 8; // offset(8) hasZip64 = true; } WriteInt(ZipConstants_Fields.CENSIG); // CEN header signature if (hasZip64) { WriteShort(45); // ver 4.5 for zip64 WriteShort(45); } else { WriteShort(version); // version made by WriteShort(version); // version needed to extract } WriteShort(flag); // general purpose bit flag WriteShort(e.Method_Renamed); // compression method WriteInt(e.Xdostime); // last modification time WriteInt(e.Crc_Renamed); // crc-32 WriteInt(csize); // compressed size WriteInt(size); // uncompressed size sbyte[] nameBytes = Zc.GetBytes(e.Name_Renamed); WriteShort(nameBytes.Length); int elen = GetExtraLen(e.Extra_Renamed); if (hasZip64) { elen += (elenZIP64 + 4); // + headid(2) + datasize(2) } // cen info-zip extended timestamp only outputs mtime // but set the flag for a/ctime, if present in loc int flagEXTT = 0; if (e.Mtime != null) { elen += 4; // + mtime(4) flagEXTT |= EXTT_FLAG_LMT; } if (e.Atime != null) { flagEXTT |= EXTT_FLAG_LAT; } if (e.Ctime != null) { flagEXTT |= EXTT_FLAT_CT; } if (flagEXTT != 0) { elen += 5; // headid + sz + flag } WriteShort(elen); sbyte[] commentBytes; if (e.Comment_Renamed != null) { commentBytes = Zc.GetBytes(e.Comment_Renamed); WriteShort(System.Math.Min(commentBytes.Length, 0xffff)); } else { commentBytes = null; WriteShort(0); } WriteShort(0); // starting disk number WriteShort(0); // internal file attributes (unused) WriteInt(0); // external file attributes (unused) WriteInt(offset); // relative offset of local header WriteBytes(nameBytes, 0, nameBytes.Length); // take care of EXTID_ZIP64 and EXTID_EXTT if (hasZip64) { WriteShort(ZIP64_EXTID); // Zip64 extra WriteShort(elenZIP64); if (size == ZIP64_MAGICVAL) { WriteLong(e.Size_Renamed); } if (csize == ZIP64_MAGICVAL) { WriteLong(e.Csize); } if (offset == ZIP64_MAGICVAL) { WriteLong(xentry.Offset); } } if (flagEXTT != 0) { WriteShort(EXTID_EXTT); if (e.Mtime != null) { WriteShort(5); // flag + mtime WriteByte(flagEXTT); WriteInt(fileTimeToUnixTime(e.Mtime)); } else { WriteShort(1); // flag only WriteByte(flagEXTT); } } WriteExtra(e.Extra_Renamed); if (commentBytes != null) { WriteBytes(commentBytes, 0, System.Math.Min(commentBytes.Length, 0xffff)); } }
/* * Writes local file (LOC) header for specified entry. */ //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: private void writeLOC(XEntry xentry) throws java.io.IOException private void WriteLOC(XEntry xentry) { ZipEntry e = xentry.Entry; int flag = e.Flag; bool hasZip64 = false; int elen = GetExtraLen(e.Extra_Renamed); WriteInt(ZipConstants_Fields.LOCSIG); // LOC header signature if ((flag & 8) == 8) { WriteShort(Version(e)); // version needed to extract WriteShort(flag); // general purpose bit flag WriteShort(e.Method_Renamed); // compression method WriteInt(e.Xdostime); // last modification time // store size, uncompressed size, and crc-32 in data descriptor // immediately following compressed entry data WriteInt(0); WriteInt(0); WriteInt(0); } else { if (e.Csize >= ZIP64_MAGICVAL || e.Size_Renamed >= ZIP64_MAGICVAL) { hasZip64 = true; WriteShort(45); // ver 4.5 for zip64 } else { WriteShort(Version(e)); // version needed to extract } WriteShort(flag); // general purpose bit flag WriteShort(e.Method_Renamed); // compression method WriteInt(e.Xdostime); // last modification time WriteInt(e.Crc_Renamed); // crc-32 if (hasZip64) { WriteInt(ZIP64_MAGICVAL); WriteInt(ZIP64_MAGICVAL); elen += 20; //headid(2) + size(2) + size(8) + csize(8) } else { WriteInt(e.Csize); // compressed size WriteInt(e.Size_Renamed); // uncompressed size } } sbyte[] nameBytes = Zc.GetBytes(e.Name_Renamed); WriteShort(nameBytes.Length); int elenEXTT = 0; // info-zip extended timestamp int flagEXTT = 0; if (e.Mtime != null) { elenEXTT += 4; flagEXTT |= EXTT_FLAG_LMT; } if (e.Atime != null) { elenEXTT += 4; flagEXTT |= EXTT_FLAG_LAT; } if (e.Ctime != null) { elenEXTT += 4; flagEXTT |= EXTT_FLAT_CT; } if (flagEXTT != 0) { elen += (elenEXTT + 5); // headid(2) + size(2) + flag(1) + data } WriteShort(elen); WriteBytes(nameBytes, 0, nameBytes.Length); if (hasZip64) { WriteShort(ZIP64_EXTID); WriteShort(16); WriteLong(e.Size_Renamed); WriteLong(e.Csize); } if (flagEXTT != 0) { WriteShort(EXTID_EXTT); WriteShort(elenEXTT + 1); // flag + data WriteByte(flagEXTT); if (e.Mtime != null) { WriteInt(fileTimeToUnixTime(e.Mtime)); } if (e.Atime != null) { WriteInt(fileTimeToUnixTime(e.Atime)); } if (e.Ctime != null) { WriteInt(fileTimeToUnixTime(e.Ctime)); } } WriteExtra(e.Extra_Renamed); Locoff = Written; }
/// <summary> /// Begins writing a new ZIP file entry and positions the stream to the /// start of the entry data. Closes the current entry if still active. /// The default compression method will be used if no compression method /// was specified for the entry, and the current time will be used if /// the entry has no set modification time. </summary> /// <param name="e"> the ZIP entry to be written </param> /// <exception cref="ZipException"> if a ZIP format error has occurred </exception> /// <exception cref="IOException"> if an I/O error has occurred </exception> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public void putNextEntry(ZipEntry e) throws java.io.IOException public virtual void PutNextEntry(ZipEntry e) { EnsureOpen(); if (Current != null) { CloseEntry(); // close previous entry } if (e.Xdostime == -1) { // by default, do NOT use extended timestamps in extra // data, for now. e.Time = DateTimeHelperClass.CurrentUnixTimeMillis(); } if (e.Method_Renamed == -1) { e.Method_Renamed = Method_Renamed; // use default method } // store size, compressed size, and crc-32 in LOC header e.Flag = 0; switch (e.Method_Renamed) { case DEFLATED: // store size, compressed size, and crc-32 in data descriptor // immediately following the compressed entry data if (e.Size_Renamed == -1 || e.Csize == -1 || e.Crc_Renamed == -1) { e.Flag = 8; } break; case STORED: // compressed size, uncompressed size, and crc-32 must all be // set for entries using STORED compression method if (e.Size_Renamed == -1) { e.Size_Renamed = e.Csize; } else if (e.Csize == -1) { e.Csize = e.Size_Renamed; } else if (e.Size_Renamed != e.Csize) { throw new ZipException("STORED entry where compressed != uncompressed size"); } if (e.Size_Renamed == -1 || e.Crc_Renamed == -1) { throw new ZipException("STORED entry missing size, compressed size, or crc-32"); } break; default: throw new ZipException("unsupported compression method"); } if (!Names.Add(e.Name_Renamed)) { throw new ZipException("duplicate entry: " + e.Name_Renamed); } if (Zc.UTF8) { e.Flag |= EFS; } Current = new XEntry(e, Written); Xentries.Add(Current); WriteLOC(Current); }
private void SetMaxLength(XEntry view) { Control.SetFilters(new IInputFilter[] { new InputFilterLengthFilter(view.MaxLength) }); }