internal void Hide(Aura a) { SharpDXState s = a.State as SharpDXState; if (s.window != null) { s.window.Hide(); } }
internal void Show(Aura a) { SharpDXState s = a.State as SharpDXState; if (s.window != null) { s.window.Show(); } }
internal override void Initialize(Aura a) { if (a.State != null) { a.State.Dispose(); a.State = null; } SharpDXState s = new SharpDXState(); a.State = s; }
internal void AdjustSurface(Aura a) { SharpDXState s = a.State as SharpDXState; if (s.window == null) { s.window = new OverlayWindow(a.Left, a.Top, a.Width, a.Height) { IsTopmost = true, IsVisible = true }; s.graphics = new Graphics { MeasureFPS = false, Width = s.window.Width, Height = s.window.Height, PerPrimitiveAntiAliasing = true, TextAntiAliasing = true, UseMultiThreadedFactories = false, VSync = false, WindowHandle = IntPtr.Zero }; s.window.CreateWindow(); s.graphics.WindowHandle = s.window.Handle; try { s.graphics.Setup(); } catch (Exception ex) { } } else { if (a.Left != s.window.X || a.Top != s.window.Y) { s.window.Move(a.Left, a.Top); } if (a.Width != s.window.Width || a.Height != s.window.Height) { s.window.Resize(a.Width, a.Height); s.graphics.Resize(a.Width, a.Height); } } }
internal override void RenderText(AuraText a) { SharpDXState s = (SharpDXState)a.State; if (s.NeedFont == true || s.TextBrush == null) { if (s.window == null) { AdjustSurface(a); } s.LoadFontOnDemand(a); s.NeedFont = false; s.NeedRender = true; } if (Owner.RenderingActive == false) { if (s.WasHidden == false) { s.NeedRender = true; s.WasHidden = true; } } else { if (s.WasHidden == true) { s.NeedRender = true; s.WasHidden = false; } } if (s.NeedRender == false) { //return; } AdjustSurface(a); s.NeedRender = false; s.graphics.BeginScene(); if (Owner.RenderingActive == false) { Color tempBgColor = new Color(); s.graphics.ClearScene(tempBgColor); s.graphics.EndScene(); return; } if (a.BackgroundColor != System.Drawing.Color.Transparent) { s.bgColor.A = a.Opacity / 100.0f; } s.graphics.ClearScene(s.bgColor); SharpDX.DirectWrite.ParagraphAlignment pa = SharpDX.DirectWrite.ParagraphAlignment.Center; SharpDX.DirectWrite.TextAlignment ta = SharpDX.DirectWrite.TextAlignment.Center; switch (a.TextAlignment) { case Triggernometry.Action.TextAuraAlignmentEnum.TopLeft: pa = SharpDX.DirectWrite.ParagraphAlignment.Near; ta = SharpDX.DirectWrite.TextAlignment.Leading; break; case Triggernometry.Action.TextAuraAlignmentEnum.TopCenter: pa = SharpDX.DirectWrite.ParagraphAlignment.Near; break; case Triggernometry.Action.TextAuraAlignmentEnum.TopRight: pa = SharpDX.DirectWrite.ParagraphAlignment.Near; ta = SharpDX.DirectWrite.TextAlignment.Trailing; break; case Triggernometry.Action.TextAuraAlignmentEnum.MiddleLeft: ta = SharpDX.DirectWrite.TextAlignment.Leading; break; case Triggernometry.Action.TextAuraAlignmentEnum.MiddleCenter: break; case Triggernometry.Action.TextAuraAlignmentEnum.MiddleRight: ta = SharpDX.DirectWrite.TextAlignment.Trailing; break; case Triggernometry.Action.TextAuraAlignmentEnum.BottomLeft: pa = SharpDX.DirectWrite.ParagraphAlignment.Far; ta = SharpDX.DirectWrite.TextAlignment.Leading; break; case Triggernometry.Action.TextAuraAlignmentEnum.BottomCenter: pa = SharpDX.DirectWrite.ParagraphAlignment.Far; break; case Triggernometry.Action.TextAuraAlignmentEnum.BottomRight: pa = SharpDX.DirectWrite.ParagraphAlignment.Far; ta = SharpDX.DirectWrite.TextAlignment.Trailing; break; } if (a.UseOutline == true) { s.TextBrush.Color = new Color(a.OutlineColor.R, a.OutlineColor.G, a.OutlineColor.B, a.Opacity / 100.0f); s.graphics.DrawTextEx(s.TextFont, a.FontStyle, a.FontSize * 1.3f, s.TextBrush, pa, ta, 1, 0, a.Width, a.Height, a.Text); s.graphics.DrawTextEx(s.TextFont, a.FontStyle, a.FontSize * 1.3f, s.TextBrush, pa, ta, -1, 0, a.Width, a.Height, a.Text); s.graphics.DrawTextEx(s.TextFont, a.FontStyle, a.FontSize * 1.3f, s.TextBrush, pa, ta, 0, 1, a.Width, a.Height, a.Text); s.graphics.DrawTextEx(s.TextFont, a.FontStyle, a.FontSize * 1.3f, s.TextBrush, pa, ta, 0, -1, a.Width, a.Height, a.Text); } s.TextBrush.Color = new Color(a.TextColor.R, a.TextColor.G, a.TextColor.B, a.Opacity / 100.0f); s.graphics.DrawTextEx(s.TextFont, a.FontStyle, a.FontSize * 1.3f, s.TextBrush, pa, ta, 0, 0, a.Width, a.Height, a.Text); s.graphics.EndScene(); }
internal override void RenderImage(AuraImage a) { SharpDXState s = a.State as SharpDXState; if (s.NeedImage == true) { if (s.window == null) { AdjustSurface(a); } //s.LoadImageOnDemand(); s.NeedImage = false; s.NeedRender = true; } if (s.IsAnimated == true) { bool af = s.AdvanceFrame(); s.NeedRender = s.NeedRender || af; } if (Owner.RenderingActive == false) { if (s.WasHidden == false) { s.NeedRender = true; s.WasHidden = true; } } else { if (s.WasHidden == true) { s.NeedRender = true; s.WasHidden = false; } } if (s.NeedRender == false) { return; } AdjustSurface(a); s.NeedRender = false; s.graphics.BeginScene(); s.graphics.ClearScene(s.bgColor); if (Owner.RenderingActive == false) { s.graphics.EndScene(); return; } switch (a.Display) { case PictureBoxSizeMode.Zoom: float mW = (float)a.Width / s.OriginalImage.Width; float mH = (float)a.Height / s.OriginalImage.Height; float aW, aH; if (mH < mW) { aW = mH * s.OriginalImage.Width; aH = a.Height; } else if (mW < mH) { aW = a.Width; aH = mW * s.OriginalImage.Height; } else { aW = a.Width; aH = a.Height; } s.graphics.DrawImage( s.OriginalImage, ((a.Width - aW) / 2), ((a.Height - aH) / 2), ((a.Width - aW) / 2) + aW, ((a.Height - aH) / 2) + aH, a.Opacity / 100.0f ); break; case PictureBoxSizeMode.Normal: if (s.OriginalImage.Width <= a.Width && s.OriginalImage.Height <= a.Height) { s.graphics.DrawImage( s.OriginalImage, 0, 0, s.OriginalImage.Width, s.OriginalImage.Height, a.Opacity / 100.0f ); } else { if (s.OriginalImage.Width <= a.Width) { s.graphics.DrawImageEx( s.OriginalImage, new Rectangle(0, 0, s.OriginalImage.Width, a.Height), new Rectangle(0, 0, s.OriginalImage.Width, a.Height), a.Opacity / 100.0f ); } else if (s.OriginalImage.Height <= a.Height) { s.graphics.DrawImageEx( s.OriginalImage, new Rectangle(0, 0, a.Width, s.OriginalImage.Height), new Rectangle(0, 0, a.Width, s.OriginalImage.Height), a.Opacity / 100.0f ); } else { s.graphics.DrawImageEx( s.OriginalImage, new Rectangle(0, 0, a.Width, a.Height), new Rectangle(0, 0, a.Width, a.Height), a.Opacity / 100.0f ); } } break; case PictureBoxSizeMode.CenterImage: if (s.OriginalImage.Width <= a.Width && s.OriginalImage.Height <= a.Height) { s.graphics.DrawImage( s.OriginalImage, ((a.Width - s.OriginalImage.Width) / 2), ((a.Height - s.OriginalImage.Height) / 2), ((a.Width - s.OriginalImage.Width) / 2) + s.OriginalImage.Width, ((a.Height - s.OriginalImage.Height) / 2) + s.OriginalImage.Height, a.Opacity / 100.0f ); } else { s.graphics.DrawImageEx( s.OriginalImage, new Rectangle( (s.OriginalImage.Width / 2) - (a.Width / 2), (s.OriginalImage.Height / 2) - (a.Height / 2), (s.OriginalImage.Width / 2) + (a.Width / 2), (s.OriginalImage.Height / 2) + (a.Height / 2) ), new Rectangle( 0, 0, a.Width, a.Height ), a.Opacity / 100.0f ); } break; case PictureBoxSizeMode.StretchImage: s.graphics.DrawImage( s.OriginalImage, 0, 0, a.Width, a.Height, a.Opacity / 100.0f ); break; } s.graphics.EndScene(); }