[WIP] Mostly working FOV UI

Print button doesn't work, and the Game output is a bit ugly! Other than that it works the same as Markus Ewert's awesome FOV calculator at https://github.com/dinex86/FOV-Calculator.
This commit is contained in:
Terry MacDonald 2022-08-09 21:33:03 +12:00
parent 98d45e7da2
commit 803544f3e1
6 changed files with 314 additions and 141 deletions

View File

@ -87,7 +87,7 @@ namespace DisplayMagician
{
private static List<GameFovDetail> _gameFovDetails = new List<GameFovDetail>() {
new GameFovDetail(){
/*new GameFovDetail(){
FovType = FovType.HorizontalFOVDegrees,
GameName = "Horizontal FOV in Degrees",
GamePublisher = "",
@ -101,7 +101,7 @@ namespace DisplayMagician
BaseTriple = 0,
Increment = 0,
Step = 0
},
},*/
new GameFovDetail(){
FovType = FovType.HorizontalFOVDegrees,
GameName = "Project CARS 1",
@ -283,7 +283,7 @@ namespace DisplayMagician
Increment = 2,
Step = 0.05 //slider step
},
new GameFovDetail(){
/*new GameFovDetail(){
FovType = FovType.VerticalFOVDegrees,
GameName = "Vertical FOV in Degrees",
GamePublisher = "",
@ -297,7 +297,7 @@ namespace DisplayMagician
BaseTriple = 0,
Increment = 0,
Step = 0
},
},*/
new GameFovDetail(){
FovType = FovType.VerticalFOVDegrees,
GameName = "Assetto Corsa",
@ -493,21 +493,21 @@ namespace DisplayMagician
Increment = 0,
Step = 0
},
/*new GameFovDetail(){
FovType = FovType.HorizontalFOVDegrees,
new GameFovDetail(){
FovType = FovType.VerticalFOVDegrees,
GameName = "BeamNG.drive",
GamePublisher = "BeamNG",
GameURL = "https://store.steampowered.com/app/284160/BeamNGdrive/",
Instructions = "",
Min = 0,
Max = 0,
Decimals = 0,
Min = 10,
Max = 120,
Decimals = 1,
Factor = 1,
BaseSingle = 0,
BaseTriple = 0,
Increment = 0,
Step = 0
},*/
},
}.OrderBy(tr => tr.GameName).ToList();
public static List<GameFovDetail> Games {
@ -535,6 +535,10 @@ namespace DisplayMagician
public static double BezelWidth { get; set; }
public static double ResultHorizontalDegrees { get; set; }
public static double ResultVerticalDegrees { get; set; }
public static ScreenMeasurementUnit BezelWidthUnit { get; set; }
public static bool CalculateFOV(ScreenFovDetail screenFovDetail)
@ -636,43 +640,45 @@ namespace DisplayMagician
}
// Check sensible minimums and maximums
// Check that screen size is between 48cm and 508cm diagonally (19 inch to 200 inch screen sizes)
if (screenSizeInCm < 48)
// Check that screen size is between cm and 508cm diagonally (7 inch to 200 inch screen sizes)
if (screenSizeInCm <= 17)
{
// Screen size is too small
return false;
screenSizeInCm = 17;
}
else if (screenSizeInCm > 508)
else if (screenSizeInCm >= 508)
{
// Screen size is too big
return false;
screenSizeInCm = 508;
}
// Check that distance to screen is between 5cm and 10m
if (distanceToScreenInCm < 5)
if (distanceToScreenInCm <= 5)
{
// Distance to screen is too small
return false;
distanceToScreenInCm = 5;
}
else if (distanceToScreenInCm > 10000)
else if (distanceToScreenInCm >= 10000)
{
// Distance to screen is too big
return false;
distanceToScreenInCm = 10000;
}
// Check that bezel size is between 0 and 10cm
if (bezelSizeInCm < 0)
if (bezelSizeInCm <= 0)
{
// Bezel size is too small
return false;
bezelSizeInCm = 0;
}
else if (bezelSizeInCm > 10)
else if (bezelSizeInCm >= 10)
{
// Bezel size is too big
return false;
bezelSizeInCm = 10;
}
// If we get here we can start doing the calculation! Yay!
double screenRatioX = 21;
double screenRatioY = 9;
if (ScreenAspectRatio == ScreenAspectRatio.SixteenByNine)
@ -723,7 +729,7 @@ namespace DisplayMagician
}
else
{
return false;
screenRatioX = 16;
}
if (ScreenRatioY > 0)
{
@ -731,12 +737,13 @@ namespace DisplayMagician
}
else
{
return false;
screenRatioY = 9;
}
}
else
{
return false;
screenRatioX = 16;
screenRatioY = 9;
}
int screenCount = 3;
@ -758,25 +765,26 @@ namespace DisplayMagician
double vAngle = calcAngle(height, distanceToScreenInCm);
double arcConstant = (180 / Math.PI);
double value = 0;
double base10 = 0;
for (int i = 0; i < _gameFovDetails.Count; i++)
{
GameFovDetail game = _gameFovDetails[i];
if (game.FovType == FovType.HorizontalFOVDegrees)
{
double value = (arcConstant * (hAngle * screenCount)) * game.Factor;
value = (arcConstant * (hAngle * screenCount)) * game.Factor;
if (value > game.Max)
value = game.Max;
else if (value < game.Min)
value = game.Min;
double base10 = Math.Pow(10, game.Decimals);
base10 = Math.Pow(10, game.Decimals);
game.ResultDegrees = Math.Round((value * base10) / base10, (int)game.Decimals);
}
else if (game.FovType == FovType.HorizontalFOVRadians)
{
double value = (arcConstant * calcAngle(width / screenRatioX * screenRatioY / 3 * 4, distanceToScreenInCm)) * game.Factor;
value = (arcConstant * calcAngle(width / screenRatioX * screenRatioY / 3 * 4, distanceToScreenInCm)) * game.Factor;
if (value > game.Max)
value = game.Max;
else if (value < game.Min)
@ -784,12 +792,12 @@ namespace DisplayMagician
value *= (Math.PI / 180);
double base10 = Math.Pow(10, game.Decimals);
base10 = Math.Pow(10, game.Decimals);
game.ResultRadians = Math.Round((value * base10) / base10, (int)game.Decimals);
}
else if (game.FovType == FovType.HorizontalFOVBaseSteps)
{
double value = (arcConstant * (hAngle * screenCount));
value = (arcConstant * (hAngle * screenCount));
value = Math.Round((value - game.BaseTriple) / game.Increment) * game.Step;
value *= game.Factor;
@ -798,23 +806,24 @@ namespace DisplayMagician
else if (value < game.Min)
value = game.Min;
double base10 = Math.Pow(10, game.Decimals);
base10 = Math.Pow(10, game.Decimals);
game.ResultBaseSteps = Math.Round((value * base10) / base10, (int)game.Decimals);
}
else if (game.FovType == FovType.VerticalFOVDegrees)
{
double value = (arcConstant * vAngle) * game.Factor;
value = (arcConstant * vAngle) * game.Factor;
if (value > game.Max)
value = game.Max;
else if (value < game.Min)
value = game.Min;
double base10 = Math.Pow(10, game.Decimals);
base10 = Math.Pow(10, game.Decimals);
game.ResultDegrees = Math.Round((value * base10) / base10, (int)game.Decimals);
}
else if (game.FovType == FovType.VerticalFOVTimes)
{
double value = (arcConstant * vAngle) * game.Factor;
value = (arcConstant * vAngle) * game.Factor;
value /= (screenCount == 1 ? game.BaseSingle : game.BaseTriple);
if (value > game.Max)
@ -822,18 +831,18 @@ namespace DisplayMagician
else if (value < game.Min)
value = game.Min;
double base10 = Math.Pow(10, game.Decimals);
base10 = Math.Pow(10, game.Decimals);
game.ResultTimes = Math.Round((value * base10) / base10, (int)game.Decimals);
}
else if (game.FovType == FovType.TripleScreenAngle)
{
double value = (arcConstant * hAngle) * game.Factor;
value = (arcConstant * hAngle) * game.Factor;
if (value > game.Max)
value = game.Max;
else if (value < game.Min)
value = game.Min;
double base10 = Math.Pow(10, game.Decimals);
base10 = Math.Pow(10, game.Decimals);
game.ResultDegrees = Math.Round((value * base10) / base10, (int)game.Decimals);
}
else
@ -844,6 +853,16 @@ namespace DisplayMagician
_gameFovDetails[i] = game;
}
// Figure out the Horizontal FOV Degrees
value = (arcConstant * (hAngle * screenCount));
base10 = Math.Pow(10, 1);
ResultHorizontalDegrees = Math.Round((value * base10) / base10, 1);
// Figure out the Horizontal Vertical Degrees
value = (arcConstant * vAngle);
base10 = Math.Pow(10, 1);
ResultVerticalDegrees = Math.Round((value * base10) / base10, 1);
return true;
}

