Beispiel #1
0
		void Track (PointF pos)
		{
			foreach (var block in blocks){
				if (!block.Bounds.Contains (pos))
					continue;

				highlighted = block;
				SetNeedsDisplay ();
			}
		}
Beispiel #2
0
		public override void Draw (RectangleF rect)
		{
			// If we have a partialTweet, we do not have this information yet.
			if (user == null)
				return;
			
			blocks.Clear();
			
			UIColor txtColor = UIColor.FromRGB(239, 239, 239);
			txtColor.SetColor();			
			
			using (var nss = new NSString (user.Name))
			{
				var dim = nss.StringSize (userFont);
				var placement = new RectangleF (30 + 2 * 26, 2, dim.Width, dim.Height);
				
				var userBlock = new Block()
	            {
					Value = user.Name,
					Bounds = placement,
					Font = userFont, 
					TextColor = txtColor,
				};
				
				blocks.Add(userBlock);
				
				DrawString (user.Name, placement, userFont, UILineBreakMode.TailTruncation);
			};
			
			UIColor relColor = UIColor.LightGray;
			string relString = "";			
			
			if (relation == (int)Relation.UserFollowsYou)
			{
				relColor = UIColor.Red;
				relString = "admirer";
			}
			if (relation == (int)Relation.YouFollowUser)
				relString = "charmer";
			if (relation == (int)Relation.MutualFollowing)
				relString = "friend";
			
			if (relString != "")
			{
				relColor.SetColor();
				using (var nss = new NSString (relString))
				{
					var font = UIFont.FromName("Helvetica", 9);
					var dim = nss.StringSize(font);					
					var placement = new RectangleF (30 + 2 * 26, 4 + userSize, dim.Width, dim.Height);
					
					var userBlock = new Block()
		            {
						Value = relString,
						Bounds = placement,
						Font = font, 
						TextColor = relColor,
					};
					
					blocks.Add(userBlock);
					
					DrawString (relString, placement, font, UILineBreakMode.TailTruncation);
				};				
				
			}
			
			var imgBlock = new Block()
			{ 
				 Value = "profile",
				 Bounds = profileImgFrame,
				 Type = BlockType.Image,
			};
			blocks.Add(imgBlock);			
		}
Beispiel #3
0
		private void OnBlockTapped(Block block)
		{
			if (PictureTapped != null)
				PictureTapped ();
		}
		public static RectangleF GetSize(MKAnnotation annotation, List<Block> blocks, RectangleF bounds)
		{			
			var size = new SizeF(0,0);
			
			float diam = 47 / 2;
			float width = size.Width + 2 * 3 + diam + 3;
			float height = size.Height + 8;			
			
			try
			{
				string title = annotation.Title;
				string subTitle = annotation.Subtitle;				
				
				if (title != null)
				{				
					float subTitleHeightPadY = 3;
					float dimWidth = 0;	
					
					using (var nss = new NSString (title)){
						UIFont font = UIFont.SystemFontOfSize(17);
						var dim = nss.StringSize (font, bounds.Width - diam - 3 * 3, UILineBreakMode.TailTruncation);
						var placement = new RectangleF(3, subTitleHeightPadY, dim.Width, dim.Height);						
						
						var block = new Block()
						{
							Font = font,
							Value = title,
							LineBreakMode = UILineBreakMode.TailTruncation,
							TextColor = UIColor.White,
							Bounds = placement,
						};
						
						blocks.Add(block);
						
						dimWidth = dim.Width;
						subTitleHeightPadY += dim.Height;
					}
					subTitleHeightPadY += 3;
					
					if (subTitle != null)
					{
						using (var nss = new NSString (subTitle)){
							UIFont font = UIFont.SystemFontOfSize(12);
							var dim = nss.StringSize (font, bounds.Width - diam - 3 * 3, UILineBreakMode.TailTruncation);						
							var placement = new RectangleF(3, subTitleHeightPadY, dim.Width, dim.Height);
							
							var block = new Block()
							{
								Font = font,
								Value = subTitle,
								LineBreakMode = UILineBreakMode.TailTruncation,
								TextColor = UIColor.White,
								Bounds = placement,
							};
						
							blocks.Add(block);
							
							dimWidth = Math.Max(dimWidth, dim.Width);
							subTitleHeightPadY += dim.Height;
						}
					}
					
					subTitleHeightPadY += 3;
					size = new SizeF(dimWidth, subTitleHeightPadY); 
				}
							
				width = size.Width + 2 * 3 + diam + 3;
				height = size.Height + 23;
			
			}
			catch (Exception ex)
			{
				Util.LogException("GetSize", ex);
			}
			return new RectangleF(5, 2, width, height);			
		}
Beispiel #5
0
		public override void TouchesEnded (NSSet touches, UIEvent evt)
		{
			CancelHoldTimer ();
			if (blockingTouchEvents)
				return;
			
			if (highlighted != null && (highlighted.Font == userFont || userFont == null)){
				Util.Log("Touches ended " + highlighted.Value);
				if (Tapped != null)
					Tapped (highlighted.Value);
				if (TappedBlock != null)
					TappedBlock(highlighted);				
				if (highlighted != null && TappedCall != null)
					TappedCall (highlighted.CallObject);				
			}
			
			highlighted = null;
			SetNeedsDisplay ();
		}
Beispiel #6
0
		public override void TouchesCancelled (NSSet touches, UIEvent evt)
		{
			CancelHoldTimer ();
			highlighted = null;
			SetNeedsDisplay ();
		}
