internal static void loadFontIfNeeded(string fontName) { string loadedFont; MaterialFontLoader.LoadedFonts.TryGetValue(fontName, out loadedFont); if ((loadedFont == null) && (UIFont.FromName(name: fontName, size: 1) == null)) { MaterialFontLoader.LoadedFonts[fontName] = fontName; var bundle = NSBundle.FromClass(new Class(typeof(MaterialFontLoader))); var identifier = bundle.BundleIdentifier; var fontURL = bundle.GetUrlForResource(name: fontName, fileExtension: "ttf", subdirectory: "Fonts/Roboto"); if (fontURL != null) { var data = NSData.FromUrl(fontURL); var provider = new CGDataProvider(data); var font = CGFont.CreateFromProvider(provider); NSError error; if (!CoreText.CTFontManager.RegisterGraphicsFont(font, out error)) { var errerrorDescription = error.Description; throw new Exception(error.Description); //new NSException(name: NSException.con, reason: error.Description, userInfo: error.UserInfo); } } } }
public static string Translate(this string translate, string defaultValue = "*NO TRANSLATION*") { var bundleClass = new DummyClass().Class; var languageBundle = NSBundle.FromClass(bundleClass); var translatedString = languageBundle.LocalizedString(translate, defaultValue, "GMImagePicker"); return(translatedString); }
private void setupDefaultDropDown() { DropDown.SetupDefaultAppearance(); foreach (var dropDown in DropDowns) { dropDown.CellNib = UINib.FromName("DropDownCell", NSBundle.FromClass(new Class(typeof(DropDownCell)))); dropDown.CustomCellConfiguration = null; } }
public UIKit.UIViewController GetViewControllerForAdaptivePresentation(UIPresentationController controller, UIModalPresentationStyle style) { /* * Load and return the adapted view controller from the Detail storyboard. * That storyboard is stored within the same bundle that contains this * class. */ var adaptableFormSheetSegueBundle = NSBundle.FromClass(new Class(typeof(AdaptableFormSheetSegue))); return(UIStoryboard.FromName("Detail", adaptableFormSheetSegueBundle).InstantiateViewController("Adapted")); }
UIImage bubbleImageFromBundleWithName(string name) { var bundle = NSBundle.FromClass(new ObjCRuntime.Class(typeof(MessagesViewController))); string bundleResourcePath = bundle.ResourcePath; string assetPath = System.IO.Path.Combine(bundleResourcePath, "JSQMessagesAssets.bundle"); var messagesAssetBundle = NSBundle.FromPath(assetPath); var path = messagesAssetBundle.PathForResource(name, "png", "Images"); return(UIImage.FromFile(path)); }
private void setupViewFromNib() { var bundle = NSBundle.FromClass(Class); // TODO: check var nib = UINib.FromName(nameof(PANView), bundle); var view = nib.Instantiate(this, null).First() as UIView; view.Frame = Bounds; view.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight; AddSubview(view); //textField.Placeholder = TODO: add view //textField.Delegate = //textField.AddTarget }
private void Initialize() { var ownType = typeof(SensorStatusView); var bundle = NSBundle.FromClass(new Class(ownType)); var nib = bundle.LoadNib(ownType.Name, owner: this, options: null); var contentView = nib?.GetItem <UIView>(0); if (contentView != null) { var adjustedFrame = Frame; adjustedFrame.Size = contentView.Frame.Size; Frame = adjustedFrame; AddSubview(contentView); } }
public static void LoadFont(string name, string format) { var bundle = NSBundle.FromClass(new Class(typeof(NBMaterialCircularActivityIndicator))); var fontURL = bundle.GetUrlForResource(name, format); var data = NSData.FromUrl(fontURL); var provider = new CGDataProvider(data); var font = CGFont.CreateFromProvider(provider); NSError error; if (!CTFontManager.RegisterGraphicsFont(font, out error)) { throw new NSErrorException(error); } }
public TabView(bool _isInfinity, TabPageOption _option) : base(CGRect.Empty) { option = _option; isInfinity = _isInfinity; NSBundle.FromClass(new ObjCRuntime.Class(typeof(TabView))).LoadNib(nameof(TabView), this, null); AddSubview(contentView); contentView.BackgroundColor = option.tabBackgroundColor.ColorWithAlpha(option.tabBarAlpha); var top = NSLayoutConstraint.Create(contentView, NSLayoutAttribute.Top, NSLayoutRelation.Equal, this, NSLayoutAttribute.Top, 1.0f, 0.0f); var left = NSLayoutConstraint.Create(contentView, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, this, NSLayoutAttribute.Leading, 1.0f, 0.0f); var bottom = NSLayoutConstraint.Create(this, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, contentView, NSLayoutAttribute.Bottom, 1.0f, 0.0f); var right = NSLayoutConstraint.Create(this, NSLayoutAttribute.Trailing, NSLayoutRelation.Equal, contentView, NSLayoutAttribute.Trailing, 1.0f, 0.0f); contentView.TranslatesAutoresizingMaskIntoConstraints = false; this.AddConstraints(new NSLayoutConstraint[] { top, left, bottom, right }); var bundle = NSBundle.FromClass(new ObjCRuntime.Class(typeof(TabView))); var nib = UINib.FromName(TabCollectionCell.cellIdentifier(), bundle); collectionView.RegisterNibForCell(nib, TabCollectionCell.cellIdentifier()); cellForSize = nib.Instantiate(null, null).First() as TabCollectionCell; collectionView.ScrollsToTop = false; collectionView.DataSource = this; collectionView.Delegate = this; //collectionView.SetCollectionViewLayout(this, true); collectionView.Delegate = this; currentBarView.BackgroundColor = option.currentColor; currentBarViewHeightConstraint.Constant = option.currentBarHeight; if (!isInfinity) { currentBarView.RemoveFromSuperview(); collectionView.AddSubview(currentBarView); collectionView.TranslatesAutoresizingMaskIntoConstraints = false; var topOne = NSLayoutConstraint.Create(currentBarView, NSLayoutAttribute.Top, NSLayoutRelation.Equal, collectionView, NSLayoutAttribute.Top, 1.0f, option.tabHeight - currentBarViewHeightConstraint.Constant); var leftOne = NSLayoutConstraint.Create(currentBarView, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, collectionView, NSLayoutAttribute.Leading, 1.0f, 0.0f); currentBarViewLeftConstraint = leftOne; collectionView.AddConstraints(new[] { topOne, leftOne }); } bottomBarViewHeightConstraint.Constant = 1.0f / UIScreen.MainScreen.Scale; }
internal static RuntimeOptions Read() { // for iOS NSBundle.ResourcePath returns the path to the root of the app bundle // for macOS apps NSBundle.ResourcePath returns foo.app/Contents/Resources // for macOS frameworks NSBundle.ResourcePath returns foo.app/Versions/Current/Resources Class bundle_finder = new Class(typeof(NSObject.NSObject_Disposer)); var resource_dir = NSBundle.FromClass(bundle_finder).ResourcePath; var plist_path = GetFileName(resource_dir); if (!File.Exists(plist_path)) { return(null); } using (var plist = NSDictionary.FromFile(plist_path)) { var options = new RuntimeOptions(); options.http_message_handler = (NSString)plist ["HttpMessageHandler"]; return(options); } }
public void SetupView() { var bundle = NSBundle.FromClass(this.Class); var nib = UINib.FromName("MenuItemView", bundle); var stackView = nib.Instantiate(this, null).FirstOrDefault() as UIStackView; if (stackView is null) { return; } var imageView = stackView.ViewWithTag((int)SubView.ImageView) as UIImageView; if (imageView is null) { return; } var titleLabel = stackView.ViewWithTag((int)SubView.TitleLabel) as UILabel; if (titleLabel is null) { return; } var subTitleLabel = stackView.ViewWithTag((int)SubView.SubTitleLabel) as UILabel; if (subTitleLabel is null) { return; } AddSubview(stackView); ImageView = imageView; TitleLabel = titleLabel; SubTitleLabel = subTitleLabel; ImageView.ClipsToBounds = true; ImageView.Layer.CornerRadius = 8; }
//#pragma mark - Accessing keyboard images. public UIImage _keyboardImageNamed(string name) { string resource = new NSString(name).DeletePathExtension(); string extension = new NSString(name).PathExtension; if (resource != null) { NSBundle bundle = NSBundle.FromClass(this.Class); if (bundle != null) { string resourcePath = bundle.PathForResource(resource, /*ofType*/ extension); return(UIImage.FromFile(resourcePath)); } else { return(UIImage.FromBundle(name)); } } return(null); }
public ButtonBarPagerTabStripViewController() { Delegate = this; DataSource = this; Func <IndicatorInfo, nfloat> widthCallback = GetWidth; ButtonBarItemSpec = ButtonBarItemSpec <ButtonBarViewCell> .Create(widthCallback, "ButtonCell", NSBundle.FromClass(new ObjCRuntime.Class(typeof(ButtonBarViewCell)))); }
public override void ViewDidLoad() { base.ViewDidLoad(); ButtonBarItemSpec = ButtonBarItemSpec.NibFile( nibName: "ButtonCell", bundle: NSBundle.FromClass(new ObjCRuntime.Class(typeof(ButtonBarViewCell))), width: (childItemInfo) => { var label = new UILabel(); label.TranslatesAutoresizingMaskIntoConstraints = false; label.Font = this.Settings.Style.ButtonBarItemFont; label.Text = childItemInfo.Title; var labelSize = label.IntrinsicContentSize; return labelSize.Width + (this.Settings.Style.ButtonBarItemLeftRightMargin?? 8) * 2; }); UICollectionViewFlowLayout flowLayout; if (ButtonBarView == null) { flowLayout = new UICollectionViewFlowLayout(); flowLayout.ScrollDirection = UICollectionViewScrollDirection.Horizontal; var buttonBarHeight = Settings.Style.ButtonBarHeight ?? 44f; var buttonBar = new ButtonBarView(new CGRect(0, 0, View.Frame.Width, buttonBarHeight), flowLayout); buttonBar.BackgroundColor = UIColor.Orange; buttonBar.SelectedBar.BackgroundColor = UIColor.Black; buttonBar.AutoresizingMask = UIViewAutoresizing.FlexibleWidth; var newContainerViewFrame = ContainerView.Frame; newContainerViewFrame.Y = buttonBarHeight; newContainerViewFrame.Height = ContainerView.Frame.Height - (buttonBarHeight - ContainerView.Frame.Y); ContainerView.Frame = newContainerViewFrame; ButtonBarView = buttonBar; } if (ButtonBarView.Superview == null) { View.AddSubview(ButtonBarView); } if (ButtonBarView.Delegate == null) { ButtonBarView.Delegate = this; } if (ButtonBarView.DataSource == null) { ButtonBarView.DataSource = this; } ButtonBarView.ScrollsToTop = false; flowLayout = ButtonBarView.CollectionViewLayout as UICollectionViewFlowLayout; flowLayout.ScrollDirection = UICollectionViewScrollDirection.Horizontal; flowLayout.MinimumInteritemSpacing = 0; flowLayout.MinimumLineSpacing = Settings.Style.ButtonBarMinimumLineSpacing ?? flowLayout.MinimumLineSpacing; var sectionInset = flowLayout.SectionInset; flowLayout.SectionInset = new UIEdgeInsets(sectionInset.Top, Settings.Style.ButtonBarLeftContentInset ?? sectionInset.Left, sectionInset.Bottom, Settings.Style.ButtonBarRightContentInset ?? sectionInset.Right); ButtonBarView.ShowsHorizontalScrollIndicator = false; ButtonBarView.BackgroundColor = Settings.Style.ButtonBarBackgroundColor ?? ButtonBarView.BackgroundColor; ButtonBarView.SelectedBar.BackgroundColor = Settings.Style.SelectedBarBackgroundColor; ButtonBarView.SelectedBarHeight = Settings.Style.SelectedBarHeight; switch (ButtonBarItemSpec.ButtonBarItemSpecType) { case ButtonBarItemSpecType.NibFile: { ButtonBarView.RegisterNibForCell(UINib.FromName(ButtonBarItemSpec.NibName, ButtonBarItemSpec.Bundle), "Cell"); } break; case ButtonBarItemSpecType.CellClass: { ButtonBarView.RegisterClassForCell(typeof(ButtonBarViewCell), "Cell"); } break; } }
//TODO Navigation : launch chat from custom navigation public void LaunchChatListWithCustomNavigationBar(UIViewController viewController) { UIStoryboard Storyboard = UIStoryboard.FromName("Applozic", NSBundle.FromClass(new ALChatLauncher().Class)); }