Inheritance: MonoBehaviour
		public LoadMoreElement (string normalCaption, string loadingCaption, Action<LoadMoreElement> tapped, UIFont font, UIColor textColor) : base ("")
		{
			this.NormalCaption = normalCaption;
			this.LoadingCaption = loadingCaption;
			this.tapped = tapped;
			this.font = font;
			
			cell = new UITableViewCell (UITableViewCellStyle.Default, "loadMoreElement");
			
			activityIndicator = new UIActivityIndicatorView () {
				ActivityIndicatorViewStyle = UIActivityIndicatorViewStyle.Gray,
				Hidden = true
			};
			activityIndicator.StopAnimating ();
			
			caption = new UILabel () {
				Font = font,
				Text = this.NormalCaption,
				TextColor = textColor,
				BackgroundColor = UIColor.Clear,
				TextAlignment = UITextAlignment.Center,
				AdjustsFontSizeToFitWidth = false,
			};
			
			Layout ();
			
			cell.ContentView.AddSubview (caption);
			cell.ContentView.AddSubview (activityIndicator);
		}
        public HeaderView()
            : base(new RectangleF(0, 0, 0, 60f))
        {
            BackgroundColor = UIColor.Clear;
            SeperatorColor = UIColor.FromRGB(199, 199, 204);

            _titleFont = TitleFont.WithSize(TitleFont.PointSize * Theme.CurrentTheme.FontSizeRatio);
            if (_titleFont == null)
                _titleFont = TitleFont;

            _subtitleFont = SubtitleFont.WithSize(SubtitleFont.PointSize * Theme.CurrentTheme.FontSizeRatio);
            if (_subtitleFont == null)
                _subtitleFont = SubtitleFont;

            _yPad = YPad;

            if (Theme.CurrentTheme.FontSizeRatio > 1.0f)
            {
                _yPad -= ((Theme.CurrentTheme.FontSizeRatio * 1.2f * YPad) - YPad);
            }

            //            Layer.MasksToBounds = false;
            //            Layer.ShadowColor = UIColor.Gray.CGColor;
            //            Layer.ShadowOpacity = 0.4f;
            //            Layer.ShadowOffset = new SizeF(0, 1f);
        }
        public static float ContentSize(string text, float width, UIFont font)
        {
            var stringToSize = new NSString (text);
            var size = stringToSize.StringSize (font, new SizeF (width, float.MaxValue), UILineBreakMode.WordWrap);

            return size.Height;
        }
	static void Load ()
	{
		mLoaded			= true;
		mPartial		= EditorPrefs.GetString("NGUI Partial");
		mFontName		= EditorPrefs.GetString("NGUI Font Name");
		mAtlasName		= EditorPrefs.GetString("NGUI Atlas Name");
		mFontData		= GetObject("NGUI Font Asset") as TextAsset;
		mFontTexture	= GetObject("NGUI Font Texture") as Texture2D;
		mFont			= GetObject("NGUI Font") as UIFont;
		mAtlas			= GetObject("NGUI Atlas") as UIAtlas;
		mAtlasPadding	= EditorPrefs.GetInt("NGUI Atlas Padding", 1);
		mAtlasTrimming	= EditorPrefs.GetBool("NGUI Atlas Trimming", true);
		mAtlasPMA		= EditorPrefs.GetBool("NGUI Atlas PMA", true);
		mUnityPacking	= EditorPrefs.GetBool("NGUI Unity Packing", true);
		mForceSquare	= EditorPrefs.GetBool("NGUI Force Square Atlas", true);
		mPivot			= (UIWidget.Pivot)EditorPrefs.GetInt("NGUI Pivot", (int)mPivot);
		mLayer			= EditorPrefs.GetInt("NGUI Layer", -1);
		mDynFont		= GetObject("NGUI DynFont") as Font;
		mDynFontSize	= EditorPrefs.GetInt("NGUI DynFontSize", 16);
		mDynFontStyle	= (FontStyle)EditorPrefs.GetInt("NGUI DynFontStyle", (int)FontStyle.Normal);

		if (mLayer < 0 || string.IsNullOrEmpty(LayerMask.LayerToName(mLayer))) mLayer = -1;

		if (mLayer == -1) mLayer = LayerMask.NameToLayer("UI");
		if (mLayer == -1) mLayer = LayerMask.NameToLayer("GUI");
		if (mLayer == -1) mLayer = 5;

		EditorPrefs.SetInt("UI Layer", mLayer);

		LoadColor();
	}
 public SplitElement(Row row)
     : base(UITableViewCellStyle.Default, "splitelement")
 {
     Value = row;
     BackgroundColor = UIColor.White;
     _font = Font.WithSize(Font.PointSize * Element.FontSizeRatio);
 }
        public static UIImage AddText(this UIImage image, string text, PointF point, UIFont font, UIColor color, UITextAlignment alignment = UITextAlignment.Left)
        {
            //var labelRect = new RectangleF(point, new SizeF(image.Size.Width - point.X, image.Size.Height - point.Y));
            var h = text.StringHeight(font, image.Size.Width);
            var labelRect = new RectangleF(point, new SizeF(image.Size.Width - point.X, h));

            var label = new UILabel(labelRect)
            { 
                Font = font, 
                Text = text,
                TextColor = color,
                TextAlignment = alignment,
                BackgroundColor = UIColor.Clear
            };

            var labelImage = label.ToNativeImage();
            

            using (var context = image.Size.ToBitmapContext())
            {
                var rect = new RectangleF(new PointF(0, 0), image.Size);
                context.DrawImage(rect, image.CGImage);
                context.DrawImage(labelRect, labelImage.CGImage);
                context.StrokePath();
                return UIImage.FromImage(context.ToImage());
            }
        }
Exemple #7
0
    static void CreateFont(UIFont font, int create, Material mat)
    {
        if (create == 1)
        {
            // New dynamic font
            font.atlas = null;
            font.dynamicFont = NGUISettings.dynamicFont;
            font.dynamicFontSize = NGUISettings.dynamicFontSize;
            font.dynamicFontStyle = NGUISettings.dynamicFontStyle;
        }
        else
        {
            // New bitmap font
            font.dynamicFont = null;
            BMFontReader.Load(font.bmFont, NGUITools.GetHierarchy(font.gameObject), NGUISettings.fontData.bytes);

            if (create == 2)
            {
                font.atlas = null;
                font.material = mat;
            }
            else if (create == 3)
            {
                font.spriteName = NGUISettings.fontTexture.name;
                font.atlas = NGUISettings.atlas;
            }
        }
    }
Exemple #8
0
        UIFont font = null; //UIFont.SystemFontOfSize(20);

        #endregion Fields

        #region Constructors

        public Font(string fontname,int fontsize)
        {
            font =UIFont.FromName(fontname,fontsize);
            if(font==null)font=UIFont.SystemFontOfSize(fontsize);
            maxcharheight =(int)font.LineHeight;
            //if (gbmp == null)
            {
            //				gdata = new byte[128 * 128 * 4];
            //				var colorSpace = CGColorSpace.CreateDeviceRGB();
            //				gbmp = new CGBitmapContext(gdata, 128, 128,
            //				                                        8, 128 * 4, colorSpace, CGBitmapFlags.PremultipliedLast);
                //gbmp =new Bitmap(128,128);
                //gfont = Graphics.FromImage(gbmp);
                //gfont.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit;
                //gfont.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
            }

            //GdiFont = new System.Drawing.Font(fontname, fontsize,GraphicsUnit.Pixel);
            //maxcharheight = GdiFont.Height;

            //设置文本输出质量
            //g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
            //g.SmoothingMode = SmoothingMode.AntiAlias;
            //Font newFont = new Font("Times New Roman", 48);
        }
 private void InitFonts()
 {
     _font1 = UIFont.FromName ("HelveticaNeue", 18f);
     _font2 = UIFont.FromName ("HelveticaNeue-Medium", 18f);
     _font3 = UIFont.FromName ("HelveticaNeue-Bold", 18f);
     _roubleFont = UIFont.FromName("Ruble", 18f);
 }
        /// <summary>
        /// Initializes the panel's controls.
        /// </summary>
        /// <param name="titleFont">The font to use for the settings panel title.</param>
        /// <param name="labelTemplate">The template to use for all settings labels.</param>
        public void Initialize(UIFont titleFont, UILabel labelTemplate) {
            this.backgroundSprite = "MenuPanel";
            this.isVisible = false;
            this.canFocus = true;
            this.isInteractive = true;
            this.height = TitleBarHeight + 8f;
            this.width = PanelWidth;

            this.CreatePanelTitle(titleFont);
            this.CreateDragHandle();
            this.CreateCloseButton();
            this.CreateControlPanel();

            int zOrder = 1;
            
            this.defaultVisibilityCheckBox = this.CreateSettingsControl(
                CityVitalsWatch.Settings.DefaultPanelVisibility, "Default Visibility", true, labelTemplate, ref zOrder);
            this.transparentUnhoveredCheckBox = this.CreateSettingsControl(
                CityVitalsWatch.Settings.TransparentUnhovered, "Transparent Unhovered", true, labelTemplate, ref zOrder);

            this.statControlMap = new Dictionary<CityVitalsWatchStat, UICheckBox>();

            foreach (CityVitalsWatchStat stat in Enum.GetValues(typeof(CityVitalsWatchStat)).Cast<CityVitalsWatchStat>()) {
                this.statControlMap[stat] = this.CreateSettingsControl(
                    CityVitalsWatch.Settings.StatDisplayed(stat), StatLocaleIdMap[stat], false, labelTemplate, ref zOrder);
            }
        }
Exemple #11
0
		public AddLoadMoreElement (string _placeholder, Action<AddLoadMoreElement> tapped) : base ("")
		{
			placeholder = _placeholder;
			
			Tapped += tapped;
			Font = font;
							
		}
Exemple #12
0
 public static void RegisterFont(UIFont font)
 {
     if (font.UseDynamicFont && !_fontList.Contains(font.dynamicFont))
     {
         _fontList.Add(font.dynamicFont);
         font.dynamicFont.textureRebuildCallback += OnFontRebuilt;
     }
 }
		public LoadMoreElement (string normalCaption, string loadingCaption, Action<LoadMoreElement> tapped, UIFont font, UIColor textColor) : base ("")
		{
			NormalCaption = normalCaption;
			LoadingCaption = loadingCaption;
			Tapped += tapped;
			Font = font;
			TextColor = textColor;
		}
 public CustomFontMultilineElement(string caption, string value, int fontSize, FontStyle fontStyle, FontStyle detailFontStyle)
     : base(caption, value)
 {
     _font = GetFontFromStyle (fontStyle, fontSize);
     TextColor = ApplicationColors.TABLE_FONT;
     _detailFont = GetFontFromStyle (detailFontStyle, fontSize);
     DetailColor = ApplicationColors.TABLE_DETAIL_FONT;
 }
Exemple #15
0
 public static void OnFontRebuilt(UIFont font)
 {
     UILabel[] list = GameObject.FindObjectsOfType(typeof(UILabel)) as UILabel[];
     foreach (UILabel label in list)
     {
         if (label.font == font)
             label.MarkAsChanged();
     }
 }
Exemple #16
0
 static CustomCell()
 {
     if (font == null)
         font = UIFont.BoldSystemFontOfSize(UIFont.SystemFontSize);
     if (background == null)
         background = UIImage.FromFile(@"Images/cell-background.png");
     if (textColor == null)
         textColor = UIColor.FromRGBA(255, 255, 255, 32);
 }
		public LoadMoreElement (string normalCaption, string loadingCaption, Action<LoadMoreElement> tapped, UIFont font, UIColor textColor) 
            : base (UITableViewCellStyle.Default, key.ToString())
		{
			NormalCaption = normalCaption;
			LoadingCaption = loadingCaption;
			Tapped += tapped;
			Font = font;
			TextColor = textColor;
		}
        protected virtual float GetLineHeight(UIFont font)
        {
            if (Math.Abs(font.PointSize - AppDelegate.Font16pt) < 0.5)
            {
                return 26;
            }

            return 15;
        }
		public UIFont ResizeProportionalAndAlternative (UIFont font)
		{
			var attributes = new UIFontAttributes (
				                 new UIFontFeature (CTFontFeatureNumberSpacing.Selector.ProportionalNumbers),
				                 new UIFontFeature ((CTFontFeatureCharacterAlternatives.Selector)1));

			var newDesc = font.FontDescriptor.CreateWithAttributes (attributes);
			return UIFont.FromDescriptor (newDesc, 40);	
		}
Exemple #20
0
    void OnSelectFont(Object obj) {
        // Undo doesn't work correctly in this case... so I won't bother.
        //NGUIEditorTools.RegisterUndo("Font Change");
        //NGUIEditorTools.RegisterUndo("Font Change", mFont);

        mFont.replacement = obj as UIFont;
        mReplacement = mFont.replacement;
        NGUITools.SetDirty(mFont);
    }
        public NameTimeStringElement() 
            : base(UITableViewCellStyle.Default, "nametimestringelement")
        {
            Lines = 9999;
			BackgroundColor = UIColor.White;
            _dateFont = DateFont.WithSize(DateFont.PointSize * Element.FontSizeRatio);
            _userFont = UserFont.WithSize(UserFont.PointSize * Element.FontSizeRatio);
            _descFont = DescFont.WithSize(DescFont.PointSize * Element.FontSizeRatio);
        }
 public FinanceElement(string caption, double amount, float captionFontSize, float amountFontSize)
     : base(UITableViewCellStyle.Default, "financeElement")
 {
     this.Label = caption;
     this.Amount = amount;
     captionFont = UIFont.SystemFontOfSize (captionFontSize);
     amountFont = UIFont.BoldSystemFontOfSize (amountFontSize);
     SetUp ();
 }
        public static float MonoStringHeight(this string s, UIFont font, float maxWidth)
        {
            if (string.IsNullOrEmpty(s))
                return 0f;

            using (var str = new NSString (s))
            {
                return str.StringSize(font, new SizeF(maxWidth, 1000), UILineBreakMode.WordWrap).Height;
            }
        }
        public static float MonoStringLength(this string s, UIFont font)
        {
            if (string.IsNullOrEmpty(s))
                return 0f;

            using (var str = new NSString (s))
            {
                return str.StringSize(font).Width;
            }
        }
        private void SetText(UILabel label, UIFont font, RoubleType type)
        {
            char roubleSym = Roubles.GetRoubleSymbFor (type);

            NSMutableAttributedString attrString = new NSMutableAttributedString();
            attrString.Append(new NSAttributedString(Text, font: font, foregroundColor: UIColor.Black));
            attrString.Append(new NSAttributedString(roubleSym.ToString(), font: _roubleFont, foregroundColor: UIColor.Black));

            label.AttributedText = attrString;
        }
		public ChatBubbleCell (bool isLeft, bool isAttaPresent, bool delivered) : base (UITableViewCellStyle.Default, isLeft ? KeyLeft : KeyRight){

			var rect = new RectangleF (0, 0, 1, 1);
			this.isLeft = isLeft;
			view = new UIView (rect);

			if(delivered){
				imageView = new UIImageView (isLeft ? left : right);
			}else
				imageView = new UIImageView (sendfalied);

			view.AddSubview (imageView);

			font = UIFont.PreferredBody;
			infoFont = UIFont.PreferredCaption1;

			label = new UILabel (rect) {
				LineBreakMode = UILineBreakMode.WordWrap,
				Lines = 0,
				Font = font,
				TextColor = (isLeft ? UIColor.Black : UIColor.White),
				BackgroundColor = UIColor.Clear
			};

			view.AddSubview (label);

			senderLabel = new UILabel (rect) {
				Lines = 1,
				TextAlignment = (isLeft ? UITextAlignment.Left : UITextAlignment.Right),
				Font = infoFont,
				TextColor = UIColor.Gray,
				BackgroundColor = UIColor.Clear

			};

			view.AddSubview (senderLabel);

			icon = UIImage.FromFile("Images/lock_30.png");
			var imgRect = new RectangleF (0, 0, 15, 15);
			imgView = new UIImageView(icon);
			imageView.Frame = imgRect;

			view.AddSubview (imgView);

			undelivered = new UIButton (UIButtonType.DetailDisclosure);
			this.undelivered.TouchDown += (sender, e) => new UIAlertView("Error", "Error sending message", null, "OK", null).Show();
			undelivered.TintColor = UIColor.Red;
			undelivered.Hidden = true;

			view.AddSubview (undelivered);

			ContentView.Add (view);
			canDelete = true;

		}
