// Build the Chart private void CreateGraph(ZedGraphControl zgc, string title, BasicItems yAxis) { // get a reference to the GraphPane GraphPane myPane = zgc.GraphPane; int unit = Global.AccountTime / Global.Second; myPane.CurveList.Clear(); // Set the Titles myPane.Title.Text = title.ToString().Replace('_', ' '); myPane.XAxis.Title.Text = $"Time Unit is Second"; myPane.YAxis.Title.Text = yAxis.ToString().Replace('_', ' '); flowLayoutPanel2.Controls.Clear(); for (int t = 0; t < _measuredValueListsTrials.Count; t++) { List <PointPairList> list = new List <PointPairList>(); list.Add(new PointPairList()); List <string> labeList = new List <string>(); labeList.Add($"{yAxis.ToString()} of Trial {_measuredValueListsTrials[t].Name}"); //var measuredValueTrail = _measuredValueListsTrials[t]; System.Windows.Forms.Label myLabel = new System.Windows.Forms.Label(); myLabel.Width = 400; myLabel.BackColor = GetColor(t); switch (yAxis) { case BasicItems.Entropy: if (cb_DrawExtra.Checked) { list.Add(new PointPairList()); labeList.Add($"Predicted Entropy of Trial {_measuredValueListsTrials[t].Name}"); } for (int i = 0; i < _measuredValueListsTrials[t].MeasuredValuesList.Count; i++) { list[0].Add(i * unit, _measuredValueListsTrials[t].MeasuredValuesList[i].Entropy); if (cb_DrawExtra.Checked) { list[1].Add(i * unit, _measuredValueListsTrials[t].MeasuredValuesList[i].PredictedEntropy); } } myLabel.Text = $"Average entropy in All the trial = {_measuredValueListsTrials[t].AverageEntropy}"; break; case BasicItems.Power_Consumption: list[0].Add(0, _measuredValueListsTrials[t].PowerConsumption); myLabel.Text = $"Power Consumption in All the trial = {_measuredValueListsTrials[t].PowerConsumption} Watts"; break; case BasicItems.Average_Needed_Volume: if (cb_DrawExtra.Checked) { list.Add(new PointPairList()); labeList.Add($"Average Predicted Volume of Trial {_measuredValueListsTrials[t].Name}"); list.Add(new PointPairList()); labeList.Add($"Min Needed Volume of Trial {_measuredValueListsTrials[t].Name}"); list.Add(new PointPairList()); labeList.Add($"Max Needed Volume of Trial {_measuredValueListsTrials[t].Name}"); } for (int i = 0; i < _measuredValueListsTrials[t].MeasuredValuesList.Count; i++) { list[0].Add(i * unit, _measuredValueListsTrials[t].MeasuredValuesList[i].AvgNeededVolume); if (cb_DrawExtra.Checked) { list[1].Add(i * unit, _measuredValueListsTrials[t].MeasuredValuesList[i].AvgPredictedVolume); list[2].Add(i * unit, _measuredValueListsTrials[t].MeasuredValuesList[i].MinNeeded); list[3].Add(i * unit, _measuredValueListsTrials[t].MeasuredValuesList[i].MaxNeeded); } } myLabel.Text = $"Average Volume in All the trial vs Average predicted volume"; break; case BasicItems.Needed_Load_Standard_Deviation: for (int i = 0; i < _measuredValueListsTrials[t].HostMeasureValuesList.Count; i++) { list[0].Add(i * unit, _measuredValueListsTrials[t].HostMeasureValuesList[i].StandardDeviation); } myLabel.Text = $"Average Standard Deviation {_measuredValueListsTrials[t].AverageStdDeviation}"; break; case BasicItems.No_of_Hosts: if (cb_DrawExtra.Checked) { list.Add(new PointPairList()); labeList.Add($"Ideal Hosts Count of Trial {_measuredValueListsTrials[t].Name}"); } for (int i = 0; i < _measuredValueListsTrials[t].MeasuredValuesList.Count; i++) { list[0].Add(i * unit, _measuredValueListsTrials[t].MeasuredValuesList[i].NoHosts); if (cb_DrawExtra.Checked) { list[1].Add(i * unit, _measuredValueListsTrials[t].MeasuredValuesList[i].IdealHostsCount); } } myLabel.Text = $"Average No of Hosts {_measuredValueListsTrials[t].AverageHosts}"; break; case BasicItems.Hosts_States: //list.Clear() list.Add(new PointPairList()); list.Add(new PointPairList()); list.Add(new PointPairList()); labeList.Clear(); labeList.Add($"Under of {_measuredValueListsTrials[t].Name}"); labeList.Add($"Over of {_measuredValueListsTrials[t].Name}"); labeList.Add($"Normal of {_measuredValueListsTrials[t].Name}"); labeList.Add($"Evacuating of {_measuredValueListsTrials[t].Name}"); for (int i = 0; i < _measuredValueListsTrials[t].MeasuredValuesList.Count; i++) { list[0].Add(i * unit, _measuredValueListsTrials[t].MeasuredValuesList[i].UnderHosts); list[1].Add(i * unit, _measuredValueListsTrials[t].MeasuredValuesList[i].OverHosts); list[2].Add(i * unit, _measuredValueListsTrials[t].MeasuredValuesList[i].NormalHosts); list[3].Add(i * unit, _measuredValueListsTrials[t].MeasuredValuesList[i].EvacuatingHosts); } myLabel.Text = $"Under:{_measuredValueListsTrials[t].FinalUnderUtilized} " + $"Over:{_measuredValueListsTrials[t].FinalOverUtilized} " + $"Normal:{_measuredValueListsTrials[t].FinalNormalUtilized} " + $"Evacuating:{_measuredValueListsTrials[t].FinalEvacuatingUtilized} "; break; case BasicItems.Total_Messages: for (int i = 0; i < _measuredValueListsTrials[t].MeasuredValuesList.Count; i++) { list[0].Add(i * unit, _measuredValueListsTrials[t].MeasuredValuesList[i].TotalMessages); } myLabel.Text = $"Total Messages in All the trial = {_measuredValueListsTrials[t].TotalMessages}"; break; case BasicItems.Total_Communicated_Size: for (int i = 0; i < _measuredValueListsTrials[t].MeasuredValuesList.Count; i++) { list[0].Add(i * unit, _measuredValueListsTrials[t].MeasuredValuesList[i].CommunicatedSize); } myLabel.Text = $"Total Communicated Size = {(int)_measuredValueListsTrials[t].TotalCommunicatedSize/1024} GB "; break; case BasicItems.Average_Host_Data_Out_and_In: list.Add(new PointPairList()); labeList[0] = ($"Data Out of Trial {_measuredValueListsTrials[t].Name}"); labeList.Add($"Data In of Trial {_measuredValueListsTrials[t].Name}"); for (int i = 0; i < _measuredValueListsTrials[t].HostMeasureValuesList.Count; i++) { list[0].Add(i * unit, _measuredValueListsTrials[t].HostMeasureValuesList[i].AverageDataOut); list[1].Add(i * unit, _measuredValueListsTrials[t].HostMeasureValuesList[i].AverageDataIn); } myLabel.Text = $"Average data Out/In = {_measuredValueListsTrials[t].AverageDataOut } / { _measuredValueListsTrials[t].AverageDataIn} MB"; break; case BasicItems.Containers: for (int i = 0; i < _measuredValueListsTrials[t].HostMeasureValuesList.Count; i++) { list[0].Add(i * unit, _measuredValueListsTrials[t].HostMeasureValuesList[i].Containers); } myLabel.Text = $"Average Containers in All the trial = {_measuredValueListsTrials[t].AverageContainers}"; break; case BasicItems.Push_Requests: for (int i = 0; i < _measuredValueListsTrials[t].MeasuredValuesList.Count; i++) { list[0].Add(i * unit, _measuredValueListsTrials[t].MeasuredValuesList[i].PushRequests); } myLabel.Text = $"Total Push Requests in All the trial = {_measuredValueListsTrials[t].TotalPushRequests}"; break; case BasicItems.Pull_Requests: for (int i = 0; i < _measuredValueListsTrials[t].MeasuredValuesList.Count; i++) { list[0].Add(i * unit, _measuredValueListsTrials[t].MeasuredValuesList[i].PullRequests); } myLabel.Text = $"Total Pull Requests in All the trial = {_measuredValueListsTrials[t].TotalPullRequests}"; break; case BasicItems.Migrations: for (int i = 0; i < _measuredValueListsTrials[t].MeasuredValuesList.Count; i++) { list[0].Add(i * unit, _measuredValueListsTrials[t].MeasuredValuesList[i].Migrations); } myLabel.Text = $"Total Migrations in All the trial = {_measuredValueListsTrials[t].TotalMigrations}"; break; case BasicItems.Migration_Count: foreach (var item in _measuredValueListsTrials[t].ContainerMeasureValuesList) { list[0].Add(item.Key, item.Value.MigrationCount); } myLabel.Text = $"Average Migration per container in All the trial = {_measuredValueListsTrials[t].AvgMigrations}"; break; case BasicItems.Push_Load_Availability_Request: for (int i = 0; i < _measuredValueListsTrials[t].MeasuredValuesList.Count; i++) { list[0].Add(i * unit, _measuredValueListsTrials[t].MeasuredValuesList[i].PushLoadAvailabilityRequest); } myLabel.Text = $"Total Push Availability Requests in All the trial = {_measuredValueListsTrials[t].TotalPushAvailabilityRequests}"; break; case BasicItems.Pull_Load_Availability_Request: for (int i = 0; i < _measuredValueListsTrials[t].MeasuredValuesList.Count; i++) { list[0].Add(i * unit, _measuredValueListsTrials[t].MeasuredValuesList[i].PullLoadAvailabilityRequest); } myLabel.Text = $"Total Pull Availability Requests in All the trial = {_measuredValueListsTrials[t].TotalPullAvailabilityRequests}"; break; case BasicItems.Utilization_SLA_Violations_Count: for (int i = 0; i < _measuredValueListsTrials[t].MeasuredValuesList.Count; i++) { list[0].Add(i * unit, _measuredValueListsTrials[t].MeasuredValuesList[i].SlaViolationsCount); } myLabel.Text = $"Total SLA Violations the trial = {_measuredValueListsTrials[t].TotalSlaViolationsCount}"; break; case BasicItems.SLA_Violations_Percent: for (int i = 0; i < _measuredValueListsTrials[t].MeasuredValuesList.Count; i++) { list[0].Add(i * unit, _measuredValueListsTrials[t].MeasuredValuesList[i].SlaViolationsPercentage); } myLabel.Text = $"Average SLA Violations % = {_measuredValueListsTrials[t].AverageSlaViolationsPercent}"; break; case BasicItems.Container_DownTime: foreach (var item in _measuredValueListsTrials[t].ContainerMeasureValuesList) { list[0].Add(item.Key, item.Value.Downtime); } myLabel.Text = $"Average Down time of all containers in All the trial = {_measuredValueListsTrials[t].AvgDownTime}"; break; case BasicItems.Image_Pulls: for (int i = 0; i < _measuredValueListsTrials[t].MeasuredValuesList.Count; i++) { list[0].Add(i * unit, _measuredValueListsTrials[t].MeasuredValuesList[i].ImagePulls); } myLabel.Text = $"Total ImagePulls of trial = {_measuredValueListsTrials[t].ImagePulls}"; break; case BasicItems.Image_Pulls_Ratio: list[0].Add(0, _measuredValueListsTrials[t].AveragePullPerImage); myLabel.Text = $"Image Pull Ratio in All the trial = {_measuredValueListsTrials[t].AveragePullPerImage}"; break; case BasicItems.Containers_Per_Host: for (int i = 0; i < _measuredValueListsTrials[t].HostMeasureValuesList.Count; i++) { list[0].Add(i * unit, _measuredValueListsTrials[t].HostMeasureValuesList[i].ContainersPerHost); } myLabel.Text = $"Average Containers in All the trial = {_measuredValueListsTrials[t].AverageContainersPerHost}"; break; default: throw new NotImplementedException(); } // Generate a red curve with diamond // symbols, and "Porsche" in the legend if (yAxis == BasicItems.Migration_Count || yAxis == BasicItems.Container_DownTime || yAxis == BasicItems.Power_Consumption || yAxis == BasicItems.Image_Pulls_Ratio)// || yAxis == BasicItems.OutOfBoundHosts) { for (int i = 0; i < list.Count; i++) { myPane.AddBar(labeList[i], list[i], GetColor(t)); } } else { for (int i = 0; i < list.Count; i++) { myPane.AddCurve(labeList[i], list[i], GetColor(t), GetSymbolType(i)); } } flowLayoutPanel2.Controls.Add(myLabel); //myPane.AddBar($"Trial no {t}", list1, GetColor(t)); //myPane.AddStick($"Trial no {t}", list1,GetColor(t)); } // Tell ZedGraph to refigure the // axes since the data have changed zgc.AxisChange(); zgc.Refresh(); }
private static void LoadBackground(Engine engine) { var backgroundPath = Path.Combine("background", "static_background.jpg"); var staticBackgroundAsset = new SpriteAsset(backgroundPath); engine.LoadAsset("static_background", staticBackgroundAsset); // TOP engine.LoadAsset("background_topleft", new SpriteAsset(backgroundPath, 0, 0, GameBackground.WallWidth, GameBackground.WallHeight)); engine.LoadAsset("background_topright", new SpriteAsset( backgroundPath, staticBackgroundAsset.Width - GameBackground.WallWidth, 0, GameBackground.WallWidth, GameBackground.WallHeight)); engine.LoadAsset("background_topstart", new SpriteAsset(backgroundPath, GameBackground.WallWidth, 0, staticBackgroundAsset.Width / 2 - GameBackground.WallWidth, GameBackground.WallHeight)); engine.LoadAsset("background_topend", new SpriteAsset( backgroundPath, staticBackgroundAsset.Width / 2, 0, staticBackgroundAsset.Width / 2 - GameBackground.WallWidth, GameBackground.WallHeight)); engine.LoadAsset("background_topcenter", new SpriteAsset( backgroundPath, staticBackgroundAsset.Width / 2 - GameBackground.WallWidth / 2, 0, GameBackground.WallWidth, GameBackground.WallHeight)); // LEFT engine.LoadAsset("background_leftstart", new SpriteAsset( backgroundPath, 0, GameBackground.WallHeight, GameBackground.WallWidth, staticBackgroundAsset.Height / 2 - GameBackground.WallHeight)); engine.LoadAsset("background_leftend", new SpriteAsset( backgroundPath, 0, staticBackgroundAsset.Height / 2 - GameBackground.WallHeight, GameBackground.WallWidth, staticBackgroundAsset.Height / 2 - GameBackground.WallHeight)); engine.LoadAsset("background_leftcenter", new SpriteAsset( backgroundPath, 0, staticBackgroundAsset.Height / 2 - GameBackground.WallHeight / 2, GameBackground.WallWidth, GameBackground.WallHeight)); // RIGHT engine.LoadAsset("background_rightstart", new SpriteAsset( backgroundPath, staticBackgroundAsset.Width - GameBackground.WallWidth, GameBackground.WallHeight, GameBackground.WallWidth, staticBackgroundAsset.Height / 2 - GameBackground.WallHeight)); engine.LoadAsset("background_rightend", new SpriteAsset( backgroundPath, staticBackgroundAsset.Width - GameBackground.WallWidth, staticBackgroundAsset.Height / 2 - GameBackground.WallHeight, GameBackground.WallWidth, staticBackgroundAsset.Height / 2 - GameBackground.WallHeight)); engine.LoadAsset("background_rightcenter", new SpriteAsset( backgroundPath, staticBackgroundAsset.Width - GameBackground.WallWidth, GameBackground.WallHeight, GameBackground.WallWidth, staticBackgroundAsset.Height / 2 + GameBackground.WallHeight / 2)); // BOTTOM engine.LoadAsset("background_bottomleft", new SpriteAsset( backgroundPath, 0, staticBackgroundAsset.Height - GameBackground.WallHeight, GameBackground.WallWidth, GameBackground.WallHeight)); engine.LoadAsset("background_bottomright", new SpriteAsset( backgroundPath, staticBackgroundAsset.Width - GameBackground.WallWidth, staticBackgroundAsset.Height - GameBackground.WallHeight, GameBackground.WallWidth, GameBackground.WallHeight)); engine.LoadAsset("background_bottomstart", new SpriteAsset( backgroundPath, GameBackground.WallWidth, staticBackgroundAsset.Height - GameBackground.WallHeight + GameBackground.BottomBlockDiff, staticBackgroundAsset.Width / 2 - GameBackground.WallWidth, GameBackground.WallHeight - GameBackground.BottomBlockDiff)); engine.LoadAsset("background_bottomend", new SpriteAsset( backgroundPath, staticBackgroundAsset.Width / 2, staticBackgroundAsset.Height - GameBackground.WallHeight + GameBackground.BottomBlockDiff, staticBackgroundAsset.Width / 2 - GameBackground.WallWidth, GameBackground.WallHeight - GameBackground.BottomBlockDiff)); engine.LoadAsset("background_bottomcenter", new SpriteAsset( backgroundPath, staticBackgroundAsset.Width / 2 - GameBackground.WallWidth / 2, staticBackgroundAsset.Height - GameBackground.WallHeight + GameBackground.BottomBlockDiff, GameBackground.WallWidth, GameBackground.WallHeight - GameBackground.BottomBlockDiff)); // BLOCKS var startX = 205; var startY = 211; engine.LoadAsset("background_blocks0", new SpriteAsset( backgroundPath, startX, startY, GameBackground.BlockSizeX * 2, GameBackground.BlockSizeY * 2)); engine.LoadAsset("background_blocks1", new SpriteAsset( backgroundPath, startX + GameBackground.BlockSizeX * 2 - 2, startY, GameBackground.BlockSizeX * 2, GameBackground.BlockSizeY * 2)); engine.LoadAsset("background_blocks2", new SpriteAsset( backgroundPath, startX + GameBackground.BlockSizeX * 4 - 4, startY, GameBackground.BlockSizeX * 2, GameBackground.BlockSizeY * 2)); engine.LoadAsset("background_blocks3", new SpriteAsset( backgroundPath, startX + GameBackground.BlockSizeX * 6 - 5, startY, GameBackground.BlockSizeX * 2, GameBackground.BlockSizeY * 2)); engine.LoadAsset("background_blocks4", new SpriteAsset( backgroundPath, startX, startY + GameBackground.BlockSizeX * 2 + 3, GameBackground.BlockSizeX * 2, GameBackground.BlockSizeY * 2)); engine.LoadAsset("background_blocks5", new SpriteAsset( backgroundPath, startX + GameBackground.BlockSizeX * 2 - 2, startY + GameBackground.BlockSizeX * 2 + 3, GameBackground.BlockSizeX * 2, GameBackground.BlockSizeY * 2)); engine.LoadAsset("background_blocks6", new SpriteAsset( backgroundPath, startX + GameBackground.BlockSizeX * 4 - 4, startY + GameBackground.BlockSizeX * 2 + 3, GameBackground.BlockSizeX * 2, GameBackground.BlockSizeY * 2)); engine.LoadAsset("background_blocks7", new SpriteAsset( backgroundPath, startX + GameBackground.BlockSizeX * 6 - 5, startY + GameBackground.BlockSizeX * 2 + 3, GameBackground.BlockSizeX * 2, GameBackground.BlockSizeY * 2)); // SHADOW engine.LoadAsset("background_shadow_top", new SpriteAsset(Path.Combine("background", "shadow_top.png"))); engine.LoadAsset("background_shadow_left", new SpriteAsset(Path.Combine("background", "shadow_left.png"))); engine.LoadAsset("background_shadow_bottom", new SpriteAsset(Path.Combine("background", "shadow_bottom.png"))); engine.LoadAsset("background_shadow_right", new SpriteAsset(Path.Combine("background", "shadow_right.png"))); BasicItems.LoadAssets(engine); }
public override void Start() { base.Start(); MainClass.LoadAssets(Engine); TextConfig.Default = new TextConfig(new Asset("font.png"), charToSprite, paddingFunc: (float width) => { float result = width; result *= -0.066f; return(result); }); GameBackground.Initialize(Engine); Engine.SpawnObject(new CharactersInfo()); var logoAsset = (SpriteAsset)Engine.GetAsset("logo"); var logoObj = new SpriteObject(logoAsset.Width, logoAsset.Height) { CurrentSprite = logoAsset }; logoObj.X = Engine.Width / 2 - logoObj.Width / 2; logoObj.Y = Engine.Height / 2 - logoObj.Height / 2; // game controls text var padding = 3f; var fontSize = 0.66f; var gameControls = new TextObject(fontSize, Color.White); gameControls.Text = "WASD: movements"; var gameControlsSize = gameControls.Measure(); gameControls.X = Engine.Width / 2 - gameControlsSize.X / 2; gameControls.Y = logoObj.Y + logoObj.Height + padding; var gameControls2 = new TextObject(fontSize, Color.White); gameControls2.Text = "Arrows+QEZC: shot"; var gameControls2Size = gameControls2.Measure(); gameControls2.X = Engine.Width / 2 - gameControls2Size.X / 2; gameControls2.Y = gameControls.Y + gameControlsSize.Y + padding; var gameControls3 = new TextObject(fontSize, Color.White); gameControls3.Text = "F: change spell"; var gameControls3Size = gameControls3.Measure(); gameControls3.X = Engine.Width / 2 - gameControls3Size.X / 2; gameControls3.Y = gameControls2.Y + gameControls2Size.Y + padding; var gameControls4 = new TextObject(fontSize, Color.White); gameControls4.Text = "M: map - Esc: pause"; var gameControls4Size = gameControls4.Measure(); gameControls4.X = Engine.Width / 2 - gameControls4Size.X / 2; gameControls4.Y = gameControls3.Y + gameControls3Size.Y + padding; var continueText = new TextObject(fontSize, Color.White); continueText.Text = "Press anything to play!"; var continueTextSize = continueText.Measure(); continueText.X = Engine.Width / 2 - continueTextSize.X / 2; continueText.Y = Engine.Height - padding - continueTextSize.Y; Engine.SpawnObject("logo", logoObj); Engine.SpawnObject("logo_controls", gameControls); Engine.SpawnObject("logo_controls2", gameControls2); Engine.SpawnObject("logo_controls3", gameControls3); Engine.SpawnObject("logo_controls4", gameControls4); Engine.SpawnObject("logo_continueText", continueText); MainWindow = "logo"; BasicItems.Initialize(Engine); AudioSource.Volume = 0.66f; AudioSource.Stream(((AudioAsset)Engine.GetAsset("sound_soundtrack")).FileName, true); }