public void LblProductionMeter_Draw(object sender, DrawEventArgs e) { Texture2D _cityProductionMeterModTexture = new Texture2D(Manager.GraphicsDevice,256,256); if (CurrentCity.CurrentBuildingTarget != null) { float radReady = CurrentCity.ProductionReady * (float)Math.PI * 2f - (float)Math.PI; // remove not present slice Color[] colors = new Color[256 * 256]; _cityProductionMeterTexture.GetData<Color>(colors); for (int x = 0; x < 256; x++) { for (int y = 0; y < 256; ++y) { int i = y * 256 + x; if (Math.Atan2(x - 128, y - 128) < radReady) colors[i] = Microsoft.Xna.Framework.Color.Transparent; } } _cityProductionMeterModTexture.SetData<Color>(colors); } Rectangle r = new Rectangle(e.Rectangle.X, e.Rectangle.Y, 256, 256); e.Renderer.Draw(_cityProductionMeterModTexture, r, Color.White); e.Renderer.Draw(_cityProductionFrameTexture, r, Color.White); if (CurrentCity.CurrentBuildingTarget != null && CurrentCity.CurrentBuildingTarget.Image != null) e.Renderer.Draw(CurrentCity.CurrentBuildingTarget.Image, r, Color.White); }
public void LblBuildings_Draw(object sender, DrawEventArgs e) { //e.Renderer.Draw(_citySeperatorTexture, e.Rectangle, new Rectangle(0,0,44,44), Color.White); if (GetControl("BuildingsList").Visible) e.Renderer.DrawString(_cityMenu, Strings.TXT_KEY_UI_CITYVIEW_BUILDINGS_COLLAPSE, e.Rectangle, Color.White, Alignment.MiddleLeft); else e.Renderer.DrawString(_cityMenu, Strings.TXT_KEY_UI_CITYVIEW_BUILDINGS_EXPAND, e.Rectangle, Color.White, Alignment.MiddleLeft); }
public void LblUnit_Draw(object sender, DrawEventArgs e) { if (CurrentUnit != null) { Rectangle r = e.Rectangle; r.Width = 256; r.Height = 256; r.X -= 26; r.Y += 24; if (CurrentUnit.Data.Image != null) e.Renderer.Draw(CurrentUnit.Data.Image, r, Color.White); else e.Renderer.DrawString(_cityTitleFont, CurrentUnit.Data.Name, r, Color.Pink, Alignment.MiddleCenter); } }
public void LblOverview_Draw(object sender, DrawEventArgs e) { if (_overviewTexture != null) { overviewInnerRect.X = e.Rectangle.X + 11; overviewInnerRect.Y = e.Rectangle.Y; e.Renderer.Draw(_overviewTexture, overviewInnerRect, Color.White); } overviewSideRect.X = e.Rectangle.X; overviewSideRect.Y = e.Rectangle.Y; e.Renderer.Draw(_overviewSideTextureLeft, overviewSideRect, Color.White); overviewSideRect.X = e.Rectangle.X + e.Rectangle.Width - 11; overviewSideRect.Y = e.Rectangle.Y; e.Renderer.Draw(_overviewSideTextureRight, overviewSideRect, Color.White); }
public void LblResearch_Draw(object sender, DrawEventArgs e) { if (Game.Human.ScienceReady != lastScience) { _scienceMeterModTexture = new Texture2D(Manager.GraphicsDevice, 220, 220); float radReady = Game.Human.ScienceReady * (float)Math.PI * 2f - (float)Math.PI; // remove not present slice Color[] colors = new Color[220 * 220]; _scienceTexture.GetData<Color>(colors); for (int x = 0; x < 220; x++) { for (int y = 0; y < 220; ++y) { int i = y * 220 + x; if (Math.Atan2(x - 110, y - 110) < radReady) colors[i] = Microsoft.Xna.Framework.Color.Transparent; } } _scienceMeterModTexture.SetData<Color>(colors); lastScience = Game.Human.ScienceReady; } Rectangle r = new Rectangle(e.Rectangle.X, e.Rectangle.Y, 128, 128); e.Renderer.Draw(_scienceMeterModTexture, r, Color.White); e.Renderer.Draw(_scienceFrameTexture, r, Color.White); if (Game.Human.CurrentResearch != null) { if (Game.Human.CurrentResearch.Image != null) e.Renderer.Draw(Game.Human.CurrentResearch.Image, r, Color.White); else e.Renderer.DrawString(_notificationFont, Game.Human.CurrentResearch.Title, r, Color.White, Alignment.MiddleCenter); } }
public void Notification_Draw(object sender, DrawEventArgs e) { ImageBox cnt = sender as ImageBox; int num = int.Parse( "" + cnt.Name.Last() ); if (Messages.Count > num) { ScreenNotification not = Messages.ElementAt(num); cnt.ToolTip.Text = not.Text; cnt.ToolTip.Left = Manager.GraphicsDevice.Viewport.Width - (int)cnt.ToolTip.Skin.Layers[0].Text.Font.Resource.MeasureString(not.Text).X - 10; switch (not.Type) { default: case NotificationType.FoundCity: e.Renderer.Draw(_notificationgenericglow, e.Rectangle, Microsoft.Xna.Framework.Color.White); break; case NotificationType.CityGrowth: e.Renderer.Draw(_notificationcitygrowthglow, e.Rectangle, Microsoft.Xna.Framework.Color.White); break; case NotificationType.CityDecline: e.Renderer.Draw(_notificationcitydeclineglow, e.Rectangle, Microsoft.Xna.Framework.Color.White); break; case NotificationType.ProducationReady: e.Renderer.Draw(_notificationiconsproduction, e.Rectangle, Microsoft.Xna.Framework.Color.White); break; case NotificationType.Science: e.Renderer.Draw(_notificationiconsscience, e.Rectangle, Microsoft.Xna.Framework.Color.White); break; case NotificationType.PolicyReady: e.Renderer.Draw(_notificationiconsculture, e.Rectangle, Microsoft.Xna.Framework.Color.White); break; } //e.Renderer.DrawString(_notificationFont, _messages.ElementAt(num).Text, e.Rectangle, Microsoft.Xna.Framework.Color.White, Alignment.MiddleCenter); } }
public void ActionButton_Draw(object sender, DrawEventArgs e) { if (CurrentUnitActions == null) return; ImageBox cnt = sender as ImageBox; int num = int.Parse("" + cnt.Name.Last()); try { if (CurrentUnitActions.Count > num) { UnitAction action = CurrentUnitActions[num]; Texture2D texture = Provider.GetAtlas("UnitActionAtlas").GetTexture(action.ToString()); if (texture != null) e.Renderer.Draw(texture, e.Rectangle, Color.White); } } catch (Exception ex) { } }
//////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// private void MainWindow_Draw(object sender, DrawEventArgs e) { if (backgroundImage != null && mainWindow != null) { e.Renderer.Draw(backgroundImage, e.Rectangle, Color.White); } }
/// <summary> /// Handles drawing the client area of the text box control. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void ClientArea_Draw(object sender, DrawEventArgs e) { // Grab the text box control's skin information. SkinLayer layer = Skin.Layers[lrTextBox]; Color col = Skin.Layers[lrTextBox].Text.Colors.Enabled; SkinLayer cursor = Skin.Layers[lrCursor]; // Multi-line text boxes are aligned top-left; other types have their line centered vertically. Alignment al = mode == TextBoxMode.Multiline ? Alignment.TopLeft : Alignment.MiddleLeft; Renderer renderer = e.Renderer; Rectangle r = e.Rectangle; // Text box has a selected text to consider? bool drawsel = !selection.IsEmpty; string tmpText = ""; // Get the font used for drawing the text box contents. font = (Skin.Layers[lrTextBox].Text != null) ? Skin.Layers[lrTextBox].Text.Font.Resource : null; // Control has text to draw and we have a font to draw it with? if (Text != null && font != null) { DeterminePages(); if (mode == TextBoxMode.Multiline) { shownText = Text; tmpText = Lines[PosY]; } else if (mode == TextBoxMode.Password) { // Mask the text using the password character. shownText = ""; for (int i = 0; i < Text.Length; i++) { shownText = shownText + passwordChar; } tmpText = shownText; } else { shownText = Text; tmpText = Lines[PosY]; } // Text color defined and control not disabled. if (TextColor != UndefinedColor && ControlState != ControlState.Disabled) { // Use the control's text color value. col = TextColor; } if (mode != TextBoxMode.Multiline) { linesDrawn = 0; vert.Value = 0; } // Is there a selection to draw? if (drawsel) { DrawSelection(e.Renderer, r); /* renderer.End(); renderer.SpriteBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.Immediate, SaveStateMode.None); renderer.SpriteBatch.GraphicsDevice.RenderState.SeparateAlphaBlendEnabled = true; renderer.SpriteBatch.GraphicsDevice.RenderState.SourceBlend = Blend.DestinationColor; renderer.SpriteBatch.GraphicsDevice.RenderState.DestinationBlend = Blend.SourceColor; renderer.SpriteBatch.GraphicsDevice.RenderState.BlendFunction = BlendFunction.Subtract; //renderer.SpriteBatch.GraphicsDevice.RenderState.AlphaFunction = CompareFunction.Equal; //renderer.SpriteBatch.GraphicsDevice.RenderState.AlphaSourceBlend = Blend.One; //renderer.SpriteBatch.GraphicsDevice.RenderState.AlphaDestinationBlend = Blend.DestinationAlpha; */ } int sizey = (int)font.LineSpacing; // Need to draw the caret? if (showCursor && caretVisible) { Vector2 size = Vector2.Zero; if (PosX > 0 && PosX <= tmpText.Length) { size = font.MeasureString(tmpText.Substring(0, PosX)); } if (size.Y == 0) { size = font.MeasureString(" "); size.X = 0; } int m = r.Height - font.LineSpacing; // Create the rectangle where the cursor should be drawn. Rectangle rc = new Rectangle(r.Left - horz.Value + (int)size.X, r.Top + m / 2, cursor.Width, font.LineSpacing); // Adjust rectangle to account for current vertical scroll bar value? if (mode == TextBoxMode.Multiline) { rc = new Rectangle(r.Left + (int)size.X - horz.Value, r.Top + (int)((PosY - vert.Value) * font.LineSpacing), cursor.Width, font.LineSpacing); } // Draw the cursor in the text box. cursor.Alignment = al; renderer.DrawLayer(cursor, rc, col, 0); } // Draw all visible text. for (int i = 0; i < linesDrawn + 1; i++) { int ii = i + vert.Value; if (ii >= Lines.Count || ii < 0) break; if (Lines[ii] != "") { if (mode == TextBoxMode.Multiline) { renderer.DrawString(font, Lines[ii], r.Left - horz.Value, r.Top + (i * sizey), col); } else { Rectangle rx = new Rectangle(r.Left - horz.Value, r.Top, r.Width, r.Height); renderer.DrawString(font, shownText, rx, col, al, false); } } } /* if (drawsel) { renderer.End(); renderer.Begin(BlendingMode.Premultiplied); }*/ } }
public void CitySidebar_Draw(object sender, DrawEventArgs e) { e.Renderer.Draw(IconProvider.Pixel, e.Rectangle, Microsoft.Xna.Framework.Color.Black); Rectangle r2 = new Rectangle(e.Rectangle.X, e.Rectangle.Y, 11, e.Rectangle.Height); e.Renderer.Draw(_overviewSideTextureLeft, r2, Color.White); }
/// <summary> /// Client area draw event callback. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ClientArea_OnDraw(object sender, DrawEventArgs e) { // Ignore if we have no history.. if (this._messages.Count == 0) return; // Prepare variables.. var font = Detox.TinyFont; var rect = e.Rectangle; var pos = 0; // Determine the chat lines to display.. for (var x = (this._chatScroller.Value + this._chatScroller.PageSize) - 1; (x >= (this._chatScroller.Value + this._chatScroller.PageSize) - this._chatScroller.PageSize); x--) { const int posX = 4; var posY = rect.Bottom - (pos + 1) * font.LineSpacing; // Draw outline around the text.. for (var y = -1; y <= 1; y++) for (var z = -1; z <= 1; z++) e.Renderer.DrawString(font, this._messages[x].Message, posX + y, posY - z, Color.Black); // Draw the chat text.. e.Renderer.DrawString(font, this._messages[x].Message, posX, posY, this._messages[x].Color); pos += 1; } }
void DrawStrings(DrawEventArgs e, Control control, SkinLayer layer, String[] str, Rectangle rectangle, bool margins) { Rectangle rect = rectangle; for (int i = 0; i < Headers.HeaderButtons.Count; i++) { //Section off each "cell" rect.X = Headers.HeaderButtons[i].Left; rect.Width = Headers.HeaderButtons[i].Width; //Draw a line on top, draw the string, draw a line on the bottom, draw a line on the left e.Renderer.Draw(line, new Rectangle(rect.X - 2, rect.Y, rect.Width, 1), Color.Black); e.Renderer.DrawString(control, layer, " " + str[i], rect, margins); e.Renderer.Draw(line, new Rectangle(rect.X - 2, rect.Y+rect.Height, rect.Width, 1), Color.Black); e.Renderer.Draw(line, new Rectangle(rect.X - 2, rect.Y, 1, rect.Height), Color.Black); } }
void btnEnabled_Draw(object sender, DrawEventArgs e) { //Button b = (Button)sender; //new Rectangle(500, 500, 600, 600) e.Renderer.Draw(Assets.textureDict[textures.blackorb], e.Rectangle, new Rectangle(0,0,25,25), Color.White); }
//////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// private void DrawImagePane(object sender, DrawEventArgs e) { try { if (Items != null && Items.Count > 0) { //SkinText font = Skin.Layers["Control"].Text; SkinLayer sel = Skin.Layers["ListBox.Selection"]; SkinLayer txt = Skin.Layers["ListBox.Text"]; int h = ItemHeight; int v = (_sbVert.Value / 10); int p = (_sbVert.PageSize / 10); int d = (int)(((_sbVert.Value % 10) / 10f) * h); int c = Items.Count; int s = ItemIndex; for (int i = v; i <= v + p + 1; i++) { if (i < c) { Texture2D image = Items[i] as AbstractNamedEntity != null ? (Items[i] as AbstractNamedEntity).Image : null; string desc = Items[i] as AbstractNamedEntity != null ? AbstractNamedEntity.LimitTextLength((Items[i] as AbstractNamedEntity).Description, 200 ) : ""; if (image != null) e.Renderer.Draw(image, new Rectangle(e.Rectangle.Left + 2, e.Rectangle.Top - d + ((i - v) * h) + 2, ItemHeight - 4, ItemHeight - 4), Color.White); e.Renderer.DrawString(this, Skin.Layers["Control"], Items[i].ToString(), new Rectangle(e.Rectangle.Left + ItemHeight, e.Rectangle.Top - d + ((i - v) * h), e.Rectangle.Width, HeadingHeight), false); e.Renderer.DrawString(this, txt, desc, new Rectangle(e.Rectangle.Left + ItemHeight, e.Rectangle.Top - d + ((i - v) * h) + HeadingHeight, e.Rectangle.Width, TextHeight), false); } } if (s >= 0 && s < c && (Focused || !HideSelection)) { int pos = -d + ((s - v) * h); if (pos > -h && pos < (p + 1) * h) { e.Renderer.DrawLayer(this, sel, new Rectangle(e.Rectangle.Left, e.Rectangle.Top + pos, e.Rectangle.Width, h)); Texture2D image = Items[s] as AbstractNamedEntity != null ? (Items[s] as AbstractNamedEntity).Image : null; string desc = Items[s] as AbstractNamedEntity != null ? AbstractNamedEntity.LimitTextLength((Items[s] as AbstractNamedEntity).Description, 200) : ""; if (image != null) e.Renderer.Draw(image, new Rectangle(e.Rectangle.Left + 2, e.Rectangle.Top + pos + 2, ItemHeight - 4, ItemHeight - 4), Color.White); e.Renderer.DrawString(this, sel, Items[s].ToString(), new Rectangle(e.Rectangle.Left + ItemHeight, e.Rectangle.Top + pos, e.Rectangle.Width, HeadingHeight), false); e.Renderer.DrawString(this, txt, desc, new Rectangle(e.Rectangle.Left + ItemHeight, e.Rectangle.Top + pos + HeadingHeight, e.Rectangle.Width, TextHeight), false); } } } } catch (Exception ex) { return; } }
public void LblCitynameTribe_Draw(object sender, DrawEventArgs e) { cityOwnerIconLocation.X = e.Rectangle.X + 106; cityOwnerIconLocation.Y = e.Rectangle.Y + 10; e.Renderer.Draw(CurrentCity.Player.Civilization.Image, cityOwnerIconLocation, Color.White); }
public void LblCityname_Draw(object sender, DrawEventArgs e) { e.Rectangle.Height = 36; e.Renderer.DrawString(_cityTitleFont, CurrentCity.Name, e.Rectangle, Color.White, Alignment.MiddleCenter); }
public void BtnCityExit_Draw(object sender, DrawEventArgs e) { e.Renderer.DrawString(_cityTitleFont, Strings.TXT_KEY_UI_CITYVIEW_RETURN_MAP, e.Rectangle, Color.White, Alignment.MiddleCenter); }
//////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// private void DrawPane(object sender, DrawEventArgs e) { if (items != null && items.Count > 0) { SkinText font = Skin.Layers["Control"].Text; SkinLayer sel = Skin.Layers["ListBox.Selection"]; int h = (int)font.Font.Resource.MeasureString(items[0].ToString()).Y; int v = (sbVert.Value / 10); int p = (sbVert.PageSize / 10); int d = (int)(((sbVert.Value % 10) / 10f) * h); int c = items.Count; int s = itemIndex; for (int i = v; i <= v + p + 1; i++) { if (i < c) { e.Renderer.DrawString(this, Skin.Layers["Control"], items[i].ToString(), new Rectangle(e.Rectangle.Left, e.Rectangle.Top - d + ((i - v) * h), e.Rectangle.Width, h), false); } } if (s >= 0 && s < c && (Focused || !hideSelection)) { int pos = -d + ((s - v) * h); if (pos > -h && pos < (p + 1) * h) { e.Renderer.DrawLayer(this, sel, new Rectangle(e.Rectangle.Left, e.Rectangle.Top + pos, e.Rectangle.Width, h)); e.Renderer.DrawString(this, sel, items[s].ToString(), new Rectangle(e.Rectangle.Left, e.Rectangle.Top + pos, e.Rectangle.Width, h), false); } } } }
//////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// void ClientArea_Draw(object sender, DrawEventArgs e) { SkinLayer layer = Skin.Layers[lrTextBox]; Color col = Skin.Layers[lrTextBox].Text.Colors.Enabled; SkinLayer cursor = Skin.Layers[lrCursor]; Alignment al = mode == TextBoxMode.Multiline ? Alignment.TopLeft : Alignment.MiddleLeft; Renderer renderer = e.Renderer; Rectangle r = e.Rectangle; bool drawsel = !selection.IsEmpty; string tmpText = ""; font = (Skin.Layers[lrTextBox].Text != null) ? Skin.Layers[lrTextBox].Text.Font.Resource : null; if (Text != null && font != null) { DeterminePages(); if (mode == TextBoxMode.Multiline) { shownText = Text; tmpText = Lines[PosY]; } else if (mode == TextBoxMode.Password) { shownText = ""; for (int i = 0; i < Text.Length; i++) { shownText = shownText + passwordChar; } tmpText = shownText; } else { shownText = Text; tmpText = Lines[PosY]; } if (TextColor != UndefinedColor && ControlState != ControlState.Disabled) { col = TextColor; } if (mode != TextBoxMode.Multiline) { linesDrawn = 0; vert.Value = 0; } if (drawsel) { DrawSelection(e.Renderer, r); /* renderer.End(); renderer.SpriteBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.Immediate, SaveStateMode.None); renderer.SpriteBatch.GraphicsDevice.RenderState.SeparateAlphaBlendEnabled = true; renderer.SpriteBatch.GraphicsDevice.RenderState.SourceBlend = Blend.DestinationColor; renderer.SpriteBatch.GraphicsDevice.RenderState.DestinationBlend = Blend.SourceColor; renderer.SpriteBatch.GraphicsDevice.RenderState.BlendFunction = BlendFunction.Subtract; //renderer.SpriteBatch.GraphicsDevice.RenderState.AlphaFunction = CompareFunction.Equal; //renderer.SpriteBatch.GraphicsDevice.RenderState.AlphaSourceBlend = Blend.One; //renderer.SpriteBatch.GraphicsDevice.RenderState.AlphaDestinationBlend = Blend.DestinationAlpha; */ } int sizey = (int)font.LineSpacing; if (showCursor && caretVisible) { Vector2 size = Vector2.Zero; if (PosX > 0 && PosX <= tmpText.Length) { size = font.MeasureString(tmpText.Substring(0, PosX)); } if (size.Y == 0) { size = font.MeasureString(" "); size.X = 0; } int m = r.Height - font.LineSpacing; Rectangle rc = new Rectangle(r.Left - horz.Value + (int)size.X, r.Top + m / 2, cursor.Width, font.LineSpacing); if (mode == TextBoxMode.Multiline) { rc = new Rectangle(r.Left + (int)size.X - horz.Value, r.Top + (int)((PosY - vert.Value) * font.LineSpacing), cursor.Width, font.LineSpacing); } cursor.Alignment = al; renderer.DrawLayer(cursor, rc, col, 0); } for (int i = 0; i < linesDrawn + 1; i++) { int ii = i + vert.Value; if (ii >= Lines.Count || ii < 0) break; if (Lines[ii] != "") { if (mode == TextBoxMode.Multiline) { renderer.DrawString(font, Lines[ii], r.Left - horz.Value, r.Top + (i * sizey), col); } else { Rectangle rx = new Rectangle(r.Left - horz.Value, r.Top, r.Width, r.Height); renderer.DrawString(font, shownText, rx, col, al, false); } } } /* if (drawsel) { renderer.End(); renderer.Begin(BlendingMode.Premultiplied); }*/ } }