Beispiel #1
0
		public TransformSection()
		{
			image = TestIcons.TestIcon;
			font = Fonts.Sans(10);

			var layout = new DynamicLayout();

			var drawable = new Drawable { Size = canvasSize };
			drawable.Paint += (sender, pe) => {
				pe.Graphics.FillRectangle(Brushes.Black, pe.ClipRectangle);
				MatrixTests(pe.Graphics);
			};
			layout.AddRow(new Label { Text = "Matrix" }, drawable);

			drawable = new Drawable { Size = canvasSize };
			drawable.Paint += (sender, pe) => {
				pe.Graphics.FillRectangle(Brushes.Black, pe.ClipRectangle);
				DirectTests(pe.Graphics);
			};
			layout.AddRow(new Label { Text = "Direct" }, drawable);
			layout.Add(null);

			var m = Matrix.Create();
			m.Scale(100, 100);
			var m2 = m.Clone();
			m2.Translate(10, 10);

			if (m == m2)
				throw new Exception("Grr!");

			Content = layout;
		}
        public AboutDialog()
        {
            this.MinimumSize = new Size(250, 250);
            
            var smallFont = new Font(SystemFont.Default, 10);
            var largeFont = new Font(SystemFont.Bold, 14);

            var version = GetType().Assembly.GetName().Version;
            var versionString = string.Format("Version {0}.{1} ({2}.{3})", version.Major, version.Minor, version.Build, version.Revision);
            
            
            var layout = new DynamicLayout();
            
            layout.AddCentered(new ImageView { Image = Icon.FromResource ("JabbR.Desktop.Resources.JabbR.ico"), Size = new Size(128, 128) }, yscale: true);

            layout.AddCentered(new Label { Text = Application.Instance.Name, Font = largeFont });
            
            layout.AddCentered(new Label { Text = versionString, Font = smallFont }, new Padding(2));

            layout.AddCentered(new Label { Text = "Copyright © 2013 Curtis Wensley", Font = smallFont }, new Padding(2));

            if (!Generator.IsMac)
            {
                layout.AddCentered(CloseButton());
            }

			Content = layout;
        }
		protected override void LogEvents (GridView control)
		{
			control.RowHeight = 36;
			var font = new Font (FontFamily.Serif, 18, FontStyle.Italic);
			control.CellFormatting += (sender, e) => {
				// Log.Write (control, "Formatting Row: {1}, Column: {2}, Item: {0}", e.Item, e.Row, control.Columns.IndexOf (e.Column));
				e.Font = font;
				e.BackgroundColor = Colors.Blue;
				e.ForegroundColor = Colors.Lime;
			};
		}
Beispiel #4
0
		static Font GetFont (FontFamily family, float size, FontStyle style, Generator generator)
		{
			var cache = generator.Cache<FontCacheKey, Font>(cacheKey);
			Font font;
			lock (cache) {
				var key = new FontCacheKey (family, size, style);
				if (!cache.TryGetValue (key, out font)) {
					font = new Font (family, size, style, generator);
					cache.Add (key, font);
				}
			}
			return font;
		}
Beispiel #5
0
		static Font GetFont (FontFamily family, float size, FontStyle style, FontDecoration decoration)
		{
			var cache = Platform.Instance.Cache<FontCacheKey, Font>(cacheKey);
			Font font;
			lock (cache) {
				var key = new FontCacheKey (family, size, style, decoration);
				if (!cache.TryGetValue (key, out font)) {
					font = new Font (family, size, style, decoration);
					cache.Add (key, font);
				}
			}
			return font;
		}
Beispiel #6
0
		static Font GetFont(SystemFont systemFont, float? size, FontDecoration decoration)
		{
			var cache = Platform.Instance.Cache<FontCacheKey, Font>(cacheKey);
			Font font;
			lock (cache)
			{
				var key = new FontCacheKey(systemFont, size, decoration);
				if (!cache.TryGetValue(key, out font))
				{
					font = new Font(systemFont, size, decoration);
					cache.Add(key, font);
				}
			}
			return font;
		}
		public TextureBrushesSection2()
		{
			var w = image.Size.Width / 3; // same as height
			var img = image.Clone(new Rectangle(w, w, w, w));
			var brush = new TextureBrush(img);
			var drawable = new Drawable();
			var font = new Font(SystemFont.Default);
			this.Content = drawable;
			var location = new PointF(100, 100);
			drawable.BackgroundColor = Colors.Green;
			drawable.MouseMove += (s, e) => {
				location = e.Location;
				drawable.Invalidate(); };
			drawable.Paint += (s, e) => {
				e.Graphics.DrawText(font, Colors.White, 3, 3, "Move the mouse in this area to move the image.");

				var temp = brush.Transform; // save state					
				brush.Transform = Matrix.FromTranslation(location);
				e.Graphics.FillRectangle(brush, new RectangleF(location, img.Size));
				brush.Transform = temp;
			};
		}