Exemple #27
0
	void OnSelectFont (MonoBehaviour obj)
	{
		// Undo doesn't work correctly in this case... so I won't bother.
		//NGUIEditorTools.RegisterUndo("Font Change");
		//NGUIEditorTools.RegisterUndo("Font Change", mFont);

		mFont.replacement = obj as UIFont;
		mReplacement = mFont.replacement;
		UnityEditor.EditorUtility.SetDirty(mFont);
		if (mReplacement == null) mType = FontType.Normal;
	}
		public AddLoadMoreWithImageElement (string _placeholder, UIImage image, Action<AddLoadMoreWithImageElement> tapped) : base ("")
		{
			activityImage = image;
			
			BackgroundColor = UIColor.Clear;
			
			placeholder = _placeholder;
			
			Tapped += tapped;
			Font = font;						
		}
        public static float StringHeight(this string text, UIFont font, float width)
        {
            var nativeString = new NSString(text);

            var rect = nativeString.GetBoundingRect(
                new System.Drawing.SizeF(width, float.MaxValue),
                NSStringDrawingOptions.UsesLineFragmentOrigin,
                new UIStringAttributes() { Font = font },
                null);

            return rect.Height;
        }
 public UIButtonElementRenderer(outki.UIButtonElement element)
 {
     m_element = element;
     if (m_element.Style != null)
     {
         m_f0 = new UIFill(m_element.Style.Normal);
         m_f1 = new UIFill(m_element.Style.Highlight);
         m_f2 = new UIFill(m_element.Style.Pressed);
         if (m_element.Style.FontStyle != null)
             m_font = new UIFont(m_element.Style.FontStyle.Font);
     }
 }
        internal static NSAttributedString ToNSAttributedString(this F9PFormattedString formattedString, UIFont baseFont, UIColor baseColor) //, EllipsePlacement ellipsePlacement = EllipsePlacement.None, int secondToLastEnd = -1, int lastLineStart = 0, int lastLineEnd = -1, int startLastVisible = -1, int midLastVisible = -1, bool twice=false) {
        {
            var text = formattedString?.Text;

            if (string.IsNullOrEmpty(text))
            {
                return(null);
            }
            if (formattedString is HTMLMarkupString hTMLMarkupString)
            {
                text = hTMLMarkupString.UnmarkedText;
            }

            var result = new NSMutableAttributedString(text);

            result.AddAttribute(UIStringAttributeKey.Font, baseFont, new NSRange(0, text.Length));
            result.AddAttribute(UIStringAttributeKey.ForegroundColor, baseColor, new NSRange(0, text.Length));

            #region Layout font-spans (MetaFonts)

            var metaFonts    = new List <MetaFont>();
            var baseMetaFont = new MetaFont(
                baseFont.FamilyName,
                (float)baseFont.PointSize,
                (baseFont.FontDescriptor.Traits.SymbolicTrait & UIFontDescriptorSymbolicTraits.Bold) > 0,
                (baseFont.FontDescriptor.Traits.SymbolicTrait & UIFontDescriptorSymbolicTraits.Italic) > 0);

            MathMetaFont = MathMetaFont ?? new MetaFont("STIXGeneral", (float)baseFont.PointSize);


            for (int i = 0; i < text.Length; i++)
            {
                if (i + 1 < text.Length && text[i] == '\ud835' && text[i + 1] >= '\udc00' && text[i + 1] <= '\udeff')
                {
                    metaFonts.Add(new MetaFont(MathMetaFont));
                    metaFonts.Add(new MetaFont(MathMetaFont));  // there are two because we're using a double byte unicode character
                    i++;
                }
                else
                {
                    metaFonts.Add(new MetaFont(baseMetaFont));
                }
            }
            #endregion

            #region Apply non-font Spans
            foreach (var span in formattedString._spans)
            {
                int spanStart = span.Start;
                int spanEnd   = span.End;

                spanEnd++;
                if (spanEnd > result.Length)
                {
                    spanEnd = (int)result.Length - 1;
                }



                NSDictionary attr;
                switch (span.Key)
                {
                    #region Spans that change UIFont attributes
                case FontFamilySpan.SpanKey:
                    for (int i = spanStart; i < spanEnd; i++)
                    {
                        metaFonts[i].Family = ((FontFamilySpan)span).FontFamilyName;
                    }
                    break;

                case FontSizeSpan.SpanKey:
                    for (int i = spanStart; i < spanEnd; i++)
                    {
                        float size = ((FontSizeSpan)span).Size;
                        metaFonts[i].Size = (size < 0 ? metaFonts[i].Size * (-size) : size);
                    }
                    break;

                case BoldSpan.SpanKey:
                    for (int i = spanStart; i < spanEnd; i++)
                    {
                        metaFonts[i].Bold = true;
                    }
                    break;

                case ItalicsSpan.SpanKey:
                    for (int i = spanStart; i < spanEnd; i++)
                    {
                        metaFonts[i].Italic = true;
                    }
                    break;

                case SuperscriptSpan.SpanKey:
                    for (int i = spanStart; i < spanEnd; i++)
                    {
                        metaFonts[i].Baseline = FontBaseline.Superscript;
                    }
                    break;

                case SubscriptSpan.SpanKey:
                    for (int i = spanStart; i < spanEnd; i++)
                    {
                        metaFonts[i].Baseline = FontBaseline.Subscript;
                    }
                    break;

                case NumeratorSpan.SpanKey:
                    for (int i = spanStart; i < spanEnd; i++)
                    {
                        metaFonts[i].Baseline = FontBaseline.Numerator;
                    }
                    break;

                case DenominatorSpan.SpanKey:
                    for (int i = spanStart; i < spanEnd; i++)
                    {
                        metaFonts[i].Baseline = FontBaseline.Denominator;
                    }
                    break;

                case ActionSpan.SpanKey:
                    attr = new NSMutableDictionary
                    {
                        [UIStringAttributeKey.ForegroundColor]    = Xamarin.Forms.Color.Blue.ToUIColor(),
                        [UIStringAttributeKey.UnderlineColor]     = Xamarin.Forms.Color.Blue.ToUIColor(),
                        [UIStringAttributeKey.StrikethroughColor] = Xamarin.Forms.Color.Blue.ToUIColor()
                    };
                    var uAttr = new NSDictionary(UIStringAttributeKey.UnderlineStyle, NSUnderlineStyle.Single);
                    attr[UIStringAttributeKey.UnderlineStyle] = uAttr[UIStringAttributeKey.UnderlineStyle];
                    result.AddAttributes(attr, new NSRange(spanStart, spanEnd - spanStart));
                    break;

                    #endregion
                    #region Font Color
                case FontColorSpan.SpanKey:
                    var fontColorSpan = span as FontColorSpan;
                    attr = new NSMutableDictionary
                    {
                        [UIStringAttributeKey.ForegroundColor]    = fontColorSpan.Color.ToUIColor(),
                        [UIStringAttributeKey.UnderlineColor]     = fontColorSpan.Color.ToUIColor(),
                        [UIStringAttributeKey.StrikethroughColor] = fontColorSpan.Color.ToUIColor()
                    };
                    result.AddAttributes(attr, new NSRange(spanStart, spanEnd - spanStart));
                    break;

                    #endregion
                    #region Background Color
                case BackgroundColorSpan.SpanKey:
                    var backgroundColorSpan = span as BackgroundColorSpan;
                    attr = new NSDictionary(UIStringAttributeKey.BackgroundColor, backgroundColorSpan.Color.ToUIColor());
                    result.AddAttributes(attr, new NSRange(spanStart, spanEnd - spanStart));
                    break;

                    #endregion
                    #region Underline
                case UnderlineSpan.SpanKey:
                    attr = new NSDictionary(UIStringAttributeKey.UnderlineStyle, NSUnderlineStyle.Single);
                    result.AddAttributes(attr, new NSRange(spanStart, spanEnd - spanStart));
                    break;

                    #endregion
                    #region Strikethrough
                case StrikethroughSpan.SpanKey:
                    attr = new NSDictionary(UIStringAttributeKey.StrikethroughStyle, NSUnderlineStyle.Single);
                    result.AddAttributes(attr, new NSRange(spanStart, spanEnd - spanStart));
                    break;
                    #endregion
                }
            }
            #endregion

            #region Apply MetaFonts
            // run through MetaFonts to see if we need to set new Font attributes
            var lastMetaFont = baseMetaFont;
            int startIndex   = 0;
            for (int i = 0; i < metaFonts.Count; i++)
            {
                var metaFont = metaFonts[i];
                if (lastMetaFont != metaFont)
                {
                    // we are at the start of a new span
                    if (i > 0 && lastMetaFont != baseMetaFont)
                    {
                        // and we've been inside of a metaFont span
                        var font  = FontExtensions.BestFont(lastMetaFont, baseFont);
                        var size  = lastMetaFont.Size;
                        var range = new NSRange(startIndex, i - startIndex);
                        switch (lastMetaFont.Baseline)
                        {
                        case FontBaseline.Superscript:
                            result.AddAttributes(new NSDictionary(UIStringAttributeKey.BaselineOffset, size / 2.22f, UIStringAttributeKey.Font, font), range);
                            break;

                        case FontBaseline.Subscript:
                            result.AddAttributes(new NSDictionary(UIStringAttributeKey.BaselineOffset, -size / 6f, UIStringAttributeKey.Font, font), range);
                            break;

                        case FontBaseline.Numerator:
                            result.AddAttributes(new NSDictionary(UIStringAttributeKey.BaselineOffset, size / 4f, UIStringAttributeKey.Font, font), range);
                            break;

                        //case FontBaseline.Denominator:
                        //	result.AddAttributes(new NSDictionary(UIStringAttributeKey.BaselineOffset, -size / 6f, UIStringAttributeKey.Font, font), range);
                        //	break;
                        default:
                            result.AddAttribute(UIStringAttributeKey.Font, font, range);
                            break;
                        }
                        //System.Diagnostics.Debug.WriteLine("\tRANGE["+range.Location+","+range.Length+"]");
                    }
                    lastMetaFont = metaFont;
                    startIndex   = i;
                }
            }
            if (lastMetaFont != baseMetaFont)
            {
                // and we've been inside of a metaFont span
                var font  = FontExtensions.BestFont(lastMetaFont, baseFont);
                var size  = lastMetaFont.Size;
                var range = new NSRange(startIndex, metaFonts.Count - startIndex);
                switch (lastMetaFont.Baseline)
                {
                case FontBaseline.Superscript:
                    result.AddAttributes(new NSDictionary(UIStringAttributeKey.BaselineOffset, size / 2.22f, UIStringAttributeKey.Font, font), range);
                    break;

                case FontBaseline.Subscript:
                    result.AddAttributes(new NSDictionary(UIStringAttributeKey.BaselineOffset, -size / 6f, UIStringAttributeKey.Font, font), range);
                    break;

                case FontBaseline.Numerator:
                    result.AddAttributes(new NSDictionary(UIStringAttributeKey.BaselineOffset, size / 4f, UIStringAttributeKey.Font, font), range);
                    break;

                //case FontBaseline.Denominator:
                //	result.AddAttributes(new NSDictionary(UIStringAttributeKey.BaselineOffset, -size / 6f, UIStringAttributeKey.Font, font), range);
                //	break;
                default:
                    result.AddAttribute(UIStringAttributeKey.Font, font, range);
                    break;
                }
                //System.Diagnostics.Debug.WriteLine("\tRANGE[" + range.Location + "," + range.Length + "]");
            }
            #endregion

            return(result);
        }
Exemple #32
0
        void AddNativeControls(NestedNativeControlGalleryPage page)
        {
            if (page.NativeControlsAdded)
            {
                return;
            }

            StackLayout sl = page.Layout;

            // Create and add a native UILabel
            var originalText = "I am a native UILabel";
            var longerText   =
                "I am a native UILabel with considerably more text. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.";

            var uilabel = new UILabel
            {
                MinimumFontSize = 14f,
                Text            = originalText,
                Lines           = 0,
                LineBreakMode   = UILineBreakMode.WordWrap,
                Font            = UIFont.FromName("Helvetica", 24f)
            };

            sl?.Children.Add(uilabel);

            // Create and add a native Button
            var uibutton = new UIButton(UIButtonType.System);

            uibutton.SetTitle("Toggle Text Amount", UIControlState.Normal);
            uibutton.Font = UIFont.FromName("Helvetica", 14f);


            uibutton.TouchUpInside += (sender, args) =>
            {
                uilabel.Text = uilabel.Text == originalText ? longerText : originalText;
                uilabel.SizeToFit();
            };

            sl?.Children.Add(uibutton.ToView());

            // Create some control which we know don't behave correctly with regard to measurement
            var difficultControl0 = new BrokenNativeControl
            {
                MinimumFontSize = 14f,
                Font            = UIFont.FromName("Helvetica", 14f),
                Lines           = 0,
                LineBreakMode   = UILineBreakMode.WordWrap,
                Text            = "Doesn't play nice with sizing. That's why there's a big gap around it."
            };

            var difficultControl1 = new BrokenNativeControl
            {
                MinimumFontSize = 14f,
                Font            = UIFont.FromName("Helvetica", 14f),
                Lines           = 0,
                LineBreakMode   = UILineBreakMode.WordWrap,
                Text            = "Custom size fix specified. No gaps."
            };

            var explanation0 = new UILabel
            {
                MinimumFontSize = 14f,
                Text            = "The next control is a customized label with a bad SizeThatFits implementation.",
                Lines           = 0,
                LineBreakMode   = UILineBreakMode.WordWrap,
                Font            = UIFont.FromName("Helvetica", 24f)
            };

            var explanation1 = new UILabel
            {
                MinimumFontSize = 14f,
                Text            = "The next control is the same broken class as above, but we pass in an override to the GetDesiredSize method.",
                Lines           = 0,
                LineBreakMode   = UILineBreakMode.WordWrap,
                Font            = UIFont.FromName("Helvetica", 24f)
            };

            // Add a misbehaving control
            sl?.Children.Add(explanation0);
            sl?.Children.Add(difficultControl0);

            // Add the misbehaving control with a custom delegate for FixSize
            sl?.Children.Add(explanation1);
            sl?.Children.Add(difficultControl1, FixSize);

            page.NativeControlsAdded = true;
        }