Beispiel #7
0
			private void RealDraw (RectangleF rect)
			{
				if (_Tweet == null)
					return;
				
				blocks.Clear();
				foreach (var url in urls)
				{
					url.RemoveFromSuperview();
				}
				urls.Clear();
				
				var bounds = Bounds;				
				
				var rectMiniMap = new RectangleF(0, 0, MiniMapWidth, MiniMapHeight);
				float cellHeight = 0;
				float lineY = 0;
				try
				{
					lineY = Layout(bounds, _Tweet, blocks, out cellHeight);
				}
				catch (Exception ex)
				{
					Util.LogException("MemberPhotoCell RealDraw", ex);
				}
				
				titlePath = titlePath ?? GraphicsUtil.MakeRoundedRectPath(new RectangleF(PicXPad, 0, PicWidth - 2 * PicXPad - 26, 
				                                                                         TitleHeight), 4);
				
				badgePath = GraphicsUtil.MakeRoundedRectPath(new RectangleF(PicXPad, 0, PicWidth, cellHeight), 4);
				minimapPath = minimapPath ?? GraphicsUtil.MakeRoundedRectPath(rectMiniMap, 4);
				imagePath = imagePath ?? GraphicsUtil.MakeRoundedRectPath(new RectangleF(0, 0, PicWidth, PicHeight), 8);
				var context = UIGraphics.GetCurrentContext ();
		
				/****	Title	****/			
				UIColor.FromRGB(239, 239, 239).SetColor ();
				context.SaveState ();
				context.TranslateCTM (0, PicYPad);
				context.SetLineWidth (1);
				
				// On device, the shadow is painted in the opposite direction!
				context.SetShadowWithColor (new SizeF (1, 1), 3, UIColor.DarkGray.CGColor);
				context.AddPath (titlePath);				
				context.FillPath ();
				context.RestoreState ();
				/*****************************************************************************/
				
				/****	Commentaires	****/				
				UIColor.FromRGB(239, 239, 239).SetColor ();
				context.SaveState ();
				context.TranslateCTM (0, 3 * PicYPad + PicHeight + TitleHeight);
				context.SetLineWidth (1);
				
				// On device, the shadow is painted in the opposite direction!
				context.SetShadowWithColor (new SizeF (1, 1), 3, UIColor.DarkGray.CGColor);
				context.AddPath (badgePath);
				context.FillPath ();
				context.RestoreState ();
				/*****************************************************************************/
								
				/****	Image	****/
				UIColor.FromRGB(239, 239, 239).SetColor ();
				context.SaveState ();
				context.TranslateCTM (PicXPad, 2 * PicYPad + TitleHeight);
				context.SetLineWidth (1);
								
				// Device and Sim interpret the Y for the shadow differently.
				context.SetShadowWithColor (new SizeF (1, 1), 3, UIColor.DarkGray.CGColor);
				context.AddPath (imagePath);
				context.FillPath();
				context.RestoreState ();
				/*****************************************************************************/				
				
				/****	Minimap	****/	
				context.SaveState ();
				context.TranslateCTM ((bounds.Width - MiniMapWidth)/2, 4 * PicYPad + PicHeight + TitleHeight);
				context.AddPath (minimapPath);
				UIColor.LightGray.SetColor ();
	
				context.SetLineWidth (1);
				// Device and Sim interpret the Y for the shadow differently.
				context.SetShadowWithColor (new SizeF (0, -1), 1, UIColor.DarkGray.CGColor);
				context.StrokePath ();
				
				// Clip the image to the path and paint it
				if (mapPlanImage != null){
					context.AddPath (minimapPath);
					context.Clip ();					
					mapPlanImage.Draw (new RectangleF (0, 0, MiniMapWidth, MiniMapHeight));
					var block = new Block()
					{
						Value = "map",
						Bounds = new RectangleF((bounds.Width - MiniMapWidth)/2, 4 * PicYPad + PicHeight + TitleHeight, 
						                        MiniMapWidth, MiniMapHeight),
						Type = BlockType.Image,
					};
					blocks.Add(block);					
	            }
				if (googleLogo != null)
					googleLogo.Draw(new RectangleF(2, MiniMapHeight - 2 - 23 / 2, 69 / 2, 23 / 2)); 
				
				context.RestoreState ();
				/*****************************************************************************/																				
								
				DrawIcons(lineY, bounds);
				
				foreach (Block block in blocks)
				{
					if (block.Type == BlockType.Text)
					{
						block.TextColor.SetColor();
						if (block.LineBreakMode.HasValue)
							DrawString (block.Value, block.Bounds, block.Font, block.LineBreakMode.Value, UITextAlignment.Left);
						else
							DrawString (block.Value, block.Bounds, block.Font);
					}
					if (block.Type == BlockType.Url)
					{
						UIButton url = CreateUrl(block.Value, block.Bounds);						
						AddSubview(url);
						urls.Add(url);
					}
				}
			}
Beispiel #8
0
			private void OnTappedBlock(Block block)
			{
				/*
				if (block.Tag == "likesCount")
				{
					GotoPhotoLikers(block.CallObject as Image);	
				}
				*/
				if (block.Tag == "keyword")
				{					
					GotoList((string)block.CallObject);
				}
				
				if (block.CallObject is User)
				{
					if (goToUserPhotos != null)
						goToUserPhotos((block.CallObject as User).Id);
				}				
			}