Skip to content

Commit

Permalink
Font sizing of application
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert-DeForrest-Reynolds committed Dec 6, 2023
1 parent 67b25be commit 4f3b87b
Show file tree
Hide file tree
Showing 7 changed files with 112 additions and 73 deletions.
1 change: 1 addition & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,4 @@ dotnet_style_qualification_for_property = false:silent
dotnet_style_qualification_for_method = false:silent
dotnet_style_qualification_for_event = false:silent
dotnet_diagnostic.CA1822.severity = none
dotnet_diagnostic.CA1416.severity = none
File renamed without changes.
14 changes: 14 additions & 0 deletions EditorSettings.cs → CustomControls/EditorSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
Expand All @@ -24,7 +25,20 @@ public EditorSettings(MainForm MF, Toolbox TB)

private void Font_Size_Changed(object sender, EventArgs e)
{
List<string> Exclusions = new()
{ "DescriptionLabel",
"IngredientsLabel",
"DirectionsLabel",
"MainToolStrip",
};

MF.Font = new Font("Arial", (float)FontSizeControl.Value);

foreach (Control C in TB.Get_All_Controls(MF, Exclusions))
{
C.Font = new Font("Arial", (float)FontSizeControl.Value);
Debug.WriteLine($"{C.Name}: {C.Font.Size}");
}
}
}
}
File renamed without changes.
87 changes: 36 additions & 51 deletions Forms/MainForm.Designer.cs

Large diffs are not rendered by default.

45 changes: 23 additions & 22 deletions Forms/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,36 @@ namespace Recipsio
public partial class MainForm : Form
{
public string? CurrentRecipe;

Check warning on line 11 in Forms/MainForm.cs

View workflow job for this annotation

GitHub Actions / Build

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
public Toolbox Manager;
public Toolbox TB;

public MainForm()
{
TB = new Toolbox(this);

foreach (Control C in TB.Get_All_Controls(this, null!))
{
C.AutoSize = true;
}

InitializeComponent();
Manager = new Toolbox(this);
Manager.Generate_User_Directories();
Manager.Load_Recipes(ref RecipeList);
Manager.Load_Ingredients();
TB.Generate_User_Directories();
TB.Load_Recipes(ref RecipeList);
TB.Load_Ingredients();
KeyPreview = true;

}

private void Create_New_Recipe_Click(object Sender, EventArgs E)
{
Manager.Clear_Content_Boxes();
TB.Clear_Content_Boxes();
CurrentRecipe = "";
RecipeList.SelectedItem = null;
}
private void Save_Recipe_Click(object Sender, EventArgs E)
{
if (Manager.Is_Valid_Recipe())
if (TB.Is_Valid_Recipe())
{
if (Manager.Save_Recipe(RecipeName.Text, this) == "New")
if (TB.Save_Recipe(RecipeName.Text, this) == "New")
{
RecipeList.Items.Add(RecipeName.Text);
}
Expand All @@ -41,8 +48,8 @@ private void Delete_Recipe_Click(object Sender, EventArgs E)
{
if (CurrentRecipe == null) { return; }
CurrentRecipe = RecipeList.SelectedItem.ToString()!;
Manager.Delete_Recipe(CurrentRecipe);
Manager.Clear_Content_Boxes();
TB.Delete_Recipe(CurrentRecipe);
TB.Clear_Content_Boxes();
RecipeList.Items.Remove(CurrentRecipe);
RecipeList.SelectedItem = null;
}
Expand Down Expand Up @@ -87,11 +94,11 @@ private void RecipeList_Selected_Value_Changed(object Sender, EventArgs E)
{
if (RecipeList.SelectedItem == null) return;

Manager.Clear_Content_Boxes();
TB.Clear_Content_Boxes();

CurrentRecipe = RecipeList.SelectedItem.ToString()!;

Manager.Load_Recipe(CurrentRecipe);
TB.Load_Recipe(CurrentRecipe);
}
private void RichTextBox_Key_Down(object Sender, KeyEventArgs KE)
{
Expand Down Expand Up @@ -119,7 +126,7 @@ private void Input_Time_Key_Down(object? Sender, KeyEventArgs KE)
Input = (RichTextBox)Sender!;
InputTimeLabel = (Label)Controls.Find(Input.Tag.ToString(), true)[0];
InputTimeLabel.Text = $"{Input.Text} {InputTimeLabel.Tag}";
Manager.Update_Times();
TB.Update_Times();
Controls.Remove(Input);

}
Expand All @@ -143,7 +150,7 @@ private void Options_Click(object Sender, EventArgs E)

ToolStripItem ItemClicked = (ToolStripItem)Sender;
_ = FormMap.TryGetValue(ItemClicked.Text, out Type? FormType);

Check warning on line 152 in Forms/MainForm.cs

View workflow job for this annotation

GitHub Actions / Build

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
Form NewForm = (Form)Activator.CreateInstance(FormType!, this, Manager)!;
Form NewForm = (Form)Activator.CreateInstance(FormType!, this, TB)!;
NewForm.ShowDialog();
}
private void Search_Leave(object Sender, EventArgs E)
Expand All @@ -168,7 +175,7 @@ private void Search_Text_Changed(object Sender, EventArgs E)
}
private void Add_Recipe_Ingredient_Click(object Sender, EventArgs E)
{
RecipeIngredientForm AIF = new(this, Manager);
RecipeIngredientForm AIF = new(this, TB);
AIF.ShowDialog(this);
}
private void Remove_Ingredient_Click(object Sender, EventArgs E)
Expand All @@ -180,7 +187,7 @@ private void Remove_Ingredient_Click(object Sender, EventArgs E)
}
private void Add_Recipe_Description_Click(object Sender, EventArgs e)
{
RecipeDirectionForm RDF = new(this, Manager);
RecipeDirectionForm RDF = new(this, TB);
RDF.ShowDialog(this);
}
private void Remove_Recipe_Description_Click(object Sender, EventArgs e)
Expand All @@ -191,10 +198,4 @@ private void Remove_Recipe_Description_Click(object Sender, EventArgs e)
}
}
}
public partial class Toolbox
{
public MainForm MF;
public Toolbox(MainForm MFPassed) => MF = MFPassed;

}
}
38 changes: 38 additions & 0 deletions Toolbox/Toolbox.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using System.Windows.Forms;
using System.Collections.Generic;

namespace Recipsio
{
public partial class Toolbox
{
public MainForm MF;
public Toolbox(MainForm MFPassed) => MF = MFPassed;

public List<Control> Get_All_Controls(Control PassedControl, List<string> Exclusions)
{
List<Control> AllControls = new();

foreach (Control C in PassedControl.Controls)
{
if (!Exclusions.Contains(C.Name))
{
AllControls.Add(C);
if (C.HasChildren)
{
foreach (Control InnerControl in Get_All_Controls(C, Exclusions))
{
if (!Exclusions.Contains(C.Name))
{
AllControls.Add(InnerControl);
}
}
}
}

}

return AllControls;
}

}
}

0 comments on commit 4f3b87b

Please sign in to comment.