Beispiel #8
0
		public void DrawText(Font font, SolidBrush brush, float x, float y, string text)
		{
			throw new NotImplementedException();
		}
Beispiel #9
0
		/// <summary>
		/// Draws text with the specified <paramref name="font"/>, <paramref name="brush"/> and location
		/// </summary>
		/// <param name="font">Font to draw the text with</param>
		/// <param name="brush">Brush to stroke the text</param>
		/// <param name="x">X co-ordinate of where to start drawing the text</param>
		/// <param name="y">Y co-ordinate of where to start drawing the text</param>
		/// <param name="text">Text string to draw</param>
		public void DrawText (Font font, SolidBrush brush, float x, float y, string text)
		{
			Handler.DrawText (font, brush, x, y, text);
		}
Beispiel #10
0
		Control SetToFontFamily()
		{
			var button = new Button { Text = "Set to a specific font family (Times New Roman 20pt)" };
			button.Click += delegate
			{
				var family = new FontFamily("Times New Roman");
				var font = new Font(family, 20);
				UpdatePreview(font);
			};
			return button;
		}
Beispiel #11
0
		void UpdatePreview(Font font)
		{
			if (updating)
				return;
			updating = true;
			var newFamily = selectedFont == null || selectedFont.Family != font.Family;
			selectedFont = font;
			DataContext = selectedFont;
			preview.Font = selectedFont;
			preview.Invalidate();

			var family = selectedFont.Family;
			if (newFamily)
			{
				fontStyles.Items.Clear();
				fontStyles.Items.AddRange(family.Typefaces.Select(r => new ListItem { Text = r.Name, Key = r.Name }).OfType<IListItem>());
			}
			fontStyles.SelectedKey = selectedFont.Typeface.Name;
			fontList.SelectedKey = family.Name;
			fontSizes.SelectedKey = font.Size.ToString();
			metricsPreview.Invalidate();

			updating = false;
		}
Beispiel #12
0
		/// <summary>
		/// Draws text with the specified <paramref name="font"/>, <paramref name="brush"/> and location
		/// </summary>
		/// <param name="font">Font to draw the text with</param>
		/// <param name="brush">Brush to stroke the text</param>
		/// <param name="location">Location of where to start drawing the text</param>
		/// <param name="text">Text string to draw</param>
		public void DrawText (Font font, SolidBrush brush, PointF location, string text)
		{
			Handler.DrawText (font, brush, location.X, location.Y, text);
		}
Beispiel #13
0
		public SizeF MeasureString(Font font, string text)
		{
			StartDrawing();
			var size = FontExtensions.MeasureString(text, font);
			EndDrawing();
			return size;
		}
Beispiel #14
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="gfx"></param>
        /// <param name="text"></param>
        /// <param name="dx"></param>
        /// <param name="dy"></param>
        /// <param name="db"></param>
        /// <param name="r"></param>
        public void Draw(object gfx, XText text, double dx, double dy, ImmutableArray<ShapeProperty> db, Record r)
        {
            var _gfx = gfx as Graphics;

            var tbind = text.BindToTextProperty(db, r);
            if (string.IsNullOrEmpty(tbind))
                return;

            var brush = ToSolidBrush(text.Style.Stroke);

            var fontStyle = Eto.Drawing.FontStyle.None;
            if (text.Style.TextStyle.FontStyle.Flags.HasFlag(Test2d.FontStyleFlags.Bold))
            {
                fontStyle |= Eto.Drawing.FontStyle.Bold;
            }

            if (text.Style.TextStyle.FontStyle.Flags.HasFlag(Test2d.FontStyleFlags.Italic))
            {
                fontStyle |= Eto.Drawing.FontStyle.Italic;
            }

            var fontDecoration = Eto.Drawing.FontDecoration.None;
            if (text.Style.TextStyle.FontStyle.Flags.HasFlag(Test2d.FontStyleFlags.Underline))
            {
                fontDecoration |= Eto.Drawing.FontDecoration.Underline;
            }

            if (text.Style.TextStyle.FontStyle.Flags.HasFlag(Test2d.FontStyleFlags.Strikeout))
            {
                fontDecoration |= Eto.Drawing.FontDecoration.Strikethrough;
            }

            var font = new Font(
                text.Style.TextStyle.FontName,
                (float)(text.Style.TextStyle.FontSize * _textScaleFactor),
                fontStyle,
                fontDecoration);

            var rect = CreateRect(
                text.TopLeft,
                text.BottomRight,
                dx, dy);

            var srect = new RectangleF(
                _scaleToPage(rect.X),
                _scaleToPage(rect.Y),
                _scaleToPage(rect.Width),
                _scaleToPage(rect.Height));

            var size = _gfx.MeasureString(font, tbind);
            var origin = GetTextOrigin(text.Style, ref srect, ref size);

            _gfx.DrawText(
                font,
                brush,
                origin,
                tbind);

            brush.Dispose();
            font.Dispose();
        }
Beispiel #15
0
		public Font(Generator generator, Font.IHandler handler)
			: base (generator, handler, true)
		{
		}