Exemple #33
0
        public void loadOptionView()
        {
            //PrecisionButton
            precisionButton = new UIButton();
            precisionButton.SetTitle("Standard", UIControlState.Normal);
            precisionButton.Font = UIFont.FromName("Helvetica", 14f);
            precisionButton.SetTitleColor(UIColor.Black, UIControlState.Normal);
            precisionButton.HorizontalAlignment = UIControlContentHorizontalAlignment.Center;
            precisionButton.Layer.CornerRadius  = 8;
            precisionButton.Layer.BorderWidth   = 2;
            precisionButton.TouchUpInside      += ShowPicker1;
            precisionButton.Layer.BorderColor   = UIColor.FromRGB(246, 246, 246).CGColor;

            //TooltipButton
            toolTipButton = new UIButton();
            toolTipButton.SetTitle("None", UIControlState.Normal);
            toolTipButton.Font = UIFont.FromName("Helvetica", 14f);
            toolTipButton.SetTitleColor(UIColor.Black, UIControlState.Normal);
            toolTipButton.HorizontalAlignment = UIControlContentHorizontalAlignment.Center;
            toolTipButton.Layer.CornerRadius  = 8;
            toolTipButton.Layer.BorderWidth   = 2;
            toolTipButton.TouchUpInside      += ShowPicker2;
            toolTipButton.Layer.BorderColor   = UIColor.FromRGB(246, 246, 246).CGColor;

            //DoneButton
            doneButton.SetTitle("Done\t", UIControlState.Normal);
            doneButton.SetTitleColor(UIColor.Black, UIControlState.Normal);
            doneButton.HorizontalAlignment = UIControlContentHorizontalAlignment.Right;
            doneButton.Font            = UIFont.FromName("Helvetica", 14f);
            doneButton.TouchUpInside  += HidePicker;
            doneButton.Hidden          = true;
            doneButton.BackgroundColor = UIColor.FromRGB(240, 240, 240);

            //Picker
            precisionPicker       = new UIPickerView();
            toolTipPicker         = new UIPickerView();
            model                 = new PickerModel(precisionList);
            precisionPicker.Model = model;
            model1                = new PickerModel(toottipplace);
            toolTipPicker.Model   = model1;
            model.PickerChanged  += SelectedIndexChanged;
            model1.PickerChanged += SelectedIndexChanged1;
            precisionPicker.ShowSelectionIndicator = true;
            precisionPicker.Hidden               = true;
            toolTipPicker.Hidden                 = true;
            precisionPicker.BackgroundColor      = UIColor.Gray;
            toolTipPicker.BackgroundColor        = UIColor.Gray;
            toolTipPicker.ShowSelectionIndicator = true;

            //ItemCountTextField
            itemCountTextfield = new UITextView();
            itemCountTextfield.TextAlignment     = UITextAlignment.Center;
            itemCountTextfield.Layer.BorderColor = UIColor.Black.CGColor;
            itemCountTextfield.BackgroundColor   = UIColor.FromRGB(246, 246, 246);
            itemCountTextfield.KeyboardType      = UIKeyboardType.NumberPad;
            itemCountTextfield.Text     = "5";
            itemCountTextfield.Font     = UIFont.FromName("Helvetica", 14f);
            itemCountTextfield.Changed += (object sender, EventArgs e) =>
            {
                if (itemCountTextfield.Text.Length > 0)
                {
                    rating1.ItemCount = int.Parse(itemCountTextfield.Text);
                }
                else
                {
                    rating1.ItemCount = 5;
                }
                UpdateText();
            };

            //adding to controlView
            controlView.AddSubview(rating1);
            controlView.AddSubview(rating2);
            controlView.AddSubview(movieRateLabel);
            controlView.AddSubview(walkLabel);
            controlView.AddSubview(timeLabel);
            controlView.AddSubview(descriptionLabel);
            controlView.AddSubview(rateLabel);
            controlView.AddSubview(valueLabel);
            controlView.AddSubview(image1);
            controlView.AddSubview(itemCountTextfield);
            this.AddSubview(controlView);

            //Adding to content view
            contentView.AddSubview(precisionLabel);
            contentView.AddSubview(toolTipLabel);
            contentView.AddSubview(precisionButton);
            contentView.AddSubview(itemCountLabel);
            contentView.AddSubview(toolTipButton);
            contentView.AddSubview(precisionPicker);
            contentView.AddSubview(toolTipPicker);
            contentView.AddSubview(doneButton);
            contentView.AddSubview(itemCountTextfield);
            contentView.BackgroundColor = UIColor.FromRGB(240, 240, 240);


            //PropertyLabel
            propertiesLabel      = new UILabel();
            propertiesLabel.Text = " OPTIONS";


            //ShowpropertyButton
            showPropertyButton        = new UIButton();
            showPropertyButton.Hidden = true;
            showPropertyButton.SetTitle("OPTIONS\t", UIControlState.Normal);
            showPropertyButton.HorizontalAlignment = UIControlContentHorizontalAlignment.Left;
            showPropertyButton.BackgroundColor     = UIColor.FromRGB(230, 230, 230);
            showPropertyButton.SetTitleColor(UIColor.Black, UIControlState.Normal);
            showPropertyButton.TouchUpInside += (object sender, EventArgs e) =>
            {
                subView.Hidden            = false;
                showPropertyButton.Hidden = true;
            };
            this.AddSubview(showPropertyButton);

            //CloseButton
            closeButton = new UIButton();
            closeButton.SetTitle("X\t", UIControlState.Normal);
            closeButton.HorizontalAlignment = UIControlContentHorizontalAlignment.Left;
            closeButton.BackgroundColor     = UIColor.FromRGB(230, 230, 230);
            closeButton.SetTitleColor(UIColor.Black, UIControlState.Normal);
            closeButton.TouchUpInside += (object sender, EventArgs e) =>
            {
                subView.Hidden            = true;
                showPropertyButton.Hidden = false;
            };


            //AddingGesture
            UITapGestureRecognizer tapgesture = new UITapGestureRecognizer(() =>
            {
                subView.Hidden            = true;
                showPropertyButton.Hidden = false;
            }
                                                                           );

            propertiesLabel.UserInteractionEnabled = true;
            propertiesLabel.AddGestureRecognizer(tapgesture);

            //Adding to subvieww
            subView             = new UIScrollView();
            subView.ContentSize = new CGSize(Frame.Width, 350);
            subView.AddSubview(contentView);
            subView.AddSubview(propertiesLabel);
            subView.AddSubview(closeButton);
            subView.BackgroundColor = UIColor.FromRGB(230, 230, 230);
            this.AddSubview(subView);
        }
 void OnSelectNewFont(MonoBehaviour obj)
 {
     mNewFont = obj as UIFont;
     Repaint();
 }
        public static UIFont ToNSFont(this Font self)
#endif
        {
            var size = (float)self.FontSize;

            if (self.UseNamedSize)
            {
                switch (self.NamedSize)
                {
                case NamedSize.Micro:
                    size = 12;
                    break;

                case NamedSize.Small:
                    size = 14;
                    break;

                case NamedSize.Medium:
                    size = 17;     // as defined by iOS documentation
                    break;

                case NamedSize.Large:
                    size = 22;
                    break;

                default:
                    size = 17;
                    break;
                }
            }

            var bold   = self.FontAttributes.HasFlag(FontAttributes.Bold);
            var italic = self.FontAttributes.HasFlag(FontAttributes.Italic);

            if (self.FontFamily != null)
            {
                try
                {
#if __MOBILE__
                    var descriptor = new UIFontDescriptor().CreateWithFamily(self.FontFamily);

                    if (bold || italic)
                    {
                        var traits = (UIFontDescriptorSymbolicTraits)0;
                        if (bold)
                        {
                            traits = traits | UIFontDescriptorSymbolicTraits.Bold;
                        }
                        if (italic)
                        {
                            traits = traits | UIFontDescriptorSymbolicTraits.Italic;
                        }

                        descriptor = descriptor.CreateWithTraits(traits);
                        return(UIFont.FromDescriptor(descriptor, size));
                    }
#else
                    var descriptor = new NSFontDescriptor().FontDescriptorWithFamily(self.FontFamily);

                    if (bold || italic)
                    {
                        var traits = (NSFontSymbolicTraits)0;
                        if (bold)
                        {
                            traits = traits | NSFontSymbolicTraits.BoldTrait;
                        }
                        if (italic)
                        {
                            traits = traits | NSFontSymbolicTraits.ItalicTrait;
                        }

                        descriptor = descriptor.FontDescriptorWithSymbolicTraits(traits);
                        return(NSFont.FromDescription(descriptor, size));
                    }

                    return(NSFont.FromFontName(self.FontFamily, size));
#endif
                }
                catch (Exception exception)
                {
                    Debug.WriteLine("Could not load font named: {0}", self.FontFamily);

                    if (bold)
                    {
                        return(UIFont.BoldSystemFontOfSize(size));
                    }

                    if (italic)
                    {
                        return(UIFont.ItalicSystemFontOfSize(size));
                    }

                    return(UIFont.SystemFontOfSize(size));
                }
            }

            if (bold && italic)
            {
                var defaultFont = UIFont.SystemFontOfSize(size);
#if __MOBILE__
                var descriptor = defaultFont.FontDescriptor.CreateWithTraits(UIFontDescriptorSymbolicTraits.Bold | UIFontDescriptorSymbolicTraits.Italic);
                return(UIFont.FromDescriptor(descriptor, 0));
            }
            if (italic)
            {
                return(UIFont.ItalicSystemFontOfSize(size));
            }
#else
                var descriptor = defaultFont.FontDescriptor.FontDescriptorWithSymbolicTraits(
                    NSFontSymbolicTraits.BoldTrait |
                    NSFontSymbolicTraits.ItalicTrait);

                return(NSFont.FromDescription(descriptor, 0));
            }
        /// <summary>
        /// Updates the UI.
        /// </summary>
        /// <param name="view">
        /// The view.
        /// </param>
        private void UpdateUi(ExtendedLabel view)
        {
            // Prefer font set through Font property.
            if (view.Font == Font.Default)
            {
                if (view.FontSize > 0)
                {
                    this.Control.Font = UIFont.FromName(this.Control.Font.Name, (float)view.FontSize);
                }

                if (!string.IsNullOrEmpty(view.FontName))
                {
                    var fontName = Path.GetFileNameWithoutExtension(view.FontName);

                    var font = UIFont.FromName(fontName, this.Control.Font.PointSize);

                    if (font != null)
                    {
                        this.Control.Font = font;
                    }
                }

                #region ======= This is for backward compatability with obsolete attrbute 'FontNameIOS' ========
                if (!string.IsNullOrEmpty(view.FontNameIOS))
                {
                    var font = UIFont.FromName(view.FontNameIOS, (view.FontSize > 0) ? (float)view.FontSize : 12.0f);

                    if (font != null)
                    {
                        this.Control.Font = font;
                    }
                }
                #endregion ====== End of obsolete section ==========================================================
            }

            //Do not create attributed string if it is not necesarry
            //if (!view.IsUnderline && !view.IsStrikeThrough && !view.IsDropShadow)
            //{
            //    return;
            //}

            var underline     = view.IsUnderline ? NSUnderlineStyle.Single : NSUnderlineStyle.None;
            var strikethrough = view.IsStrikeThrough ? NSUnderlineStyle.Single : NSUnderlineStyle.None;

            NSShadow dropShadow = null;

            if (view.IsDropShadow)
            {
                dropShadow = new NSShadow
                {
                    ShadowColor      = view.DropShadowColor.ToUIColor(),
                    ShadowBlurRadius = 1.4f,
                    ShadowOffset     = new CoreGraphics.CGSize(new CoreGraphics.CGPoint(0.3f, 0.8f))
                };
            }

            // For some reason, if we try and convert Color.Default to a UIColor, the resulting color is
            // either white or transparent. The net result is the ExtendedLabel does not display.
            // Only setting the control's TextColor if is not Color.Default will prevent this issue.
            if (view.TextColor != Color.Default)
            {
                this.Control.TextColor = view.TextColor.ToUIColor();
            }

            this.Control.AttributedText = new NSMutableAttributedString(view.Text,
                                                                        this.Control.Font,
                                                                        underlineStyle: underline,
                                                                        strikethroughStyle: strikethrough,
                                                                        shadow: dropShadow);;
        }
Exemple #37
0
    /// <summary>
    /// Refill the text label based on what's currently visible.
    /// </summary>

    protected void UpdateVisibleText()
    {
        if (textLabel != null)
        {
            UIFont font = textLabel.bitmapFont;

            if (font != null)
            {
                int lines    = 0;
                int maxLines = maxHeight > 0 ? Mathf.FloorToInt(maxHeight / (textLabel.fontSize * textLabel.bitmapFont.pixelSize)) : 100000;
                int offset   = Mathf.RoundToInt(mScroll);

                // Don't let scrolling to exceed the visible number of lines
                if (maxLines + offset > mTotalLines)
                {
                    offset  = Mathf.Max(0, mTotalLines - maxLines);
                    mScroll = offset;
                }

                if (style == Style.Chat)
                {
                    offset = Mathf.Max(0, mTotalLines - maxLines - offset);
                }

                StringBuilder final = new StringBuilder();

                for (int i = 0, imax = mParagraphs.Count; i < imax; ++i)
                {
                    Paragraph p = mParagraphs[i];

                    for (int b = 0, bmax = p.lines.Length; b < bmax; ++b)
                    {
                        string s = p.lines[b];

                        if (offset > 0)
                        {
                            --offset;
                        }
                        else
                        {
                            if (final.Length > 0)
                            {
                                final.Append("\n");
                            }
                            final.Append(s);
                            ++lines;
                            if (lines >= maxLines)
                            {
                                break;
                            }
                        }
                    }
                    if (lines >= maxLines)
                    {
                        break;
                    }
                }
                textLabel.text = final.ToString();
            }
        }
    }
Exemple #38
0
 public static void ApplyMovieAttributeValue(UITextView label)
 {
     label.TextColor = UIColor.FromRGB(0, 0, 0);
     label.Font = UIFont.SystemFontOfSize(12);
 }
Exemple #39
0
 public static void ApplyMovieAttributeLabel(UILabel label)
 {
     label.TextColor = UIColor.FromRGB(160, 160, 150);
     label.Font = UIFont.SystemFontOfSize(10);
 }
