public virtual void DrawThumbnail (IDocument doc, IGraphics g, SizeF size, Theme theme)
		{
			g.SetColor (GetThumbnailBackgroundColor (theme));
			g.FillRect (new RectangleF (PointF.Empty, size));
		}
		public virtual Color GetThumbnailBackgroundColor (Theme theme) {
			return theme.DocumentBackgroundColor.GetColor ();
		}
			public override void ApplyTheme (Theme theme)
			{
				SetNeedsDisplay ();
			}
		public override void ApplyTheme (Theme theme)
		{
			base.ApplyTheme (theme);
			RefreshThumbnail ();
		}
		async Task<UIImage> GenerateDocumentThumbnailAsync (IDocument s, Praeclarum.Graphics.SizeF size, Theme theme)
		{
			var scale = UIScreen.MainScreen.Scale;
			return await Task.Run (() => {

				var width = (int)(size.Width * scale);
				var height = (int)(size.Height * scale);

				using (var colorSpace = CoreGraphics.CGColorSpace.CreateDeviceRGB ()) {
					using (var c = new CoreGraphics.CGBitmapContext (
						              IntPtr.Zero,
						              width,
						              height,
						              8,
						              4 * width,
						              colorSpace,
						              CoreGraphics.CGImageAlphaInfo.NoneSkipFirst)) {

						c.TranslateCTM (0, height);
						c.ScaleCTM (scale, -scale);

						var g = new Praeclarum.Graphics.CoreGraphicsGraphics (c, true);
						App.DrawThumbnail (s, g, size, theme);

						//
						// Create the bitmap
						//
						return UIImage.FromImage (c.ToImage (), scale, UIImageOrientation.Up);
					}
				}
			});
		}
		public override void ApplyTheme (Theme theme)
		{
			base.ApplyTheme (theme);
			RefreshThumbnails ().ContinueWith (t => {
				if (t.IsFaulted) {
					Console.WriteLine (t.Exception);
				}
			});
		}
		public void ApplyTheme (Theme theme)
		{
			button.SetNeedsDisplay ();
		}
		public virtual string GetThumbnailKey (IFile file, Theme theme)
		{
			if (file == null)
				return "";

			return string.Format ("{0}-{1}{2}",
				FileSystemManager.Shared.ActiveFileSystem.Id,
				file.Path.Replace ('/', '-').Replace ('.', '-'),
				theme.IsDark ? "-Dark14" : "");
		}
		public void ApplyTheme (Theme theme)
		{
			BackgroundColor = theme.DocumentsBackgroundColor;
			if (ios7) {
				segs.TintColor = theme.DocumentsControlColor;
			}
		}
			public void ApplyTheme (Theme theme)
			{
//				var appdel = DocumentAppDelegate.Shared;
				BackgroundColor = UIColor.Clear;// appdel.App.GetThumbnailBackgroundColor (appdel.Theme).GetUIColor ().ColorWithAlpha (0.5f);
			}
		public virtual void ApplyTheme (Theme theme)
		{
			SetNeedsDisplay ();
		}
		public void ApplyTheme (Theme theme)
		{
			BackgroundColor = theme.DocumentsBackgroundColor;	
		}
		public void ApplyTheme (Theme theme)
		{
			BackgroundColor = theme.DocumentsBackgroundColor;
			if (label != null) {
				label.TextColor = theme.NavigationTextColor;
			}
		}
			public void ApplyTheme (Theme theme)
			{
				BackgroundColor = theme.TableCellBackgroundColor;
				TextLabel.TextColor = theme.TableCellTextColor;
			}
		public static UIColor GetNotSelectableColor (Theme theme) {
			if (theme.IsDark) {
				return UIColor.FromWhiteAlpha (1.0f - 0.875f, 0.5961f);;
			}
			return UIColor.FromWhiteAlpha (0.875f, 0.5961f);
		}
Beispiel #16
0
		static Theme ()
		{
			Current = new Theme (dark: false);
		}
		public virtual void ApplyTheme (Theme theme)
		{
			BackgroundColor = theme.DocumentsBackgroundColor;
			if (label != null) {
				label.BackgroundColor = theme.DocumentsBackgroundColor;
			}
		}
		public virtual async Task<UIImage> GenerateThumbnailAsync (DocumentReference docRef, Praeclarum.Graphics.SizeF size, Theme theme)
		{
			UIImage r = null;

			IDocument doc = null;
			LocalFileAccess local = null;
			var opened = false;

			//
			// Draw the document
			//
			try {
				local = await docRef.File.BeginLocalAccess ();
				var f = local.LocalPath;

				doc = App.CreateDocument (f);
				await doc.OpenAsync ();
				opened = true;

//				Console.WriteLine ("GenerateThumbnail: " + docRef.File.Path + " " + docRef.File.ModifiedTime);

				r = await GenerateDocumentThumbnailAsync (doc, size, theme);

			} catch (Exception ex) {
				Debug.WriteLine ("FAILED to genenerate thumbnail for {0}, {1}", docRef.File.Path, ex.Message);
//				Debug.WriteLine (ex);
			}

			if (opened) {
				try {
					await doc.CloseAsync ();					
				} catch (Exception ex) {
					Console.WriteLine (ex);
				}
			}

			if (local != null) {
				try {
					await local.End ();
				} catch (Exception ex) {
					Console.WriteLine (ex);
				}
			}

			return r;
		}
		public override void ApplyTheme (Theme theme)
		{
			base.ApplyTheme (theme);
			if (label != null) {
				label.TextColor = theme.NavigationTextColor;
			}
		}
		protected virtual void SetTheme (Theme newTheme)
		{
			Theme.Current = newTheme;
			newTheme.Apply ();
			UpdateFonts ();
		}
		async Task<UIImage> GetThumbnail (DocumentReference doc, Theme theme)
		{
			var appDel = DocumentAppDelegate.Shared;
			var Cache = appDel.ThumbnailCache;

			var thumbKey = appDel.GetThumbnailKey (doc.File, theme);

			var thumbImage = await Cache.GetImageAsync (thumbKey, doc.ModifiedTime);

			if (thumbImage == null) {
				thumbImage = await appDel.GenerateThumbnailAsync (doc, ThumbnailSize, theme);
				if (thumbImage != null) {
					await Cache.SetGeneratedImageAsync (thumbKey, thumbImage, saveToDisk: true);
				}
			}

			return thumbImage;
		}