Now main form is also responsive
This commit is contained in:
@@ -24,6 +24,25 @@ namespace Test_Merge
|
||||
string ConfigFile = "";
|
||||
string GpUrl = "";
|
||||
|
||||
//For the responsive content
|
||||
|
||||
Size oldSize = new Size();
|
||||
Size oldRankingSize = new Size();
|
||||
Size oldLapTimesSize = new Size();
|
||||
Size oldBattles = new Size();
|
||||
|
||||
Size oldPnlBattles = new Size();
|
||||
Size oldPnlRankings = new Size();
|
||||
Size oldPnlFastest = new Size();
|
||||
Size oldPnlSlowest = new Size();
|
||||
|
||||
Point oldRankingPosition = new Point();
|
||||
Point oldBattlePosition = new Point();
|
||||
Point oldDriverInfoPosition = new Point();
|
||||
|
||||
Point olPnlFastestPosition = new Point();
|
||||
Point oldPnlSlowestPosition = new Point();
|
||||
|
||||
public Main()
|
||||
{
|
||||
InitializeComponent();
|
||||
@@ -48,6 +67,7 @@ namespace Test_Merge
|
||||
|
||||
Settings settingsForm = new Settings();
|
||||
settingsForm.ShowDialog();
|
||||
RefreshUI();
|
||||
//MessageBox.Show(settingsForm.GrandPrixUrl + Environment.NewLine + settingsForm.GrandPrixName + Environment.NewLine + settingsForm.GrandPrixYear);
|
||||
if (settingsForm.GrandPrixUrl != "" && settingsForm.SelectedConfigFile != "")
|
||||
{
|
||||
@@ -76,6 +96,23 @@ namespace Test_Merge
|
||||
|
||||
tbxGpUrl.Text = GpUrl;
|
||||
|
||||
oldSize = this.Size;
|
||||
oldRankingSize = gpbxRanking.Size;
|
||||
oldLapTimesSize = gpbxLapTimes.Size;
|
||||
oldBattles = gpbxBattles.Size;
|
||||
|
||||
oldPnlRankings = pnlLiveRanking.Size;
|
||||
oldPnlBattles = pnlBattles.Size;
|
||||
oldPnlFastest = pnlFastest.Size;
|
||||
oldPnlSlowest = pnlSlowest.Size;
|
||||
|
||||
oldRankingPosition = gpbxRanking.Location;
|
||||
oldBattlePosition = gpbxBattles.Location;
|
||||
oldDriverInfoPosition = gpbxDriverInfos.Location;
|
||||
|
||||
olPnlFastestPosition = pnlFastest.Location;
|
||||
oldPnlSlowestPosition = pnlSlowest.Location;
|
||||
|
||||
tip1.SetToolTip(btnResetEmulator, "Starts or restarts the emulator. You need to start this to use the app");
|
||||
tip1.SetToolTip(btnSettings, "Opens the configuration menu");
|
||||
tip1.SetToolTip(tbxGpUrl, "Insert the URL of the Grand Prix you want to track. Dont forget the \"?action=play\" at the end");
|
||||
@@ -310,7 +347,32 @@ namespace Test_Merge
|
||||
|
||||
private void Main_Resize(object sender, EventArgs e)
|
||||
{
|
||||
int xDiff = this.Width - oldSize.Width;
|
||||
int yDiff = this.Height - oldSize.Height;
|
||||
int padding = 10;
|
||||
//This will take half the newly created space
|
||||
gpbxRanking.Size = new Size(oldRankingSize.Width + xDiff / 2, oldRankingSize.Height + yDiff);
|
||||
gpbxRanking.Location = new Point(oldRankingPosition.X + xDiff / 2, gpbxRanking.Location.Y);
|
||||
//Will take half the new height and half the new height
|
||||
gpbxLapTimes.Size = new Size(oldLapTimesSize.Width + xDiff / 2, oldLapTimesSize.Height + yDiff / 2);
|
||||
//Will take half the new height and half the new width
|
||||
gpbxBattles.Size = new Size(oldBattles.Width + xDiff / 2, oldBattles.Height + yDiff / 2);
|
||||
gpbxBattles.Location = new Point(gpbxBattles.Location.X, oldBattlePosition.Y + yDiff / 2);
|
||||
//The infos wont change width but will need to be centerd
|
||||
Point startOfZone = new Point(gpbxOvertakes.Width + gpbxOvertakes.Location.X, gpbxOvertakes.Location.Y);
|
||||
Point endOfZone = new Point(gpbxRanking.Location.X, gpbxOvertakes.Location.Y);
|
||||
int totalWidth = endOfZone.X - startOfZone.X;
|
||||
gpbxDriverInfos.Location = new Point(startOfZone.X + (totalWidth / 2 - gpbxDriverInfos.Width / 2), oldDriverInfoPosition.Y + yDiff);
|
||||
//Now resizing internals
|
||||
pnlFastest.Size = new Size(oldPnlFastest.Width + xDiff / 4,oldPnlFastest.Height + yDiff / 4);
|
||||
pnlFastest.Location = new Point(olPnlFastestPosition.X,olPnlFastestPosition.Y + yDiff / 4);
|
||||
|
||||
pnlSlowest.Size = new Size(oldPnlSlowest.Width + xDiff / 4, oldPnlSlowest.Height + yDiff / 4);
|
||||
pnlSlowest.Location = new Point(oldPnlSlowestPosition.X + xDiff / 4, oldPnlSlowestPosition.Y + yDiff / 4);
|
||||
|
||||
pnlBattles.Size = new Size(oldPnlBattles.Width + xDiff / 2,oldPnlBattles.Height + yDiff / 2);
|
||||
|
||||
pnlLiveRanking.Size = new Size(oldPnlRankings.Width + xDiff / 2,oldPnlRankings.Height + yDiff);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user