Exemple #40
0
    /// <summary>
    /// Draw the UI for this tool.
    /// </summary>

    void OnGUI()
    {
        Object fnt    = NGUISettings.ambigiousFont;
        UIFont uiFont = (fnt as UIFont);

        NGUIEditorTools.SetLabelWidth(80f);
        GUILayout.Space(3f);

        NGUIEditorTools.DrawHeader("Input", true);
        NGUIEditorTools.BeginContents();

        GUILayout.BeginHorizontal();
        mType = (FontType)EditorGUILayout.EnumPopup("Type", mType, GUILayout.MinWidth(200f));
        GUILayout.Space(18f);
        GUILayout.EndHorizontal();
        Create create = Create.None;

        if (mType == FontType.ImportedBitmap)
        {
            NGUISettings.fontData    = EditorGUILayout.ObjectField("Font Data", NGUISettings.fontData, typeof(TextAsset), false) as TextAsset;
            NGUISettings.fontTexture = EditorGUILayout.ObjectField("Texture", NGUISettings.fontTexture, typeof(Texture2D), false, GUILayout.Width(140f)) as Texture2D;
            NGUIEditorTools.EndContents();

            // Draw the atlas selection only if we have the font data and texture specified, just to make it easier
            EditorGUI.BeginDisabledGroup(NGUISettings.fontData == null || NGUISettings.fontTexture == null);
            {
                NGUIEditorTools.DrawHeader("Output", true);
                NGUIEditorTools.BeginContents();
                ComponentSelector.Draw <UIAtlas>(NGUISettings.atlas, OnSelectAtlas, false);
                NGUIEditorTools.EndContents();
            }
            EditorGUI.EndDisabledGroup();

            if (NGUISettings.fontData == null)
            {
                EditorGUILayout.HelpBox("To create a font from a previously exported FNT file, you need to use BMFont on " +
                                        "Windows or your choice of Glyph Designer or the less expensive bmGlyph on the Mac.\n\n" +
                                        "Either of these tools will create a FNT file for you that you will drag & drop into the field above.", MessageType.Info);
            }
            else if (NGUISettings.fontTexture == null)
            {
                EditorGUILayout.HelpBox("When exporting your font, you should get two files: the FNT, and the texture. Only one texture can be used per font.", MessageType.Info);
            }
            else if (NGUISettings.atlas == null)
            {
                EditorGUILayout.HelpBox("You can create a font that doesn't use a texture atlas. This will mean that the text " +
                                        "labels using this font will generate an extra draw call.\n\nIf you do specify an atlas, the font's texture will be added to it automatically.", MessageType.Info);
            }

            EditorGUI.BeginDisabledGroup(NGUISettings.fontData == null || NGUISettings.fontTexture == null);
            {
                GUILayout.BeginHorizontal();
                GUILayout.Space(20f);
                if (GUILayout.Button("Create the Font"))
                {
                    create = Create.Import;
                }
                GUILayout.Space(20f);
                GUILayout.EndHorizontal();
            }
            EditorGUI.EndDisabledGroup();
        }
        else
        {
            GUILayout.BeginHorizontal();
            if (NGUIEditorTools.DrawPrefixButton("Source"))
            {
                ComponentSelector.Show <Font>(OnUnityFont, new string[] { ".ttf", ".otf" });
            }

            Font ttf = EditorGUILayout.ObjectField(NGUISettings.ambigiousFont as Font, typeof(Font), false) as Font;
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            {
                NGUISettings.fontSize = EditorGUILayout.IntField("Size", NGUISettings.fontSize, GUILayout.Width(120f));

                if (mType == FontType.Dynamic)
                {
                    NGUISettings.fontStyle = (FontStyle)EditorGUILayout.EnumPopup(NGUISettings.fontStyle);
                    GUILayout.Space(18f);
                }
            }
            GUILayout.EndHorizontal();

            // Choose the font style if there are multiple faces present
            if (mType == FontType.GeneratedBitmap)
            {
                if (!FreeType.isPresent)
                {
                    string filename = (Application.platform == RuntimePlatform.WindowsEditor) ? "FreeType.dll" : "FreeType.dylib";

                    EditorGUILayout.HelpBox("Assets/NGUI/Editor/" + filename + " is missing", MessageType.Error);

                    GUILayout.BeginHorizontal();
                    GUILayout.Space(20f);

                    if (GUILayout.Button("Find " + filename))
                    {
                        string path = EditorUtility.OpenFilePanel("Find " + filename, NGUISettings.currentPath,
                                                                  (Application.platform == RuntimePlatform.WindowsEditor) ? "dll" : "dylib");

                        if (!string.IsNullOrEmpty(path))
                        {
                            if (System.IO.Path.GetFileName(path) == filename)
                            {
                                NGUISettings.currentPath    = System.IO.Path.GetDirectoryName(path);
                                NGUISettings.pathToFreeType = path;
                            }
                            else
                            {
                                Debug.LogError("The library must be named '" + filename + "'");
                            }
                        }
                    }
                    GUILayout.Space(20f);
                    GUILayout.EndHorizontal();
                }
                else if (ttf != null)
                {
                    string[] faces = FreeType.GetFaces(ttf);

                    if (faces != null)
                    {
                        if (mFaceIndex >= faces.Length)
                        {
                            mFaceIndex = 0;
                        }

                        if (faces.Length > 1)
                        {
                            GUILayout.Label("Style", EditorStyles.boldLabel);
                            for (int i = 0; i < faces.Length; ++i)
                            {
                                GUILayout.BeginHorizontal();
                                GUILayout.Space(10f);
                                if (DrawOption(i == mFaceIndex, " " + faces[i]))
                                {
                                    mFaceIndex = i;
                                }
                                GUILayout.EndHorizontal();
                            }
                        }
                    }

                    GUILayout.Label("Characters", EditorStyles.boldLabel);

                    CharacterMap cm = characterMap;

                    GUILayout.BeginHorizontal(GUILayout.Width(100f));
                    GUILayout.BeginVertical();
                    GUI.changed = false;
                    if (DrawOption(cm == CharacterMap.Numeric, " Numeric"))
                    {
                        cm = CharacterMap.Numeric;
                    }
                    if (DrawOption(cm == CharacterMap.Ascii, " ASCII"))
                    {
                        cm = CharacterMap.Ascii;
                    }
                    if (DrawOption(cm == CharacterMap.Latin, " Latin"))
                    {
                        cm = CharacterMap.Latin;
                    }
                    if (DrawOption(cm == CharacterMap.Custom, " Custom"))
                    {
                        cm = CharacterMap.Custom;
                    }
                    if (GUI.changed)
                    {
                        characterMap = cm;
                    }
                    GUILayout.EndVertical();

                    EditorGUI.BeginDisabledGroup(cm != CharacterMap.Custom);
                    {
                        if (cm != CharacterMap.Custom)
                        {
                            string chars = "";

                            if (cm == CharacterMap.Ascii)
                            {
                                for (int i = 33; i < 127; ++i)
                                {
                                    chars += System.Convert.ToChar(i);
                                }
                            }
                            else if (cm == CharacterMap.Numeric)
                            {
                                chars = "01234567890";
                            }
                            else if (cm == CharacterMap.Latin)
                            {
                                for (int i = 33; i < 127; ++i)
                                {
                                    chars += System.Convert.ToChar(i);
                                }

                                for (int i = 161; i < 256; ++i)
                                {
                                    chars += System.Convert.ToChar(i);
                                }
                            }

                            NGUISettings.charsToInclude = chars;
                        }

                        GUI.changed = false;

                        string text = NGUISettings.charsToInclude;

                        if (cm == CharacterMap.Custom)
                        {
                            text = EditorGUILayout.TextArea(text, GUI.skin.textArea,
                                                            GUILayout.Height(80f), GUILayout.Width(Screen.width - 100f));
                        }
                        else
                        {
                            GUILayout.Label(text, GUI.skin.textArea,
                                            GUILayout.Height(80f), GUILayout.Width(Screen.width - 100f));
                        }

                        if (GUI.changed)
                        {
                            string final = "";

                            for (int i = 0; i < text.Length; ++i)
                            {
                                char c = text[i];
                                if (c < 33)
                                {
                                    continue;
                                }
                                string s = c.ToString();
                                if (!final.Contains(s))
                                {
                                    final += s;
                                }
                            }

                            if (final.Length > 0)
                            {
                                char[] chars = final.ToCharArray();
                                System.Array.Sort(chars);
                                final = new string(chars);
                            }
                            else
                            {
                                final = "";
                            }

                            NGUISettings.charsToInclude = final;
                        }
                    }
                    EditorGUI.EndDisabledGroup();
                    GUILayout.EndHorizontal();
                }
            }
            NGUIEditorTools.EndContents();

            if (mType == FontType.Dynamic)
            {
                EditorGUI.BeginDisabledGroup(ttf == null);
                GUILayout.BeginHorizontal();
                GUILayout.Space(20f);
                if (GUILayout.Button("Create the Font"))
                {
                    create = Create.Dynamic;
                }
                GUILayout.Space(20f);
                GUILayout.EndHorizontal();
                EditorGUI.EndDisabledGroup();
#if UNITY_3_5
                EditorGUILayout.HelpBox("Dynamic fonts require Unity 4.0 or higher.", MessageType.Error);
#else
                // Helpful info
                if (ttf == null)
                {
                    EditorGUILayout.HelpBox("You don't have to create a UIFont to use dynamic fonts. You can just reference the Unity Font directly on the label.", MessageType.Info);
                }
                EditorGUILayout.HelpBox("Please note that dynamic fonts can't be made a part of an atlas, and using dynamic fonts will result in at least one extra draw call.", MessageType.Warning);
#endif
            }
            else
            {
                bool isBuiltIn = (ttf != null) && string.IsNullOrEmpty(UnityEditor.AssetDatabase.GetAssetPath(ttf));

                // Draw the atlas selection only if we have the font data and texture specified, just to make it easier
                EditorGUI.BeginDisabledGroup(ttf == null || isBuiltIn || !FreeType.isPresent);
                {
                    NGUIEditorTools.DrawHeader("Output", true);
                    NGUIEditorTools.BeginContents();
                    ComponentSelector.Draw <UIAtlas>(NGUISettings.atlas, OnSelectAtlas, false);
                    NGUIEditorTools.EndContents();

                    if (ttf == null)
                    {
                        EditorGUILayout.HelpBox("You can create a bitmap font by specifying a dynamic font to use as the source.", MessageType.Info);
                    }
                    else if (isBuiltIn)
                    {
                        EditorGUILayout.HelpBox("You chose an embedded font. You can't create a bitmap font from an embedded resource.", MessageType.Warning);
                    }
                    else if (NGUISettings.atlas == null)
                    {
                        EditorGUILayout.HelpBox("You can create a font that doesn't use a texture atlas. This will mean that the text " +
                                                "labels using this font will generate an extra draw call.\n\nIf you do specify an atlas, the font's texture will be added to it automatically.", MessageType.Info);
                    }

                    GUILayout.BeginHorizontal();
                    GUILayout.Space(20f);
                    if (GUILayout.Button("Create the Font"))
                    {
                        create = Create.Bitmap;
                    }
                    GUILayout.Space(20f);
                    GUILayout.EndHorizontal();
                }
                EditorGUI.EndDisabledGroup();
            }
        }

        if (create == Create.None)
        {
            return;
        }

        // Open the "Save As" file dialog
#if UNITY_3_5
        string prefabPath = EditorUtility.SaveFilePanel("Save As",
                                                        NGUISettings.currentPath, "New Font.prefab", "prefab");
#else
        string prefabPath = EditorUtility.SaveFilePanelInProject("Save As",
                                                                 "New Font.prefab", "prefab", "Save font as...");
#endif
        if (string.IsNullOrEmpty(prefabPath))
        {
            return;
        }
        NGUISettings.currentPath = System.IO.Path.GetDirectoryName(prefabPath);

        // Load the font's prefab
        GameObject go     = AssetDatabase.LoadAssetAtPath(prefabPath, typeof(GameObject)) as GameObject;
        Object     prefab = null;
        string     fontName;

        // Font doesn't exist yet
        if (go == null || go.GetComponent <UIFont>() == null)
        {
            // Create a new prefab for the atlas
            prefab = PrefabUtility.CreateEmptyPrefab(prefabPath);

            fontName = prefabPath.Replace(".prefab", "");
            fontName = fontName.Substring(prefabPath.LastIndexOfAny(new char[] { '/', '\\' }) + 1);

            // Create a new game object for the font
            go     = new GameObject(fontName);
            uiFont = go.AddComponent <UIFont>();
        }
        else
        {
            uiFont   = go.GetComponent <UIFont>();
            fontName = go.name;
        }

        if (create == Create.Dynamic)
        {
            uiFont.atlas            = null;
            uiFont.dynamicFont      = NGUISettings.dynamicFont;
            uiFont.dynamicFontStyle = NGUISettings.fontStyle;
            uiFont.defaultSize      = NGUISettings.fontSize;
        }
        else if (create == Create.Import)
        {
            Material mat = null;

            if (NGUISettings.atlas != null)
            {
                // Add the font's texture to the atlas
                UIAtlasMaker.AddOrUpdate(NGUISettings.atlas, NGUISettings.fontTexture);
            }
            else
            {
                // Create a material for the font
                string matPath = prefabPath.Replace(".prefab", ".mat");
                mat = AssetDatabase.LoadAssetAtPath(matPath, typeof(Material)) as Material;

                // If the material doesn't exist, create it
                if (mat == null)
                {
                    Shader shader = Shader.Find("Unlit/Transparent Colored");
                    mat = new Material(shader);

                    // Save the material
                    AssetDatabase.CreateAsset(mat, matPath);
                    AssetDatabase.Refresh(ImportAssetOptions.ForceSynchronousImport);

                    // Load the material so it's usable
                    mat = AssetDatabase.LoadAssetAtPath(matPath, typeof(Material)) as Material;
                }

                mat.mainTexture = NGUISettings.fontTexture;
            }

            uiFont.dynamicFont = null;
            BMFontReader.Load(uiFont.bmFont, NGUITools.GetHierarchy(uiFont.gameObject), NGUISettings.fontData.bytes);

            if (NGUISettings.atlas == null)
            {
                uiFont.atlas    = null;
                uiFont.material = mat;
            }
            else
            {
                uiFont.spriteName = NGUISettings.fontTexture.name;
                uiFont.atlas      = NGUISettings.atlas;
            }
            NGUISettings.fontSize = uiFont.defaultSize;
        }
        else if (create == Create.Bitmap)
        {
            // Create the bitmap font
            BMFont    bmFont;
            Texture2D tex;

            if (FreeType.CreateFont(
                    NGUISettings.dynamicFont,
                    NGUISettings.fontSize, mFaceIndex,
                    NGUISettings.charsToInclude, out bmFont, out tex))
            {
                uiFont.bmFont = bmFont;
                tex.name      = fontName;

                if (NGUISettings.atlas != null)
                {
                    // Add this texture to the atlas and destroy it
                    UIAtlasMaker.AddOrUpdate(NGUISettings.atlas, tex);
                    NGUITools.DestroyImmediate(tex);
                    NGUISettings.fontTexture = null;
                    tex = null;

                    uiFont.atlas      = NGUISettings.atlas;
                    uiFont.spriteName = fontName;
                }
                else
                {
                    string texPath = prefabPath.Replace(".prefab", ".png");
                    string matPath = prefabPath.Replace(".prefab", ".mat");

                    byte[]     png = tex.EncodeToPNG();
                    FileStream fs  = File.OpenWrite(texPath);
                    fs.Write(png, 0, png.Length);
                    fs.Close();

                    // See if the material already exists
                    Material mat = AssetDatabase.LoadAssetAtPath(matPath, typeof(Material)) as Material;

                    // If the material doesn't exist, create it
                    if (mat == null)
                    {
                        Shader shader = Shader.Find("Unlit/Transparent Colored");
                        mat = new Material(shader);

                        // Save the material
                        AssetDatabase.CreateAsset(mat, matPath);
                        AssetDatabase.Refresh(ImportAssetOptions.ForceSynchronousImport);

                        // Load the material so it's usable
                        mat = AssetDatabase.LoadAssetAtPath(matPath, typeof(Material)) as Material;
                    }
                    else
                    {
                        AssetDatabase.Refresh(ImportAssetOptions.ForceSynchronousImport);
                    }

                    // Re-load the texture
                    tex = AssetDatabase.LoadAssetAtPath(texPath, typeof(Texture2D)) as Texture2D;

                    // Assign the texture
                    mat.mainTexture          = tex;
                    NGUISettings.fontTexture = tex;

                    uiFont.atlas    = null;
                    uiFont.material = mat;
                }
            }
            else
            {
                return;
            }
        }

        if (prefab != null)
        {
            // Update the prefab
            PrefabUtility.ReplacePrefab(go, prefab);
            DestroyImmediate(go);
            AssetDatabase.Refresh(ImportAssetOptions.ForceSynchronousImport);

            // Select the atlas
            go     = AssetDatabase.LoadAssetAtPath(prefabPath, typeof(GameObject)) as GameObject;
            uiFont = go.GetComponent <UIFont>();
        }

        if (uiFont != null)
        {
            NGUISettings.ambigiousFont = uiFont;
        }
        MarkAsChanged();
        Selection.activeGameObject = go;
    }
