internal static void Game_OnGameLoad(EventArgs args) { if (Player.ChampionName != "AurelionSol") { return; } font = new Font(Drawing.Direct3DDevice, new SharpDX.Direct3D9.FontDescription { Height = 25, FaceName = "微软雅黑" }); LoadSpell(); LoadMenu(); LoadEvent(); }
protected override void Initialize() { try { this.Font = new Font("Impact", 18.0f); this.drawingFont = new SharpDX.Direct3D9.Font(this.Device, this.Font); this.Color = System.Drawing.Color.Yellow; this.lastDrawTime = DateTime.Now; this.NumFractionalDigits = 1; this.Fps = 1; this.DisplayMode = DisplayMode.Spf; this.FpsWeightRatio = 0.1; this.lastRecordedFpsDateTime = DateTime.Now; } catch (Exception ex) { this.Log.Warn(ex); } }
/// <summary> /// Initializes the button by loading the texture, creating the sprite and figure out the scaling. /// /// Called on the GUI thread. /// </summary> /// <param name="drawArgs">The drawing arguments passed from the WW GUI thread.</param> public void Initialize(DrawArgs drawArgs) { if (!this.m_enabled) { return; } if (this.m_TitleFont == null) { Font localHeaderFont = new Font("Arial", 12.0f, FontStyle.Italic | FontStyle.Bold); this.m_TitleFont = new SharpDX.Direct3D9.Font(drawArgs.device, localHeaderFont); Font wingdings = new Font("Wingdings", 12.0f); this.m_wingdingsFont = new SharpDX.Direct3D9.Font(drawArgs.device, wingdings); Font worldwinddings = new Font("World Wind dings", 12.0f); this.m_worldwinddingsFont = new SharpDX.Direct3D9.Font(drawArgs.device, worldwinddings); } this.m_TextFont = drawArgs.defaultDrawingFont; this.m_isInitialized = true; }
public void ComputeAutoSize(DrawArgs drawArgs) { SharpDX.Direct3D9.Font font = drawArgs.defaultDrawingFont; if (font == null) { font = drawArgs.CreateFont("", 10); } Rectangle bounds = font.MeasureString(null, this.m_Text, this.m_Format, 0); if (this.m_useParentWidth) { this.m_size.Width = this.WidgetSize.Width - this.m_location.X; this.m_size.Height = bounds.Height * ((int)(bounds.Width / this.m_size.Width) + 1); } else { this.m_size.Width = bounds.Width + this.m_borderWidth; this.m_size.Height = bounds.Height + this.m_borderWidth; } if (this.m_useParentHeight) { this.m_size.Height = this.WidgetSize.Height - this.m_location.Y; } // This code is iffy - no idea why Y is offset by more than specified. if (this.m_location.X == 0) { this.m_location.X = this.m_borderWidth; this.m_size.Width += this.m_borderWidth; } if (this.m_location.Y == 0) { this.m_location.Y = this.m_borderWidth; this.m_size.Height += this.m_borderWidth; } }
public static void DrawText(Font vFont, String vText, int vPosX, int vPosY, Color vColor) { vFont.DrawText(null, vText, vPosX + 2, vPosY + 2, vColor != Color.Black ? Color.Black : Color.White); vFont.DrawText(null, vText, vPosX, vPosY, vColor); }
internal static void Game_OnGameLoad(EventArgs args) { if (Player.ChampionName != "AurelionSol") { return; } font = new Font(Drawing.Direct3DDevice,new SharpDX.Direct3D9.FontDescription { Height = 25, FaceName = "微软雅黑" }); LoadSpell(); LoadMenu(); LoadEvent(); }
public override int Render(DrawArgs drawArgs, int xOffset, int yOffset) { this.m_ConsumedSize.Height = 0; if (m_textFont == null) { Font localHeaderFont = new Font("Arial", 12.0f, FontStyle.Bold); m_textFont = new SharpDX.Direct3D9.Font(drawArgs.device, localHeaderFont); } if (this.m_visible) { if (!this.m_isInitialized) { this.Initialize(drawArgs); } this.m_ConsumedSize.Height = NODE_HEIGHT; // This value is dynamic based on the number of expanded nodes above this one this.m_location.Y = yOffset; // store this value so the mouse events can figure out where the buttons are this.m_xOffset = xOffset; // compute the color int color = this.Enabled ? this.m_itemOnColor : this.m_itemOffColor; // create the bounds of the text draw area Rectangle bounds = new Rectangle(this.AbsoluteLocation, new Size(this.ClientSize.Width, NODE_HEIGHT)); if (this.m_isMouseOver) { if (!this.Enabled) { color = this.m_mouseOverOffColor; } WidgetUtilities.DrawBox( bounds.X, bounds.Y, bounds.Width, bounds.Height, 0.0f, this.m_mouseOverColor, drawArgs.device); } #region Draw arrow bounds.X = this.AbsoluteLocation.X + xOffset; bounds.Width = NODE_ARROW_SIZE; // draw arrow if any children if (this.m_subNodes.Count > 0) { m_worldwinddingsFont.DrawText( null, (this.m_isExpanded ? "L" : "A"), bounds, DrawTextFormat.None, color); } #endregion Draw arrow #region Draw checkbox bounds.Width = NODE_CHECKBOX_SIZE; bounds.X += NODE_ARROW_SIZE; // Normal check symbol string checkSymbol; if (this.m_isRadioButton) { checkSymbol = this.IsChecked ? "O" : "P"; } else { checkSymbol = this.IsChecked ? "N" : "F"; } m_worldwinddingsFont.DrawText( null, checkSymbol, bounds, DrawTextFormat.NoClip, color); #endregion draw checkbox #region Draw update bounds.X += NODE_CHECKBOX_SIZE; bounds.Width = NODE_UPDATE_SIZE; string updateSymbol = "U"; //m_worldwinddingsFont m_textFont.DrawText(null, updateSymbol, bounds, DrawTextFormat.NoClip, color); #endregion draw update #region Draw name // compute the length based on name length // TODO: Do this only when the name changes Rectangle stringBounds = drawArgs.defaultDrawingFont.MeasureString(null, this.Name, DrawTextFormat.NoClip, 0); this.m_size.Width = NODE_ARROW_SIZE + NODE_CHECKBOX_SIZE + NODE_UPDATE_SIZE + 5 + stringBounds.Width; this.m_ConsumedSize.Width = this.m_size.Width; bounds.Y += 2; bounds.X += NODE_UPDATE_SIZE + 5; bounds.Width = stringBounds.Width; drawArgs.defaultDrawingFont.DrawText( null, this.Name, bounds, DrawTextFormat.None, color); #endregion Draw name if (this.m_isExpanded) { int newXOffset = xOffset + NODE_INDENT; for (int i = 0; i < this.m_subNodes.Count; i++) { if (this.m_subNodes[i] is TreeNodeWidget) { this.m_ConsumedSize.Height += ((TreeNodeWidget)this.m_subNodes[i]).Render(drawArgs, newXOffset, this.m_ConsumedSize.Height); } else { Point newLocation = this.m_subNodes[i].Location; newLocation.Y = this.m_ConsumedSize.Height; newLocation.X = newXOffset; this.m_ConsumedSize.Height += this.m_subNodes[i].WidgetSize.Height; this.m_subNodes[i].Location = newLocation; this.m_subNodes[i].Render(drawArgs); // render normal widgets as a stack of widgets } // if the child width is bigger than my width save it as the consumed width for widget size calculations if (this.m_subNodes[i].WidgetSize.Width + newXOffset > this.m_ConsumedSize.Width) { this.m_ConsumedSize.Width = this.m_subNodes[i].WidgetSize.Width + newXOffset; } } } } return(this.m_ConsumedSize.Height); }
public static void DrawFont(Font vFont, string vText, float vPosX, float vPosY, ColorBGRA vColor) { vFont.DrawText(null, vText, (int)vPosX, (int)vPosY, vColor); }
protected override void Initialize() { try { this.Font = new Font ("Impact", 18.0f); this.drawingFont = new SharpDX.Direct3D9.Font (this.Device, this.Font); this.Color = System.Drawing.Color.Yellow; this.lastDrawTime = DateTime.Now; this.NumFractionalDigits = 1; this.Fps = 1; this.DisplayMode = DisplayMode.Spf; this.FpsWeightRatio = 0.1; this.lastRecordedFpsDateTime = DateTime.Now; } catch (Exception ex) { this.Log.Warn (ex); } }
public static void DrawText(Font aFont, String aText, int aPosX, int aPosY, SharpDX.Color aColor) { aFont.DrawText(null, aText, aPosX + 2, aPosY + 2, aColor != SharpDX.Color.Black ? SharpDX.Color.Black : SharpDX.Color.White); aFont.DrawText(null, aText, aPosX, aPosY, aColor); }
public void Initialize(DrawArgs drawArgs) { // Initialize fonts if (m_drawingFont == null) { Font localHeaderFont = new Font("Arial", 12.0f, FontStyle.Italic | FontStyle.Bold); m_drawingFont = new SharpDX.Direct3D9.Font(drawArgs.device, localHeaderFont); } if (m_wingdingsFont == null) { Font wingdings = new Font("Wingdings", 12.0f); m_wingdingsFont = new SharpDX.Direct3D9.Font(drawArgs.device, wingdings); } if (m_worldwinddingsFont == null) { AddFontResource(Path.Combine(Application.StartupPath, "World Wind Dings 1.04.ttf")); System.Drawing.Text.PrivateFontCollection fpc = new System.Drawing.Text.PrivateFontCollection(); fpc.AddFontFile(Path.Combine(Application.StartupPath, "World Wind Dings 1.04.ttf")); Font m_worldwinddings = new Font(fpc.Families[0], 12.0f); m_worldwinddingsFont = new SharpDX.Direct3D9.Font(drawArgs.device, m_worldwinddings); } // Initialize icon if any if (this.m_imageName.Trim() != string.Empty) { object key = null; // Icon image from file this.m_iconTexture = (IconTexture)DrawArgs.Textures[this.m_imageName]; if (this.m_iconTexture == null) { key = this.m_imageName; this.m_iconTexture = new IconTexture(drawArgs.device, this.m_imageName); } if (this.m_iconTexture != null) { this.m_iconTexture.ReferenceCount++; if (key != null) { // New texture, cache it DrawArgs.Textures.Add(key, this.m_iconTexture); } if (this.m_size.Width == 0) { this.m_size.Width = this.m_iconTexture.Width; } if (this.m_size.Height == 0) { this.m_size.Height = this.m_iconTexture.Height; } this.XScale = (float)this.m_size.Width / this.m_iconTexture.Width; this.YScale = (float)this.m_size.Height / this.m_iconTexture.Height; } if (this.m_sprite == null) { this.m_sprite = new Sprite(drawArgs.device); } } this.m_isInitialized = true; }