本文整理汇总了C#中ProgressBar.Draw方法的典型用法代码示例。如果您正苦于以下问题:C# ProgressBar.Draw方法的具体用法?C# ProgressBar.Draw怎么用?C# ProgressBar.Draw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProgressBar
的用法示例。
在下文中一共展示了ProgressBar.Draw方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Draw
public override void Draw(GameTime gameTime)
{
base.ScreenManager.GraphicsDevice.Clear(Color.Black);
base.ScreenManager.SpriteBatch.Begin();
Rectangle ArtRect = new Rectangle(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth / 2 - 960, base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight / 2 - 540, 1920, 1080);
base.ScreenManager.SpriteBatch.Draw(this.TextureList[this.whichTexture], ArtRect, Color.White);
Rectangle MeterBar = new Rectangle(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth / 2 - 150, base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight - 25, 300, 25);
ProgressBar pb = new ProgressBar(MeterBar)
{
Max = 100f,
Progress = this.percentloaded * 100f
};
pb.Draw(base.ScreenManager.SpriteBatch);
Vector2 Cursor = new Vector2(this.ScreenCenter.X - 250f, (float)MeterBar.Y - Fonts.Arial12Bold.MeasureString(this.text).Y - 5f);
base.ScreenManager.SpriteBatch.DrawString(Fonts.Arial12Bold, this.text, Cursor, Color.White);
if (this.ready)
{
this.percentloaded = 1f;
Cursor.Y = Cursor.Y - (float)Fonts.Pirulen16.LineSpacing - 10f;
string begin = "Click to Continue!";
Cursor.X = this.ScreenCenter.X - Fonts.Pirulen16.MeasureString(begin).X / 2f;
TimeSpan totalGameTime = gameTime.TotalGameTime;
float f = (float)Math.Sin((double)totalGameTime.TotalSeconds);
f = Math.Abs(f) * 255f;
Color flashColor = new Color(255, 255, 255, (byte)f);
base.ScreenManager.SpriteBatch.DrawString(Fonts.Pirulen16, begin, Cursor, flashColor);
}
base.ScreenManager.SpriteBatch.End();
}
示例2: Draw
public void Draw(Ship_Game.ScreenManager ScreenManager)
{
string str;
string str1;
float x = (float)Mouse.GetState().X;
MouseState state = Mouse.GetState();
Vector2 MousePos = new Vector2(x, (float)state.Y);
Color TextColor = new Color(255, 239, 208);
if (Fonts.Pirulen16.MeasureString(this.p.system.Name).X <= (float)this.SysNameRect.Width)
{
Vector2 SysNameCursor = new Vector2((float)(this.SysNameRect.X + this.SysNameRect.Width / 2) - Fonts.Pirulen16.MeasureString(this.p.system.Name).X / 2f, (float)(this.SysNameRect.Y + this.SysNameRect.Height / 2 - Fonts.Pirulen16.LineSpacing / 2));
ScreenManager.SpriteBatch.DrawString(Fonts.Pirulen16, this.p.system.Name, SysNameCursor, TextColor);
}
else
{
Vector2 SysNameCursor = new Vector2((float)(this.SysNameRect.X + this.SysNameRect.Width / 2) - Fonts.Pirulen12.MeasureString(this.p.system.Name).X / 2f, (float)(this.SysNameRect.Y + this.SysNameRect.Height / 2 - Fonts.Pirulen12.LineSpacing / 2));
ScreenManager.SpriteBatch.DrawString(Fonts.Pirulen12, this.p.system.Name, SysNameCursor, TextColor);
}
Rectangle planetIconRect = new Rectangle(this.PlanetNameRect.X + 5, this.PlanetNameRect.Y + 25, this.PlanetNameRect.Height - 50, this.PlanetNameRect.Height - 50);
ScreenManager.SpriteBatch.Draw(ResourceManager.TextureDict[string.Concat("Planets/", this.p.planetType)], planetIconRect, Color.White);
Vector2 cursor = new Vector2((float)(this.PopRect.X + this.PopRect.Width - 5), (float)(this.PlanetNameRect.Y + this.PlanetNameRect.Height / 2 - Fonts.Arial12.LineSpacing / 2));
float population = this.p.Population / 1000f;
string popstring = population.ToString("#.0");
cursor.X = cursor.X - Fonts.Arial12.MeasureString(popstring).X;
HelperFunctions.ClampVectorToInt(ref cursor);
ScreenManager.SpriteBatch.DrawString(Fonts.Arial12, popstring, cursor, Color.White);
cursor = new Vector2((float)(this.FoodRect.X + this.FoodRect.Width - 5), (float)(this.PlanetNameRect.Y + this.PlanetNameRect.Height / 2 - Fonts.Arial12.LineSpacing / 2));
if (this.p.Owner.data.Traits.Cybernetic == 0)
{
float netFoodPerTurn = this.p.NetFoodPerTurn - this.p.consumption;
str = netFoodPerTurn.ToString("#.0");
}
else
{
str = this.p.NetFoodPerTurn.ToString("#.0");
}
string fstring = str;
cursor.X = cursor.X - Fonts.Arial12.MeasureString(fstring).X;
HelperFunctions.ClampVectorToInt(ref cursor);
ScreenManager.SpriteBatch.DrawString(Fonts.Arial12, fstring, cursor, (this.p.NetFoodPerTurn - this.p.consumption >= 0f ? Color.White : Color.LightPink));
cursor = new Vector2((float)(this.ProdRect.X + this.FoodRect.Width - 5), (float)(this.PlanetNameRect.Y + this.PlanetNameRect.Height / 2 - Fonts.Arial12.LineSpacing / 2));
if (this.p.Owner.data.Traits.Cybernetic != 0)
{
float netProductionPerTurn = this.p.NetProductionPerTurn - this.p.consumption;
str1 = netProductionPerTurn.ToString("#.0");
}
else
{
str1 = this.p.NetProductionPerTurn.ToString("#.0");
}
string pstring = str1;
cursor.X = cursor.X - Fonts.Arial12.MeasureString(pstring).X;
HelperFunctions.ClampVectorToInt(ref cursor);
bool pink = false;
if (this.p.Owner.data.Traits.Cybernetic != 0 && this.p.NetProductionPerTurn - this.p.consumption < 0f)
{
pink = true;
}
ScreenManager.SpriteBatch.DrawString(Fonts.Arial12, pstring, cursor, (pink ? Color.LightPink : Color.White));
cursor = new Vector2((float)(this.ResRect.X + this.FoodRect.Width - 5), (float)(this.PlanetNameRect.Y + this.PlanetNameRect.Height / 2 - Fonts.Arial12.LineSpacing / 2));
string rstring = this.p.NetResearchPerTurn.ToString("#.0");
cursor.X = cursor.X - Fonts.Arial12.MeasureString(rstring).X;
HelperFunctions.ClampVectorToInt(ref cursor);
ScreenManager.SpriteBatch.DrawString(Fonts.Arial12, rstring, cursor, Color.White);
cursor = new Vector2((float)(this.MoneyRect.X + this.FoodRect.Width - 5), (float)(this.PlanetNameRect.Y + this.PlanetNameRect.Height / 2 - Fonts.Arial12.LineSpacing / 2));
float Money = this.p.GrossMoneyPT + this.p.Owner.data.Traits.TaxMod * this.p.GrossMoneyPT - (this.p.TotalMaintenanceCostsPerTurn + this.p.TotalMaintenanceCostsPerTurn * this.p.Owner.data.Traits.MaintMod);
string mstring = Money.ToString("#.0");
cursor.X = cursor.X - Fonts.Arial12.MeasureString(mstring).X;
HelperFunctions.ClampVectorToInt(ref cursor);
ScreenManager.SpriteBatch.DrawString(Fonts.Arial12, mstring, cursor, (Money >= 0f ? Color.White : Color.LightPink));
if (Fonts.Pirulen16.MeasureString(this.p.Name).X + (float)planetIconRect.Width + 10f <= (float)this.PlanetNameRect.Width)
{
Vector2 PlanetNameCursor = new Vector2((float)(planetIconRect.X + planetIconRect.Width + 10), (float)(this.SysNameRect.Y + this.SysNameRect.Height / 2 - Fonts.Pirulen16.LineSpacing / 2));
ScreenManager.SpriteBatch.DrawString(Fonts.Pirulen16, this.p.Name, PlanetNameCursor, TextColor);
}
else if (Fonts.Pirulen12.MeasureString(this.p.Name).X + (float)planetIconRect.Width + 10f <= (float)this.PlanetNameRect.Width)
{
Vector2 PlanetNameCursor = new Vector2((float)(planetIconRect.X + planetIconRect.Width + 10), (float)(this.SysNameRect.Y + this.SysNameRect.Height / 2 - Fonts.Pirulen12.LineSpacing / 2));
ScreenManager.SpriteBatch.DrawString(Fonts.Pirulen12, this.p.Name, PlanetNameCursor, TextColor);
}
else
{
Vector2 PlanetNameCursor = new Vector2((float)(planetIconRect.X + planetIconRect.Width + 10), (float)(this.SysNameRect.Y + this.SysNameRect.Height / 2 - Fonts.Arial8Bold.LineSpacing / 2));
ScreenManager.SpriteBatch.DrawString(Fonts.Arial8Bold, this.p.Name, PlanetNameCursor, TextColor);
}
this.DrawSliders(ScreenManager);
if (this.p.Owner.data.Traits.Cybernetic != 0)
{
this.FoodStorage.DrawGrayed(ScreenManager.SpriteBatch);
this.foodDropDown.DrawGrayed(ScreenManager.SpriteBatch);
}
else
{
this.FoodStorage.Draw(ScreenManager.SpriteBatch);
this.foodDropDown.Draw(ScreenManager.SpriteBatch);
}
this.ProdStorage.Draw(ScreenManager.SpriteBatch);
this.prodDropDown.Draw(ScreenManager.SpriteBatch);
ScreenManager.SpriteBatch.Draw(ResourceManager.TextureDict["NewUI/icon_food"], this.foodStorageIcon, (this.p.Owner.data.Traits.Cybernetic == 0 ? Color.White : new Color(110, 110, 110, 255)));
ScreenManager.SpriteBatch.Draw(ResourceManager.TextureDict["NewUI/icon_production"], this.prodStorageIcon, Color.White);
//.........这里部分代码省略.........
示例3: Draw
public void Draw(SpriteBatch spriteBatch)
{
if (this.Copied.Count > this.entriesToDisplay)
{
float count = (float)this.entriesToDisplay / (float)this.Copied.Count;
float single = (float)this.indexAtTop / (float)this.Copied.Count;
int updownsize = (this.ScrollBar.Height - ResourceManager.TextureDict["NewUI/scrollbar_bar_mid"].Height) / 2;
Rectangle up = new Rectangle(this.ScrollBar.X, this.ScrollBar.Y, this.ScrollBar.Width, updownsize);
Rectangle mid = new Rectangle(this.ScrollBar.X, this.ScrollBar.Y + updownsize, this.ScrollBar.Width, ResourceManager.TextureDict["NewUI/scrollbar_bar_mid"].Height);
Rectangle bot = new Rectangle(this.ScrollBar.X, mid.Y + mid.Height, this.ScrollBar.Width, updownsize);
if (this.ScrollBarHover == 0)
{
spriteBatch.Draw(ResourceManager.TextureDict["NewUI/scrollbar_bar_updown"], up, Color.White);
spriteBatch.Draw(ResourceManager.TextureDict["NewUI/scrollbar_bar_mid"], mid, Color.White);
spriteBatch.Draw(ResourceManager.TextureDict["NewUI/scrollbar_bar_updown"], bot, Color.White);
}
else if (this.ScrollBarHover == 1)
{
spriteBatch.Draw(ResourceManager.TextureDict["NewUI/scrollbar_bar_updown_hover1"], up, Color.White);
spriteBatch.Draw(ResourceManager.TextureDict["NewUI/scrollbar_bar_mid_hover1"], mid, Color.White);
spriteBatch.Draw(ResourceManager.TextureDict["NewUI/scrollbar_bar_updown_hover1"], bot, Color.White);
}
else if (this.ScrollBarHover == 2)
{
spriteBatch.Draw(ResourceManager.TextureDict["NewUI/scrollbar_bar_updown_hover2"], up, Color.White);
spriteBatch.Draw(ResourceManager.TextureDict["NewUI/scrollbar_bar_mid_hover2"], mid, Color.White);
spriteBatch.Draw(ResourceManager.TextureDict["NewUI/scrollbar_bar_updown_hover2"], bot, Color.White);
}
float x = (float)Mouse.GetState().X;
MouseState state = Mouse.GetState();
Vector2 mousepos = new Vector2(x, (float)state.Y);
spriteBatch.Draw((HelperFunctions.CheckIntersection(this.ScrollUp, mousepos) ? ResourceManager.TextureDict["NewUI/scrollbar_arrow_up_hover1"] : ResourceManager.TextureDict["NewUI/scrollbar_arrow_up"]), this.ScrollUp, Color.White);
spriteBatch.Draw((HelperFunctions.CheckIntersection(this.ScrollDown, mousepos) ? ResourceManager.TextureDict["NewUI/scrollbar_arrow_down_hover1"] : ResourceManager.TextureDict["NewUI/scrollbar_arrow_down"]), this.ScrollDown, Color.White);
}
if (this.DraggedEntry != null && this.DraggedEntry.item is QueueItem)
{
float x1 = (float)Mouse.GetState().X;
MouseState mouseState = Mouse.GetState();
Vector2 MousePos = new Vector2(x1, (float)mouseState.Y);
if ((this.DraggedEntry.item as QueueItem).isBuilding)
{
Vector2 bCursor = MousePos + this.DraggedOffset;
spriteBatch.Draw(ResourceManager.TextureDict[string.Concat("Buildings/icon_", (this.DraggedEntry.item as QueueItem).Building.Icon, "_48x48")], new Rectangle((int)bCursor.X, (int)bCursor.Y, 29, 30), Color.White);
Vector2 tCursor = new Vector2(bCursor.X + 40f, bCursor.Y);
spriteBatch.DrawString(Fonts.Arial12Bold, (this.DraggedEntry.item as QueueItem).Building.Name, tCursor, Color.White);
tCursor.Y = tCursor.Y + (float)Fonts.Arial12Bold.LineSpacing;
Rectangle pbRect = new Rectangle((int)tCursor.X, (int)tCursor.Y, 150, 18);
ProgressBar pb = new ProgressBar(pbRect)
{
Max = (this.DraggedEntry.item as QueueItem).Cost,
Progress = (this.DraggedEntry.item as QueueItem).productionTowards
};
pb.Draw(spriteBatch);
}
if ((this.DraggedEntry.item as QueueItem).isShip)
{
Vector2 bCursor = MousePos + this.DraggedOffset;
spriteBatch.Draw(ResourceManager.TextureDict[ResourceManager.HullsDict[(this.DraggedEntry.item as QueueItem).sData.Hull].IconPath], new Rectangle((int)bCursor.X, (int)bCursor.Y, 29, 30), Color.White);
Vector2 tCursor = new Vector2(bCursor.X + 40f, bCursor.Y);
spriteBatch.DrawString(Fonts.Arial12Bold, (this.DraggedEntry.item as QueueItem).sData.Name, tCursor, Color.White);
tCursor.Y = tCursor.Y + (float)Fonts.Arial12Bold.LineSpacing;
Rectangle pbRect = new Rectangle((int)tCursor.X, (int)tCursor.Y, 150, 18);
ProgressBar pb = new ProgressBar(pbRect)
{
Max = (this.DraggedEntry.item as QueueItem).Cost,
Progress = (this.DraggedEntry.item as QueueItem).productionTowards
};
pb.Draw(spriteBatch);
}
if ((this.DraggedEntry.item as QueueItem).isTroop)
{
Vector2 bCursor = MousePos + this.DraggedOffset;
(this.DraggedEntry.item as QueueItem).troop.Draw(spriteBatch, new Rectangle((int)bCursor.X, (int)bCursor.Y, 29, 30));
Vector2 tCursor = new Vector2(bCursor.X + 40f, bCursor.Y);
spriteBatch.DrawString(Fonts.Arial12Bold, (this.DraggedEntry.item as QueueItem).troop.Name, tCursor, Color.White);
tCursor.Y = tCursor.Y + (float)Fonts.Arial12Bold.LineSpacing;
Rectangle pbRect = new Rectangle((int)tCursor.X, (int)tCursor.Y, 150, 18);
ProgressBar pb = new ProgressBar(pbRect)
{
Max = (this.DraggedEntry.item as QueueItem).Cost,
Progress = (this.DraggedEntry.item as QueueItem).productionTowards
};
pb.Draw(spriteBatch);
}
}
}