Exemple #41
0
    override public void OnInspectorGUI()
    {
        mFont = target as UIFont;
        EditorGUIUtility.LookLikeControls(80f);

        NGUIEditorTools.DrawSeparator();

        //UNISIP
        if (mFont.dynamicFont != null)
        {
            mType = FontType.Dynamic;
        }

        if (mFont.replacement != null)
        {
            mType        = FontType.Reference;
            mReplacement = mFont.replacement;
        }

        FontType after = (FontType)EditorGUILayout.EnumPopup("Font Type", mType);

        if (mType != after)
        {
            if (after == FontType.Normal)
            {
                OnSelectFont(null);
            }
            else
            {
                mType = after;
            }

            //UNISIP
            if (mType != FontType.Dynamic && mFont.dynamicFont != null)
            {
                mFont.dynamicFont = null;
            }
        }

        //UNISIP
        if (mType == FontType.Dynamic)
        {
            //UNISIP - Draw settings for dynamic font
            bool changed = false;
            Font f       = EditorGUILayout.ObjectField("Font", mFont.dynamicFont, typeof(Font), false) as Font;
            if (f != mFont.dynamicFont)
            {
                mFont.dynamicFont = f;
                changed           = true;
            }

            Material mat = EditorGUILayout.ObjectField("Material", mFont.dynamicFontMaterial, typeof(Material), false) as Material;
            if (mat != mFont.dynamicFontMaterial)
            {
                mFont.dynamicFontMaterial = mat;
                changed = true;
            }
            if (mFont.dynamicFontMaterial == null)
            {
                GUILayout.Label("Warning: no coloring or clipping when using default font material");
            }

            int i = EditorGUILayout.IntField("Size", mFont.dynamicFontSize);
            if (i != mFont.dynamicFontSize)
            {
                mFont.dynamicFontSize = i;
                changed = true;
            }

            float ttfSize = EditorGUILayout.FloatField("TTF Size", mFont.ttfSize);
            if (ttfSize != mFont.ttfSize)
            {
                mFont.ttfSize = ttfSize;
                changed       = true;
            }

            float fontConstYOffset = EditorGUILayout.FloatField("Const Offset", mFont.fontConstYOffset);
            if (fontConstYOffset != mFont.fontConstYOffset)
            {
                mFont.fontConstYOffset = fontConstYOffset;
                changed = true;
            }

            FontStyle style = (FontStyle)EditorGUILayout.EnumPopup("Style", mFont.dynamicFontStyle);
            if (style != mFont.dynamicFontStyle)
            {
                mFont.dynamicFontStyle = style;
                changed = true;
            }

            if (changed)
            {
                //force access to material property as it refreshes the texture assignment
                Debug.Log("font changed...");
                Material fontMat = mFont.material;
                if (fontMat.mainTexture == null)
                {
                    Debug.Log("font material texture issue...");
                }
                UIFont.OnFontRebuilt(mFont);
            }

            NGUIEditorTools.DrawSeparator();

            // Font spacing
            GUILayout.BeginHorizontal();
            {
                EditorGUIUtility.LookLikeControls(0f);
                GUILayout.Label("Spacing", GUILayout.Width(60f));
                GUILayout.Label("X", GUILayout.Width(12f));
                int x = EditorGUILayout.IntField(mFont.horizontalSpacing);
                GUILayout.Label("Y", GUILayout.Width(12f));
                int y = EditorGUILayout.IntField(mFont.verticalSpacing);
                EditorGUIUtility.LookLikeControls(80f);

                if (mFont.horizontalSpacing != x || mFont.verticalSpacing != y)
                {
                    NGUIEditorTools.RegisterUndo("Font Spacing", mFont);
                    mFont.horizontalSpacing = x;
                    mFont.verticalSpacing   = y;
                }
            }
            GUILayout.EndHorizontal();
        }

        if (mType == FontType.Reference)
        {
            ComponentSelector.Draw <UIFont>(mFont.replacement, OnSelectFont);

            NGUIEditorTools.DrawSeparator();
            GUILayout.Label("You can have one font simply point to\n" +
                            "another one. This is useful if you want to be\n" +
                            "able to quickly replace the contents of one\n" +
                            "font with another one, for example for\n" +
                            "swapping an SD font with an HD one, or\n" +
                            "replacing an English font with a Chinese\n" +
                            "one. All the labels referencing this font\n" +
                            "will update their references to the new one.");

            if (mReplacement != mFont && mFont.replacement != mReplacement)
            {
                NGUIEditorTools.RegisterUndo("Font Change", mFont);
                mFont.replacement = mReplacement;
                UnityEditor.EditorUtility.SetDirty(mFont);
            }
            return;
        }



        if (mType != FontType.Dynamic)
        {
            NGUIEditorTools.DrawSeparator();

            ComponentSelector.Draw <UIAtlas>(mFont.atlas, OnSelectAtlas);

            if (mFont.atlas != null)
            {
                if (mFont.bmFont.isValid)
                {
                    NGUIEditorTools.AdvancedSpriteField(mFont.atlas, mFont.spriteName, SelectSprite, false);
                }
            }
            else
            {
                // No atlas specified -- set the material and texture rectangle directly
                Material mat = EditorGUILayout.ObjectField("Material", mFont.material, typeof(Material), false) as Material;

                if (mFont.material != mat)
                {
                    NGUIEditorTools.RegisterUndo("Font Material", mFont);
                    mFont.material = mat;
                }
            }

            // For updating the font's data when importing from an external source, such as the texture packer
            bool resetWidthHeight = false;

            if (mFont.atlas != null || mFont.material != null)
            {
                GUILayout.BeginHorizontal();
                TextAsset data = EditorGUILayout.ObjectField("Import Data", null, typeof(TextAsset), false) as TextAsset;
                GUILayout.Space(44f);
                GUILayout.EndHorizontal();

                if (data != null)
                {
                    NGUIEditorTools.RegisterUndo("Import Font Data", mFont);
                    BMFontReader.Load(mFont.bmFont, NGUITools.GetHierarchy(mFont.gameObject), data.bytes);
                    mFont.MarkAsDirty();
                    resetWidthHeight = true;
                    Debug.Log("Imported " + mFont.bmFont.glyphCount + " characters");
                }
            }

            if (mFont.bmFont.isValid)
            {
                Color     green = new Color(0.4f, 1f, 0f, 1f);
                Texture2D tex   = mFont.texture;

                if (tex != null)
                {
                    if (mFont.atlas == null)
                    {
                        // Pixels are easier to work with than UVs
                        Rect pixels = NGUIMath.ConvertToPixels(mFont.uvRect, tex.width, tex.height, false);

                        // Automatically set the width and height of the rectangle to be the original font texture's dimensions
                        if (resetWidthHeight)
                        {
                            pixels.width  = mFont.texWidth;
                            pixels.height = mFont.texHeight;
                        }

                        // Font sprite rectangle
                        GUI.backgroundColor = green;
                        pixels = EditorGUILayout.RectField("Pixel Rect", pixels);
                        GUI.backgroundColor = Color.white;

                        // Create a button that can make the coordinates pixel-perfect on click
                        GUILayout.BeginHorizontal();
                        {
                            GUILayout.Label("Correction", GUILayout.Width(75f));

                            Rect corrected = NGUIMath.MakePixelPerfect(pixels);

                            if (corrected == pixels)
                            {
                                GUI.color = Color.grey;
                                GUILayout.Button("Make Pixel-Perfect");
                                GUI.color = Color.white;
                            }
                            else if (GUILayout.Button("Make Pixel-Perfect"))
                            {
                                pixels      = corrected;
                                GUI.changed = true;
                            }
                        }
                        GUILayout.EndHorizontal();

                        // Convert the pixel coordinates back to UV coordinates
                        Rect uvRect = NGUIMath.ConvertToTexCoords(pixels, tex.width, tex.height);

                        if (mFont.uvRect != uvRect)
                        {
                            NGUIEditorTools.RegisterUndo("Font Pixel Rect", mFont);
                            mFont.uvRect = uvRect;
                        }
                    }

                    // Font spacing
                    GUILayout.BeginHorizontal();
                    {
                        EditorGUIUtility.LookLikeControls(0f);
                        GUILayout.Label("Spacing", GUILayout.Width(60f));
                        GUILayout.Label("X", GUILayout.Width(12f));
                        int x = EditorGUILayout.IntField(mFont.horizontalSpacing);
                        GUILayout.Label("Y", GUILayout.Width(12f));
                        int y = EditorGUILayout.IntField(mFont.verticalSpacing);
                        GUILayout.Space(62f);
                        EditorGUIUtility.LookLikeControls(80f);

                        if (mFont.horizontalSpacing != x || mFont.verticalSpacing != y)
                        {
                            NGUIEditorTools.RegisterUndo("Font Spacing", mFont);
                            mFont.horizontalSpacing = x;
                            mFont.verticalSpacing   = y;
                        }
                    }
                    GUILayout.EndHorizontal();

                    if (mFont.atlas == null)
                    {
                        mView      = View.Font;
                        mUseShader = false;

                        float pixelSize = EditorGUILayout.FloatField("Pixel Size", mFont.pixelSize, GUILayout.Width(120f));

                        if (pixelSize != mFont.pixelSize)
                        {
                            NGUIEditorTools.RegisterUndo("Font Change", mFont);
                            mFont.pixelSize = pixelSize;
                        }
                    }
                    else
                    {
                        GUILayout.Space(4f);
                        GUILayout.BeginHorizontal();
                        {
                            mView = (View)EditorGUILayout.EnumPopup("Preview", mView);
                            GUILayout.Label("Shader", GUILayout.Width(45f));
                            mUseShader = EditorGUILayout.Toggle(mUseShader, GUILayout.Width(20f));
                        }
                        GUILayout.EndHorizontal();
                    }
                }

                if (mFont.atlas != null)
                {
                    NGUIEditorTools.DrawHeader("Symbols and Emoticons");

                    List <BMSymbol> symbols = mFont.symbols;

                    for (int i = 0; i < symbols.Count;)
                    {
                        BMSymbol sym = symbols[i];

                        GUILayout.BeginHorizontal();
                        GUILayout.Label(sym.sequence, GUILayout.Width(40f));
                        if (NGUIEditorTools.SimpleSpriteField(mFont.atlas, sym.spriteName, ChangeSymbolSprite))
                        {
                            mSelectedSymbol = sym;
                        }

                        if (GUILayout.Button("Edit", GUILayout.Width(40f)))
                        {
                            if (mFont.atlas != null)
                            {
                                EditorPrefs.SetString("NGUI Selected Sprite", sym.spriteName);
                                NGUIEditorTools.Select(mFont.atlas.gameObject);
                            }
                        }

                        GUI.backgroundColor = Color.red;

                        if (GUILayout.Button("X", GUILayout.Width(22f)))
                        {
                            NGUIEditorTools.RegisterUndo("Remove symbol", mFont);
                            mSymbolSequence = sym.sequence;
                            mSymbolSprite   = sym.spriteName;
                            symbols.Remove(sym);
                            mFont.MarkAsDirty();
                        }
                        GUI.backgroundColor = Color.white;
                        GUILayout.EndHorizontal();
                        GUILayout.Space(4f);
                        ++i;
                    }

                    if (symbols.Count > 0)
                    {
                        NGUIEditorTools.DrawSeparator();
                    }

                    GUILayout.BeginHorizontal();
                    mSymbolSequence = EditorGUILayout.TextField(mSymbolSequence, GUILayout.Width(40f));
                    NGUIEditorTools.SimpleSpriteField(mFont.atlas, mSymbolSprite, SelectSymbolSprite);

                    bool isValid = !string.IsNullOrEmpty(mSymbolSequence) && !string.IsNullOrEmpty(mSymbolSprite);
                    GUI.backgroundColor = isValid ? Color.green : Color.grey;

                    if (GUILayout.Button("Add", GUILayout.Width(40f)) && isValid)
                    {
                        NGUIEditorTools.RegisterUndo("Add symbol", mFont);
                        mFont.AddSymbol(mSymbolSequence, mSymbolSprite);
                        mFont.MarkAsDirty();
                        mSymbolSequence = "";
                        mSymbolSprite   = "";
                    }
                    GUI.backgroundColor = Color.white;
                    GUILayout.EndHorizontal();

                    if (symbols.Count == 0)
                    {
                        EditorGUILayout.HelpBox("Want to add an emoticon to your font? In the field above type ':)', choose a sprite, then hit the Add button.", MessageType.Info);
                    }
                    else
                    {
                        GUILayout.Space(4f);
                    }
                }
            }
        }
    }