View File

@ -26,8 +26,8 @@ using System.Resources;
[assembly: Guid("e4ceaf5e-ad01-4695-b179-31168eb74c48")]
// Version information
[assembly: AssemblyVersion("2.4.1.53")]
[assembly: AssemblyFileVersion("2.4.1.53")]
[assembly: AssemblyVersion("2.4.1.69")]
[assembly: AssemblyFileVersion("2.4.1.69")]
[assembly: NeutralResourcesLanguageAttribute( "en" )]
[assembly: CLSCompliant(true)]

View File

@ -30,7 +30,6 @@
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FovCalcForm));
this.btn_back = new System.Windows.Forms.Button();
this.btn_update = new System.Windows.Forms.Button();
this.pnl_fov = new System.Windows.Forms.Panel();
this.split_fov = new System.Windows.Forms.SplitContainer();
this.lbl_bezel_thickness_description = new System.Windows.Forms.Label();
@ -57,11 +56,15 @@
this.cmb_aspect_ratio = new System.Windows.Forms.ComboBox();
this.lbl_aspect_ratio_arrow = new System.Windows.Forms.Label();
this.lbl_aspect_ratio_separator = new System.Windows.Forms.Label();
this.lbl_vresult = new System.Windows.Forms.Label();
this.lbl_vtitle = new System.Windows.Forms.Label();
this.lbl_hresult = new System.Windows.Forms.Label();
this.lbl_htitle = new System.Windows.Forms.Label();
this.btn_print = new System.Windows.Forms.Button();
this.lbl_results = new System.Windows.Forms.Label();
this.rtb_results = new System.Windows.Forms.RichTextBox();
this.lbl_title = new System.Windows.Forms.Label();
this.lbl_about_fov = new System.Windows.Forms.Label();
this.btn_print = new System.Windows.Forms.Button();
this.pnl_fov.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.split_fov)).BeginInit();
this.split_fov.Panel1.SuspendLayout();
@ -85,29 +88,12 @@
this.btn_back.UseVisualStyleBackColor = true;
this.btn_back.Click += new System.EventHandler(this.btn_back_Click);
//
// btn_update
//
this.btn_update.Anchor = System.Windows.Forms.AnchorStyles.Bottom;
this.btn_update.BackColor = System.Drawing.Color.Black;
this.btn_update.FlatAppearance.MouseDownBackColor = System.Drawing.Color.IndianRed;
this.btn_update.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Brown;
this.btn_update.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btn_update.Font = new System.Drawing.Font("Microsoft Sans Serif", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btn_update.ForeColor = System.Drawing.Color.White;
this.btn_update.Location = new System.Drawing.Point(577, 718);
this.btn_update.Name = "btn_update";
this.btn_update.Size = new System.Drawing.Size(128, 40);
this.btn_update.TabIndex = 7;
this.btn_update.Text = "&Update";
this.btn_update.UseVisualStyleBackColor = false;
this.btn_update.Click += new System.EventHandler(this.btn_update_Click);
//
// pnl_fov
//
this.pnl_fov.Controls.Add(this.split_fov);
this.pnl_fov.Location = new System.Drawing.Point(2, 128);
this.pnl_fov.Name = "pnl_fov";
this.pnl_fov.Size = new System.Drawing.Size(1301, 578);
this.pnl_fov.Size = new System.Drawing.Size(1301, 594);
this.pnl_fov.TabIndex = 9;
//
// split_fov
@ -148,9 +134,14 @@
// split_fov.Panel2
//
this.split_fov.Panel2.BackColor = System.Drawing.Color.Black;
this.split_fov.Panel2.Controls.Add(this.lbl_vresult);
this.split_fov.Panel2.Controls.Add(this.lbl_vtitle);
this.split_fov.Panel2.Controls.Add(this.lbl_hresult);
this.split_fov.Panel2.Controls.Add(this.lbl_htitle);
this.split_fov.Panel2.Controls.Add(this.btn_print);
this.split_fov.Panel2.Controls.Add(this.lbl_results);
this.split_fov.Panel2.Controls.Add(this.rtb_results);
this.split_fov.Size = new System.Drawing.Size(1301, 578);
this.split_fov.Size = new System.Drawing.Size(1301, 594);
this.split_fov.SplitterDistance = 711;
this.split_fov.TabIndex = 0;
//
@ -252,7 +243,7 @@
this.btn_triple_screens.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btn_triple_screens.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btn_triple_screens.ForeColor = System.Drawing.Color.White;
this.btn_triple_screens.Location = new System.Drawing.Point(549, 39);
this.btn_triple_screens.Location = new System.Drawing.Point(549, 55);
this.btn_triple_screens.Name = "btn_triple_screens";
this.btn_triple_screens.Size = new System.Drawing.Size(139, 33);
this.btn_triple_screens.TabIndex = 45;
@ -268,7 +259,7 @@
this.btn_single_screen.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btn_single_screen.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btn_single_screen.ForeColor = System.Drawing.Color.White;
this.btn_single_screen.Location = new System.Drawing.Point(389, 39);
this.btn_single_screen.Location = new System.Drawing.Point(389, 55);
this.btn_single_screen.Name = "btn_single_screen";
this.btn_single_screen.Size = new System.Drawing.Size(139, 33);
this.btn_single_screen.TabIndex = 44;
@ -286,7 +277,6 @@
this.lbl_bezel_thickness.Size = new System.Drawing.Size(150, 20);
this.lbl_bezel_thickness.TabIndex = 15;
this.lbl_bezel_thickness.Text = "5. Bezel Thickness?";
this.lbl_bezel_thickness.Click += new System.EventHandler(this.lbl_bezel_thickness_Click);
//
// cmb_bezel_thickness
//
@ -296,6 +286,7 @@
this.cmb_bezel_thickness.Name = "cmb_bezel_thickness";
this.cmb_bezel_thickness.Size = new System.Drawing.Size(133, 28);
this.cmb_bezel_thickness.TabIndex = 14;
this.cmb_bezel_thickness.SelectedIndexChanged += new System.EventHandler(this.cmb_bezel_thickness_SelectedIndexChanged);
//
// txt_bezel_thickness
//
@ -314,6 +305,7 @@
this.cmb_distance_to_screen.Name = "cmb_distance_to_screen";
this.cmb_distance_to_screen.Size = new System.Drawing.Size(133, 28);
this.cmb_distance_to_screen.TabIndex = 11;
this.cmb_distance_to_screen.SelectedIndexChanged += new System.EventHandler(this.cmb_distance_to_screen_SelectedIndexChanged);
//
// txt_distance_to_screen
//
@ -353,6 +345,7 @@
this.txt_aspect_ratio_y.Name = "txt_aspect_ratio_y";
this.txt_aspect_ratio_y.Size = new System.Drawing.Size(69, 26);
this.txt_aspect_ratio_y.TabIndex = 6;
this.txt_aspect_ratio_y.TextChanged += new System.EventHandler(this.txt_aspect_ratio_y_TextChanged);
//
// txt_aspect_ratio_x
//
@ -361,6 +354,7 @@
this.txt_aspect_ratio_x.Name = "txt_aspect_ratio_x";
this.txt_aspect_ratio_x.Size = new System.Drawing.Size(64, 26);
this.txt_aspect_ratio_x.TabIndex = 5;
this.txt_aspect_ratio_x.TextChanged += new System.EventHandler(this.txt_aspect_ratio_x_TextChanged);
//
// txt_screen_size
//
@ -369,6 +363,7 @@
this.txt_screen_size.Name = "txt_screen_size";
this.txt_screen_size.Size = new System.Drawing.Size(78, 26);
this.txt_screen_size.TabIndex = 4;
this.txt_screen_size.TextChanged += new System.EventHandler(this.txt_screen_size_TextChanged);
//
// cmb_screen_size_units
//
@ -378,6 +373,7 @@
this.cmb_screen_size_units.Name = "cmb_screen_size_units";
this.cmb_screen_size_units.Size = new System.Drawing.Size(133, 28);
this.cmb_screen_size_units.TabIndex = 3;
this.cmb_screen_size_units.SelectedIndexChanged += new System.EventHandler(this.cmb_screen_size_units_SelectedIndexChanged);
//
// cmb_aspect_ratio
//
@ -411,6 +407,67 @@
this.lbl_aspect_ratio_separator.TabIndex = 53;
this.lbl_aspect_ratio_separator.Text = ":";
//
// lbl_vresult
//
this.lbl_vresult.Font = new System.Drawing.Font("Microsoft Sans Serif", 20.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lbl_vresult.ForeColor = System.Drawing.Color.White;
this.lbl_vresult.Location = new System.Drawing.Point(374, 543);
this.lbl_vresult.Name = "lbl_vresult";
this.lbl_vresult.Size = new System.Drawing.Size(171, 35);
this.lbl_vresult.TabIndex = 27;
this.lbl_vresult.Text = "33.9";
this.lbl_vresult.TextAlign = System.Drawing.ContentAlignment.TopCenter;
//
// lbl_vtitle
//
this.lbl_vtitle.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lbl_vtitle.ForeColor = System.Drawing.Color.White;
this.lbl_vtitle.Location = new System.Drawing.Point(374, 526);
this.lbl_vtitle.Name = "lbl_vtitle";
this.lbl_vtitle.Size = new System.Drawing.Size(171, 23);
this.lbl_vtitle.TabIndex = 26;
this.lbl_vtitle.Text = "Vertical FOV Degrees";
this.lbl_vtitle.TextAlign = System.Drawing.ContentAlignment.TopCenter;
//
// lbl_hresult
//
this.lbl_hresult.Font = new System.Drawing.Font("Microsoft Sans Serif", 20.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lbl_hresult.ForeColor = System.Drawing.Color.White;
this.lbl_hresult.Location = new System.Drawing.Point(39, 543);
this.lbl_hresult.Name = "lbl_hresult";
this.lbl_hresult.Size = new System.Drawing.Size(171, 35);
this.lbl_hresult.TabIndex = 25;
this.lbl_hresult.Text = "160.5";
this.lbl_hresult.TextAlign = System.Drawing.ContentAlignment.TopCenter;
//
// lbl_htitle
//
this.lbl_htitle.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lbl_htitle.ForeColor = System.Drawing.Color.White;
this.lbl_htitle.Location = new System.Drawing.Point(40, 526);
this.lbl_htitle.Name = "lbl_htitle";
this.lbl_htitle.Size = new System.Drawing.Size(171, 23);
this.lbl_htitle.TabIndex = 24;
this.lbl_htitle.Text = "Horizontal FOV Degrees";
this.lbl_htitle.TextAlign = System.Drawing.ContentAlignment.TopCenter;
//
// btn_print
//
this.btn_print.Anchor = System.Windows.Forms.AnchorStyles.Bottom;
this.btn_print.BackColor = System.Drawing.Color.Black;
this.btn_print.FlatAppearance.MouseDownBackColor = System.Drawing.Color.IndianRed;
this.btn_print.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Brown;
this.btn_print.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btn_print.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btn_print.ForeColor = System.Drawing.Color.White;
this.btn_print.Location = new System.Drawing.Point(246, 538);
this.btn_print.Name = "btn_print";
this.btn_print.Size = new System.Drawing.Size(92, 33);
this.btn_print.TabIndex = 23;
this.btn_print.Text = "&Print";
this.btn_print.UseVisualStyleBackColor = false;
this.btn_print.Click += new System.EventHandler(this.btn_print_Click);
//
// lbl_results
//
this.lbl_results.AutoSize = true;
@ -428,7 +485,7 @@
//
this.rtb_results.Location = new System.Drawing.Point(12, 52);
this.rtb_results.Name = "rtb_results";
this.rtb_results.Size = new System.Drawing.Size(560, 418);
this.rtb_results.Size = new System.Drawing.Size(560, 464);
this.rtb_results.TabIndex = 0;
this.rtb_results.Text = "";
//
@ -456,22 +513,6 @@
this.lbl_about_fov.Text = resources.GetString("lbl_about_fov.Text");
this.lbl_about_fov.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// btn_print
//
this.btn_print.Anchor = System.Windows.Forms.AnchorStyles.Bottom;
this.btn_print.BackColor = System.Drawing.Color.Black;
this.btn_print.FlatAppearance.MouseDownBackColor = System.Drawing.Color.IndianRed;
this.btn_print.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Brown;
this.btn_print.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btn_print.Font = new System.Drawing.Font("Microsoft Sans Serif", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btn_print.ForeColor = System.Drawing.Color.White;
this.btn_print.Location = new System.Drawing.Point(720, 718);
this.btn_print.Name = "btn_print";
this.btn_print.Size = new System.Drawing.Size(128, 40);
this.btn_print.TabIndex = 22;
this.btn_print.Text = "&Print";
this.btn_print.UseVisualStyleBackColor = false;
//
// FovCalcForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -480,10 +521,8 @@
this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.ClientSize = new System.Drawing.Size(1301, 770);
this.Controls.Add(this.btn_print);
this.Controls.Add(this.lbl_about_fov);
this.Controls.Add(this.lbl_title);
this.Controls.Add(this.btn_update);
this.Controls.Add(this.pnl_fov);
this.Controls.Add(this.btn_back);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
@ -507,7 +546,6 @@
#endregion
private System.Windows.Forms.Button btn_back;
private System.Windows.Forms.Button btn_update;
private System.Windows.Forms.Panel pnl_fov;
private System.Windows.Forms.SplitContainer split_fov;
private System.Windows.Forms.Label lbl_title;
@ -538,6 +576,10 @@
private System.Windows.Forms.Label lbl_aspect_ratio_separator;
private System.Windows.Forms.Label lbl_results;
private System.Windows.Forms.RichTextBox rtb_results;
private System.Windows.Forms.Label lbl_vresult;
private System.Windows.Forms.Label lbl_vtitle;
private System.Windows.Forms.Label lbl_hresult;
private System.Windows.Forms.Label lbl_htitle;
private System.Windows.Forms.Button btn_print;
}
}

View File

@ -10,6 +10,7 @@ using System.Windows.Forms;
using DisplayMagician;
using DisplayMagicianShared;
using DisplayMagicianShared.Windows;
using Microsoft.WindowsAPICodePack.Win32Native;
namespace DisplayMagician.UIForms
{
@ -17,7 +18,8 @@ namespace DisplayMagician.UIForms
{
private ScreenLayout _screenLayout = ScreenLayout.TripleScreen;
private bool _formLoaded = false;
public FovCalcForm()
{
InitializeComponent();
@ -110,6 +112,10 @@ namespace DisplayMagician.UIForms
lbl_bezel_thickness_description.Visible = false;
txt_bezel_thickness.Visible = false;
if (_formLoaded)
{
RunFovCalculation();
}
}
private void btn_triple_screens_Click(object sender, EventArgs e)
@ -123,9 +129,15 @@ namespace DisplayMagician.UIForms
lbl_bezel_thickness.Visible = true;
lbl_bezel_thickness_description.Visible = true;
txt_bezel_thickness.Visible = true;
if (_formLoaded)
{
RunFovCalculation();
}
}
private void btn_update_Click(object sender, EventArgs e)
private void RunFovCalculation()
{
double result;
// Populate the FOV Calc data, ready for the calculation
@ -141,12 +153,16 @@ namespace DisplayMagician.UIForms
{
FovCalculator.BezelWidth = 0;
}
}
}
else
{
FovCalculator.ScreenLayout = ScreenLayout.SingleScreen;
FovCalculator.BezelWidth = 0;
}
if (cmb_bezel_thickness.SelectedValue == null)
{
return;
}
FovCalculator.BezelWidthUnit = (ScreenMeasurementUnit)cmb_bezel_thickness.SelectedValue;
// Next, do the Screen size
@ -158,21 +174,33 @@ namespace DisplayMagician.UIForms
{
FovCalculator.ScreenSize = 0;
}
if (cmb_screen_size_units.SelectedValue == null)
{
return;
}
FovCalculator.ScreenSizeUnit = (ScreenMeasurementUnit)cmb_screen_size_units.SelectedValue;
// Next, do the Distance to Screen
if (Double.TryParse(txt_distance_to_screen.Text, out result))
{
FovCalculator.DistanceToScreen = result;
}
}
else
{
FovCalculator.DistanceToScreen = 0;
}
if (cmb_distance_to_screen.SelectedValue == null)
{
return;
}
FovCalculator.DistanceToScreenUnit = (ScreenMeasurementUnit)cmb_distance_to_screen.SelectedValue;
// Next, do the Screen Aspect Ratio
if (cmb_aspect_ratio.SelectedValue == null)
{
return;
}
FovCalculator.ScreenAspectRatio = (ScreenAspectRatio)cmb_aspect_ratio.SelectedValue;
if (((ScreenAspectRatio)cmb_aspect_ratio.SelectedValue).Equals(ScreenAspectRatio.Custom))
{
result = 0;
@ -194,23 +222,17 @@ namespace DisplayMagician.UIForms
FovCalculator.ScreenRatioY = 9;
}
}
// Now actually do the calculation!
FovCalculator.CalculateFOV();
rtb_results.Text = FovCalculator.PrintResultsToString();
}
private void lbl_bezel_thickness_Click(object sender, EventArgs e)
{
}
private void txt_bezel_thickness_TextChanged(object sender, EventArgs e)
{
lbl_hresult.Text = FovCalculator.ResultHorizontalDegrees.ToString();
lbl_vresult.Text = FovCalculator.ResultVerticalDegrees.ToString();
}
private void cmb_aspect_ratio_SelectedIndexChanged(object sender, EventArgs e)
{
@ -230,6 +252,10 @@ namespace DisplayMagician.UIForms
txt_aspect_ratio_x.Visible = false;
txt_aspect_ratio_y.Visible = false;
}
if (_formLoaded)
{
RunFovCalculation();
}
}
private void FovCalcForm_Load(object sender, EventArgs e)
@ -243,11 +269,11 @@ namespace DisplayMagician.UIForms
if (ProfileRepository.CurrentProfile.WindowsDisplayConfig.DisplayIdentifiers.Count >= 3)
{
currentScreenFovDetail.ScreenLayout = ScreenLayout.TripleScreen;
btn_triple_screens.PerformClick();
}
else
{
currentScreenFovDetail.ScreenLayout = ScreenLayout.SingleScreen;
btn_single_screen.PerformClick();
}
try
@ -255,85 +281,171 @@ namespace DisplayMagician.UIForms
GDI_DISPLAY_SETTING gdiDevice = ProfileRepository.CurrentProfile.WindowsDisplayConfig.GdiDisplaySettings.Where(dp => dp.Value.IsPrimary).First().Value;
double aspectRatio = gdiDevice.DeviceMode.PixelsWidth / gdiDevice.DeviceMode.PixelsHeight;
if (aspectRatio == (16 / 9)) {
currentScreenFovDetail.ScreenAspectRatio = ScreenAspectRatio.SixteenByNine;
cmb_aspect_ratio.SelectedValue = ScreenAspectRatio.SixteenByNine;
}
else if (aspectRatio == (16 / 10)) {
currentScreenFovDetail.ScreenAspectRatio = ScreenAspectRatio.SixteenByTen;
cmb_aspect_ratio.SelectedValue = ScreenAspectRatio.SixteenByTen;
}
else if (aspectRatio == (21 / 9)) {
currentScreenFovDetail.ScreenAspectRatio = ScreenAspectRatio.TwentyOneByNine;
cmb_aspect_ratio.SelectedValue = ScreenAspectRatio.TwentyOneByNine;
}
else if (aspectRatio == (21 / 10)) {
currentScreenFovDetail.ScreenAspectRatio = ScreenAspectRatio.TwentyOneByTen;
cmb_aspect_ratio.SelectedValue = ScreenAspectRatio.TwentyOneByTen;
}
else if (aspectRatio == (32 / 9)) {
currentScreenFovDetail.ScreenAspectRatio = ScreenAspectRatio.ThirtyTwoByNine;
cmb_aspect_ratio.SelectedValue = ScreenAspectRatio.ThirtyTwoByNine;
}
else if (aspectRatio == (32 / 10)) {
currentScreenFovDetail.ScreenAspectRatio = ScreenAspectRatio.ThirtyTwoByTen;
cmb_aspect_ratio.SelectedValue = ScreenAspectRatio.ThirtyTwoByTen;
}
else if (aspectRatio == (4 / 3)) {
currentScreenFovDetail.ScreenAspectRatio = ScreenAspectRatio.FourByThree;
cmb_aspect_ratio.SelectedValue = ScreenAspectRatio.FourByThree;
}
else if (aspectRatio == (5 / 4))
{
currentScreenFovDetail.ScreenAspectRatio = ScreenAspectRatio.FiveByFour;
cmb_aspect_ratio.SelectedValue = ScreenAspectRatio.FiveByFour;
}
else
{
currentScreenFovDetail.ScreenAspectRatio = ScreenAspectRatio.Custom;
currentScreenFovDetail.ScreenAspectRatioX = gdiDevice.DeviceMode.PixelsWidth;
currentScreenFovDetail.ScreenAspectRatioY = gdiDevice.DeviceMode.PixelsHeight;
cmb_aspect_ratio.SelectedValue = ScreenAspectRatio.Custom;
txt_aspect_ratio_x.Text = gdiDevice.DeviceMode.PixelsWidth.ToString();
txt_aspect_ratio_y.Text = gdiDevice.DeviceMode.PixelsHeight.ToString();
}
}
catch (Exception ex)
{
currentScreenFovDetail.ScreenAspectRatio = ScreenAspectRatio.SixteenByNine;
cmb_aspect_ratio.SelectedValue = ScreenAspectRatio.SixteenByNine;
}
currentScreenFovDetail.ScreenSize = 27;
currentScreenFovDetail.ScreenSizeUnit = ScreenMeasurementUnit.Inch;
txt_screen_size.Text = 27.ToString();
cmb_screen_size_units.SelectedValue = ScreenMeasurementUnit.Inch;
currentScreenFovDetail.DistanceToScreen = 60;
currentScreenFovDetail.DistanceToScreenUnit = ScreenMeasurementUnit.CM;
txt_distance_to_screen.Text = 60.ToString();
cmb_distance_to_screen.SelectedValue = ScreenMeasurementUnit.CM;
currentScreenFovDetail.BezelWidth = 3;
currentScreenFovDetail.BezelWidthUnit = ScreenMeasurementUnit.MM;
// Now set the UI based on the currentScreenFovDetail
if (currentScreenFovDetail.ScreenLayout == ScreenLayout.TripleScreen)
txt_bezel_thickness.Text = 3.ToString();
cmb_bezel_thickness.SelectedValue = ScreenMeasurementUnit.MM;
RunFovCalculation();
_formLoaded = true;
}
private bool CheckValueWithinRange(TextBox value, ComboBox unit, double lowerBound, double upperBound)
{
// Convert bezelSize to cm
double result = 0;
double resultInCm = 0;
if (Double.TryParse(value.Text, out result))
{
btn_triple_screens.PerformClick();
ScreenMeasurementUnit unitValue = (ScreenMeasurementUnit)unit.SelectedValue;
if (unitValue == ScreenMeasurementUnit.Inch)
{
resultInCm = result * 2.54;
}
else if (unitValue == ScreenMeasurementUnit.MM)
{
resultInCm = result / 10;
}
else if (unitValue == ScreenMeasurementUnit.CM)
{
resultInCm = result;
}
else
{
// Unit supplied is not one we know about!
resultInCm = 0;
}
if (resultInCm >= lowerBound && resultInCm <= upperBound)
{
return true;
}
else
{
return false;
}
}
else
{
btn_single_screen.PerformClick();
return false;
}
txt_screen_size.Text = currentScreenFovDetail.ScreenSize.ToString();
cmb_screen_size_units.SelectedValue = currentScreenFovDetail.ScreenSizeUnit;
cmb_aspect_ratio.SelectedValue = currentScreenFovDetail.ScreenAspectRatio;
if (currentScreenFovDetail.ScreenAspectRatio == ScreenAspectRatio.Custom)
}
private void btn_print_Click(object sender, EventArgs e)
{
// Print to file
}
private void cmb_screen_size_units_SelectedIndexChanged(object sender, EventArgs e)
{
if (_formLoaded && CheckValueWithinRange(txt_screen_size, cmb_screen_size_units, 17, 508))
{
txt_aspect_ratio_x.Text = currentScreenFovDetail.ScreenAspectRatioX.ToString();
txt_aspect_ratio_y.Text = currentScreenFovDetail.ScreenAspectRatioY.ToString();
RunFovCalculation();
}
}
private void cmb_distance_to_screen_SelectedIndexChanged(object sender, EventArgs e)
{
// Check that distance to screen is between 5cm and 10m
if (_formLoaded && CheckValueWithinRange(txt_distance_to_screen, cmb_distance_to_screen, 5, 10000))
{
RunFovCalculation();
}
txt_distance_to_screen.Text = currentScreenFovDetail.DistanceToScreen.ToString();
cmb_distance_to_screen.SelectedValue = currentScreenFovDetail.DistanceToScreenUnit;
txt_bezel_thickness.Text = currentScreenFovDetail.BezelWidth.ToString();
cmb_bezel_thickness.SelectedValue = currentScreenFovDetail.BezelWidthUnit;
}
// Run the FOVCal on load so we have something to see!
FovCalculator.CalculateFOV(currentScreenFovDetail);
private void cmb_bezel_thickness_SelectedIndexChanged(object sender, EventArgs e)
{
// Check that bezel size is between 0 and 10cm
if (_formLoaded && CheckValueWithinRange(txt_bezel_thickness, cmb_bezel_thickness, 0, 10))
{
RunFovCalculation();
}
}
rtb_results.Text = FovCalculator.PrintResultsToString();
private void txt_screen_size_TextChanged(object sender, EventArgs e)
{
// Check that screen size is between 17cm and 508cm diagonally (7 inch to 200 inch screen sizes)
if (_formLoaded && CheckValueWithinRange(txt_screen_size, cmb_screen_size_units, 17, 508))
{
RunFovCalculation();
}
}
private void txt_aspect_ratio_y_TextChanged(object sender, EventArgs e)
{
if (_formLoaded)
{
RunFovCalculation();
}
}
private void txt_aspect_ratio_x_TextChanged(object sender, EventArgs e)
{
if (_formLoaded)
{
RunFovCalculation();
}
}
private void txt_distance_to_screen_TextChanged(object sender, EventArgs e)
{
if (_formLoaded && CheckValueWithinRange(txt_distance_to_screen, cmb_distance_to_screen, 5, 10000))
{
RunFovCalculation();
}
}
private void txt_bezel_thickness_TextChanged(object sender, EventArgs e)
{
if (_formLoaded && CheckValueWithinRange(txt_bezel_thickness, cmb_bezel_thickness, 0, 10))
{
RunFovCalculation();
}
}
}
}