Beispiel #16
0
		/// <summary>
		/// Draws text with the specified <paramref name="font"/>, <paramref name="color"/> and location
		/// </summary>
		/// <param name="font">Font to draw the text with</param>
		/// <param name="color">Color of the text</param>
		/// <param name="location">Location of where to start drawing the text</param>
		/// <param name="text">Text string to draw</param>
		public void DrawText (Font font, Color color, Point location, string text)
		{
			handler.DrawText (font, color, location.X, location.Y, text);
		}
Beispiel #17
0
		/// <summary>
		/// Measures the string with the given <paramref name="font"/>
		/// </summary>
		/// <param name="font">Font to measure with</param>
		/// <param name="text">Text string to measure</param>
		/// <returns>Size representing the dimensions of the entire text would take to draw given the specified <paramref name="font"/></returns>
		public SizeF MeasureString (Font font, string text)
		{
			return handler.MeasureString (font, text);
		}
Beispiel #18
0
		/// <summary>
		/// Draws text with the specified <paramref name="font"/>, <paramref name="color"/> and location
		/// </summary>
		/// <param name="font">Font to draw the text with</param>
		/// <param name="color">Color of the text</param>
		/// <param name="x">X co-ordinate of where to start drawing the text</param>
		/// <param name="y">Y co-ordinate of where to start drawing the text</param>
		/// <param name="text">Text string to draw</param>
		public void DrawText (Font font, Color color, int x, int y, string text)
		{
			handler.DrawText (font, color, x, y, text);
		}
Beispiel #19
0
		/// <summary>
		/// Measures the string with the given <paramref name="font"/>
		/// </summary>
		/// <param name="font">Font to measure with</param>
		/// <param name="text">Text string to measure</param>
		/// <returns>Size representing the dimensions of the entire text would take to draw given the specified <paramref name="font"/></returns>
		public virtual SizeF MeasureString (Font font, string text)
		{
			if (string.IsNullOrEmpty(text)) return SizeF.Empty; // handle null explicitly
			return Handler.MeasureString (font, text);
		}
Beispiel #20
0
		/// <summary>
		/// Draws text with the specified <paramref name="font"/>, <paramref name="color"/> and location
		/// </summary>
		/// <param name="font">Font to draw the text with</param>
		/// <param name="color">Color of the text</param>
		/// <param name="location">Location of where to start drawing the text</param>
		/// <param name="text">Text string to draw</param>
		public void DrawText(Font font, Color color, PointF location, string text)
		{
			using (var brush = new SolidBrush(color, Generator))
				Handler.DrawText(font, brush, location.X, location.Y, text);
		}
Beispiel #21
0
		public SizeF MeasureString(Font font, string text)
		{
			// A fixed-width implementation that returns 10 * the length of the string.
			return new SizeF(text.Length * 10f, font.LineHeight);
		}
Beispiel #22
0
		public void DrawText(Font font, SolidBrush brush, float x, float y, string text)
		{
			SetOffset(true);
			if (string.IsNullOrEmpty(text))
				return;

			StartDrawing();
			FontExtensions.DrawString(text, new PointF(x, y), brush.Color, font);
			EndDrawing();
		}
Beispiel #23
0
		public DirectDrawingRenderer()
		{
			texture = TestIcons.Textures;
			font = SystemFonts.Default();
			textBrush = new SolidBrush(Colors.White);
		}
Beispiel #24
0
		/// <summary>
		/// Draws text with the specified <paramref name="font"/>, <paramref name="color"/> and location
		/// </summary>
		/// <param name="font">Font to draw the text with</param>
		/// <param name="color">Color of the text</param>
		/// <param name="x">X co-ordinate of where to start drawing the text</param>
		/// <param name="y">Y co-ordinate of where to start drawing the text</param>
		/// <param name="text">Text string to draw</param>
		public void DrawText(Font font, Color color, float x, float y, string text)
		{
			using (var brush = new SolidBrush(color, Generator))
				Handler.DrawText(font, brush, x, y, text);			
		}
Beispiel #25
0
		public DirectDrawingRenderer(Generator generator = null)
		{
			Generator = generator ?? Generator.Current;
			texture = TestIcons.Textures(generator);
			font = SystemFonts.Default(generator: generator);
			textBrush = new SolidBrush(Colors.White, generator);
		}
Beispiel #26
0
        Control StatusBar()
        {
            var font = new Font(SystemFont.StatusBar);
            var layout = new TableLayout(3, 1) { Size = new Size(Size.Width, 18), Spacing = new Size(5, 5), Padding = new Padding(5, 0) };
            layout.Add(_showMsgLabel = new Label { Text = "Ready", Font = font }, 0, 0);
            layout.Add(null, 1, 0);

            var version = string.Format("Version: {0}@KeePwn", Assembly.GetExecutingAssembly().GetName().Version);
            layout.Add(new Label { Text = version, Font = font, HorizontalAlign = HorizontalAlign.Right }, 2, 0);
            return layout;
        }