Exemple #42
0
    override public void OnInspectorGUI()
    {
        mFont = target as UIFont;
        EditorGUIUtility.LookLikeControls(80f);

        NGUIEditorTools.DrawSeparator();

        if (mFont.replacement != null)
        {
            mType        = FontType.Reference;
            mReplacement = mFont.replacement;
        }

        FontType after = (FontType)EditorGUILayout.EnumPopup("Font Type", mType);

        if (mType != after)
        {
            if (after == FontType.Normal)
            {
                OnSelectFont(null);
            }
            else
            {
                mType = FontType.Reference;
            }
        }

        if (mType == FontType.Reference)
        {
            ComponentSelector.Draw <UIFont>(mFont.replacement, OnSelectFont);

            NGUIEditorTools.DrawSeparator();
            GUILayout.Label("You can have one font simply point to\n" +
                            "another one. This is useful if you want to be\n" +
                            "able to quickly replace the contents of one\n" +
                            "font with another one, for example for\n" +
                            "swapping an SD font with an HD one, or\n" +
                            "replacing an English font with a Chinese\n" +
                            "one. All the labels referencing this font\n" +
                            "will update their references to the new one.");

            if (mReplacement != mFont && mFont.replacement != mReplacement)
            {
                NGUIEditorTools.RegisterUndo("Font Change", mFont);
                mFont.replacement = mReplacement;
                UnityEditor.EditorUtility.SetDirty(mFont);
            }
            return;
        }

        NGUIEditorTools.DrawSeparator();
        ComponentSelector.Draw <UIAtlas>(mFont.atlas, OnSelectAtlas);

        if (mFont.atlas != null)
        {
            if (mFont.bmFont.LegacyCheck())
            {
                Debug.Log(mFont.name + " uses a legacy font data structure. Upgrading, please save.");
                EditorUtility.SetDirty(mFont);
            }

            if (mFont.bmFont.isValid)
            {
                NGUIEditorTools.AdvancedSpriteField(mFont.atlas, mFont.spriteName, SelectSprite, false);
            }
        }
        else
        {
            // No atlas specified -- set the material and texture rectangle directly
            Material mat = EditorGUILayout.ObjectField("Material", mFont.material, typeof(Material), false) as Material;

            if (mFont.material != mat)
            {
                NGUIEditorTools.RegisterUndo("Font Material", mFont);
                mFont.material = mat;
            }
        }

        bool resetWidthHeight = false;

        if (mFont.atlas != null || mFont.material != null)
        {
            TextAsset data = EditorGUILayout.ObjectField("Import Font", null, typeof(TextAsset), false) as TextAsset;

            if (data != null)
            {
                NGUIEditorTools.RegisterUndo("Import Font Data", mFont);
                BMFontReader.Load(mFont.bmFont, NGUITools.GetHierarchy(mFont.gameObject), data.bytes);
                mFont.MarkAsDirty();
                resetWidthHeight = true;
                Debug.Log("Imported " + mFont.bmFont.glyphCount + " characters");
            }
        }

        if (mFont.bmFont.isValid)
        {
            Color     green = new Color(0.4f, 1f, 0f, 1f);
            Texture2D tex   = mFont.texture;

            if (tex != null)
            {
                if (mFont.atlas == null)
                {
                    // Pixels are easier to work with than UVs
                    Rect pixels = NGUIMath.ConvertToPixels(mFont.uvRect, tex.width, tex.height, false);

                    // Automatically set the width and height of the rectangle to be the original font texture's dimensions
                    if (resetWidthHeight)
                    {
                        pixels.width  = mFont.texWidth;
                        pixels.height = mFont.texHeight;
                    }

                    // Font sprite rectangle
                    GUI.backgroundColor = green;
                    pixels = EditorGUILayout.RectField("Pixel Rect", pixels);
                    GUI.backgroundColor = Color.white;

                    // Create a button that can make the coordinates pixel-perfect on click
                    GUILayout.BeginHorizontal();
                    {
                        GUILayout.Label("Correction", GUILayout.Width(75f));

                        Rect corrected = NGUIMath.MakePixelPerfect(pixels);

                        if (corrected == pixels)
                        {
                            GUI.color = Color.grey;
                            GUILayout.Button("Make Pixel-Perfect");
                            GUI.color = Color.white;
                        }
                        else if (GUILayout.Button("Make Pixel-Perfect"))
                        {
                            pixels      = corrected;
                            GUI.changed = true;
                        }
                    }
                    GUILayout.EndHorizontal();

                    // Convert the pixel coordinates back to UV coordinates
                    Rect uvRect = NGUIMath.ConvertToTexCoords(pixels, tex.width, tex.height);

                    if (mFont.uvRect != uvRect)
                    {
                        NGUIEditorTools.RegisterUndo("Font Pixel Rect", mFont);
                        mFont.uvRect = uvRect;
                    }
                }

                // Font spacing
                GUILayout.BeginHorizontal();
                {
                    EditorGUIUtility.LookLikeControls(0f);
                    GUILayout.Label("Spacing", GUILayout.Width(60f));
                    GUILayout.Label("X", GUILayout.Width(12f));
                    int x = EditorGUILayout.IntField(mFont.horizontalSpacing);
                    GUILayout.Label("Y", GUILayout.Width(12f));
                    int y = EditorGUILayout.IntField(mFont.verticalSpacing);
                    EditorGUIUtility.LookLikeControls(80f);

                    if (mFont.horizontalSpacing != x || mFont.verticalSpacing != y)
                    {
                        NGUIEditorTools.RegisterUndo("Font Spacing", mFont);
                        mFont.horizontalSpacing = x;
                        mFont.verticalSpacing   = y;
                    }
                }
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                {
                    mView = (View)EditorGUILayout.EnumPopup("Preview", mView);
                    GUILayout.Label("Shader", GUILayout.Width(45f));
                    mUseShader = EditorGUILayout.Toggle(mUseShader, GUILayout.Width(20f));
                }
                GUILayout.EndHorizontal();
            }
        }
    }
 public static void TitleLabel(UILabel v)
 {
     v.Font          = UIFont.FromName("HelveticaNeue", 17f);
     v.TextAlignment = UITextAlignment.Center;
     v.TextColor     = Color.DarkGray;
 }
        protected void OnBindingContextChanged(Cell cell)
        {
            var context = cell.BindingContext as MessageTable;

            if (context != null)
            {
                const int totalPadding = 20;                 // Width Padding
                cell.Height = Convert.ToDouble(EstimateHeight(context.Text, Convert.ToInt32(UIScreen.MainScreen.Bounds.Width) - totalPadding, UIFont.FromName("Helvetica Neue", 14)));
            }
        }
        private Decimal EstimateHeight(String text, Int32 width, UIFont font)
        {
            var size = ((NSString)text).StringSize(font, new SizeF(width, float.MaxValue), UILineBreakMode.WordWrap);

            return((Decimal)size.Height + 40);            // The +40 is for extra height padding
        }
        public SunburstChart()
        {
            var Data = new ObservableCollection <SunburstModel>();

            Data.Add(new SunburstModel()
            {
                Quarter = "Q1", Month = "Jan", Sales = 11
            });
            Data.Add(new SunburstModel()
            {
                Quarter = "Q1", Month = "Feb", Sales = 8
            });
            Data.Add(new SunburstModel()
            {
                Quarter = "Q1", Month = "Mar", Sales = 5
            });

            Data.Add(new SunburstModel()
            {
                Quarter = "Q2", Month = "Apr", Sales = 13
            });
            Data.Add(new SunburstModel()
            {
                Quarter = "Q2", Month = "May", Sales = 12
            });
            Data.Add(new SunburstModel()
            {
                Quarter = "Q2", Month = "Jun", Sales = 17
            });

            Data.Add(new SunburstModel()
            {
                Quarter = "Q3", Month = "Jul", Sales = 5
            });
            Data.Add(new SunburstModel()
            {
                Quarter = "Q3", Month = "Aug", Sales = 4
            });
            Data.Add(new SunburstModel()
            {
                Quarter = "Q3", Month = "Sep", Sales = 5
            });

            Data.Add(new SunburstModel()
            {
                Quarter = "Q4", Month = "Oct", Sales = 7
            });
            Data.Add(new SunburstModel()
            {
                Quarter = "Q4", Month = "Nov", Sales = 18
            });
            Data.Add(new SunburstModel()
            {
                Quarter = "Q4", Month = "Dec", Week = "W1", Sales = 5
            });
            Data.Add(new SunburstModel()
            {
                Quarter = "Q4", Month = "Dec", Week = "W2", Sales = 5
            });
            Data.Add(new SunburstModel()
            {
                Quarter = "Q4", Month = "Dec", Week = "W3", Sales = 5
            });
            Data.Add(new SunburstModel()
            {
                Quarter = "Q4", Month = "Dec", Week = "W4", Sales = 5
            });



            chart                 = new SfSunburstChart();
            chart.ItemsSource     = Data;
            chart.Radius          = 0.95;
            chart.ValueMemberPath = "Sales";
            var levels = new SunburstLevelCollection()
            {
                new SunburstHierarchicalLevel()
                {
                    GroupMemberPath = "Quarter"
                },
                new SunburstHierarchicalLevel()
                {
                    GroupMemberPath = "Month"
                },
                new SunburstHierarchicalLevel()
                {
                    GroupMemberPath = "Week"
                },
            };

            chart.Levels = levels;


            chart.Title.IsVisible = true;
            chart.Title.Text      = "Sales Performance";
            chart.Title.Font      = UIFont.SystemFontOfSize(20);
            chart.Title.Margin    = new UIEdgeInsets(10, 5, 5, 5);

            chart.Legend.IsVisible       = true;
            chart.Legend.LegendPosition  = SunburstDockPosition.Bottom;
            chart.Legend.LabelStyle.Font = UIFont.SystemFontOfSize(16);
            chart.Legend.IconHeight      = 12;
            chart.Legend.IconWidth       = 12;

            chart.DataLabel.ShowLabel = true;

            chart.EnableAnimation = true;

            chart.TooltipSettings             = new CustomTooltip();
            chart.TooltipSettings.ShowTooltip = true;

            this.AddSubview(chart);
        }
Exemple #47
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();



            StackView = new UIStackView();



            var titleLabel = new UILabel(new CGRect(10, 20, View.Bounds.Width - 10, 30));

            titleLabel.Text = "BHASVIC";
            titleLabel.Font = UIFont.BoldSystemFontOfSize(25);
            StackView.AddArrangedSubview(titleLabel);

            var nameLabel = new UILabel(new CGRect(10, 0, View.Bounds.Width - 10, 200));

            nameLabel.Text          = NewsItem.Name;
            nameLabel.Lines         = 0;
            nameLabel.Font          = UIFont.BoldSystemFontOfSize(30);
            nameLabel.LineBreakMode = UILineBreakMode.WordWrap;
            StackView.AddArrangedSubview(nameLabel);

            var      dateLabel = new UILabel(new CGRect(10, 100, View.Bounds.Width - 10, 30));
            DateTime dt        = DateTime.ParseExact(NewsItem.DatePublished, "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture);

            dateLabel.Text = dt.ToShortDateString();
            StackView.AddArrangedSubview(dateLabel);

            var    contentLabel     = new UILabel(new CGRect(10, 120, View.Bounds.Width - 20, 300));
            string noHTML           = Regex.Replace(NewsItem.Content, @"<[^>]+>|&nbsp;", "").Trim();
            string noHTMLNormalised = Regex.Replace(noHTML, @"\s{2,}", " ");

            contentLabel.Text          = noHTMLNormalised;
            contentLabel.Lines         = 0;
            contentLabel.LineBreakMode = UILineBreakMode.WordWrap;
            StackView.AddArrangedSubview(contentLabel);

            var dateoELabel = new UILabel(new CGRect(10, 80, View.Bounds.Width - 10, 30));

            //DateTime dtt = DateTime.ParseExact(NewsItem.DateOfEvent, "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture);
            dateLabel.Text = NewsItem.DateOfEvent;
            Console.WriteLine(NewsItem.DateOfEvent);

            StackView.AddArrangedSubview(dateoELabel);


            var dateNLabel = new UILabel(new CGRect(10, 130, View.Bounds.Width - 10, 30));

            //DateTime dtt = DateTime.ParseExact(NewsItem.DateOfEvent, "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture);
            dateLabel.Text = NewsItem.NotificationDate;
            Console.WriteLine(NewsItem.NotificationDate);
            StackView.AddArrangedSubview(dateNLabel);



            //var image = new UIImage();
            ////image = this.LoadImage("some image url");
            //var imageView = new UIImageView();
            //imageView.Image = image;
            //View.AddSubview(imageView);


            //var categoryLabel = new UILabel(new CGRect(10, 80, View.Bounds.Width, 30));
            ////DateTime dtt = DateTime.ParseExact(NewsItem.DateOfEvent, "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture);
            //dateLabel.Text = NewsItem.Category;
            //scrollView.AddSubview(categoryLabel);



            View.AddSubview(StackView);


            //	NavigationController.SetHasNavigationBar(this, false);
            //this.NavigationController.PopToRootViewController(true);
        }
 void OnSelectOldFont(MonoBehaviour obj)
 {
     mOldFont = obj as UIFont;
     Repaint();
 }
Exemple #49
0
        public override void LayoutSubviews()
        {
            base.LayoutSubviews();

            _view.BackgroundColor = NativeCell.IsIncoming ? NativeCell.IncomingColor.ToUIColor() : NativeCell.OutgoingColor.ToUIColor();

            var frame          = ContentView.Frame;
            var sizeForMessage = GetSizeForText(this, MessageText.Text, UIFont.SystemFontOfSize(NativeCell.TextFontSize)) + BubblePadding;
            var sizeForDate    = GetSizeForText(this, DateText.Text, UIFont.SystemFontOfSize(NativeCell.InfoFontSize)) + BubblePadding;

            _view.SetNeedsDisplay();

            var noBubbleSize = sizeForMessage - BubblePadding;
            var bubbleSize   = sizeForMessage + BubblePadding;

            if (NativeCell.IsIncoming)
            {
                int nameHeight = (string.IsNullOrWhiteSpace(NameText.Text) ? 0 : 20);

                float bubleWidth = bubbleSize.Width;
                if (sizeForDate.Width > bubbleSize.Width)
                {
                    bubleWidth = sizeForDate.Width + BubblePadding.Width;
                }

                _view.Frame = new CGRect(frame.X + BubblePadding.Width, frame.Y, bubleWidth, bubbleSize.Height + nameHeight);

                if (!string.IsNullOrWhiteSpace(NameText.Text))
                {
                    NameText.Frame = new CGRect(frame.X + BubblePadding.Width, frame.Y + 5, bubleWidth, 20);
                }

                MessageText.Frame = new CGRect(frame.X + BubblePadding.Width, frame.Y + 6 + nameHeight, noBubbleSize.Width, noBubbleSize.Height);
                DateText.Frame    = new CGRect(bubleWidth - sizeForDate.Width,
                                               bubbleSize.Height - sizeForDate.Height + nameHeight,
                                               sizeForDate.Width,
                                               sizeForDate.Height);
            }
            else
            {
                var sizeForStatus = GetSizeForText(this, StatusText.Text, UIFont.SystemFontOfSize(NativeCell.InfoFontSize)) + BubblePadding;
                var infoLineSize  = sizeForStatus + sizeForDate;

                float bubleWidth = bubbleSize.Width;
                if (infoLineSize.Width > bubbleSize.Width)
                {
                    bubleWidth = infoLineSize.Width;
                }

                _view.Frame       = new CGRect(frame.GetMaxX() - bubleWidth - BubblePadding.Width, frame.Y, bubleWidth, bubbleSize.Height);
                MessageText.Frame = new CGRect(frame.X + BubblePadding.Width, frame.Y + 6, noBubbleSize.Width, noBubbleSize.Height);

                DateText.Frame = new CGRect(bubleWidth - sizeForDate.Width,
                                            bubbleSize.Height - sizeForDate.Height,
                                            sizeForDate.Width,
                                            sizeForDate.Height);
                StatusText.Frame = new CGRect(frame.X + BubblePadding.Width,
                                              bubbleSize.Height - sizeForStatus.Height,
                                              sizeForStatus.Width,
                                              sizeForStatus.Height);
            }
        }
 protected SizeF calculateHeightOfTextForWidth(string text, UIFont font, float width, UILineBreakMode lineBreakMode)
 {
     return(text == null? new SizeF(0, 0) : this.StringSize(text, font, new SizeF(width, 300), lineBreakMode));
 }
        /* Creates the container view here: create the dialog, then add the custom content and buttons */
        private UIView createContainerView()
        {
            var screenSize = CountScreenSize();
            var dialogSize = new CGSize(
                300,
                230
                + kDatePickerDialogDefaultButtonHeight
                + kDatePickerDialogDefaultButtonSpacerHeight);

            // For the black background
            Frame = new CGRect(0, 0, screenSize.Width, screenSize.Height);

            // This is the dialog's container; we attach the custom content and the buttons to this one
            var dialogContainer = new UIView(new CGRect((screenSize.Width - dialogSize.Width) / 2, (screenSize.Height - dialogSize.Height) / 2, dialogSize.Width, dialogSize.Height));

            // First, we style the dialog to match the iOS8 UIAlertView >>>
            var gradient = new CAGradientLayer();

            gradient.Frame  = dialogContainer.Bounds;
            gradient.Colors = new[]
            {
                UIColor.FromRGB(218, 218, 218).CGColor,
                UIColor.FromRGB(233, 233, 233).CGColor,
                UIColor.FromRGB(218, 218, 218).CGColor
            };

            var cornerRadius = kDatePickerDialogCornerRadius;

            gradient.CornerRadius = cornerRadius;
            dialogContainer.Layer.InsertSublayer(gradient, 0);

            dialogContainer.Layer.CornerRadius  = cornerRadius;
            dialogContainer.Layer.BorderColor   = UIColor.FromRGB(198, 198, 198).CGColor;
            dialogContainer.Layer.BorderWidth   = 1;
            dialogContainer.Layer.ShadowRadius  = cornerRadius + 5;
            dialogContainer.Layer.ShadowOpacity = 0.1f;
            dialogContainer.Layer.ShadowOffset  = new CGSize(0 - (cornerRadius + 5) / 2, 0 - (cornerRadius + 5) / 2);
            dialogContainer.Layer.ShadowColor   = UIColor.Black.CGColor;
            dialogContainer.Layer.ShadowPath    = UIBezierPath.FromRoundedRect(dialogContainer.Bounds, dialogContainer.Layer.CornerRadius).CGPath;

            // There is a line above the button
            var lineView = new UIView(new CGRect(0, dialogContainer.Bounds.Size.Height - kDatePickerDialogDefaultButtonHeight - kDatePickerDialogDefaultButtonSpacerHeight, dialogContainer.Bounds.Size.Width, kDatePickerDialogDefaultButtonSpacerHeight));

            lineView.BackgroundColor = UIColor.FromRGB(198, 198, 198);
            dialogContainer.AddSubview(lineView);
            // ˆˆˆ
            //Title
            _titleLabel = new UILabel(new CGRect(10, 10, 280, 30));
            _titleLabel.TextAlignment = UITextAlignment.Center;
            _titleLabel.Font          = UIFont.BoldSystemFontOfSize(17);
            _titleLabel.Text          = _title;
            dialogContainer.AddSubview(_titleLabel);


            _datePicker = new UIDatePicker(new CGRect(0, 30, 0, 0));
            _datePicker.AutoresizingMask = UIViewAutoresizing.FlexibleRightMargin;
            _datePicker.Frame            = new CGRect(_datePicker.Frame.Location, new CGSize(300, _datePicker.Frame.Size.Height));
            _datePicker.Mode             = _datePickerMode;
            _datePicker.Date             = (NSDate)_defaultDate;

            if (_maximumDate.HasValue)
            {
                _datePicker.MaximumDate = (NSDate)_maximumDate.Value;
            }

            if (_minimumDate.HasValue)
            {
                _datePicker.MinimumDate = (NSDate)_minimumDate.Value;
            }

            dialogContainer.AddSubview(_datePicker);
            AddButtonsToView(dialogContainer);
            return(dialogContainer);
        }