View File

@ -130,7 +130,7 @@
L6wlizhexCplZoSlcvyZ9LL6fY9biU/PTk3K2iKzGYsIw4TRGGWQAUJ00yc+RCdBumRHifhALn6CJYlV
4g1WMVkkSQpbequxLNl1WROi6zLSrLr9/9tXK9ETzGf3haHiyXHeWqFyC743Hefz0HG+j8D7CBfZQvzS
AfS+i75Z0Pz7ULcOZ5cFLb4D5xvQ9GDEzFhO8sr0JBLwegK1M9BwDdVz+Z79nnN8D9E1+aor2N2DNrlf
N/8DYltn5LNebX8AAAAJcEhZcwAADr0AAA69AUf7kK0AAP40SURBVHhe5P0HYBVHsvcNs+v12jhgAyYr
N/8DYltn5LNebX8AAAAJcEhZcwAADrwAAA68AZW8ckkAAP40SURBVHhe5P0HYBVHsvcNs+v12jhgAyYr
J3LGNs4mZ5FEFgiBEBKSyDmDcc4552wcyTlHgRASklDO0pFOzkcJ+H49Jc5yd5/nvs997t57932/drmp
qa6urg4zU3/1zJwmvoHd/YJ6BIb2Du7YNyCkl09AN//gnvDk7f26yCF5B/+uwqMMQy2qwMOIkCpiJCis
D8qt24dJFU2HKl19A7uRQ0iogjJ1IRpFwiEVkXMIT10Rcgjf1qcTh5opVQWz4oM0QUWK0BGzCKVKO9/O

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<IsPackable>false</IsPackable>