Exemple #52
0
        public override void PreferredContentSizeChanged()
        {
            UIFontDescriptor descriptor = textView.Font.FontDescriptor;

            textView.Font = UIFont.GetPreferredFontForTextStyle(descriptor.FontAttributes.TextStyle);
        }
Exemple #53
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            this.flexGrid.SelectionMode    = GridSelectionMode.Cell;
            this.flexGrid.IsReadOnly       = true;
            this.flexGrid.ColumnHeaderFont = UIFont.BoldSystemFontOfSize(this.flexGrid.Font.PointSize);
            this.flexGrid.AutoSizeMode     = GridAutoSizeMode.Both;
            this.flexGrid.AllowMerging     = GridAllowMerging.All;

            string[] weekdays = new string[] { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" };

            foreach (string s in weekdays)
            {
                this.flexGrid.Columns.Add(new GridColumn {
                    Header                    = s,
                    WidthType                 = GridColumnWidth.Star,
                    Width                     = 1,
                    DataType                  = Xuni.iOS.Core.XuniDataType.String,
                    MinWidth                  = 120,
                    HorizontalAlignment       = UITextAlignment.Center,
                    HeaderHorizontalAlignment = UITextAlignment.Center,
                    AllowMerging              = true
                });
            }

            string[] timespans = new string[] { "12", "13", "14", "15", "16", "17", "18" };

            foreach (string s in timespans)
            {
                GridRow newRow = new GridRow();
                this.flexGrid.Rows.Add(newRow);
                this.flexGrid.RowHeaders[this.flexGrid.Rows.IndexOf(newRow), 0] = new NSString(s + ":00");
            }

            this.flexGrid.ColumnHeaders.Rows.Insert(0, new GridRow()
            {
                AllowMerging = true
            });
            this.flexGrid.ColumnHeaders[0, 0] = "Weekday";
            this.flexGrid.ColumnHeaders[0, 1] = "Weekday";
            this.flexGrid.ColumnHeaders[0, 2] = "Weekday";
            this.flexGrid.ColumnHeaders[0, 3] = "Weekday";
            this.flexGrid.ColumnHeaders[0, 4] = "Weekday";
            this.flexGrid.ColumnHeaders[0, 5] = "Weekend";
            this.flexGrid.ColumnHeaders[0, 6] = "Weekend";

            this.flexGrid[0, 0] = "Walker";
            this.flexGrid[0, 1] = "Morning Show";
            this.flexGrid[0, 2] = "Morning Show";
            this.flexGrid[0, 3] = "Sports";
            this.flexGrid[0, 4] = "Weather";
            this.flexGrid[0, 5] = "N/A";
            this.flexGrid[0, 6] = "N/A";
            this.flexGrid[1, 5] = "N/A";
            this.flexGrid[1, 6] = "N/A";
            this.flexGrid[2, 5] = "N/A";
            this.flexGrid[2, 6] = "N/A";
            this.flexGrid[3, 5] = "N/A";
            this.flexGrid[3, 6] = "N/A";
            this.flexGrid[4, 5] = "N/A";
            this.flexGrid[4, 6] = "N/A";
            this.flexGrid[1, 0] = "Today Show";
            this.flexGrid[1, 1] = "Today Show";
            this.flexGrid[2, 0] = "Today Show";
            this.flexGrid[2, 1] = "Today Show";
            this.flexGrid[1, 2] = "Sesame Street";
            this.flexGrid[1, 3] = "Football";
            this.flexGrid[2, 3] = "Football";
            this.flexGrid[1, 4] = "Market Watch";
            this.flexGrid[2, 2] = "Kids Zone";
            this.flexGrid[2, 4] = "Soap Opera";
            this.flexGrid[3, 0] = "News";
            this.flexGrid[3, 1] = "News";
            this.flexGrid[3, 2] = "News";
            this.flexGrid[3, 3] = "News";
            this.flexGrid[3, 4] = "News";
            this.flexGrid[4, 0] = "News";
            this.flexGrid[4, 1] = "News";
            this.flexGrid[4, 2] = "News";
            this.flexGrid[4, 3] = "News";
            this.flexGrid[4, 4] = "News";
            this.flexGrid[5, 0] = "Wheel of Fortune";
            this.flexGrid[5, 1] = "Wheel of Fortune";
            this.flexGrid[5, 2] = "Wheel of Fortune";
            this.flexGrid[5, 3] = "Jeopardy";
            this.flexGrid[5, 4] = "Jeopardy";
            this.flexGrid[5, 5] = "Movie";
            this.flexGrid[6, 5] = "Movie";
            this.flexGrid[5, 6] = "Golf";
            this.flexGrid[6, 6] = "Golf";
            this.flexGrid[6, 0] = "Night Show";
            this.flexGrid[6, 1] = "Night Show";
            this.flexGrid[6, 2] = "Sports";
            this.flexGrid[6, 3] = "Big Brother";
            this.flexGrid[6, 4] = "Big Brother";

            this.flexGrid.AutoSizeColumn(0, true);

            this.flexGrid.SelectionChanged += (object sender, SelectionChangedEventArgs e) => {
                string thisShow = this.flexGrid[(int)e.Range.Row, (int)e.Range.Col].ToString();
                this.tvShowName.Text = thisShow;

                string timeTable = "";

                for (int cc = 0; cc < weekdays.Length; cc++)
                {
                    string day = weekdays[cc];
                    string spanStart = null, spanEnd = null;

                    for (int cr = 0; cr < timespans.Length; cr++)
                    {
                        string candidate = this.flexGrid[cr, cc].ToString();
                        if (candidate.Equals(thisShow))
                        {
                            if (spanStart == null)
                            {
                                spanStart = timespans[cr];
                            }
                        }
                        else
                        {
                            if (spanStart != null)
                            {
                                spanEnd = timespans[cr];
                                break;
                            }
                        }
                    }

                    if (spanStart != null && spanEnd == null)
                    {
                        spanEnd = "19";
                    }

                    if (spanStart != null && spanEnd != null)
                    {
                        timeTable = timeTable + day + ": " + spanStart + ":00-" + spanEnd + ":00\r";
                    }
                }



                this.tvShowTimeTable.Text = timeTable;
            };
        }
Exemple #54
0
        protected async override void OnElementChanged(VisualElementChangedEventArgs e)
        {
            base.OnElementChanged(e);

            var view           = NativeView;
            var viewController = ViewController;

            // Get the device's display for width and height.
            RectangleF screen = UIScreen.MainScreen.Bounds;

            // create top label - "Scan QR code to swap contact info"
            var topLabel = new UILabel(new RectangleF(
                                           0,
                                           0,
                                           screen.Width,
                                           30)
                                       );

            topLabel.Text          = "Scan QR code to swap contact info";
            topLabel.TextAlignment = UITextAlignment.Center;
            topLabel.TextColor     = UIColor.FromRGB(38, 173, 230);
            topLabel.Font          = UIFont.FromName(Fonts.OpenSansBold, 12);

            view.Add(topLabel);

            // create the QR code scanner & add to view
            SIBarcodePicker scanner = new SIBarcodePicker("EeQ6GjLtEeSWsF/zcFfsWC8RqIt/+skbdZJ/MWpLIR8");

            var scannerDelegate = new QrCodeScannerDelegate()
            {
                qrScanner = scanner
            };

            scanner.OverlayController.Delegate = scannerDelegate;

            // disable all codes except QR for scanning
            scanner.Set1DScanningEnabled(false);
            scanner.Set2DScanningEnabled(false);
            scanner.SetCode128Enabled(false);
            scanner.SetCode39Enabled(false);
            scanner.SetCode93Enabled(false);
            scanner.SetDataMatrixEnabled(false);
            scanner.SetEan13AndUpc12Enabled(false);
            scanner.SetEan8Enabled(false);
            scanner.SetItfEnabled(false);
            scanner.SetMicroDataMatrixEnabled(false);
            scanner.SetUpceEnabled(false);
            /* - * - * - * - * - * - * - */
            scanner.SetQrEnabled(true);
            /* - * - * - * - * - * - * - */

            // Set the scanner size
            scanner.Size = new SizeF(
                screen.Size.Width,
                screen.Size.Height * 0.45f
                );
            scanner.View.Bounds = new RectangleF(
                0,
                topLabel.Frame.Height,
                screen.Size.Width,
                screen.Size.Height * 0.45f
                );
            scanner.View.Frame = new RectangleF(
                0,
                topLabel.Frame.Height,
                screen.Size.Width,
                screen.Size.Height * 0.45f
                );

            scanner.OverlayController.SetViewfinderSize(0.5f, 0.5f, 0.5f, 0.5f);
            scanner.OverlayController.SetTorchEnabled(false);

            view.Add(scanner.View);
            scanner.StartScanning();

            /* Creating the lower label - "Share your contact info" */
            var lowerLabel = new UILabel(new RectangleF(
                                             0,
                                             (scanner.View.Frame.Location.Y + scanner.View.Frame.Height),
                                             screen.Width,
                                             20)
                                         );

            lowerLabel.Text          = "Share your contact info";
            lowerLabel.TextAlignment = UITextAlignment.Center;
            lowerLabel.TextColor     = UIColor.FromRGB(38, 173, 230);
            lowerLabel.Font          = UIFont.FromName(Fonts.OpenSansBold, 12);

            view.Add(lowerLabel);
            /* * * * * * * * * * * * * * * * * * * * * * * * * * * */

            /* Generating QR code  */
            var qrWidthHeight = 0;

            if (screen.Height == 480)                   // iPhone 4 & 4S -- shorter screens
            {
                qrWidthHeight = 150;
            }
            else                                                        // iPhone 5, 5C, & 5S -- longer screens
            {
                qrWidthHeight = 175;
            }

            IBarcodeWriter barcodeWriter = new BarcodeWriter
            {
                Format  = BarcodeFormat.QR_CODE,
                Options = new ZXing.Common.EncodingOptions
                {
                    Width  = qrWidthHeight,
                    Height = qrWidthHeight
                }
            };


            // TODO: temp code - move to view model
            var service   = TinyIoC.TinyIoCContainer.Current.Resolve <CouchbaseConnect2014.Services.ICouchbaseService> ();
            var contactId = service.GetUserId();
            var repo      = TinyIoC.TinyIoCContainer.Current.Resolve <CouchbaseConnect2014.Services.IRepository> ();
            var localUser = await repo.GetProfile();

            // end of temp code

            var qrContent = string.Format("{0},{1},{2}", contactId, localUser.First, localUser.Last);

            var result = barcodeWriter.Write(qrContent);

            var qrImageView = new UIImageView(new RectangleF(
                                                  0,
                                                  (lowerLabel.Frame.Location.Y + lowerLabel.Frame.Height),
                                                  result.Size.Width,
                                                  result.Size.Height
                                                  ));

            qrImageView.Image  = result;
            qrImageView.Center = new PointF(
                view.Center.X,
                qrImageView.Center.Y
                );
            /* - * - * - * - * - * - * - */

            view.Add(qrImageView);
        }
Exemple #55
0
        /// <summary>
        /// Views the did load.
        /// </summary>
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            //base.StyleNavigationBar();

            View.BackgroundColor = UIColor.White;

            Title = "Login";

            var mainView = new UIView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
            };

            Add(mainView);

            _usernameTextField = new UITextField()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Placeholder = "Username",
            };

            _passwordTextField = new UITextField()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Placeholder     = "Password",
                SecureTextEntry = true,
            };

            var errorLabel = new UILabel()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                TextAlignment = UITextAlignment.Center,
                Font          = UIFont.FromName("Helvetica", 20f),
                TextColor     = iOSColorPalette.Red,
            };

            _loginButton = new UIButton()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Font            = UIFont.FromName("Alfa Slab One", 20f),
                BackgroundColor = iOSColorPalette.Blue
            };
            _loginButton.SetTitle("Login", UIControlState.Normal);
            _loginButton.SetTitleColor(UIColor.White, UIControlState.Normal);

            var activityIndicatorView = new CustomIndicatorView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Color  = UIColor.Black,
                Hidden = true,
            };

            mainView.Add(_usernameTextField);
            mainView.Add(_passwordTextField);
            mainView.Add(errorLabel);
            mainView.Add(_loginButton);
            mainView.Add(activityIndicatorView);

            var views = new DictionaryViews()
            {
                { "mainView", mainView },
            };

            var mainViews = new DictionaryViews()
            {
                { "usernameTextField", _usernameTextField },
                { "passwordTextField", _passwordTextField },
                { "errorLabel", errorLabel },
                { "loginButton", _loginButton },
                { "activityIndicatorView", activityIndicatorView }
            };

            View.AddConstraints(
                NSLayoutConstraint.FromVisualFormat("V:|[mainView]|", NSLayoutFormatOptions.DirectionLeftToRight, null, views)
                .Concat(NSLayoutConstraint.FromVisualFormat("H:|[mainView]|", NSLayoutFormatOptions.AlignAllTop, null, views))
                .ToArray());

            mainView.AddConstraints(
                NSLayoutConstraint.FromVisualFormat("V:|-140-[usernameTextField]-40-[passwordTextField]-40-[loginButton]-40-[errorLabel]-40-[activityIndicatorView(60)]", NSLayoutFormatOptions.DirectionLeftToRight, null, mainViews)
                .Concat(NSLayoutConstraint.FromVisualFormat("H:[usernameTextField(300)]", NSLayoutFormatOptions.AlignAllTop, null, mainViews))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:[passwordTextField(300)]", NSLayoutFormatOptions.AlignAllTop, null, mainViews))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:[loginButton(300)]", NSLayoutFormatOptions.AlignAllTop, null, mainViews))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:[errorLabel(300)]", NSLayoutFormatOptions.AlignAllTop, null, mainViews))
                .Concat(NSLayoutConstraint.FromVisualFormat("H:[activityIndicatorView(60)]", NSLayoutFormatOptions.AlignAllTop, null, mainViews))
                .Concat(new[] { NSLayoutConstraint.Create(_usernameTextField, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, mainView, NSLayoutAttribute.CenterX, 1f, 0) })
                .Concat(new[] { NSLayoutConstraint.Create(_passwordTextField, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, mainView, NSLayoutAttribute.CenterX, 1f, 0) })
                .Concat(new[] { NSLayoutConstraint.Create(_loginButton, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, mainView, NSLayoutAttribute.CenterX, 1f, 0) })
                .Concat(new[] { NSLayoutConstraint.Create(errorLabel, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, mainView, NSLayoutAttribute.CenterX, 1f, 0) })
                .Concat(new[] { NSLayoutConstraint.Create(activityIndicatorView, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, mainView, NSLayoutAttribute.CenterX, 1f, 0) })
                .ToArray());

            // create the binding set
            //var set = this.CreateBindingSet<LoginPage, LoginPageViewModel>();
            //set.Bind(usernameTextField).To(vm => vm.Username);
            //set.Bind(passwordTextField).To(vm => vm.Password);
            //set.Bind(_loginButton).To(vm => vm.LoginCommand);
            //set.Bind(errorLabel).To(vm => vm.ErrorMessage);
            //set.Bind(errorLabel).For("Hidden").To(vm => vm.IsError).WithConversion("NotValueConverter", false);
            //set.Bind(activityIndicatorView).For("IsRunning").To(vm => vm.IsLoading);
            //set.Apply();

            this.WhenActivated(d =>
            {
                this.Bind(ViewModel, x => x.Username, x => x._usernameTextField.Text);
                this.Bind(ViewModel, x => x.Password, x => x._passwordTextField.Text);

                this.BindCommand(ViewModel, x => x.LoginCommand, x => x._loginButton);
            });
        }
Exemple #56
0
        public void mainPageDesign()
        {
            customView = new UIView();
            customView.BackgroundColor = UIColor.FromRGB(165, 165, 165);

            //Image
            image1       = new UIImageView();
            image1.Image = UIImage.FromBundle("Images/walk.png");

            //PrecisionLabell
            precisionLabel               = new UILabel();
            precisionLabel.Text          = "Precision";
            precisionLabel.Font          = UIFont.FromName("Helvetica", 14f);
            precisionLabel.TextColor     = UIColor.Black;
            precisionLabel.TextAlignment = UITextAlignment.Left;

            //ToolTipLabell
            toolTipLabel               = new UILabel();
            toolTipLabel.Text          = "ToolTip Placement";
            toolTipLabel.Font          = UIFont.FromName("Helvetica", 14f);
            toolTipLabel.TextColor     = UIColor.Black;
            toolTipLabel.TextAlignment = UITextAlignment.Left;

            //ItemCountLabell
            itemCountLabel               = new UILabel();
            itemCountLabel.Text          = "Item Count";
            itemCountLabel.Font          = UIFont.FromName("Helvetica", 14f);
            itemCountLabel.TextColor     = UIColor.Black;
            itemCountLabel.TextAlignment = UITextAlignment.Left;

            //MovieRateLabell
            movieRateLabel               = new UILabel();
            movieRateLabel.Text          = "Movie Rating";
            movieRateLabel.TextColor     = UIColor.Black;
            movieRateLabel.TextAlignment = UITextAlignment.Left;
            movieRateLabel.Font          = UIFont.FromName("Helvetica", 22f);

            //WalkLabell
            walkLabel               = new UILabel();
            walkLabel.Text          = "The Walk (2015)";
            walkLabel.TextColor     = UIColor.Black;
            walkLabel.TextAlignment = UITextAlignment.Left;
            walkLabel.Font          = UIFont.FromName("Helvetica", 18f);

            //TimeLabell
            timeLabel               = new UILabel();
            timeLabel.Text          = "PG | 2 h 20 min";
            timeLabel.TextColor     = UIColor.Black;
            timeLabel.TextAlignment = UITextAlignment.Left;
            timeLabel.Font          = UIFont.FromName("Helvetica", 12f);

            //DescriptionLabell
            descriptionLabel               = new UILabel();
            descriptionLabel.Text          = "In 1974, high-wire artist Philippe Petit recruits a team of people to help him realize his dream: to walk the immense void between the world Trade Centre towers.";
            descriptionLabel.TextColor     = UIColor.Black;
            descriptionLabel.TextAlignment = UITextAlignment.Left;
            descriptionLabel.Font          = UIFont.FromName("Helvetica", 14f);
            descriptionLabel.LineBreakMode = UILineBreakMode.WordWrap;
            descriptionLabel.Lines         = 0;

            //RateLabell
            rateLabel               = new UILabel();
            rateLabel.Text          = "Rate";
            rateLabel.TextColor     = UIColor.Black;
            rateLabel.TextAlignment = UITextAlignment.Left;
            rateLabel.Font          = UIFont.FromName("Helvetica", 18f);

            //ValueLabell
            valueLabel               = new UILabel();
            valueLabel.TextColor     = UIColor.Black;
            valueLabel.TextAlignment = UITextAlignment.Left;
            valueLabel.Font          = UIFont.FromName("Helvetica", 14f);
            UpdateText();
        }
Exemple #57
0
 protected override void OnElementPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
 {
     base.OnElementPropertyChanged(sender, e);
     try
     {
         CustomEntry element = Element as CustomEntry;
         if (Control != null)
         {
             // do whatever you want to the UITextField here
             //var element = Element as CustomEntry;
             Control.BorderStyle        = UITextBorderStyle.Line;
             Control.Layer.CornerRadius = 0;
             Control.ExclusiveTouch     = true;
             //Control.MinimumFontSize = 15f;
             Control.AdjustsFontSizeToFitWidth = true;
             Control.TextColor = UIColor.Black; //for place holder
                                                //var entry1 = new Entry();
                                                //Control.Layer.BorderColor = Color.FromHex("#0000").ToCGColor();
                                                //Control.Layer.BorderWidth = 0;
                                                //entry1.Layer.BorderWidth = 1f;
                                                //Control.TintColor = UIColor.Gray;
                                                //Control.TintColor = Color.FromHex(element.BorderColors).ToUIColor();
             Control.TintColor         = UIColor.Gray;
             Control.Layer.BorderWidth = 1f;
             //Control.Layer.BorderColor = Color.FromHex(element.BorderColors).ToCGColor();
             if (element.BorderColors == "#ff0000")
             {
                 Control.Layer.BorderColor = Color.Red.ToCGColor();
             }
             else if (element.BorderColors == "#6C6C6C")
             {
                 Control.Layer.BorderColor = Color.Gray.ToCGColor();
             }
             //Control.Layer.BorderColor = Color.FromHex("F78F1E").ToCGColor();
             //Control.Layer.BorderWidth = 0.1f;
             //Control.TintColor = Color.FromHex("#F78F1E").ToUIColor();
             if (element.CustomFontFamily == "Avenir65")
             {
                 Control.Font = UIFont.FromName("AvenirLTStd-Medium.ttf", 20.0f);
             }
             else if (element.CustomFontFamily == "Avenir45")
             {
                 Control.Font = UIFont.FromName("AvenirLTStd-Book.ttf", 20.0f);
             }
             else
             {
             }
             if (element.CustomFontSize != 0)
             {
                 UIFont font = Control.Font.WithSize(element.CustomFontSize);
                 Control.Font = font;
             }
             else
             {
             }
         }
     }
     catch (Exception ex)
     {
         var msg = ex.Message;
     }
 }
Exemple #58
0
        public TurnOnLocalitationView(CGSize size)
        {
            nfloat lx = (UIScreen.MainScreen.Bounds.Width - size.Width);
            nfloat ly = (UIScreen.MainScreen.Bounds.Height - size.Height);

            this.Frame = new CGRect(new CGPoint(lx, ly), size);

            effectView.Alpha = 0;

            var attributes = new UIStringAttributes
            {
                Font            = UIFont.FromName("System Semibold", 20f),
                ForegroundColor = UIColor.FromRGB(75, 171, 229)
            };
            var titleText = new NSAttributedString("Open Settings", attributes);

            nfloat btnHeight = 50;

            nfloat oopsHeight = 40;

            nfloat enable_location_height = 80;

            nfloat goSettings_height = 120;

            this.BackgroundColor = UIColor.White;

            btnClose.SetAttributedTitle(titleText, UIControlState.Normal);

            btnClose.SetTitleColor(UIColor.FromRGB(75, 171, 229), UIControlState.Normal);

            btnClose.Layer.BorderColor = UIColor.FromRGB(75, 171, 229).CGColor;

            btnClose.Layer.BorderWidth = 2f;

            btnClose.Layer.CornerRadius = 25;

            btnClose.Frame = new CGRect(this.Frame.Width / 2 - 100, this.Frame.Height / 2 - btnHeight / 2, 200, btnHeight);

            goSettings.Frame = new CGRect(this.Frame.Width / 2 - 150, this.Frame.Height / 2 - btnHeight - goSettings_height / 2 - 40, 300, goSettings_height);

            enable_location.Frame = new CGRect(this.Frame.Width / 2 - 125, this.Frame.Height / 2 - btnHeight - goSettings_height / 2 - enable_location_height - 20, 250, goSettings_height);

            oops.Frame = new CGRect(this.Frame.Width / 2 - 125, this.Frame.Height / 2 - btnHeight - goSettings_height / 2 - enable_location_height - oopsHeight - 20, 250, oopsHeight);

            Console.WriteLine(this.Frame.Width);

            btnClose.TouchUpInside += delegate {
                UIApplication.SharedApplication.OpenUrl(new NSUrl(UIApplication.OpenSettingsUrlString));

                //Close();
            };
            oops.Text          = "Oops";
            oops.Font          = UIFont.FromName("Helvetica-Bold", 25f);
            oops.TextAlignment = UITextAlignment.Center;
            oops.TextColor     = UIColor.FromRGB(112, 112, 112);


            enable_location.Text          = "In order to use Srendip you need to enable your location";
            enable_location.Lines         = 2;
            enable_location.TextAlignment = UITextAlignment.Center;
            enable_location.TextColor     = UIColor.FromRGB(112, 112, 112);

            goSettings.Text          = "Go to settings > Srendip > Location > Enable Location While Using the App";
            goSettings.Lines         = 3;
            goSettings.TextAlignment = UITextAlignment.Center;
            goSettings.TextColor     = UIColor.FromRGB(112, 112, 112);
            //goSettings.Frame = new CGRect(0, this.Frame.Height / 2 - btnHeight - goSettings_height / 2, this.Frame.Width, goSettings_height);



            this.AddSubview(btnClose);
            this.AddSubview(enable_location);
            this.AddSubview(goSettings);
            this.AddSubview(oops);
        }
 void OnSelectColorFont(MonoBehaviour obj)
 {
     mColorFont = obj as UIFont;
     Repaint();
 }
        public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
        {
            //check if the table data has changed before redrawing the table cells
            UITableViewCell BusinessCell = tableView.DequeueReusableCell(this.firstTimeID);

            if (BusinessCell == null)
            {
                BusinessCell = new UITableViewCell(UITableViewCellStyle.Subtitle, this.firstTimeID);
            }


            this.application.cellFirstMeeting = BusinessCell;

            this.favouritesIndicator      = new UILabel();
            this.favouritesIndicator.Text = "\ud83d\udc9d";
            //this.favouritesIndicator.Text = "⭐";
            this.favouritesIndicator.MinimumFontSize           = 24.0f;
            this.favouritesIndicator.AdjustsFontSizeToFitWidth = true;
            this.favouritesIndicator.Frame = new CoreGraphics.CGRect(0, 20, 40, 40);

            BusinessCell.TextLabel.Text            = this.firstTimeDict[indexPath.Row];
            BusinessCell.DetailTextLabel.Text      = this.firstTimeTranslated[indexPath.Row];
            BusinessCell.DetailTextLabel.TextColor = UIColor.Gray;
            BusinessCell.DetailTextLabel.Font      = UIFont.SystemFontOfSize(12.5f);

            if (BusinessCell.EditingStyle == UITableViewCellEditingStyle.Insert)
            {
                this.application.cellFirstMeeting.AccessoryView        = null;
                this.application.cellFirstMeeting.EditingAccessoryView = null;
            }

            if (this.application.localizedTextMeeting.Count == 0)
            {
                this.application.cellFirstMeeting.AccessoryView        = null;
                this.application.cellFirstMeeting.EditingAccessoryView = null;
            }

            else if (this.application.localizedTextMeeting.Count >= 1)
            {
                if (this.application.localizedTextMeeting.Count == 1)
                {
                    if (this.application.tabBarID == 1)
                    {
                        BusinessCell.AccessoryView        = this.favouritesIndicator;
                        BusinessCell.EditingAccessoryView = this.favouritesIndicator;
                    }
                    else
                    {
                        BusinessCell.AccessoryView        = this.favouritesIndicator;
                        BusinessCell.EditingAccessoryView = this.favouritesIndicator;
                    }
                }

                //try this code first
                if (indexPath.Row == this.application.indexTableFirstTimeMeeting.Row)
                {
                    Console.WriteLine("index chosen");
                    BusinessCell.AccessoryView        = this.favouritesIndicator;
                    BusinessCell.EditingAccessoryView = this.favouritesIndicator;
                }

                else if (this.application.indexIntFirstTimeMeeting.Contains(indexPath.Row) == false)
                {
                    Console.WriteLine("Index is not found");
                    BusinessCell.AccessoryView        = null;
                    BusinessCell.EditingAccessoryView = null;
                }

                else if (this.application.indexIntFirstTimeMeeting.Contains(indexPath.Row) == true)
                {
                    Console.WriteLine("Index table chosen _ 1");
                    if (indexPath.Row != this.application.indexTableFirstTimeMeeting.Row)
                    {
                        Console.WriteLine("Index table chosen _ 2");
                        BusinessCell.AccessoryView        = this.favouritesIndicator;
                        BusinessCell.EditingAccessoryView = this.favouritesIndicator;
                    }
                }


                //the previously listed indices have accessory views labelled
                //this takes the final index path instead of a range

                /*	if (indexPath.Row == this.application.indexInt.Find((int obj) => obj >= indexPath.Row)) {
                 *              Console.WriteLine("wtf?");
                 *              BusinessCell.AccessoryView = this.favouritesIndicator;
                 *      }*/

                //try this code. Using logic operators



                /*if(this.application.indexTableFavourite.Row == 0 || this.application.indexTableFavourite.Row == 1) {
                 *      BusinessCell.AccessoryView = this.favouritesIndicator;
                 *      return BusinessCell;
                 * }
                 * else {
                 *      BusinessCell.AccessoryView = null;
                 *      return BusinessCell;
                 * }*/
                return(BusinessCell);
            }

            return(BusinessCell);
        }